• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

change ownership trigger problem

Status
Not open for further replies.
Hi,

Well, I would like to make trigger so when a player brings a unit on a Circle of Power, the Circle of Power will change its ownership to be owned by the same player.
My problem is, I don't know how to make the event. When I use the event
Unit - Unit within range
I can't choose a unit type or a variable. I can only choose a unit on the map.
Am I supposed to do this for each circle of power? I mean, for every 88 circle of power in the map?
If someone know how to help me, please help.

Thanks in advance :)
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
This seems to work:

  • Trigger
    • Events
      • Time - Every 0.09 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CircleofPowerGroup and do (Actions)
        • Loop - Actions
          • Set CircleofPowerUnit = (Picked unit)
          • Set TempGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Circle of Power (medium)))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Set TempPoint = (Position of CircleofPowerUnit)
              • Set TempPoint2 = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between TempPoint and TempPoint2) Less than or equal to 100.00
                • Then - Actions
                  • Unit - Change ownership of CircleofPowerUnit to Player 2 (Blue) and Change color
                • Else - Actions
              • Custom script: call RemoveLocation (udg_TempPoint)
              • Custom script: call RemoveLocation (udg_TempPoint2)
          • Custom script: call DestroyGroup (udg_TempGroup)
The CircleofPowerGroup are all units on the map except for the circles of power. You need a system to compile all units that enter the game into this group, and a system to remove these units when they perhaps die. I believe a unit indexing system might do exactly that. For the purpose of my demo map, I just just set the units at map initialization.
 

Attachments

  • Unit Ownership.w3x
    17.5 KB · Views: 55
Level 16
Joined
Mar 27, 2011
Messages
1,349
As I said, I have over 80 circle of power. I don't know if it's the problem,
but when I test the map, I get HUUUGE lags. I can't even test it and I don't think players will like these lags

Yeah, when I tested, I only had 3 circles and 4 units. Just added 88 circles to the map and it was unplayable, even after optimizing the trigger. Using only 4 circles despite having hundreds of units doesn't lag however. The lag happens when there are lots of circles.

Unless you somehow cut down your circles to 4 or less, my method won't work :/ sorry.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Just found another way to do it. This way doesn't lag, despite having lots of units and/or circles. You don't need to have any unit indexer either. You just need to create a region the size of a circle of power (Hopefully all your circles are the same size).

  • Register Units
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Circle of Power (medium)))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to PowerCirclesGroup
      • Custom script: call DestroyGroup (udg_TempGroup)
  • Trigger
    • Events
      • Time - Every 0.33 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PowerCirclesGroup and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • Region - Center Circle of Power Region <gen> on TempPoint
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Set TempGroup = (Units in Circle of Power Region <gen> matching ((Unit-type of (Matching unit)) Not equal to Circle of Power (medium)))
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color
          • Custom script: call DestroyGroup (udg_TempGroup)
 

Attachments

  • Unit Ownership.w3x
    34.9 KB · Views: 39
sorry for keeping you waiting.
I think there was a misunderstanding.
I was trying to include this trigger in my map before testing your map.
It didn't worked in my map, but when I tryed your map, when footmens walked on circle of power, their ownership changed.
That's not what I wanted.
What I wanted is that the Circle of Power itself will have its ownership changed to the player who sent a unit on it.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I have seen a risk map which use this circle system, map creator was using Enter region events for all circles instead of looping through.And there were something like 100 circles.You need to start working :)
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Use the Trigger - Add Event when creating your circles to a trigger that changes the ownership of the circle?

Oh yeah. Didn't think of this. Is this how to do it?

  • Register Units
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Circle of Power (medium)))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Trigger - Add to Circle Trigger <gen> the event (Unit - A unit comes within 100.00 of (Picked unit))
      • Custom script: call DestroyGroup (udg_TempGroup)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Yeah that enter range event is very good idea, although you should also save "Unit being entered" somewhere.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
"Circle Trigger"

The "CircleTrigger" is your trigger. The trigger that converts the ownership of the circle to the owner of the unit who stepped on it. Simple really:

  • CircleTrigger
    • Events
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 150.00 of TempPoint matching ((Unit-type of (Matching unit)) Equal to Circle of Power (medium)))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
      • Custom script: call DestroyGroup (udg_TempGroup)
      • Custom script: call RemoveLocation (udg_TempPoint)
Remember, the trigger has no events. The other trigger I posted adds the events to it. At the moment, this trigger allows other players to "steal" the circle of power from other units who have claimed it. If you only want a circle to be captured once, do this:

  • CircleTrigger
    • Events
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempGroup = (Units within 150.00 of TempPoint matching ((Unit-type of (Matching unit)) Equal to Circle of Power (medium)))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Neutral Passive
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
            • Else - Actions
      • Custom script: call DestroyGroup (udg_TempGroup)
      • Custom script: call RemoveLocation (udg_TempPoint)
 

Attachments

  • Unit Ownership.w3x
    34.8 KB · Views: 47
Status
Not open for further replies.
Top