What I want to do is I want to make him fly when jetting and use gravitational pull when crouching. I also want him his weapon so set it energy back to its max. It doesn't seem to work. What is the problem?
function SupermanRechargerImage::onFire(%this,%obj,%slot)
{
if((getSimTime() - %obj.lastSupermanCharge) > 1500)
{
Parent::onFire(%this,%obj,%slot);
%obj.setEnergyLevel(500);
%obj.mountImage(SupermanRechargerEndImage,1);
%obj.mountImage(SupermanRechargerPauseImage,1);
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.setVelocity("0 0 0");
%obj.lastSupermanCharge=getSimTime();
}
}
function SupermanBoss::onNewDataBlock(%this,%obj)
{
%obj.checkFlySched = schedule(50,0,checkFly,%obj);
%obj.checkGravitySched = schedule(50,checkGravitySched,%obj);
%obj.tool[0] = SupermanRechargerImage.getID();
messageClient(%obj.client,'MsgItemPickup','',0,SupermanRechargerImage.getID());
}
function player::checkFly(%pl)
{
if(%pl.jet == true)
{
if(%pl.getEnergyLevel() >= 0.1)
{
%pl.setEnergyLevel(%pl.getEnergyLevel() - 0.1);
%pl.addVelocity("0 0 2");
%pl.checkFlySched = schedule(50,0,checkFly,%this);
}
else
{
messageClient(%pl.client, '', "You don't have enough energy! Use the recharger!");
%pl.checkFlySched = schedule(50,checkFly,%this);
}
}
}
function player::checkGravity(%pl)
{
if(%pl.crouch == true)
{
if(%pl.getEnergyLevel() >= 0.1)
{
%pl.setEnergyLevel(%pl.getEnergyLevel() - 0.1);
%pl.addVelocity("0 0 -2");
%pl.checkGravitySched = schedule(50,checkGravitySched,%this);
}
else
{
messageClient(%pl.client, '', "You don't have enough energy! Use the recharger!");
%pl.checkGravitySched = schedule(50,checkGravitySched,%this);
}
}
}