• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Replace Item (Unit Group) with Time Event

Status
Not open for further replies.
Level 5
Joined
Mar 24, 2020
Messages
80
Hi!

I have an item in my game that has set effects depending on whether it is day or night.

Below is a trigger I am having issues with.

When the event occurs where it hits 6PM/6AM - this trigger is supposed to replace the item with the night/day variant.

Below is the trigger. Let me know if there is something obvious i'm doing wrong or if you may see why there can be a crashing issue.

  • Day Time
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
    • Conditions
    • Actions
      • Set VariableSet DayTime = True
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has an item of type Night Time Item) Equal to True)) and do (Actions)
        • Loop - Actions
          • Hero - Drop (Item carried by (Picked unit) of type Night Time Item) from (Picked unit).
          • Item - Remove (Last dropped item)
          • Hero - Create Day Time Item and give it to (Picked unit)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
If there's a crash it's most likely because of another trigger, I suspect one that involves "A unit loses/acquires" an item.

That aside, if you have multiples of these items then you probably want to replace all of them if a unit is carrying more than 1.

  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Picked unit) in slot (Integer A))) Equal to Night Item
            • Then - Actions
              • Item - Remove (Item carried by (Picked unit) in slot (Integer A))
              • Hero - Create Day Item and give it to (Picked unit)
            • Else - Actions
 
Level 5
Joined
Mar 24, 2020
Messages
80
If there's a crash it's most likely because of another trigger, I suspect one that involves "A unit loses/acquires" an item.

That aside, if you have multiples of these items then you probably want to replace all of them if a unit is carrying more than 1.

  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Picked unit) in slot (Integer A))) Equal to Night Item
            • Then - Actions
              • Item - Remove (Item carried by (Picked unit) in slot (Integer A))
              • Hero - Create Day Item and give it to (Picked unit)
            • Else - Actions

Hi Uncle,

Thanks for the trigger. it should work, unfortunately when it hits the time Warcraft crashes. I will disable a few other Item based triggers and see if it works.
 
Status
Not open for further replies.
Top