• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Need to get facing of unit

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
Summoned Units to return mana to their Summoner

EDIT: Everything marked with * is not the final trigger. Scroll down to my last post.

So, as it turns out Raise Dead on the Necromancer does not actually target a point. Which means something like this,

  • Unit - A unit Starts the effect of an ability
  • ...
  • (Ability being cast) Equal to Raise Dead
  • ...
  • Unit - Create 1 Skeleton Warrior for (Owner of (Triggering unit)) at (Target Point of Ability being cast) facing (Target Point of Ability being cast)
Will instead spawn the units in the center of the playable map area.

So, since when Raise Dead is used the unit using the spell still FACES the corpse, I could grab all units within the range of the spell, check if they're dead, then check if the angle between the unit and the corpse is the same exact angle as the facing, then just get the point of the corpse. But, I'm not really sure how, or if I even can, get the facing of a unit...


I also need to know how to make it that when a unit finishes training, it spawns with a corpse inside it. I'm not really sure how to do that, if it's even possible.



EDIT: So, turns out there was a much easier way. So instead, I just need help finishing this trigger, as it does not work properly at all.

In my Mod, I am now starting to rebalance each race and the Undead was the first one to work on as most of their arsenal is highly underutilized. So, I started with the Crypt Fiend. Anyway, here are the triggers.


  • Cryptling Start
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Summoned unit)) Equal to Cryptling
        • Then - Actions
          • Set CryptyMaxIndex = (CryptyMaxIndex + 1)
          • For each (Integer CryptySummonedInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Summoning unit) Equal to CryptFiend[CryptySummonedInit]
                • Then - Actions
                • Else - Actions
                  • Set CryptFiend[(CryptyMaxIndex + 1)] = (Triggering unit)
          • Set Cryptling[CryptyMaxIndex] = (Last created unit)
        • Else - Actions
  • Harvest Flesh Cryptling
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of GDD_DamageSource) Equal to Cryptling
        • Then - Actions
          • For each (Integer CryptyInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CryptyInit mod 2) Not equal to 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • GDD_DamageSource Equal to Cryptling[CryptyInit]
                          • GDD_DamageSource Equal to Cryptling[(CryptyInit + 1)]
                    • Then - Actions
                      • Set TempCryptling[1] = GDD_DamageSource
                      • Unit - Create 1 Dummy Ability Unit 1 for (Owner of GDD_DamageSource) at (Position of GDD_DamagedUnit) facing (Position of GDD_DamagedUnit)
                      • Unit - Order (Last created unit) to Human Sorceress - Slow GDD_DamagedUnit
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (GDD_DamagedUnit has buff Harvest Flesh ) Equal to True
                        • Then - Actions
                        • Else - Actions
                          • Set CryptLingyDamage = (Random real number between 3.00 and 5.00)
                          • Unit - Set mana of CryptFiend[(CryptyInit + 1)] to ((Mana of CryptFiend[(CryptyInit + 1)]) + CryptLingyDamage)
                          • Trigger - Turn off (This trigger)
                          • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing CryptLingyDamage damage of attack type Pierce and damage type Normal
                          • Trigger - Turn on (This trigger)
                          • Set CryptLingyDamage = 0.00
                    • Else - Actions
                • Else - Actions
        • Else - Actions
  • Cryptors Die
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer CryptyContInit) from 1 to CryptyMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Triggering unit) Equal to CryptFiend[CryptyContInit]
            • Then - Actions
              • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
              • Set CryptFiend[CryptyMaxIndex] = No unit
              • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
              • Set Cryptling[CryptyMaxIndex] = No unit
              • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
              • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
              • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CryptyContInit mod 2) Equal to 0
                  • Cryptling[CryptyContInit] Equal to (Triggering unit)
                  • (Cryptling[CryptyContInit] is alive) Equal to False
                • Then - Actions
                  • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
                  • Set CryptFiend[CryptyMaxIndex] = No unit
                  • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
                  • Set Cryptling[CryptyMaxIndex] = No unit
                  • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
                  • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
                  • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (CryptyContInit mod 2) Not equal to 0
                      • Cryptling[CryptyContInit] Equal to (Triggering unit)
                      • (Cryptling[(CryptyContInit + 1)] is alive) Equal to False
                    • Then - Actions
                      • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
                      • Set CryptFiend[CryptyMaxIndex] = No unit
                      • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
                      • Set Cryptling[CryptyMaxIndex] = No unit
                      • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
                      • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
                      • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
                    • Else - Actions


Also, for future references if anyone needs to figure out how to get a unit to carry a corpse upon being trained, this is how I did it. You'll need Unit Event v2.0.

Here's how I did it:

  • Abomo Cargo Load
    • Events
      • Game - CargoEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of CargoTransportUnit[UDex]) Equal to Abomination
        • Then - Actions
          • Unit - Add Abomo Life Bonus to CargoTransportUnit[UDex] \\NOT NECESSARY
          • Unit - Remove Exhume Corpses from CargoTransportUnit[UDex]
          • Animation - Play CargoTransportUnit[UDex]'s stand animation \\NOT NECESSARY
        • Else - Actions
  • Abomo Cargo Unload \\NOT NECESSARY
    • Events
      • Game - CargoEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of CargoTransportUnit[UDex]) Equal to Abomination
        • Then - Actions
          • Unit - Remove Abomo Life Bonus from CargoTransportUnit[UDex]
          • Animation - Play CargoTransportUnit[UDex]'s stand animation
        • Else - Actions
 
Last edited:
Level 12
Joined
May 20, 2009
Messages
822
I would think Triggering Unit would refer to the unit that is summoning, and summoned unit refers to the summoned unit...? And it appears there is a Summoning Unit event. But, will this work for BOTH units summoned?

As in, will both units summoned from the spell have their summoner be the same unit? I mean, I don't see why not but WarCraft III is crazy sometimes...

EDIT: So, here's my trigger so far


  • Cryptling Start
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Summoned unit)) Equal to Cryptling
        • Then - Actions
          • Set CryptyMaxIndex = (CryptyMaxIndex + 1)
          • For each (Integer CryptySummonedInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Summoning unit) Equal to CryptFiend[CryptySummonedInit]
                • Then - Actions
                • Else - Actions
                  • Set CryptFiend[(CryptyMaxIndex + 1)] = (Triggering unit)
          • Set Cryptling[CryptyMaxIndex] = (Last created unit)
        • Else - Actions
 
Last edited:
Level 12
Joined
May 20, 2009
Messages
822
That doesn't help me. =\

Here's why I need them to be indexed:


  • Harvest Flesh Cryptling
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of GDD_DamageSource) Equal to Cryptling
        • Then - Actions
          • For each (Integer CryptyInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CryptyInit mod 2) Not equal to 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • GDD_DamageSource Equal to Cryptling[CryptyInit]
                          • GDD_DamageSource Equal to Cryptling[(CryptyInit + 1)]
                    • Then - Actions
                      • Unit - Create 1 Dummy Ability Unit 1 for (Owner of GDD_DamageSource) at (Position of GDD_DamagedUnit) facing (Position of GDD_DamagedUnit)
                      • Unit - Order (Last created unit) to Human Sorceress - Slow GDD_DamagedUnit
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (GDD_DamagedUnit has buff Harvest Flesh ) Equal to True
                        • Then - Actions
                        • Else - Actions
                          • Set CryptLingyDamage = (Random real number between 3.00 and 5.00)
                          • Unit - Set mana of CryptFiend[(CryptyInit + 1)] to ((Mana of CryptFiend[(CryptyInit + 1)]) + CryptLingyDamage)
                          • Trigger - Turn off (This trigger)
                          • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing CryptLingyDamage damage of attack type Pierce and damage type Normal
                          • Trigger - Turn on (This trigger)
                          • Set CryptLingyDamage = 0.00
                    • Else - Actions
                • Else - Actions
        • Else - Actions
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
Umm yeah, your crypt fiend has a spell which summons cryptlings.When these cryptlings attack something your crypt fiend gains mana right?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Why not just save the summoner to the custom value of summoned unit, or to the key id(hashtable) to summoned unit, it would be easier.
 
Level 12
Joined
May 20, 2009
Messages
822
Because I have no idea how to use Hashtables and I want to save Custom Values for something I'll actually need that for, like maybe a custom shield or another mana source or something. =o

But I guess I could look at some kinda Hashtable tutorial if that'd help...

If I could, I'd like to make this work though. And I know this could work. But I just can't figure out what's wrong with it...


EDIT:

Okay, so after some trial and error I was able to find out what was wrong with it. Thanks for trying to help, though, Ceday. =p
I'm PRETTY SURE this all works now. So I'm leaving it here for future references.

Here are the Triggers:
  • Cryptling Start
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Summoned unit)) Equal to Cryptling
        • Then - Actions
          • Set CryptyMaxIndex = (CryptyMaxIndex + 1)
          • For each (Integer CryptySummonedInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Summoning unit) Not equal to CryptFiend[CryptySummonedInit]
                      • (Summoning unit) Not equal to CryptFiend[(CryptySummonedInit + 1)]
                • Then - Actions
                  • Set CryptFiend[(CryptyMaxIndex + 1)] = (Summoning unit)
                • Else - Actions
          • Set Cryptling[CryptyMaxIndex] = (Summoned unit)
        • Else - Actions
This indexes the summoned unit. Since two units are summoned, they will always be indexed right after the other. So they will always start on an uneven number and land on an even number. But, you still need both of those conditions because the first unit summoned will have to do the Init+1, because the summoner will HAVE to always be on an even (Or odd. Just depends on preference) number. After that, all the units are indexed.

  • Harvest Flesh Cryptling
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of GDD_DamageSource) Equal to Cryptling
        • Then - Actions
          • For each (Integer CryptyInit) from 1 to CryptyMaxIndex, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CryptyInit mod 2) Not equal to 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • GDD_DamageSource Equal to Cryptling[CryptyInit]
                          • GDD_DamageSource Equal to Cryptling[(CryptyInit + 1)]
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Unit-type of GDD_DamagedUnit) is Mechanical) Equal to False
                        • Then - Actions
                          • Set CryptLingyDamage = (Random real number between 3.00 and 5.00)
                          • Unit - Set mana of CryptFiend[(CryptyInit + 1)] to ((Mana of CryptFiend[(CryptyInit + 1)]) + CryptLingyDamage)
                          • Trigger - Turn off (This trigger)
                          • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing CryptLingyDamage damage of attack type Pierce and damage type Normal
                          • Trigger - Turn on (This trigger)
                          • Set CryptLingyDamage = 0.00
                        • Else - Actions
                    • Else - Actions
                • Else - Actions
        • Else - Actions
I guess you could say this is my example trigger to use the indexed units. This causes the SUMMONED units to give extra mana to the SUMMONER unit when they attack. (CryptyInit mod 2) returns the remainder between CryptyInit and 2. If it is any number other then 0, then the Init is odd. If it IS zero, then it is even. Again, this is just preference because you could do is equal to 0, which would then mean that the number is an even number, thus the unit that launches the event will be the SECOND summoned unit (Index 2, 4, 6, 8, etc. Instead of the unit at the odd index, 1, 3, 5, 7, etc). So then instead of doing "GDD_DamageSource Equal to Cryptling[(CryptyInit + 1)]" you do "GDD_DamageSource Equal to Cryptling[(CryptyInit - 1)]"

  • Cryptors Die
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer CryptyContInit) from 1 to CryptyMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Triggering unit) Equal to CryptFiend[CryptyContInit]
            • Then - Actions
              • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
              • Set CryptFiend[CryptyMaxIndex] = No unit
              • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
              • Set Cryptling[CryptyMaxIndex] = No unit
              • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
              • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
              • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CryptyContInit mod 2) Equal to 0
                  • Cryptling[CryptyContInit] Equal to (Triggering unit)
                  • (Cryptling[(CryptyContInit + 1)] is alive) Equal to False
                • Then - Actions
                  • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
                  • Set CryptFiend[CryptyMaxIndex] = No unit
                  • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
                  • Set Cryptling[CryptyMaxIndex] = No unit
                  • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
                  • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
                  • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (CryptyContInit mod 2) Not equal to 0
                      • Cryptling[(CryptyContInit + 1)] Equal to (Triggering unit)
                      • (Cryptling[CryptyContInit] is alive) Equal to False
                    • Then - Actions
                      • Set CryptFiend[CryptyContInit] = CryptFiend[CryptyMaxIndex]
                      • Set CryptFiend[CryptyMaxIndex] = No unit
                      • Set Cryptling[CryptyContInit] = Cryptling[CryptyMaxIndex]
                      • Set Cryptling[CryptyMaxIndex] = No unit
                      • Set Cryptling[(CryptyContInit - 1)] = Cryptling[(CryptyMaxIndex - 1)]
                      • Set Cryptling[(CryptyMaxIndex - 1)] = No unit
                      • Set CryptyMaxIndex = (CryptyMaxIndex - 1)
                    • Else - Actions
This trigger Deindexes the units. Basically, if the Summoner dies then every unit is deindexed. Otherwise, we check if the Init is an Odd number again, and if it is then we check if the dying unit is equal to the Init, and if the second unit is ALREADY dead. If it is, then both units are deindexed. Vis-Versa for the final part, if the second unit is dying but the first unit is already dead, then the units are deindexed.

This sytem has a limit of 4,095 (8,912 / 2 slots used per array at a time = 4,096, - 1 because we're not using slot 0) units that can be indexed for the two arrays a piece. Thankfully, the actual limit on summoned units via Raise Dead is like 25 (In Blizzard.j, this exists: constant integer bj_MAX_SKELETONS = 25). I'm pretty sure that this counts for ALL copies of Raise Dead, or maybe all copies of Raise Dead have their own limit of 25. Either way, for all players, even if we includes the 4 neutral houses, it'd only be 400. So you'll never come anywhere near the limit of 4,095.
 
Last edited:
Status
Not open for further replies.
Top