Start with no weapon, and making an object appear using a command
by Maximillian Brewer · in Torque 3D Professional · 06/16/2010 (2:31 am) · 4 replies
Hi,
I was wondering how I would make my game character (in Torque 3D) start without a weapon mounted? I am just using the default Starter.FPS with Gideon.
And then, how would I make it so that I can make the weapon (which is already set up to run into to mount etc) appear using a command from a GUI. eg:
gunAppear(); or something.
Thanks
I was wondering how I would make my game character (in Torque 3D) start without a weapon mounted? I am just using the default Starter.FPS with Gideon.
And then, how would I make it so that I can make the weapon (which is already set up to run into to mount etc) appear using a command from a GUI. eg:
gunAppear(); or something.
Thanks
About the author
#2
Now to start without a weapon you have to comment out the line
%player.mountImage....
To add the weapon by a command you can do something like [pseudo-code]:
Now you can call the function with
Make sure you have the right datablocks executed (see the file art/datablocks/weapons/rocketlauncher.cs).
Edit:
@Steve:
Sorry, your post crossed mine, but both have the same solution.
06/16/2010 (4:34 am)
It is really easy to do this. If you look at the file game/art/scripts/server/gamecore.cs there is a function called gameCore::loadout(...) in where the player is setup with weapons on mission start.function GameCore::loadOut(%game, %player)
{
//echo (%game @"c4 -> "@ %game.class @" -> GameCore::loadOut");
%player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo));
%player.setInventory(RocketLauncher);
%player.mountImage(RocketLauncherImage,0);
}Now to start without a weapon you have to comment out the line
%player.mountImage....
To add the weapon by a command you can do something like [pseudo-code]:
function gunAppear(%player, %weapon)
{
%player.setInventory(%weapon @ "Ammo", %player.maxInventory(%weapon @ "Ammo"));
%player.setInventory(%weapon);
%player.mountImage(%weapon @ "Image",0);
}Now you can call the function with
gunAppear(yourplayer, "yourWeapon");
Make sure you have the right datablocks executed (see the file art/datablocks/weapons/rocketlauncher.cs).
Edit:
@Steve:
Sorry, your post crossed mine, but both have the same solution.
#3
Then using a command to make it visible. sort of like:
function unvealGun()
{
%name.isHidden = False;
}
how would something like that work...and can you give me a working block of code, as I am quite new and have an assingment due in 2 days :/
06/16/2010 (5:37 am)
What about making an item placed with the World Editor being masked, so invisible.Then using a command to make it visible. sort of like:
function unvealGun()
{
%name.isHidden = False;
}
how would something like that work...and can you give me a working block of code, as I am quite new and have an assingment due in 2 days :/
#4
As for the codeblock it might be a little difficult, because I am on a very thight schedule this week and I don't have much knowledge about using a GUI. There are a few things I need to know to get you on the road for this.
- Is it a single or multi player thing?
This for detecting the player/client using the weapon.
- Is it a FPS-style or an RPG-style?
In a fps your mouse is normally not visible, so to activate something with a gui, I think you need a button, which you must click to activate the command assigned to it. And here you need a visible mouse, which is normally the case in a RPG-stylish game.
A little work-around for this problem is to assign a key to the command. This can be done in scripts/client/default.bind.cs. But be aware that if you make modifications to this file you have to delete scripts/client/config.cs if it is present (this file is created by the engine when needed, when you change assigned keys in the options menu).
As an example you can do the following with an unassigned key (let's say the u-key).
device = keyboard,
key = u,
command key-pressed = unvealGun(); and
command key-released = empty.
06/17/2010 (2:36 am)
That should work for objects which are already present in the world, although I haven't test it.As for the codeblock it might be a little difficult, because I am on a very thight schedule this week and I don't have much knowledge about using a GUI. There are a few things I need to know to get you on the road for this.
- Is it a single or multi player thing?
This for detecting the player/client using the weapon.
- Is it a FPS-style or an RPG-style?
In a fps your mouse is normally not visible, so to activate something with a gui, I think you need a button, which you must click to activate the command assigned to it. And here you need a visible mouse, which is normally the case in a RPG-stylish game.
A little work-around for this problem is to assign a key to the command. This can be done in scripts/client/default.bind.cs. But be aware that if you make modifications to this file you have to delete scripts/client/config.cs if it is present (this file is created by the engine when needed, when you change assigned keys in the options menu).
As an example you can do the following with an unassigned key (let's say the u-key).
moveMap.bindCmd(keyboard, "u", "unvealGun();","");The arguments are:
device = keyboard,
key = u,
command key-pressed = unvealGun(); and
command key-released = empty.
Associate Steve Acaster
[YorkshireRifles.com]
I've not had much chance to use GUI's but I'd expect that tying the weapon/object "use" command to a GUI button would be the way forward.