• 🏆 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!

Unit Selection Problems with Locust

Status
Not open for further replies.
Level 14
Joined
Aug 31, 2009
Messages
775
Hey all, I'm making a projectile system for myself for a little Deathmatch/Arena type game, and I seem to have cracked the system pretty well and got it all working great.

The only real problem I have is that I cannot get an ability to work called "Reflective Shield". What this ability does, is apply a buff to your unit and all enemy incoming projectiles are bounced back and change owner (so they can hurt the original caster).

The problem is, the trigger simply refuses to pick the projectiles. The spell works absolutely perfectly when the projectiles do NOT have Locust... but this is totally not an option for obvious reasons.

So my question is... why can't I pick units in range matching condition if they're Locust Units?

Trigger in question:

Here's an example of a projectile creation trigger:
  • Frostbolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt
    • Actions
      • Set temploc = (Position of (Triggering unit))
      • Set temploc2 = (Target point of ability being cast)
      • Set tempreal = (Angle from temploc to temploc2)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at temploc facing tempreal degrees
      • Custom script: call UnitAddAbilityBJ( 'Aloc', GetLastCreatedUnit() )
      • Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
      • Hashtable - Save tempreal as 0 of (Key (Last created unit)) in HTable
      • Hashtable - Save 700.00 as 1 of (Key (Last created unit)) in HTable
      • Hashtable - Save 1400.00 as 2 of (Key (Last created unit)) in HTable
      • Hashtable - Save (50.00 x (Real((Level of (Ability being cast) for (Triggering unit))))) as 3 of (Key (Last created unit)) in HTable
      • Hashtable - Save Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl as 4 of (Key (Last created unit)) in HTable
      • Hashtable - Save Handle Of(Last created special effect) as 5 of (Key (Last created unit)) in HTable
      • Hashtable - Save 0 as 6 of (Key (Last created unit)) in HTable
      • Hashtable - Save Handle Of(Triggering unit) as 7 of (Key (Last created unit)) in HTable
      • Hashtable - Save 0.00 as 8 of (Key (Last created unit)) in HTable
      • Unit Group - Add (Last created unit) to Projectiles
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call RemoveLocation(udg_temploc2)
Where Entry 0 is Angle, Entry 1 is Speed, Entry 2 is max distance, Entry 3 is damage, Entry 4 is impact effect, Entry 5 is projectile effect, Entry 6 is an identification number (used for Frost effect of Frost Bolt, a stun effect or whatever), Entry 7 is the "owner" of the bolt".

The move/impact triggers work absolutely fine for the Projectiles, so I won't post that here.

However, it is this trigger that is not working for some reason.
  • Reflective Shield
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set tempunitgroup = (Units in (Playable map area) matching (((Matching unit) has buff Reflective Shield ) Equal to True))
      • Unit Group - Pick every unit in tempunitgroup and do (Actions)
        • Loop - Actions
          • Set tempunit = (Picked unit)
          • Set temploc = (Position of tempunit)
          • Set tempunitgroup2 = (Units within 150.00 of temploc matching ((((Matching unit) is in Projectiles) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of tempunit)) Equal to True)))
          • Unit Group - Pick every unit in tempunitgroup2 and do (Actions)
            • Loop - Actions
              • Set temploc2 = (Position of (Picked unit))
              • Special Effect - Create a special effect at temploc2 using Abilities\Spells\NightElf\ManaBurn\ManaBurnTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set tempreal = ((Angle from temploc to temploc2) + 180.00)
              • Hashtable - Save 0.00 as 8 of (Key (Picked unit)) in HTable
              • Hashtable - Save tempreal as 0 of (Key (Picked unit)) in HTable
              • Hashtable - Save Handle Oftempunit as 7 of (Key (Picked unit)) in HTable
              • Unit - Change ownership of (Picked unit) to (Owner of tempunit) and Change color
              • Custom script: call RemoveLocation(udg_temploc2)
          • Custom script: call RemoveLocation(udg_temploc)
          • Custom script: call DestroyGroup(udg_tempunitgroup2)
      • Custom script: call DestroyGroup(udg_tempunitgroup)
I wanted to reset the "Distance Travelled" back to 0 so the projectile could be fully reflected, hence the "Hashtable - Save 0.00 as 8 of (Key (Picked unit)) in HTable" part.

This second trigger works perfectly fine however when the Locust ability ('Aloc') is NOT added to the units.
 
Last edited:
Level 14
Joined
Aug 31, 2009
Messages
775
Ok, the version I came up with was this:
  • Reflective Shield
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set tempunitgroup = (Units in (Playable map area) matching (((Matching unit) has buff Reflective Shield ) Equal to True))
      • Unit Group - Pick every unit in tempunitgroup and do (Actions)
        • Loop - Actions
          • Set tempunit = (Picked unit)
          • Set temploc = (Position of tempunit)
          • Unit Group - Pick every unit in Projectiles and do (Actions)
            • Loop - Actions
              • Set temploc2 = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between temploc and temploc2) Less than or equal to 200.00
                  • ((Picked unit) belongs to an enemy of (Owner of tempunit)) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect at temploc2 using Abilities\Spells\NightElf\ManaBurn\ManaBurnTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set tempreal = ((Angle from temploc to temploc2) + 180.00)
                  • Hashtable - Save 0.00 as 8 of (Key (Picked unit)) in HTable
                  • Hashtable - Save tempreal as 0 of (Key (Picked unit)) in HTable
                  • Hashtable - Save Handle Oftempunit as 7 of (Key (Picked unit)) in HTable
                  • Unit - Change ownership of (Picked unit) to (Owner of tempunit) and Change color
                • Else - Actions
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call DestroyGroup(udg_tempunitgroup)
Is this the kind of thing you were getting at?

Edit: Just tested this and the projectiles are sort of stuck going back and forth (+180 degrees is added again and again, making them alternate). So my angle-changing needs editing somewhat - can you suggest what I need to do here?

Edit: Just realised that the Remove temploc2 was in the wrong part of the loop.
 
Level 14
Joined
Aug 31, 2009
Messages
775
Aye, it was something wrong with my Changing Owner ... I was using a debug version of the trigger by removing the "((Picked unit) belongs to an enemy of (Owner of tempunit)) Equal to True" line.

Also, I don't need to add 180 degrees to the angle - I can just leave it as Angle between temploc1 and temploc2.

Adding that back in, and with some help from a friend to test it, it works great.

Thanks for the help again Maker, you're a star.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You're welcome.

Also remember to remove temploc2 and move the temploc1 removal to the correct place.

And instead of creating a group from units that have the buff every 0.04 seconds, use a group that you won't destroy. Add units to it when they get the buff, then in the loop trigger check whether they have the buff or not, If not, remove them from the group, otherwise do the normal thing.
 
Status
Not open for further replies.
Top