any dummy in range of any unit?

Status
Not open for further replies.
Level 9
Joined
Dec 6, 2007
Messages
233
I'm working on my first projectile system, and it's going well so far save for the collision part. I'm having difficulty setting up a MUI trigger that detects whether any unit of unit-type dummy is within range of any other unit. My brain is hurting from trying to figure this out, so can anyone help?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
So you have a repeating trigger that moves the projectile? Create a unit group matching conditions...like this:

  • Set Temp_Group_1 = (Units within 64.00 of Temp_Loc_1 matching ((((Matching unit) is alive) Equal to True) and ((((Unit type of (Matching unit)) not equal to (Dummy)) and ...
Temp_Loc_1 is the position of the projectile. If the group is empty, there are no units in range.
 
  • Like
Reactions: Rui
Level 9
Joined
Dec 6, 2007
Messages
233
is that MUI? the movement trigger is (leaks, yeah i know, still working it out)

  • cannon shell
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set CannonShell = (Units of type Dummy Cannon Shell)
      • Unit Group - Pick every unit in CannonShell and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 20.00 towards (Facing of (Picked unit)) degrees)
EDIT: i guess i don't understand how i can make a in-range detector MUI
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You should use a group that is not created/destroyed every 0.01 seconds.

When you create projectiles, add them to a unit group, "Projectiles" or something. In the repeting trigger, pick every unit in that group.

Like here:

  • Spell Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spell
    • Actions
      • Set Temp_Unit_1 = (Triggering unit)
      • ...
      • Unit - Create 1 Dummy for Neutral Passive at Temp_Loc_1 facing Temp_Real_1 degrees
      • Custom script: call UnitAddAbility(GetLastCreatedUnit(), 'Aloc')
      • Unit Group - Add (Last created unit) to Spell_Group
      • ...
      • Trigger - Turn on Spell Loop <gen>
  • Spell Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Spell_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Unit_1 = Picked Unit
          • Set Temp_Loc_1 = (Position of Temp_Unit_1)
          • Set Temp_Loc_2 = (Temp_Loc_1 offset by Spell_Reals[2] towards Temp_Real_2 degrees)
          • -------- -------------------- --------
          • Unit - Move Temp_Unit_1 instantly to Temp_Loc_2
          • ...
          • Set Temp_Group_1 = (Units within Spell_Reals[3] of Temp_Loc_2 matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of Temp_Unit_2)) Equal to True)))
          • ...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Spell_Group is empty) Equal to True
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
Then you check if the unit group (Temp_Group_1) is empty or not right after creating it. And do your things. If the projectile exlodes or something, remove it from the group, Spell Group in this case.
 
Last edited:
Level 9
Joined
Dec 6, 2007
Messages
233
I understand what you are saying about the movement trigger, i will fix that (+rep). But, for the other trigger, what if a shell is fired, then another shell is fired before the first one hits anything. Will it still work? Wouldn't Temp_Unit_1 be overwritten, therefore stopping the first shell in it's tracks? I didn't imagine a trigger to kill any dummy within 50 of any other unit would be so complicated
 
Level 9
Joined
Dec 6, 2007
Messages
233
soz for double post, but i tried your method, and it didn't work. The shells fired, but they didn't explode

Here's full code:

Shell Spawn (spawns two shells):

  • cannon
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to space ship
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Attacking unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set Shooter_Owner = Player 11 (Dark Green)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Attacking unit)) Equal to Player 2 (Blue)
            • Then - Actions
              • Set Shooter_Owner = Player 12 (Brown)
            • Else - Actions
      • Set Temp_Point1 = (Position of (Attacking unit))
      • Set Temp_Point3 = (Position of (Triggering unit))
      • Set Temp_Point2 = (Temp_Point1 offset by 25.00 towards ((Facing of (Attacking unit)) + 90.00) degrees)
      • Unit - Create 1 Dummy Cannon Shell for Shooter_Owner at Temp_Point2 facing Temp_Point3
      • Unit - Turn collision for (Last created unit) Off
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to CannonShell
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Set Temp_Point2 = (Temp_Point1 offset by 25.00 towards ((Facing of (Attacking unit)) + 270.00) degrees)
      • Unit - Create 1 Dummy Cannon Shell for Shooter_Owner at Temp_Point2 facing Temp_Point3
      • Unit - Turn collision for (Last created unit) Off
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to CannonShell
      • Custom script: call RemoveLocation(udg_Temp_Point2)
      • Custom script: call RemoveLocation(udg_Temp_Point1)
      • Custom script: call RemoveLocation(udg_Temp_Point3)
Movement+Death:

  • cannon shell
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CannonShell and do (Actions)
        • Loop - Actions
          • Set Temp_Unit1 = (Picked unit)
          • Set Temp_Point4 = ((Position of (Picked unit)) offset by 60.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to Temp_Point4
      • Set Temp_Group1 = (Units within 50.00 of Temp_Point4 matching ((((Triggering unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of Temp_Unit1)) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Group1 is empty) Equal to False
        • Then - Actions
          • Unit - Kill (Triggering unit)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Group1)
      • Custom script: call RemoveLocation(udg_Temp_Point4)
Edit: oops, leaks in second trigger. let me fix

Edit2: changed out second trigger, leaks fixed

Edit3: after trying out some planned features, i've discovered that my general problem is that i don't know how to detect collisions and the unit-types that collided using GUI
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • cannon shell
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CannonShell and do (Actions)
        • Loop - Actions
          • Set Temp_Unit1 = (Picked unit)
          • Set Temp_Point1 = Position of Temp_Unit_1
          • Set Temp_Point2 = (Temp_Point1) offset by 60.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Move (Picked unit) instantly to Temp_Point2
          • Set Temp_Group1 = (Units within 50.00 of Temp_Point2 matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of Temp_Unit1)) Equal to True)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Temp_Group1 is empty) Equal to False
            • Then - Actions
              • Unit - Kill (Temp_Unit1)
              • Remove Temp_Unit_1 from CannonShell
              • If CannocShell is empty turn off this trigger
            • Else - Actions
          • Custom script: call DestroyGroup(udg_Temp_Group1)
          • Custom script: call RemoveLocation(udg_Temp_Point1)
          • Custom script: call RemoveLocation(udg_Temp_Point2)
 
Level 9
Joined
Dec 6, 2007
Messages
233
sweet, thanks for the help

{EDIT}
Another problem cropped up.

The only projectile i'm having issues with anymore is the fighter's rocket. If one rocket hits, the rest immediately stop, whether they've hit or not. And occasionally, the rocket never goes, just sits where it spawned. Here is the map, see if you can figure it out:

View attachment spacebattletest.w3x

I've set up a little test on the terrain. NOTE: the random number added to the facing angle in the rockets code is to give it a wobbly path, which works nicely.

EDIT: updated version, this has a working shield system. But with these shields comes another problem: remove the three fighters and the frigate on the bottom, and observe the fight between the two frigates up top. When the shields go down, the shells continue to deal 0 damage, EXCEPT if you issue your frigate another order, then tell it to attack again. Bizarre, right? any ideas about the cause?
 
Last edited by a moderator:
Level 9
Joined
Dec 6, 2007
Messages
233
yup, this has fixed it. About the triggered damage: i don't see how that would change things. The projectiles are essentially mines. Shields don't disarm the mine, they just force it to detonate further out. The mine never deals any less damage, so that bug... was just weird. In any case, it's fixed now. thanks for the help, i'll holler again if i need any more.

{EDIT}
I did a large scale test today, and found large scale lag. After some investigation, i determined that the shield triggers are the culprits. However, i couldn't spot any leaks.

Updated shield triggers:

  • apply
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Sheilds_Ready = (Units in (Playable map area) matching ((((Custom value of (Matching unit)) Equal to 0) and ((Max mana of (Matching unit)) Greater than 0.00)) and ((Mana of (Matching unit)) Greater than or equal to 50.00)))
      • Unit Group - Pick every unit in Sheilds_Ready and do (Actions)
        • Loop - Actions
          • Unit - Add Sheilds to (Picked unit)
          • Unit - Set the custom value of (Picked unit) to 1
          • Unit Group - Add (Picked unit) to Sheild_Protectees
      • Custom script: call DestroyGroup(udg_Sheilds_Ready)
  • function
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Sheild_Protectees and do (Actions)
        • Loop - Actions
          • Set Sheild_Violatee = (Picked unit)
          • Set Sheild_Violatee_Loc = (Position of Sheild_Violatee)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Frigate
            • Then - Actions
              • Set Sheild_Radius = 300.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Railgun Emplacement
                • Then - Actions
                  • Set Sheild_Radius = 150.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to Carrier
                    • Then - Actions
                      • Set Sheild_Radius = 250.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to Cruiser
                        • Then - Actions
                          • Set Sheild_Radius = 500.00
                        • Else - Actions
          • Set Sheild_Violators = (Units within Sheild_Radius of Sheild_Violatee_Loc matching ((((Matching unit) is A sapper) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
          • Unit Group - Pick every unit in Sheild_Violators and do (Actions)
            • Loop - Actions
              • Set Sheild_Violator = (Picked unit)
              • Set Sheild_Violator_Loc = (Position of Sheild_Violator)
              • Set Sheild_Violatees = (Units within Sheild_Radius of (Position of Sheild_Violatee) matching ((Custom value of (Matching unit)) Equal to 1))
              • Unit Group - Pick every unit in Sheild_Violatees and do (Actions)
                • Loop - Actions
                  • Unit - Set mana of Sheild_Violatee to ((Mana of Sheild_Violatee) - (Life of Sheild_Violator))
                  • Unit - Kill Sheild_Violator
      • Custom script: call DestroyGroup(udg_Sheild_Violators)
      • Custom script: call DestroyGroup(udg_Sheild_Violatees)
      • Custom script: call RemoveLocation(udg_Sheild_Violatee_Loc)
      • Custom script: call RemoveLocation(udg_Sheild_Violator_Loc)
  • effect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Sheild_Protectees and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\ReplenishMana\ReplenishManaCasterOverhead.mdl
          • Special Effect - Destroy (Last created special effect)
  • remove
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Sheilds_Dying = (Units in (Playable map area) matching (((Mana of (Matching unit)) Equal to 0.00) and (((Custom value of (Matching unit)) Equal to 1) and ((Mana of (Matching unit)) Less than 50.00))))
      • Unit Group - Pick every unit in Sheilds_Dying and do (Actions)
        • Loop - Actions
          • Unit - Remove Sheilds from (Picked unit)
          • Unit Group - Remove (Picked unit) from Sheild_Protectees
          • Unit - Set the custom value of (Picked unit) to 0
          • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call DestroyGroup(udg_Sheilds_Dying)
NOTE: I've classified all missiles "sappers"
 
Last edited by a moderator:
  • Angry
Reactions: Rui
Level 37
Joined
Mar 6, 2006
Messages
9,243
In "apply" trigger you check the max mana and current mana. Check only current mana.
In function, use Sheild_Violatee variable instead of "picked unit" in the IF/THEN/ELSE and in the unit group pick, "belongs to an enemy of (Owner of (Picked unit))..."
All your custom script leak removals are in wrong places. Move "call DestroyGroup(udg_Sheild_Violators)" and "call RemoveLocation(udg_Sheild_Violatee_Loc)" inside the "Unit Group - Pick every unit in Sheild_Protectees" loop, and the other two leak removals inside "Unit Group - Pick every unit in Sheild_Violators" loop.

  • Set Sheild_Violatees = (Units within Sheild_Radius of (Position of Sheild_Violatee)...
Position of... leaks.
 
Level 9
Joined
Dec 6, 2007
Messages
233
no, if i move the destroy scripts there then the trigger won't work because it will kill variables before i'm done using them. Why does it even matter where the script is anyway? wouldn't it still remove the leaks?

EDIT: otherwise, you were right about the apply trigger
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
spencenator said:

I'm not talking out of my ass here...

Do it like this:

  • function
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Sheild_Protectees and do (Actions)
        • Loop - Actions
          • Set Sheild_Violatee = (Picked unit)
          • Set Sheild_Violatee_Loc = (Position of Sheild_Violatee)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Frigate
            • Then - Actions
              • Set Sheild_Radius = 300.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Railgun Emplacement
                • Then - Actions
                  • Set Sheild_Radius = 150.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to Carrier
                    • Then - Actions
                      • Set Sheild_Radius = 250.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to Cruiser
                        • Then - Actions
                          • Set Sheild_Radius = 500.00
                        • Else - Actions
          • Set Sheild_Violators = (Units within Sheild_Radius of Sheild_Violatee_Loc matching ((((Matching unit) is A sapper) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
          • Unit Group - Pick every unit in Sheild_Violators and do (Actions)
            • Loop - Actions
              • Set Sheild_Violator = (Picked unit)
              • Set Sheild_Violator_Loc = (Position of Sheild_Violator)
              • Set Sheild_Violatees = (Units within Sheild_Radius of (Position of Sheild_Violatee) matching ((Custom value of (Matching unit)) Equal to 1))
              • Unit Group - Pick every unit in Sheild_Violatees and do (Actions)
                • Loop - Actions
                  • Unit - Set mana of Sheild_Violatee to ((Mana of Sheild_Violatee) - (Life of Sheild_Violator))
                  • Unit - Kill Sheild_Violator
              • Custom script: call RemoveLocation(udg_Sheild_Violator_Loc)
              • Custom script: call DestroyGroup(udg_Sheild_Violatees)
          • Custom script: call DestroyGroup(udg_Sheild_Violators)
          • Custom script: call RemoveLocation(udg_Sheild_Violatee_Loc)
 
Level 9
Joined
Dec 6, 2007
Messages
233
mmk, i guess i was just confused about where you were telling me to put them. Unfortunately, the lag persists, and it's just as horrendous as before.
 
Status
Not open for further replies.
Top