• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Tree resurrection skill

Level 2
Joined
Dec 8, 2023
Messages
11
I need help in debugging some scripts. what i want to find out is if it has some memory leaks (i have no idea what that means) or whatever that will make the game crash after a long run. and other suggestions to make the script cleaner. and other stuff that evaded my noobie eyes that you may have noticed. thanks! ;)


SCRIPT 1
Natures Prophet resurrect
Events
Time - Every 10.00 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Keeper of the Grove
Then - Actions
Set NaturesProphetcasterunit = (Picked unit)
Destructible - Pick every destructible within 1000.00 of (Position of NaturesProphetcasterunit) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked destructible) is dead) Equal to True
Then - Actions
Set NaturesProphettreeresurrectrea = (NaturesProphettreeresurrectrea + 1.00)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Life of NaturesProphetcasterunit) Less than ((Max life of NaturesProphetcasterunit) x 0.50)
(NaturesProphettreeresurrectrea x 50.00) Greater than ((Life of NaturesProphetcasterunit) x 0.50)
(NaturesProphettreeresurrectrea x 50.00) Greater than ((Max life of NaturesProphetcasterunit) x 0.50)
NaturesProphettreeresurrectrea Equal to 0.00
Then - Actions
Set NaturesProphettreeresurrectrea = 0.00
Skip remaining actions
Else - Actions
Unit - Set life of NaturesProphetcasterunit to ((Life of NaturesProphetcasterunit) - (NaturesProphettreeresurrectrea x 20.00))
Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Show birth animation
Hero - Add ((Integer(NaturesProphettreeresurrectrea)) x 10) experience to NaturesProphetcasterunit, Show level-up graphics
Set NaturesProphetsfxinteger = 1
Else - Actions
Do nothing
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
NaturesProphetsfxinteger Equal to 1
Then - Actions
Animation - Play NaturesProphetcasterunit's spell animation
Special Effect - Create a special effect attached to the origin of NaturesProphetcasterunit using Abilities\Spells\NightElf\Tranquility\Tranquility.mdl
Set NaturesProphetsfx = (Last created special effect)
Wait 2.00 seconds
Animation - Reset NaturesProphetcasterunit's animation
Special Effect - Destroy NaturesProphetsfx
Set NaturesProphettreeresurrectrea = 0.00
Set NaturesProphetsfxinteger = 0
Else - Actions
Do nothing


DESCRIPTION
What it does is that for every 10 secs a hero if there are dead trees in 1000 aoe around him will resurrect it that will cost him 20 hp and give him 10 xp. but if the hero doesn't have enough life, it will not work. the math that i used is sloppy and i think does not really work how i intended it to be, but works nonetheless. it is supposed to be that when his life is less than half or if the cost is more than half is current or max life.


SCRIPT 2
Natures Prophet regen
Events
Time - Every 2.00 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Keeper of the Grove
Then - Actions
Destructible - Pick every destructible within 1000.00 of (Position of (Picked unit)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked destructible) is alive) Equal to True
Then - Actions
Set NaturesProphettreeregenreal = (NaturesProphettreeregenreal + 1.00)
Else - Actions
Do nothing
Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + (NaturesProphettreeregenreal x 0.50))
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + (NaturesProphettreeregenreal x 0.25))
Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\NightElf\EntBirthTarget\EntBirthTarget.mdl
Set NaturesProphettreeregenreal = 0.00
Else - Actions
Do nothing


DESCRIPTION
what this does is that every two seconds every tree in 1000 aoe around the hero will restore him
 
Top