|
Post by keepitsimple on Dec 3, 2022 11:55:43 GMT 1
How to destroy an unit can be found in Calvin Lua Guide.
With below script which I place below INIT part of the program (so don't need scroll throw it looking up the bug in script), makes slighty easier as only need give number of unit ones. --------------------------------------------------------- --------------- New command: DestroyUnit ------------------ ---------------------------------------------------------
function DestroyUnit(iScriptID) DamageObject(iScriptID, GetObjectHPs(iScriptID)); end;
To destroy a unit is now enough to add the following line in you script DestroyUnit(nr)
-- example this will destroy units 100, 110 and 120
function Destroy() DestroyUnit(100); DestroyUnit(110); DestroyUnit(120); Suicide(); end;
Now, if don't want to destroy but only damage an unit then following script helps to make it easy. Again place below the UNIT section in the script and now you give the command DamageUnit(100,75) to give the unit 100 a health of 75. Of course you can also bring back the health with 100 or destroy it with 0.
--------------------------------------------------------- ----- New command: DamageUnit ------------------ ---------------------------------------------------------
function DamageUnit(iScriptID, DamageHP) local health=GetObjectHPs(iScriptID); local dhp=((100-DamageHP)/100)*health; --DisplayTrace("Damage to unit %g is %g",iScriptID,dhp); DamageObject(iScriptID, dhp); end;
|
|
|
Post by keepitsimple on Dec 10, 2022 11:13:42 GMT 1
A small correction on previous post. There is difference between an object like a building and unit like a tank.
To damage or destory an object previous post is correct. However, it doesn't work for an unit. The good news for an unit it's much simpler.
To destroy a unit (100) this is enough DamageObject(100, 0);
To damage a unti (100) this is enough DamageObject(100,nr); with nr > 0 and nr <HP unit. The higher nr the more damage.
|
|
|
Post by keepitsimple on Dec 11, 2022 0:21:27 GMT 1
Don't want to damage but cure an unit?
DamageObject(100,-nr) restores an unit back to health again with nr. The greater nr the greater the cure up 100% health!
|
|