mr. Duck 0 Posted May 15, 2007 Right, so I tried making some sort of health regeneration script for vehicles. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; We are an armored vehicle _vehicle = _this select 0 ; check our health _damage = getDammage _vehicle ; start damage control, start repair when damage is sufficient #loopcheck ?(0.4 < _damage) : goto "repair" goto "loopcheck" ; start repairing #repair ?(0 == _damage) : goto "ending1" ~1.5 _damage = _damage - 0.2 goto "repair" #ending1 ~0.5 _vehicle vehicleChat "Hull repaired" Exit And the relevant eventhandler for this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers : ECP_EventHandlers { incomingMissile="_this call (ECP_resources select 44); if((_this select 0)==(_this select 0)) then {[_this] exec ""\TerranTank\scripts\spoofmissile.sqs""}"; hit="if((_this select 0)==(_this select 0)) then {[_this] exec ""\TerranTank\scripts\nanobots.sqs""}"; }; And, this gives me an error... Share this post Link to post Share on other sites
Metal Heart 0 Posted May 15, 2007 _damage is not a pointer to the vehicles damage but a new variable with its value, you need to use setDammage in the script to repair the vehicle. It would help if you told what the error message says, but I think the problem is that you assume the "hit" 's _this is the unit, but it's an array: _this=[unit, causedBy, damage] http://community.bistudio.com/wiki....ist#Hit So change the hit handler to: _this exec ""\TerranTank\scripts\nanobots.sqs""; NOT: [_this] exec... Also, does the array ECP_resources exist? Share this post Link to post Share on other sites
mr. Duck 0 Posted May 15, 2007 Ok, I tried the setDammage commands, now the script looks like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Right, we are an armored vehicle _vehicle = _this select 0 ; check our health _damage = getDammage _vehicle ; start damage control, start repair when damage is sufficient #loopcheck ?(0.1 < _damage) : goto "repair" goto "loopcheck" ; start repairing #repair _vehicle vehicleChat "Hull damage detected, activating nanobots" ~1 _vehicle setDammage 0.2 ~1 _vehicle setDammage 0.1 ~1 _vehicle setDammage 0 ~0.7 _vehicle vehicleChat "Hull repaired" Exit The good news is, the error is gone. The bad news is, the script won't activate (afaik), I keep on receiving damage untill I die. Correct me if I'm wrong but this part: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(0.1 < _damage) : goto "repair" Stands for when the vehicle has received 10% damage, then go to repair, right? Share this post Link to post Share on other sites
Macser_old 0 Posted May 15, 2007 Hey Mr.Duck, That script works very well for me. I took a few hits,it reported the damage and repaired it. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Hit= "if((_this select 0)==(_this select 0)) then {_this exec ""\PJTA_UD4L\S\Heal.sqs""}"; Does your hit EH differ much from this one? Apart from the obvious. I made no changes in the script. So could it be something to do with the Ecp EHs? Share this post Link to post Share on other sites
mr. Duck 0 Posted May 15, 2007 It works now, nope my EH did not differ from yours. The problem was that I put the script on the wrong tank... Thanks all! Here's a reworked version in case anybody might be interested for future use: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Right, we are an armored vehicle _vehicle = _this select 0 ; check our health _damage = getDammage _vehicle ; start damage control, start repair when damage is sufficient #loopcheck ?(0.25 < _damage) : goto "repair" goto "loopcheck" ; start repairing #repair _vehicle vehicleChat "Hull damage detected, activating nanobots" #repairing ?(0 == _damage) goto "end1" _damage = getDammage _vehicle ~1 _damage = _damage - 0.1 _vehicle setDammage _damage goto "repairing" #end1 _vehicle vehicleChat "Hull repaired, nanobots deactivated" Exit Share this post Link to post Share on other sites