Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: [SOLVED] Detecting energy of a high templar
[SOLVED] Detecting energy of a high templar
This topic is locked. You can no longer write replies here.
Aug 13 2011, 6:32 pm
By: Ice Baby  

Aug 13 2011, 6:32 pm Ice Baby Post #1



I would like to be able to detect the energy of a high templar. Even wen the ht uses storm and hallucination. Any ideas on how to do this?



None.

Aug 13 2011, 6:37 pm xAngelSpiritx Post #2

eternal lurker

You'll need to look into EUDs. There's links in the FAQ/Map Making Resources topics (they're the pinned topics) to get you started.



None.

Aug 13 2011, 6:49 pm NudeRaider Post #3

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

You could detect the spell effects. E.g. hallucination detection or a unit dying by psi storm. But that's only viable in very defined scenarios. Otherwise, yes you have to use EUDs which are not beginner friendly. You'll have to learn a lot of new stuff.




Aug 13 2011, 11:19 pm Ice Baby Post #4



Ok i spent the last few hours looking at posts and the suggested topics. It didnt really say how to "learn" eud. I know slightly more but i still have no idea how to detect energy.

This is exactly what i want to do,
When the high templar has anything less than 50 energy, then set energy to 55. But i still want it to be able to gain more if u dont use storm or hallucination, and possibly even sit at 250 energy if its not being used for awhile.

Even after looking at those posts im not sure where to start. Most of the information went right over my head.



None.

Aug 13 2011, 11:32 pm TiKels Post #5



Quote
Even after looking at those posts im not sure where to start. Most of the information went right over my head.
Quote
Otherwise, yes you have to use EUDs which are not beginner friendly. You'll have to learn a lot of new stuff.

Best thing you can do is find someone knowledgeable about the subject (I would do my best to help you but I'm not at home) and start asking questions. Probably start with health detection and work your way up.



"If a topic that clearly interest noone needs to be closed to underline the "we don't want this here" message, is up to debate."

-NudeRaider

Aug 13 2011, 11:43 pm Roy Post #6

An artist's depiction of an Extended Unit Death

The energy address for a unit is +40 from the start index (using EPDs).
59CD48    19065    ENERGY POINTS: AtLeast 16777216(x), AtMost 16777216(x) + 16777215


From: http://www.staredit.net/topic/10471/




Aug 14 2011, 1:25 am Sacrieur Post #7

Still Napping

Keep in mind EUDs won't work in multiplayer. (Only local EUDs affecting a global action won't work).

Post has been edited 2 time(s), last time on Aug 14 2011, 9:35 pm by Sacrieur.



None.

Aug 14 2011, 1:30 am Roy Post #8

An artist's depiction of an Extended Unit Death

Quote from Sacrieur
Keep in mind EUDs won't work in multiplayer.
Wrong, wrong, wrong! These types of EUDs will work flawlessly in multiplayer, as unit data is shared. Only unshared (aka local) data won't work.

Quote from Roy
The energy address for a unit is +40 from the start index (using EPDs).
59CD48    19065    ENERGY POINTS: AtLeast 16777216(x), AtMost 16777216(x) + 16777215


From: http://www.staredit.net/topic/10471/
I figured you would probably need more guidance as to how to approach this problem, since you are unfamiliar with EUDs:

To find a unit's index, open up the map in SCMDraft 2, select the unit, and right-click -> properties. The "Index" column is the value of interest. If your SCMDraft doesn't have this, you have an old version; the latest can be found here

If your unit's index is 0, then you already have the EPD value you need from the Known EUD Reference link (19065). If your unit's index is not 0, you can calculate the EPD value for energy by following this special equation I just made:

y = 161865 - 84x

Where x is the unit index. For example, if your unit's index was 19:

y = 161865 - 84(19)
y = 161865 - 1596
y = 160269

So your Memory condition would read:

Memory at + 160269 is X Y


As for calculating the range of values, you have to follow the "AtLeast 16777216(x), AtMost 16777216(x) + 16777215" equation specified. If you wanted to check if the unit had between 100 and 200 energy:

a = 16777216(100)
a = 1677721600

b = 16777216(200) + 16777215
b = 3355443200 + 16777215
b = 3372220415

So the final condition would look like:

Memory at + 160269 is at least 1677721600
Memory at + 160269 is at most 3372220415


Since you only want to check if the High Templar has less than 50 energy, you would only need to check for an "at most" using 49 as X in the equation "AtMost 16777216(x) + 16777215."

This should be a good learning exercise for you. If you are unsure if you calculated your numbers correctly, post the unit index and the values you got and someone here will verify it. I encourage you to try this yourself first, though.

As for your action, to reset the Templar's energy to 55, you'll want to use "Modify Unit Energy" and set it to 22%. Assuming each player only has one High Templar, your final trigger will look something like:

Trigger
Players
  • Player 1
  • Conditions
  • Memory at + XXXXXX is at most YYYYYY
  • Actions
  • Set energy points for All Protoss High Templar owned by Current Player at 'Anywhere' to 22%.
  • Preserve Trigger.

  • You would have a trigger like this for each player that owns a High Templar.

    If players have multiple High Templars, you're going to have to implement a way to uniquely identify each Templar, such as using http://www.staredit.net/topic/11454/.




    Aug 14 2011, 9:22 pm Lanthanide Post #9



    I've never really done anything with EUDs, but I see that it relies on unit index.

    Does this mean it's only feasible for use with pre-placed units?



    None.

    Aug 14 2011, 9:28 pm Roy Post #10

    An artist's depiction of an Extended Unit Death

    Yeah, if you cannot accurately figure out the unit index, then you're kinda dead in the water. This almost always requires the unit to be preplaced.




    Aug 14 2011, 10:44 pm Azrael Post #11



    Or if all units are always created in the same order.




    Aug 15 2011, 3:24 pm NudeRaider Post #12

    We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

    Quote from name:Azrael.Wrath
    Or if all units are always created in the same order.
    and "uncreated" aka die, killed or removed.




    Aug 15 2011, 5:44 pm Sacrieur Post #13

    Still Napping

    Supposing that you can keep track of all the units created/destroyed, you still have the problem of having to create the triggers for all of the IDs that the unit could be.

    That's not practical.



    None.

    Aug 15 2011, 6:26 pm Roy Post #14

    An artist's depiction of an Extended Unit Death

    Quote from Roy
    Yeah, if you cannot accurately figure out the unit index, then you're kinda dead in the water. This almost always requires the unit to be preplaced.
    Quote from name:Azrael.Wrath
    Or if all units are always created in the same order.
    Quote from NudeRaider
    and "uncreated" aka die, killed or removed.
    Quote from Sacrieur
    Supposing that you can keep track of all the units created/destroyed, you still have the problem of having to create the triggers for all of the IDs that the unit could be.
    There seems to be a lot of discussion on this, so I'll clarify:

    The Index ID is determined based on when the unit is placed on the map. Assuming no units have died, this means that the ID will increment upwards, starting from 0 (which is the first unit placed on the map). Start locations DO NOT get assigned an Index ID (SCMD2 incorrectly does this). To make your Index list accurate, place the Start Locations after all units you're checking indexes for. Start Locations appear to be the only exception (units like Map Revealers, Scanner Sweeps, etc. have Index IDs).

    The way the next index is assigned to a unit is as follows: As soon as that unit is either in production or has otherwise appeared on the map, they are given an Index ID. This Index ID is not released until the unit's presence on the map is gone. After a unit comes into existence, SC performs some logical test to find the next index. THIS INDEX IS NOT ALWAYS PREDICTABLE.

    For example:

    1) The Index Queue is set to 0 at the beginning of the game (no units exist yet).
    2) A unit is created. Its index gets set to the Index Queue's current value (0).
    3) SC finds a new available index (1).
    4) The Index Queue is set to the available index (1).
    5) 50 more units are created following this pattern. They each have a unique index from 1 to 50.
    6) SC finds a new available index (51).
    7) The Index Queue is set to the available index (51).
    8) All 51 units on the map are removed via triggers.
    9) A unit is created. Its index gets set to the Index Queue's current value (51).
    10) SC finds a new available index (0).
    11) The Index Queue is set to the available index (0).

    In the above example, at step 9, even though there were no units on the map, and thus index 0 is available, the next unit to be placed gets assigned index 51 before SC looks for a new available index. In other words, the next index is predetermined, and it is calculated immediately after some unit is assigned an Index ID.

    Now, that was all based on observation and hypothesis. To be honest, I am unsure exactly how SC assigns indexes. Attached to this post is a map you can experiment with if you want to try and find a pattern. It almost seems like SC is using some strange variation of the Quick Sort algorithm, as you may notice that when creating/killing units very quickly, it begins to alternate between two polarized points in the list.

    TL;DR: Just preplace the damn units.




    Aug 15 2011, 6:50 pm jjf28 Post #15

    Cartography Artisan

    Important to note that the index you pre-placed a unit at, is not guarenteed unless every unit before it is always in the game (all players with units that have earlier index's are in the game).

    Having the units you are going to detect energy/health for pre-placed at the earliest index's for player 9-12 (or for a player that is required for the game), then given to appropriate players gets around this annoyance.



    TheNitesWhoSay - Clan Aura - github

    Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

    Aug 15 2011, 8:38 pm Sacrieur Post #16

    Still Napping

    You can find a unit's index ID with a free computer slot.

    • Run a trigger that identifies all currently existing index IDs (by confirming they have HP).
    • Create unit at LID x for player 8 (computer).
    • Recheck index IDs that were not identified as being active. Run triggers that check for each inactive index ID for a unit that has HP and is owned by player 8.
    • The index ID of the newly created unit has been identified.




    None.

    Aug 15 2011, 9:00 pm Roy Post #17

    An artist's depiction of an Extended Unit Death

    Quote from Sacrieur
    Run a trigger that identifies all currently existing index IDs (by confirming they have HP).
    If a unit is removed or killed via triggers, the value of their HP is still stored in memory. It seems as though your system would otherwise have no issues.

    We are going off-topic, though. Ice Baby probably doesn't have a strong understanding of EUDs in the first place, and to suggest him to use such a complex system over using a preplaced unit is a tad ludicrous.




    Aug 15 2011, 9:09 pm Sacrieur Post #18

    Still Napping

    Continuing discussion in another thread.



    None.

    Aug 15 2011, 9:15 pm Ice Baby Post #19



    Ok so the unit index is the number at which the unulit was created on the map correct? But what if i make the high templar in the middle of the game? Since there would be multiple units on the map and some may havr died already. How do i find the index of tge high templar i created mid game?



    None.

    Aug 15 2011, 9:19 pm Lanthanide Post #20



    Don't. It's not worth the hassle, and even the experts don't really know how to do this.

    Depending on how many high templars you need and how you use them, you may be best just pre-placing them for P9-12 in some un-used corner of the map, and then when you need to create one for the player, instead of creating it, simply move one of them from the holding pen and Give it to your human player.

    If the human player can freely build templars, eg from a gateway, then you're basically screwed. Redesign your map so you can use a fixed number of pre-placed templars, or give up on the idea. You're only talking about setting energy to 55 when it goes below 50 anyway; you can most likely achieve very close to the same effect that you want by simply making Psi Storm cost less energy and start all high templars off with 0 energy instead of 50 (again, difficult if the player is building high templar from gateways).



    None.

    Options
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [02:26 pm]
    UndeadStar -- Vrael, since the ad messages get removed, you look like a total madman for someone that come late
    [2024-5-02. : 1:19 pm]
    Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
    [2024-5-02. : 1:35 am]
    Ultraviolet -- Vrael
    Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
    Gonna put deez sportballs in your mouth
    [2024-5-01. : 1:24 pm]
    Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
    [2024-4-30. : 5:08 pm]
    Oh_Man -- https://youtu.be/lGxUOgfmUCQ
    [2024-4-30. : 7:43 am]
    NudeRaider -- Vrael
    Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
    Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
    [2024-4-29. : 6:36 pm]
    RIVE -- Nah, I'm still on Orange Box.
    [2024-4-29. : 4:36 pm]
    Oh_Man -- anyone play Outside the Box yet? it was a fun time
    [2024-4-29. : 12:52 pm]
    Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
    [2024-4-29. : 11:17 am]
    Zycorax -- :wob:
    Please log in to shout.


    Members Online: Roy, lil-Inferno