Need help with trigger!

Status
Not open for further replies.
Level 2
Joined
May 18, 2012
Messages
18
Hi, so I want to add something to a private usage map.
I want a preset unit to attack anyone carrying a specific item, but only at night.
If the items gets dropped, daytime kicks in or the targeted unit dies, I want the preset unit to stop attacking, and return to the region he came from.

If anyone could help me make this, that'd be great
 

EdgeOfChaos

E

EdgeOfChaos

I'll explain generally how to do so, ask if you need more help.

You're going to want a Unit Indexer to index the attacking unit to the hero it's attacking. When night comes, select every unit with the item, create a unit, order it to attack, and index it properly. Do the same thing if a unit picks up the item.

When day comes, a unit dies, or a unit drops an item, simply call RemoveUnit(index) to get rid of the attacker.
 
Level 2
Joined
May 18, 2012
Messages
18
Well, I'm quite new to scrypting, my triggers are very basic and I have no idea what you just said, would you mind adding a map or a screenshot for me? Just so I'll have an example
 
Level 11
Joined
Jan 23, 2015
Messages
788
u need these two triggers:

trig1
events
every 1 second of game time
condition
actions
if
day time is greater or equal to 18:00 and daytime is less than 6:00 and Night is equal to false
then
set Night = true
order [unit] to attack random unit from units matching (matching unit is owning [item]
if
day time is greater or equal to 6:00 and daytime is less than 18:00 and Night is equal to true
then
set Night = false
order [unit] to move to center of region

trigger 2
events
every 1 sec of gametime
conditions
Night = true
order of [unit] = stop
actions
order [unit] to attack random unit from units matching (matching unit is owning [item]

hope i helped you sorry i couldnt give u a trigger, its coz im not using my PC
if theres smth u dont understand just ask me ;)
 
Level 2
Joined
May 18, 2012
Messages
18
It didn't work, these are the triggers I wrote according to your comment
[trigger=Nazgul attack basic]Nazgul attack basic
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((In-game time of day) Greater than or equal to 18.00) and (((In-game time of day) Less than 6.00) and (Night Equal to False))
Then - Actions
Set Night = True
Unit - Order Nazgûl (on foot) 0159 <gen> to Attack (Random unit from (Units in (Playable map area) matching (((Item carried by (Matching unit) of type The 1 ring) is owned) Equal to True)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((In-game time of day) Greater than or equal to 6.00) and (((In-game time of day) Less than 18.00) and (Night Equal to True))
Then - Actions
Set Night = False
Unit - Order Nazgûl (on foot) 0159 <gen> to Move To (Center of Nazguls spot <gen>)
Else - Actions[/trigger]

[trigger=Nazgul attack refresh]Nazgul attack refresh
Events
Time - Every 1.00 seconds of game time
Conditions
Night Equal to True
(Current order of Nazgûl (on foot) 0159 <gen>) Equal to (Order(stop))
Actions
Unit - Order Nazgûl (on foot) 0159 <gen> to Attack (Random unit from (Units in (Playable map area) matching (((Item carried by (Matching unit) of type The 1 ring) is owned) Equal to True)))[/trigger]

Am I doing anything wrong?
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
Your condition is wrong. By setting (In-game time of day) Greater than or equal to 18.00) and (((In-game time of day) Less than 6.00), you're creating a condition which is impossible to satisfy. How come a number will be greater than 18 and at the same time less than 6? The trigger editor isn't smart enough to understand that you mean between 6 PM and 6 AM. You should use the "or" function, not and.
 
Level 11
Joined
Jan 23, 2015
Messages
788
Oops, I've totally forgot about that. Well, do it like this:

trigger1
conditions
gametime greater than or equal to 18:00
gametime less than 23:59
gametime greater than or equal to 00:00
gametime less than 6:00
Night equal to false

trigger2
conditions
gametime greater than or equal to 6:00
gametime less than 18:00
Night equal to true

Better, Shadow? :D
 
Level 9
Joined
Apr 23, 2011
Messages
527
on another note, your trigger leaks. here, i fixed them.
  • Nazgul attack basic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((In-game time of day) Greater than or equal to 18.00) or (((In-game time of day) Less than 6.00) and (Night Equal to False))
        • Then - Actions
          • Set Night = True
          • Set p = (Units in (Playable map area)
          • Set group = (Random unit from Units in p matching (((Item carried by (Matching unit) of type The 1 ring) is owned) Equal to True)))
          • Unit - Order Nazgûl (on foot) 0159 <gen> to Attack group
          • Custom script: call RemoveLocation(udg_p)
          • Custom script: call DestroyGroup(udg_group)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((In-game time of day) Greater than or equal to 6.00) or (((In-game time of day) Less than 18.00) and (Night Equal to True))
            • Then - Actions
              • Set Night = False
              • Set p = (Center of Nazguls spot <gen>)
              • Unit - Order Nazgûl (on foot) 0159 <gen> to Move To p
              • Custom script: call RemoveLocation(udg_p)
            • Else - Actions
  • Nazgul attack refresh
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Night Equal to True
      • (Current order of Nazgûl (on foot) 0159 <gen>) Equal to (Order(stop))
    • Actions
      • Set p = (Units in (Playable map area)
      • Set group = (Random unit from Units in p matching (((Item carried by (Matching unit) of type The 1 ring) is owned) Equal to True)))
      • Unit - Order Nazgûl (on foot) 0159 <gen> to Attack group
      • Custom script: call RemoveLocation(udg_p)
      • Custom script: call DestroyGroup(udg_group)
 
Status
Not open for further replies.
Top