Author Topic: Flash Repair breaks changing datablocks?  (Read 570 times)

I'm kinda confused whats wrong
Code: [Select]
datablock AudioProfile(StealthJumpSound)
{
   filename    = "./StealthJump.wav";
   description = Audio2d;
   preload = true;
};


datablock PlayerData(PlayerStealthArmor : PlayerStandardArmor)
{
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
  runForce = 100 * 60;
   runEnergyDrain = 0;
   minRunEnergy = 0;
   maxForwardSpeed = 8;
   maxBackwardSpeed = 5;
   maxSideSpeed = 6;

//maxDamage = 100;
repairRate = (200/35);

   maxForwardCrouchSpeed = 5;
   maxBackwardCrouchSpeed = 3;
   maxSideCrouchSpeed = 2;
  
jumpForce = 12 * 90; //8.3 * 90;
   jumpEnergyDrain = 0;
   minJumpEnergy = 0;
   jumpDelay = 0;

jumpsound = "StealthJumpSound";
uiName = "Stealth Player";
showEnergyBar = false;
};
datablock PlayerData(PlayerStealthInjuredArmor : PlayerStandardArmor)
{
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
  runForce = 100 * 60;
   runEnergyDrain = 0;
   minRunEnergy = 0;
   maxForwardSpeed = 6;
   maxBackwardSpeed = 2;
   maxSideSpeed = 2;

//maxDamage = 100;
//repairRate = (1000/5);

   maxForwardCrouchSpeed = 3;
   maxBackwardCrouchSpeed = 1;
   maxSideCrouchSpeed = 1;
  
jumpForce = 6 * 90; //8.3 * 90;
   jumpEnergyDrain = 0;
   minJumpEnergy = 0;
   jumpDelay = 100;

jumpsound = "StealthJumpSound";
uiName = "StealthInjured Player";
showEnergyBar = false;
};

function PlayerStealthArmor::onDamage(%this,%obj,%am)
{
parent::onDamage(%this,%obj,%am);
if(%obj.getdamagelevel() >= 80)
{
%obj.setdatablock("PlayerStealthInjuredArmor");
StealthNearDeathLoop(%obj);
return;
}
}

function PlayerStealthInjuredArmor::onDamage(%this,%obj,%am)
{
parent::onDamage(%this,%obj,%am);
if(%obj.getdamagelevel() <= 80)
{
%obj.setdatablock("PlayerStealthArmor");
}
}


function StealthNearDeathLoop(%obj)
{
cancel(%obj.NearDeathSchedule);
if(isobject(%obj) && %obj.getstate() !$= "Dead" && %obj.getdatablock().getname() $= "PlayerStealthInjuredArmor")
{
//%obj.playpain();
%obj.setdamageflash(0.3);
%obj.NearDeathSchedule = schedule(500,%obj,StealthNearDeathLoop,%obj);
}
}
/////////////////////////////////////////////////////////////////////////////////////
function PlayerStealthArmor::onDamage(%this,%obj,%delta)
{
  Parent::onDamage(%this,%obj,%delta);
   if(%delta > 0)
   {
      if(isEventPending(%obj.StealthRepairSched))
         cancel(%obj.StealthRepairSched);
      
      %obj.setRepairRate(0);
      if(%obj.getState() !$= "Dead")
         %obj.StealthRepairSched = %obj.schedule(1750,doFlashRepair);
   }
}

function Player::doFlashRepair(%obj)
{
%obj.setRepairRate((%obj.getDamageLevel()*1)/(6*%obj.dataBlock.maxDamage*%obj.getDamageFlash()));
}


if I remove all the lines after the ////'s it works fine, how would I fix this?

Code: [Select]
package(playertype);

datablock AudioProfile(StealthJumpSound)
{
   filename    = "./StealthJump.wav";
   description = Audio2d;
   preload = true;
};


datablock PlayerData(PlayerStealthArmor : PlayerStandardArmor)
{
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
  runForce = 100 * 60;
  runEnergyDrain = 0;
    minRunEnergy = 0;
    maxForwardSpeed = 8;
    maxBackwardSpeed = 5;
    maxSideSpeed = 6;

//maxDamage = 100;
repairRate = (200/35);

  maxForwardCrouchSpeed = 5;
    maxBackwardCrouchSpeed = 3;
    maxSideCrouchSpeed = 2;
   
jumpForce = 12 * 90; //8.3 * 90;
    jumpEnergyDrain = 0;
    minJumpEnergy = 0;
    jumpDelay = 0;

jumpsound = "StealthJumpSound";
uiName = "Stealth Player";
showEnergyBar = false;
};
datablock PlayerData(PlayerStealthInjuredArmor : PlayerStandardArmor)
{
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
  runForce = 100 * 60;
  runEnergyDrain = 0;
    minRunEnergy = 0;
    maxForwardSpeed = 6;
    maxBackwardSpeed = 2;
    maxSideSpeed = 2;

//maxDamage = 100;
//repairRate = (1000/5);

  maxForwardCrouchSpeed = 3;
    maxBackwardCrouchSpeed = 1;
    maxSideCrouchSpeed = 1;
   
jumpForce = 6 * 90; //8.3 * 90;
    jumpEnergyDrain = 0;
    minJumpEnergy = 0;
    jumpDelay = 100;

jumpsound = "StealthJumpSound";
uiName = "StealthInjured Player";
showEnergyBar = false;
};

function PlayerStealthArmor::onDamage(%this,%obj,%am)
{
parent::onDamage(%this,%obj,%am);
if(%obj.getdamagelevel() >= 80)
{
%obj.setdatablock("PlayerStealthInjuredArmor");
StealthNearDeathLoop(%obj);
return;
}
}

function PlayerStealthInjuredArmor::onDamage(%this,%obj,%am)
{
parent::onDamage(%this,%obj,%am);
if(%obj.getdamagelevel() <= 80)
{
%obj.setdatablock("PlayerStealthArmor");
}
}


function StealthNearDeathLoop(%obj)
{
cancel(%obj.NearDeathSchedule);
if(isobject(%obj) && %obj.getstate() !$= "Dead" && %obj.getdatablock().getname() $= "PlayerStealthInjuredArmor")
{
//%obj.playpain();
%obj.setdamageflash(0.3);
%obj.NearDeathSchedule = schedule(500,%obj,StealthNearDeathLoop,%obj);
}
}
/////////////////////////////////////////////////////////////////////////////////////
function PlayerStealthArmor::onDamage(%this,%obj,%delta)
{
  Parent::onDamage(%this,%obj,%delta);
   if(%delta > 0)
   {
      if(isEventPending(%obj.StealthRepairSched))
         cancel(%obj.StealthRepairSched);
     
      %obj.setRepairRate(0);
      if(%obj.getState() !$= "Dead")
         %obj.StealthRepairSched = %obj.schedule(1750,doFlashRepair);
   }
}

function Player::doFlashRepair(%obj)
{
%obj.setRepairRate((%obj.getDamageLevel()*1)/(6*%obj.dataBlock.maxDamage*               %obj.getDamageFlash()));
              }
      }
}
activatepackage(playertpe);

I'm asking how to fix it not for a code that has syntax errors and doesn't work

I'm asking how to fix it not for a code that has syntax errors and doesn't work

Make it a package.