Author Topic: Superman : Datablock Powers problem  (Read 378 times)

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?

Code: [Select]
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);
  }
 }
}
« Last Edit: March 10, 2013, 05:38:22 PM by Advanced Bot »

Nevermind, fixed it. Gah, I really need to think before posting.

Code: [Select]
%obj.mountImage(SupermanRechargerEndImage,1);
%obj.mountImage(SupermanRechargerPauseImage,1);

uh

did you mean to mount those in separate slots or

Code: [Select]
%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");

uhh

I fixed all of that, it looks like this now.

Code: [Select]
function SupermanRechargerImage::onFire(%this,%obj,%slot)
{
Parent::onFire(%this,%obj,%slot);
 if((getSimTime() - %this.lastSupermanCharge) > 2000)
 {
%obj.setEnergyLevel(500);
%obj.mountImage(SupermanRechargerEndImage,1);
%obj.setSuperFreeze = %obj.schedule(10,"setSuperFreeze");
%obj.stopSuperFreeze = %obj.schedule(990,"stopSuperFreeze");
%obj.setDatablock(SupermanFrozenBoss);
%obj.lastSupermanCharge=getSimTime();
 }
}

function player::stopSuperFreeze(%this,%obj)
{
%this.unmountImage(%this.getMountedImage(1) == SupermanRechargerEndImage.getID());
cancel(%this.setSuperFreeze);
%this.setDatablock(SupermanBoss);
}

function player::setSuperFreeze(%this,%obj)
{
%this.setVelocity("0 0 0");
%this.setSuperFreeze = %this.schedule(10,"setSuperFreeze");
}

function SupermanBoss::onNewDataBlock(%this,%obj)
{
parent::onNewDataBlock(%this,%obj);
%this.checkFlySched = %this.schedule(10,"checkFly");
%this.checkGravitySched = %this.schedule(10,"checkGravity");
}

Everything works. I just need to re-look before posting.