I would like my ammo stations in my mod to work like those in tribes2.
Players can get a new armor, weapon, core, just by using the station.
This code works but some times the player coil skin, electric skin, effects get messed up..
I just can't seem to find the issue in my code below, if there are any Devs, around that understand how this could work, please help...
Players can get a new armor, weapon, core, just by using the station.
This code works but some times the player coil skin, electric skin, effects get messed up..
I just can't seem to find the issue in my code below, if there are any Devs, around that understand how this could work, please help...
Code:
// not working right....
function Player::equipLoadout( %this, %loadout )
{
%client = %this.client;
%curArmor = %this.getDatablock();
%curWeapon = %this.getMountedImage(0).item;
%damagePercent = %this.getDamagePercent();
Game.awardLifetime(%this);
%loadout = %client.selectedLoadout;
%newDb = (%loadout.dataBlock !$= %curArmor.getName());
%this.setDatablock(%loadout.dataBlock);
%this.spawnTime = getSimTime()/1000;
%this.stats = %this.team.stats.getPlayerStats(%client).getArmorStats(%loadout.dataBlock);
%name = %client.playerInfo.name;
if (%newDb){
%this.pickRandomSkin();
}
%this.setDamageLevel(%this.getDataBlock().maxDamage * %damagePercent);
%this.setEnergyLevel(%this.getDataBlock().maxEnergy);
%this.setRechargeRate(%this.getDataBlock().rechargeRate);
%this.setGroundRechargeRate(%this.getDataBlock().groundRechargeRate);
// make sure these settings are the same as the armor data in players folder, and preload.
if(%this.dataBlock $= "OutriderPlayer"){
%this.sethorizResistFactor(0.3);
%this.sethorizResistSpeed(100);
%this.setupResistFactor(0.3);
%this.setupResistSpeed(85);
%this.setdrag(0.004);
%this.setmass(75);
%this.setrunForce(10000);
%this.setrunSurfaceAngle(50);
}
if(%this.dataBlock $= "RaiderPlayer"){
%this.sethorizResistFactor(0.3);
%this.sethorizResistSpeed(100);
%this.setupResistFactor(0.3);
%this.setupResistSpeed(85);
%this.setdrag(0.004);
%this.setmass(95);
%this.setrunForce(10000);
%this.setrunSurfaceAngle(50);
}
if(%this.dataBlock $= "SentinelPlayer"){
%this.sethorizResistFactor(0.3);
%this.sethorizResistSpeed(100);
%this.setupResistFactor(0.3);
%this.setupResistSpeed(85);
%this.setdrag(0.004);
%this.setmass(180);
%this.setrunForce(10000);
%this.setrunSurfaceAngle(50);
}
%flags = %this.getInventory(Flag);
%this.clearLoadout();
%weaponCount = %loadout.weaponCount;
%weaponString = "";
for (%i = 0; %i < %weaponCount; %i++)
{
%this.setInventory(%loadout.weapon[%i], 1);
%weaponString = %weaponString @ ((%i) ? " " : "") @ %loadout.weapon[%i];
}
// Fill up the core hud progress bar
//ores::sendHUDUpdate(%this.client, true);
%this.inTimeOut = false;
%this.grenade = %loadout.grenade;
%this.core = %loadout.core;
if(isObject(%this.coreData))
%this.coreData.delete();
%this.coreData = new ScriptObject();
%this.setCoreIsActivated(false);
%this.warpCoreDisabledByIOD = false;
%this.core.onEquip(%this);
/*
%special = "";
switch$ (%loadout.core.longname) {
case "Overdrive":
%this.setInventory(OverdriveCore, 1);
%this.mountImage(OverdriveCoreImage, $CoreSlot);
%this.setSelectedCore($Cores::OverdriveCore);
if(%this.getDataBlock().maxDamage == 200) // <--- Aaaahahaha! What the hell :D
%special = "Sentinel";
commandToClient(%client,'EnableEngyPassive',false);
case "Regeneration":
%this.setInventory(RegenerationCore, 1);
%this.mountImage(RegenerationCoreImage, $CoreSlot);
%this.setSelectedCore($Cores::RegenerationCore);
%this.setCoreCooldownTime($Cores::RegenerationCooldownTime);
commandToClient(%client,'EnableEngyPassive',false);
case "Warp":
%this.setInventory(WarpCore, 1);
%this.mountImage(WarpCoreImage, $CoreSlot);
%this.setSelectedCore($Cores::WarpCore);
%this.setWarpCoreTimeAmount($Cores::WarpTimeAmount);
%this.setCoreCooldownTime($Cores::WarpCooldownTime);
commandToClient(%client,'EnableEngyPassive',false);
case "Shield":
%this.setInventory(ShieldCore, 1);
%this.setSelectedCore($Cores::ShieldCore);
%this.mountImage(ShieldCoreImage, $CoreSlot);
%this.setShieldCoreRadius($Cores::ShieldRadius);
commandToClient(%client,'EnableEngyPassive',false);
switch$(%this.getDataBlock().playerClass) {
case $Player::Outrider:
%this.setShieldCorePassiveDrain($Cores::ShieldDrainOutrider);
%this.data["Shield","Power"] = $Cores::ShieldPowerOutrider;
case $Player::Raider:
%this.setShieldCorePassiveDrain($Cores::ShieldDrainRaider);
%this.data["Shield","Power"] = $Cores::ShieldPowerRaider;
case $Player::Sentinel:
%this.setShieldCorePassiveDrain($Cores::ShieldDrainSentinel);
%this.data["Shield","Power"] = $Cores::ShieldPowerSentinel;
}
case "Boost":
%this.setInventory(BoostCore, 1);
%this.setSelectedCore($Cores::BoostCore);
%this.setCoreCooldownTime($Cores::BoostCooldownTime);
%this.mountImage(BoostCoreImage, $CoreSlot);
commandToClient(%client,'EnableEngyPassive',false);
case "Dodge":
%this.setInventory(DodgeCore, 1);
%this.setSelectedCore($Cores::DodgeCore);
%this.setCoreCooldownTime($Cores::DodgeCooldownTime);
%this.mountImage(DodgeCoreImage, $CoreSlot);
commandToClient(%client,'EnableEngyPassive',false);
%special = $Cores::DodgeCost;
case "Engineer":
%this.setInventory(EngineerCore, 1);
%this.setSelectedCore($Cores::EngineerCore);
%this.setCoreCooldownTime(0);
%this.mountImage(EngineerCoreImage, $CoreSlot);
commandToClient(%client,'EnableEngyPassive',true);
updateEngyGUI(%this);
//Deployables::UpdatePlayerList(%client);
}
*/
//commandToClient(%client,'SelectCore',%loadout.core.longname,%special);
%client.oldCore = %this.client.newCore;
%client.newCore = %loadout.core.longname;
if(%this.client.oldCore $= "Engineer" && %this.client.newCore !$= "Engineer")
Deployables::killOwnedDeployables(%this.client);
// This is to prevent a spawned player from being able to open up the loadout gui,
// select the ovdrive core (while using a different core), and then actually be
// able to use it (since overdrive is activated directy from the client scripts).
/*
if(%this.core.longname !$= "Overdrive") {
%this.setOverdriveAllowed(false);
} else {
%this.setOverdriveAllowed(true);
}
*/
if (%this.hasInventory(%curWeapon))
%this.use(%curWeapon);
else
%this.use(%this.weapon[0]);
%pack = %loadout.pack;
if (%pack !$= "")
%this.setInventory(%pack, 1);
%this.client.setVisibleItems(%loadout.grenade);
%this.client.setVisibleWeapons(%weaponString);
%this.setInventory(Flag, %flags);
%loadout.onEquip(%this);
}
Last edited: