Game Development Community

Default Mount = Null

by Andrew13 · in Torque Game Engine Advanced · 03/16/2009 (3:50 pm) · 4 replies

I am modifying the template as a learning exercise.

I am trying to set the default weapon mount to nothing.

Working backwards from the GUI editor i found the ObjectPickerGui.CS file

I set the default value as follows

$PICKER::WEAPON["Default"] = $defaultGame @ "";

as opposed to

$PICKER::WEAPON["Default"] = $defaultGame @ "/data/shapes/weapons/SwarmGun/swarmgun.dts";

the GUI reflects this change and shows no weapon mounted in the GUI. However when i then play the game its loads the swarmgun on character spawn.

Based on the console.log it seems to be interpreting "" as a object rather then NULL. OK that sort of makes sense so i change as follows

$PICKER::WEAPON["Default"] = 0;

Which again works correctly in the GUI but the game loads the /data/shapes/weapons/SwarmGun/swarmgun.dts

The console shows

Resource<TSShape>::create - Could not open '0'
Failed to create resource: [0]
GuiObjectView: Failed to load mounted object model 0. Please check your model name and load a valid model.

So can i pass NULL here and if so how ?

#1
03/16/2009 (4:46 pm)
Take a look at function GameConnection::createPlayer() in "~/server/scripts/game.cs", especially at this section of code:
// Starting equipment
if ($pref::Player:Weapon $= "Crossbow")
{
    %player.setInventory(Crossbow, 1);
    %player.setInventory(CrossbowAmmo, 10);
    %player.mountImage(CrossbowImage, 0);
}
else
{
    %player.setInventory(RocketLauncher, 1);
    %player.setInventory(RocketLauncherAmmo, 10);
    %player.mountImage(RocketLauncherImage, 0);
}
Basically what that is doing is automatically giving you the Rocketlauncher (the swarmgun) if $Pref::Player:Weapon is not set to the Crossbow. That's why it keeps spawning you with weapon even though you specified "" as the preference.

Simply remove or alter the if/else conditions.


#2
03/16/2009 (4:52 pm)
OK ...

So the GUI set the values in $pref::Player: ?

Seems i could change this to a case statement if its supported ...

Am i correctly interpreting that if set the image as follows

%player.mountImage(RocketLauncherImage, 1);

that the player will have the weapon but it will be invisible?
#3
03/16/2009 (5:06 pm)
Yes. The createPlayer function simply allows a default weapon to be given to the player if one isn't chosen in the GUI.

You can do that. There's actually several different ways of handling this functionality. Just remember that you will be comparing strings and not values.

No, that should be interpreted as a slot# in which to mount the weapon Image, mountImage(%weaponImage, %slotNumber), 0 is the default weapon slot for the player. It's the setInventory(%item, %amount) that gives it to the player.
#4
03/16/2009 (5:17 pm)
Great...

thanks for the information