Targeting lowest health unit

A forum for discussing map making ideas and problems for the Myth series.

Moderator: Doobie

Targeting lowest health unit

Postby SamualACarver » Mon Sep 10, 2012 8:12 am

Is there anyway that you can have then enemy units target the Players unit with the lowest health? I was looking through the Test Unit actions in the Vitality stuff but didnt see anything I thought would work. I guess I would need a way to check a group of units compare their health then target the units with the lowest health. I'm just not sure if it is possible or what combination of commands I would need. Can anyone help me out on this?

Thanks Sam
SamualACarver
 
Posts: 83
Joined: Thu Dec 13, 2007 10:08 am

Re: Targeting lowest health unit

Postby A-Red » Mon Sep 10, 2012 11:58 am

Certainly not with TUNIs. It might be possible with some sequence of GEOM and MATH (the latter is after my time--I really don't know what it's capable of). Unless you have a very specific reason to want to do this, the complexity and problematic side effects would probably keep it from being worth the effort. For one thing, a feature like this is fairly hard to notice ingame (except in the "why is this level so much more frustrating than usual?" sense), unless players have a very limited number of units, like in a hero level. Also, it gives the player the opportunity to exploit the enemy's AI--hit a zerk with a bottle and then have him run all the enemies around in circles while your missile units wear them down.
User avatar
A-Red
 
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm

Re: Targeting lowest health unit

Postby Pyro » Mon Sep 10, 2012 2:44 pm

What A-Red said is worth thinking about, but if you still want to give it a shot keep reading. Do the following and adjust it to match your needs. In this thread I describe how to use the Math action. It might help.

GEOM. Find Hurt Units
Monsters (subj)
Health Fraction Less Than
Entire Map
Tested Items Inside Field Name
Results Action Identifier
Activates on Failure "Increase Health Check"
Activates on Success "Reset Health Check"

MATH. Increase Health Check
Left Action Identifier "Find Hurt Units"
Left Field Name "hef<"
Add
Right Decimal Number "0.01"
Destination Action Identifier "Find Hurt Units"
Destination Field Name "hef<"
Activates on Execution "Find Hurt Units"

MATH. Reset Health Check
Left Decimal Number "0.01"
Destination Action Identifier "Find Hurt Units"
Destination Field Name "hef<"
Activates on Execution "Find Hurt Units"

Make the GEOM's expiration mode to be "on execution". In the GEOM, for the "Monsters (subj)" parameter, add all the possible units you want to run this test on. For "Health Fraction Less Than", add a small value for example "0.01". You might need to play around with that to see what is best for you. Keep in mind for that parameter 0.0 means no health and 1.0 means 100% full health. If the location of these units does not matter, then "Entire Map" is what you want. If you only want to check near certain locations you will need to use a Polygon or a Circle geometry.

For "Tested Items Inside Field Name" it depends where these results will go. If these units are "Targets" in an Attack action then you will use "obje". For "Results Action Identifier" you will put the action you want these results to go. For example, you can put them into an Attack action.

For "Activates on Failure" you will put the "MATH. Increase Health Check" action. This will alter the "Health Fraction Less Than" value when no units are found with that much health. For "Activates on Success" you will put whatever you want to happen when it finds a unit with that little health. Also you will want to activate the "MATH. Reset Health Check" action. This will reset the value back to a low number. This way it can run a new test and find hurt units that might have gotten damaged when the GEOM was not running.

Whatever you decide to use for the starting "Health Fraction Less Than" value use it on the "Reset Health Check" Math action as well. In the "Increase Health Check" Math action I used a value of 0.01 for the increments, but you can change that to whatever you want as well.
User avatar
Pyro
Bug Finder Extraordinaire
 
Posts: 4687
Joined: Sun Mar 21, 2004 2:14 pm
Location: Texas

Re: Targeting lowest health unit

Postby SamualACarver » Tue Sep 11, 2012 12:07 am

Awesome Thanks Pyro! Now if I can just put everything together right. As far a your concerns A-Red the player just gets a few units and this should work good. It wont be the only attack option the enemy can make just one of them. Thanks though for pointing out possible issues.

Thanks Sam
SamualACarver
 
Posts: 83
Joined: Thu Dec 13, 2007 10:08 am

Re: Targeting lowest health unit

Postby A-Red » Fri Sep 14, 2012 10:51 am

Cool, I'm glad you could get it to work. Also keep in mind that you can only have so many GEOMs going at a time, I think 6 or 7 (at least as of 1.6), so you'll want to be aware of how many different groups of enemies are using scripts like this at a time and how many other features you want to use that require GEOMs. The way the script is set up (geom then math then geom, looping infinitely) would help to stagger them somewhat, but if you run into trouble, that may be the reason.
User avatar
A-Red
 
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm


Return to Map Making Support

Who is online

Users browsing this forum: No registered users and 1 guest