RepairRate woe
by Chris Byars · in Torque Game Engine · 02/23/2006 (6:40 pm) · 9 replies
Having a bit of trouble getting the repairRate of a player's health to stop for 3 seconds until it resumes repairing. (Basically a delay before healing when you take damage)
In player.cs, I have:
Then down in function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType) , I put:
I've tried many variations, all to no success. Anyone have any ideas on how to do this?
Thanks in advance! :)
In player.cs, I have:
function Armor::resumeRepair(%this,%obj)
{
%obj.setRepairRate(0.4);
}Then down in function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType) , I put:
%obj.setRepairRate(0); // This stops the repair, works. %obj.schedule(3000, resumeRepair); // this has issues
I've tried many variations, all to no success. Anyone have any ideas on how to do this?
Thanks in advance! :)
#2
02/23/2006 (7:36 pm)
Isn't.. that what it is?
#3
02/23/2006 (9:17 pm)
Note the " "
#4
%obj.schedule(3000, resumeRepair, %obj); instead of what you have
I think :)
02/24/2006 (12:26 am)
You need to pass the %obj%obj.schedule(3000, resumeRepair, %obj); instead of what you have
I think :)
#5
@Mr Meikel: Nope, nothing. No console reports on anything either.
Edit: Ah, got it.
Only trouble is, I want the last damage taken to set the countdown to 5 seconds before it repairs. Say I get damaged, then in 5 seconds the repairRate will be set to 0.4. Well if I got damaged two seconds after the initial damage, I'll heal in 3 seconds, since the schedule was called already from the initial damage to, in five seconds, set the repairRate back to 0.4.
02/24/2006 (6:52 am)
@Tim: There's really no difference though, that was one of the variations I tried, same effect. @Mr Meikel: Nope, nothing. No console reports on anything either.
Edit: Ah, got it.
function Player::resumeRepair(%this)
{
%this.setRepairRate(0.4);
}
function Armor::damage(%this, %obj, ...)
{
...
%obj.setRepairRate(0); // This stops the repair
%obj.schedule(5000, resumeRepair); // lets the repair continue after 5 seconds
...Only trouble is, I want the last damage taken to set the countdown to 5 seconds before it repairs. Say I get damaged, then in 5 seconds the repairRate will be set to 0.4. Well if I got damaged two seconds after the initial damage, I'll heal in 3 seconds, since the schedule was called already from the initial damage to, in five seconds, set the repairRate back to 0.4.
#6
I'm just curious if those nice little dollar signs will function right if you're in a networked game.
02/24/2006 (11:32 am)
Well I got it working perfectly by doing this in Armor::damage:%obj.setRepairRate(0); // This stops the repair, works.
if ($repairSchedule) { cancel($repairSchedule); }
$repairSchedule = %obj.schedule(5000, resumeRepair);I'm just curious if those nice little dollar signs will function right if you're in a networked game.
#7
02/24/2006 (11:49 am)
Why store it as a global variable?%obj.setRepairRate(0);
if (%obj.pendingRepairScheduledEvent)
{
cancel(%obj.pendingRepairScheduledEvent);
}
%obj.pendingRepairScheduledEvent = %obj.schedule(5000, resumeRepair);
#8
02/24/2006 (11:57 am)
Yeah, storing it as a global will cause you grief if more than one player is going to repair.
#9
02/24/2006 (12:19 pm)
Thanks Stephen. :)
Torque 3D Owner Martin "Founder" Hoover
%obj.schedule(3000, "resumeRepair");