Author Topic: Playertype with a special ability when pressing jet. need help  (Read 934 times)

I need this for my player type shooter
When the player will press the jet button, he will do sprint forward and he will lose energy with animation of Am_activate2

If someone can help me by giving me a code for the option I will release the player type. please help.
I suck at scripting, I tried to put a code from Gamemode_Zapt, but it didn't work:
Code: [Select]
function BlockRiotPHoleBot::Special(%this, %obj)
{
%energy = %obj.getEnergyLevel();

if(%energy >= 15)
{
%mount = %obj.getObjectMount();

if(!isObject(%mount))
{
%start = %obj.getPosition();
%end = vectorSub(%start, "0 0 1");
%masks = ($TypeMasks::FxBrickObjectType | $TypeMasks::PlayerObjectType | $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::VehicleObjectType);

%ground = getWord(containerRayCast(%start, %end, %masks, %obj), 0);

if(isObject(%ground))
{
%aimVec = %obj.zombieAimVec();
%obj.setVelocity(vectorScale(%aimVec, 18));

%obj.setEnergyLevel(%energy - 15);
%obj.playThread(2, "jump");

return true;
}
}
else if(%energy >= 50)
{
%start = %mount.getPosition();
%end = vectorSub(%start, "0 0 1");
%masks = ($TypeMasks::FxBrickObjectType | $TypeMasks::PlayerObjectType | $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::VehicleObjectType);

%ground = getWord(containerRayCast(%start, %end, %masks, %obj), 0);

if(isObject(%ground))
{
%aimVec = %obj.zombieAimVec();
%mount.setVelocity(vectorScale(%aimVec, 12));

%obj.setEnergyLevel(%energy - 35);
%mount.playThread(2, "jump");

return true;
}
}
}

return false;
}

Sorry for bad English


Does it possible that it will cost energy?

Well, you could attach a energy variable to their %target.player when they spawn. The variable will last as long as the player does (Until the player dies) and you can deduct and add to that variable as you wish.

This should be in coding help first of all.

Second of all, to have it cost energy, most people probably would use an alternative datablock that has the runEnergyDrain on the player datablock to a certain value.
That would be more reliable then a looped reduction of energy whenever they start running.

Shouldn't this be in coding help?