PlayerData defined weapon loadout
by Glenn Bermingham · 05/24/2013 (2:01 am) · 0 comments
This will change the players loadout from a predefined set of weapons to what ever the MainWeapon is set to inside of the PlayerData. This can be used for multiple PlayerData's classes with different main weapons.
In game/scripts/server/gamecore.cs change:
Now in game/art/datablocks/player.cs
Snd Weapon
With additional code this is not limited to a single weapon, you can define an entire weapon set for a class or player.
Example:
In game/server/scripts/gamecore.cs
Add:
Mainweapon will be the default weapon mounted first and now SndWeapon will be loaded into your inventory with full ammo and clips. To define the 2nd weapon simply follow below.
In art/datablocks/player.cs find:
Now you should spawn with the Ryder as your main weapon with the Lurker being your secondary in your inventory. Also note you'll need to change the keybinds to match up with your new inventory start up in (game/scripts/client/default.bind.cs).
If you want to add a 3rd weapon to your playerData startup simply redo the SndWeapon section and change all of the SndWeapon parts with something like ThdWeapon.
In game/scripts/server/gamecore.cs change:
function GameCore::loadOut(%game, %player)
{
//echo (%game @"c4 -> "@ %game.class @" -> GameCore::loadOut");
%player.clearWeaponCycle();
%player.setInventory(Ryder, 1);
%player.setInventory(RyderClip, %player.maxInventory(RyderClip));
%player.setInventory(RyderAmmo, %player.maxInventory(RyderAmmo)); // Start the gun loaded
%player.addToWeaponCycle(Ryder);
%player.setInventory(Lurker, 1);
%player.setInventory(LurkerClip, %player.maxInventory(LurkerClip));
%player.setInventory(LurkerAmmo, %player.maxInventory(LurkerAmmo)); // Start the gun loaded
%player.addToWeaponCycle(Lurker);
%player.setInventory(LurkerGrenadeLauncher, 1);
%player.setInventory(LurkerGrenadeAmmo, %player.maxInventory(LurkerGrenadeAmmo));
%player.addToWeaponCycle(LurkerGrenadeLauncher);
%player.setInventory(ProxMine, %player.maxInventory(ProxMine));
%player.addToWeaponCycle(ProxMine);
%player.setInventory(DeployableTurret, %player.maxInventory(DeployableTurret));
%player.addToWeaponCycle(DeployableTurret);
if (%player.getDatablock().mainWeapon.image !$= "")
{
%player.mountImage(%player.getDatablock().mainWeapon.image, 0);
}
else
{
%player.mountImage(Ryder, 0);
}
}to:function GameCore::loadOut(%game, %player)
{
//echo (%game @"c4 -> "@ %game.class @" -> GameCore::loadOut");
%player.clearWeaponCycle();
if (%player.getDatablock().mainWeapon.image !$= "")
{
%player.mountImage(%player.getDatablock().mainWeapon.image, 0);
%player.addToWeaponCycle(%player.getDatablock().mainWeapon);
%player.setInventory(%player.getDatablock().mainWeapon, 1);
%player.setInventory(%player.getDatablock().mainWeapon.image.clip, %player.getDatablock().mainWeapon.image.clip.maxInventory); // Fill Clips
%player.setInventory(%player.getDatablock().mainWeapon.image.ammo, %player.getDatablock().mainWeapon.image.ammo.maxInventory); // Fill Gun
}
else
{
%player.mountImage(Ryder, 0);
}
}Now in game/art/datablocks/player.cs
mainWeapon = Ryder;Will automatically set the weapon to Ryder when you spawn as that PlayerData.
Snd Weapon
With additional code this is not limited to a single weapon, you can define an entire weapon set for a class or player.
Example:
In game/server/scripts/gamecore.cs
Add:
if (%player.getDatablock().SndWeapon.image !$= "")
{
%player.addToWeaponCycle(%player.getDatablock().SndWeapon);
%player.setInventory(%player.getDatablock().SndWeapon, 1);
%player.setInventory(%player.getDatablock().SndWeapon.image.clip, %player.getDatablock().SndWeapon.image.clip.maxInventory); // Fill Clips
%player.setInventory(%player.getDatablock().SndWeapon.image.ammo, %player.getDatablock().SndWeapon.image.ammo.maxInventory); // Fill Gun
}
else
{
%player.setInventory(Lurker, 0);
}after:if (%player.getDatablock().mainWeapon.image !$= "")
{
%player.mountImage(%player.getDatablock().mainWeapon.image, 0);
%player.addToWeaponCycle(%player.getDatablock().mainWeapon);
%player.setInventory(%player.getDatablock().mainWeapon, 1);
%player.setInventory(%player.getDatablock().mainWeapon.image.clip, %player.getDatablock().mainWeapon.image.clip.maxInventory); // Fill Clips
%player.setInventory(%player.getDatablock().mainWeapon.image.ammo, %player.getDatablock().mainWeapon.image.ammo.maxInventory); // Fill Gun
}
else
{
%player.mountImage(Ryder, 0);
}Mainweapon will be the default weapon mounted first and now SndWeapon will be loaded into your inventory with full ammo and clips. To define the 2nd weapon simply follow below.
In art/datablocks/player.cs find:
mainWeapon = Ryder;and under add:
SndWeapon = Lurker;
Now you should spawn with the Ryder as your main weapon with the Lurker being your secondary in your inventory. Also note you'll need to change the keybinds to match up with your new inventory start up in (game/scripts/client/default.bind.cs).
If you want to add a 3rd weapon to your playerData startup simply redo the SndWeapon section and change all of the SndWeapon parts with something like ThdWeapon.
About the author
I spend most of my time working on games.
