Comrades in Arms Discussion Board
Converting a script - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: Converting a script (/showthread.php?tid=3182)



Converting a script - Watchmen - 11-29-2015

I made this health regen script, or stole a few, combined the bits and added to it^^ but it is for player units and i want to turn it into a script that works where it only needs to be called in the unit init. Basically something that does not require player to be fulfilled in order to work that works for ai and any number of units that are playable. Thanks


Code:
while {alive player} do
{
_t = time;
waitUntil {time - _t > 1};

if (damage player > 0) then
{
_newDamage = (damage player) - 0.1;
player setdamage _newDamage;
};
sleep 0.05;};



Re: Converting a script - Phantom - 11-29-2015

change player to _this .

I called it in unit's init a nul = this execVM "regen.sqf";

Here's taken from a very old zombie mission I made with a boss bloodsucker with increased health
Code:
private ["_newDamage","_t"];
while {alive _this} do
{
   _t = time;
   waitUntil {time - _t > 1};
   if (damage _this > 0) then
      {
      _newDamage = (damage _this) - 0.01;
      _this setdamage _newDamage;
      };
   sleep 0.5;
};



Re: Converting a script - Watchmen - 11-29-2015

That script looks alot like mine but i have some questions.
Why the null=this why not just execVM "script".
What is purpose of the line private ["_newDamage","_t"];


Re: Converting a script - Phantom - 11-29-2015

I have no idea for the private, but I don't think its necessary. I grabbed it off the forums somewhere and copied verbatim except I replaced player with _this.


You need nul = execVM for unit's init since it's not the init.sqf . If you don't put nul = in unit's init line you get "Type Script, expected Nothing". You can put any other variable instead of nul anyways, but by default, use nul/null if you're not going to assign that script to some variable or something.


Re: Converting a script - Phantom - 11-30-2015

I think private isn't necessary since scoping isn't an issue here.


Re: Converting a script - Alwarren - 11-30-2015

(11-30-2015, 10:31 AM)Phantom link Wrote: I think private isn't necessary since scoping isn't an issue here.

You need private only if you use a function va 'call'.