🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!
How to make a trigger so that a computer hero attacks anyone withing [specific range] that has lower then 30% of health? To chase the lower health heroes within range.
The idea is to get the lowest health target, the first unit encountered is set to be saved, when the next unit is selected it is compared to the saved unit, if their health is lower it becomes the saved unit for targeting.
Ex. 5 footman with %30, %0 (dead), %21, %5, & %60 health
The footmen with %0 & %60 are ignored as they are blocked by the conditions for being deadbeat losers who have no business bothering our super intelligent AI who has better things to do then deal with foppish twits
Now we are left with %30, %21, & %5, for this example let's assume that 21% is chosen first and saved to EnBa_Target[1]:
(picked unit) %30's health is compared EnBa_Target[1]
- EnBa_Target[1]'s health is lower than %30's so we do not change EnBa_Target[1]
Lastly we are left with only EnBa_Target[1] (21%) & %5 footmen:
(picked unit) %5's health is compared EnBa_Target[1]
EnBa_Target[1]'s health is higher than %5's so we do change EnBa_Target[1] to the (picked unit) resulting in the lowest health target being selected!
When I filled out the previous example I was rather hasty, (note the "Custom script: call DestroyGroup thing idk lazy to remembr")
If you plan on using it be sure to set EnBa_Target[1] = no unit after ordering the hero, along with the proper usage of the group destruction:
Great i now undrestood why you done it so. Thanks man.
Can you tell me where should i put Custom script: call DestroyGroup cause i don't understand anything about it "Custom script: call DestroyGroup ..." ?
AI Move attack low health
Events
Time - Every 20.00 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in AIGroup and do (Actions)
Loop - Actions
Set PicketAi = (Picked unit)
Unit Group - Pick every unit in (Units within 512.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 unit) is alive) Equal to True
((Picked unit) belongs to an enemy of (Owner of PicketAi)) Equal to True
(Life of (Picked unit)) Less than or equal to 30.00
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Life of (Picked unit)) Less than or equal to (Percentage life of LowestHealth[1])
LowestHealth[1] Equal to No unit
Then - Actions
Set LowestHealth[1] = (Picked unit)
Else - Actions
Else - Actions
Unit - Order PicketAi to Attack LowestHealth[1]
Why "Unit - Remove (Picked unit) from the game" would that remove the unit??
That is an example on removing the leak caused by unit groups.
Refer to the link about memory leaks, you will see the destroy group is after the action of selecting all units.
You're creating an Ouroboros.
AIGroup1 is looking for units within range of the position of the picked units within range of picked units within range...etc.
Change "Unit Group - Pick every unit in (Units within 512.00 of (Position of (Picked unit))) and do (Actions)"
To "Unit Group - Pick every unit in (Units within 512.00 of (Position of PicketAi)) and do (Actions)"
I"ll be able to fully flesh this out once I get home, keep experimenting and look at that link regarding leaks to brush up!
ETA: Tested, works just fine
Map init (this is to establish your ai hero)
Map init
Events
Map initialization
Conditions
Actions
Custom script: set bj_wantDestroyGroup=true
Unit Group - Pick every unit in (Units in (Playable map area) matching ((Matching unit) Equal to Orc Warlock 0001 <gen>)) and do (Actions)
Loop - Actions
Set My_AIHero = (Picked unit)
Periodic
Periodic
Events
Time - Every 3.00 seconds of game time
Conditions
Actions
Set My_AIHero_Location = (Position of My_AIHero)
Set My_AIHero_Group = (Units within 2000.00 of My_AIHero_Location)
Unit Group - Pick every unit in My_AIHero_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is alive) Equal to True
(Percentage life of (Picked unit)) Less than or equal to 30.00
((Picked unit) belongs to an enemy of (Owner of My_AIHero)) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Life of (Picked unit)) Less than (Life of My_AIHero_Target)
My_AIHero_Target Equal to No unit
Then - Actions
Set My_AIHero_Target = (Picked unit)
Else - Actions
Else - Actions
Unit - Order My_AIHero to Attack My_AIHero_Target
Special Effect - Create a special effect attached to the origin of My_AIHero_Target using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
Special Effect - Destroy (Last created special effect)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.