• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random Region Conflict

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I am creating a system for a boss fight in my map. The "Infected Farmer" boss runs to a random region (Green rectangle). He then teleports to another random region (Green rectangle), leaving behind some zombies. He runs from this new region to the center region (Blue rectangle).

Demonstration.jpg


  • Infected Farmer Run Start
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • DamageEventTarget Equal to Infected Farmer 0302 <gen>
    • Actions
      • Game - Display to (All players) the text: Farmer's Damage Detected
      • Countdown Timer - Start InfectedFarmerTimer as a One-shot timer that will expire in (Random real number between 6.00 and 8.00) seconds
      • Trigger - Turn off (This trigger)
  • Infected Farmer Run
    • Events
      • Time - InfectedFarmerTimer expires
    • Conditions
    • Actions
      • Custom script: call DestroyTimer(udg_InfectedFarmerTimer)
      • Game - Display to (All players) the text: Timer expired. Farmer running.
      • Set InfectedFarmerTempRegion1 = InfectedFarmerRegions[(Random integer number between 1 and 4)]
      • Set TempPoint = (Center of InfectedFarmerTempRegion1)
      • Unit - Order Infected Farmer 0302 <gen> to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Trigger - Turn on Infected Farmer Damage <gen>
      • Trigger - Turn on Infected Farmer Teleport <gen>
      • Trigger - Turn off (This trigger)
  • Infected Farmer Damage
    • Events
      • Unit - A unit comes within 128.00 of Infected Farmer 0302 <gen>
    • Conditions
      • ((Triggering unit) belongs to an enemy of (Owner of Infected Farmer 0302 <gen>)) Equal to True
      • (Unit-type of (Triggering unit)) Not equal to Ghost
    • Actions
      • Unit - Cause Infected Farmer 0302 <gen> to damage (Triggering unit), dealing 85.00 damage of attack type Spells and damage type Normal
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\ManaBurn\ManaBurnTarget.mdl
      • Special Effect - Destroy (Last created special effect)
  • Infected Farmer Teleport
    • Events
      • Unit - A unit enters Zombie 1 Spawn <gen>
      • Unit - A unit enters Zombie 2 Spawn <gen>
      • Unit - A unit enters Zombie 3 Spawn 1 <gen>
      • Unit - A unit enters Zombie 3 Spawn 2 <gen>
    • Conditions
      • (Triggering unit) Equal to Infected Farmer 0302 <gen>
    • Actions
      • Game - Display to (All players) the text: Farmer has teleported.
      • Trigger - Turn off (This trigger)
      • Trigger - Turn on Infected Farmer Return <gen>
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Create (Random integer number between 2 and 3) Mutated Zombie for Player 9 (Gray) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Set TempPoint = (Center of InfectedFarmerRegions[(Random integer number between 1 and 4)])
      • Unit - Move (Triggering unit) instantly to TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Set TempPoint = (Center of Infected Farmer Spawn <gen>)
      • Unit Group - Order (Last created unit group) to Patrol To TempPoint
      • Unit - Order (Triggering unit) to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
  • Infected Farmer Return
    • Events
      • Unit - A unit enters Infected Farmer Spawn <gen>
    • Conditions
      • (Triggering unit) Equal to Infected Farmer 0302 <gen>
    • Actions
      • Game - Display to (All players) the text: Farmer has Returned.
      • Trigger - Turn on Infected Farmer Run Start <gen>
      • Trigger - Turn off Infected Farmer Damage <gen>
      • Trigger - Turn off (This trigger)
Two Problems:

1.) The Infected Farmer can teleport to a region that he teleported from giving the appearance that he never teleported at all. I need to make the Farmer teleport to any random region BUT NOT the region he was teleporting from.

2.) Does the timer leak at all? Read somewhere that it leaks.

Could I get some help please?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Know which rect has been entered/which rect the Farmer is supposed to move to first and ensure it's the one that triggers Infected Farmer Teleport. Save that rect in a variable, move the last element of the array to the index of the rolled rect. For selecting a rect to teleport to, only roll from 1 to 3 now. Afterwards put the previously cached rect on the last index of the array [4].
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Know which rect has been entered/which rect the Farmer is supposed to move to first and ensure it's the one that triggers Infected Farmer Teleport. Save that rect in a variable, move the last element of the array to the index of the rolled rect. For selecting a rect to teleport to, only roll from 1 to 3 now. Afterwards put the previously cached rect on the last index of the array [4].

I could follow the first half of your instructions, but I got confused on how to compile 3 regions into the arrays. I've done it this way (although I'm sure there's a better way to do it):

  • Infected Farmer Run
    • Events
      • Time - InfectedFarmerTimer expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Timer expired. Farm...
      • Set InfectedFarmerRegions[1] = Zombie 1 Spawn <gen>
      • Set InfectedFarmerRegions[2] = Zombie 2 Spawn <gen>
      • Set InfectedFarmerRegions[3] = Zombie 3 Spawn 1 <gen>
      • Set InfectedFarmerRegions[4] = Zombie 3 Spawn 2 <gen>
      • Set InfectedFarmerTempRegion1 = InfectedFarmerRegions[(Random integer number between 1 and 4)]
      • Trigger - Add to Infected Farmer Teleport <gen> the event (Unit - A unit enters InfectedFarmerTempRegion1)
      • Set TempPoint = (Center of InfectedFarmerTempRegion1)
      • Unit - Order Infected Farmer 0302 <gen> to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Trigger - Turn on Infected Farmer Damage <gen>
      • Trigger - Turn on Infected Farmer Teleport <gen>
      • Trigger - Turn off (This trigger)
  • Infected Farmer Teleport
    • Events
    • Conditions
      • (Triggering unit) Equal to Infected Farmer 0302 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Zombie 1 Spawn <gen> contains (Center of InfectedFarmerTempRegion1)) Equal to True
        • Then - Actions
          • Set InfectedFarmerRegions[1] = Zombie 2 Spawn <gen>
          • Set InfectedFarmerRegions[2] = Zombie 3 Spawn 1 <gen>
          • Set InfectedFarmerRegions[3] = Zombie 3 Spawn 2 <gen>
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Zombie 2 Spawn <gen> contains (Center of InfectedFarmerTempRegion1)) Equal to True
            • Then - Actions
              • Set InfectedFarmerRegions[1] = Zombie 1 Spawn <gen>
              • Set InfectedFarmerRegions[2] = Zombie 3 Spawn 1 <gen>
              • Set InfectedFarmerRegions[3] = Zombie 3 Spawn 2 <gen>
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Zombie 3 Spawn 1 <gen> contains (Center of InfectedFarmerTempRegion1)) Equal to True
                • Then - Actions
                  • Set InfectedFarmerRegions[1] = Zombie 1 Spawn <gen>
                  • Set InfectedFarmerRegions[2] = Zombie 2 Spawn <gen>
                  • Set InfectedFarmerRegions[3] = Zombie 3 Spawn 2 <gen>
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Zombie 3 Spawn 2 <gen> contains (Center of InfectedFarmerTempRegion1)) Equal to True
                    • Then - Actions
                      • Set InfectedFarmerRegions[1] = Zombie 1 Spawn <gen>
                      • Set InfectedFarmerRegions[2] = Zombie 2 Spawn <gen>
                      • Set InfectedFarmerRegions[3] = Zombie 3 Spawn 1 <gen>
                    • Else - Actions
      • Game - Display to (All players) the text: Farmer has teleport...
      • Trigger - Turn off (This trigger)
      • Trigger - Turn on Infected Farmer Return <gen>
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Create (Random integer number between 2 and 3) Mutated Zombie for Player 9 (Gray) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Set TempPoint = (Center of InfectedFarmerRegions[(Random integer number between 1 and 3)])
      • Unit - Move (Triggering unit) instantly to TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Set TempPoint = (Center of Infected Farmer Spawn <gen>)
      • Unit Group - Order (Last created unit group) to Patrol To TempPoint
      • Unit - Order (Triggering unit) to Move To TempPoint
      • Custom script: call RemoveLocation (udg_TempPoint)
I'm normally one to be satisfied with whatever dodgy system I make as long as it works and doesn't lag, lol. One question though. How do I clear the events within a trigger? I mean, the event "A unit enters region" is added to one of the triggers every time this runs. Theoretically, this can eventually lead to hundreds of events. Isn't this a form of leak (Redundant memory usage).
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Yes, it leaks. And it would trigger on any rect entered. In GUI, you do not have an event response to get the triggered rect/region. You could either ask if the unit is within a rect that slightly surrounds the one in question (and that does not overlap with the other) when any is entered. Or you go jass and work with regions instead of GUI rects. Or you make separate triggers for each rect (you can still outsource the common actions in an extra trigger and execute it).

Instead of
  • (Zombie 1 Spawn <gen> contains (Center of InfectedFarmerTempRegion1)) Equal to True
(which leaks a location btw), you could have simply saved the rolled index and compared that to fixed numbers.
 
Status
Not open for further replies.
Top