• 🏆 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!

[Trigger] Trigger makes Warcraft 3 crash

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hello, I have made an RPG with a bunch of units in at map initialization. I believe it is too much for the pc to handle a Unit Group - Pick all units in playable map area.
But I have several triggers and some just crashes, while others don't.

Trigger 1: crashes
  • Backpack drops an item
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Backpack
    • Actions
      • Set A_Caster = (Hero manipulating item)
      • Set A_Counter = 0
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set A_All_Units = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of A_All_Units) Not equal to Player 12 (Brown)
              • (Owner of A_All_Units) Not equal to Neutral Passive
              • (Owner of A_All_Units) Equal to (Owner of A_Caster)
              • A_All_Units Not equal to A_Caster
              • (A_All_Units is A Hero) Equal to True
            • Then - Actions
              • Set A_Point = (Position of A_All_Units)
              • Item - Move (Item being manipulated) to A_Point
              • Custom script: call RemoveLocation (udg_A_Point)
              • Set A_Counter = (A_Counter + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • A_Counter Equal to 0
        • Then - Actions
          • Item - Move (Item being manipulated) to (Position of A_Caster)
        • Else - Actions
(When the backpack unit drops an item, it picks all units and if it finds the hero, it will move the item to it. If it doesn't, the item will move to the backpacks location.)

  • Backpack skills up
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Unit-type of (Learning Hero)) Equal to Backpack
      • Or - Any (Conditions) are true
        • Conditions
          • (Learned Hero Skill) Equal to Attribute Bonus: Ability Power
          • (Learned Hero Skill) Equal to Attribute Bonus: Dexterity
          • (Learned Hero Skill) Equal to Attribute Bonus: Endurance
          • (Learned Hero Skill) Equal to Attribute Bonus: Knowledge
    • Actions
      • Set A_Caster = (Learning Hero)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set A_All_Units = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of A_All_Units) Not equal to Player 12 (Brown)
              • (Owner of A_All_Units) Not equal to Neutral Passive
              • (A_All_Units is A Hero) Equal to True
              • (Unit-type of A_All_Units) Not equal to Backpack
            • Then - Actions
              • Set A_SingleTarget = A_All_Units
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned Hero Skill) Equal to Attribute Bonus: Ability Power
        • Then - Actions
          • Unit - Set level of Attribute Bonus: Ability Power for (Learning Hero) to 1
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Hero_AP_Skillup[(Player number of (Owner of A_SingleTarget))] Less than 99
            • Then - Actions
              • Set Player_Hero_AP_Skillup[(Player number of (Owner of A_SingleTarget))] = (Player_Hero_AP_Skillup[(Player number of (Owner of A_SingleTarget))] + 1)
              • Hero - Create Skill Up: Ability Power and give it to A_SingleTarget
            • Else - Actions
              • Game - Display to (Player group((Owner of A_SingleTarget))) the text: |cffff0000Maximum v...
              • Hero - Modify unspent skill points of A_Caster: Add 1 points
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned Hero Skill) Equal to Attribute Bonus: Dexterity
        • Then - Actions
          • Unit - Set level of Attribute Bonus: Dexterity for (Learning Hero) to 1
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Agility of A_SingleTarget (Exclude bonuses)) Less than 99
            • Then - Actions
              • Hero - Create Tome of Agility and give it to A_SingleTarget
            • Else - Actions
              • Game - Display to (Player group((Owner of A_SingleTarget))) the text: |cffff0000Maximum v...
              • Hero - Modify unspent skill points of A_Caster: Add 1 points
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned Hero Skill) Equal to Attribute Bonus: Endurance
        • Then - Actions
          • Unit - Set level of Attribute Bonus: Endurance for (Learning Hero) to 1
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Strength of A_SingleTarget (Exclude bonuses)) Less than 99
            • Then - Actions
              • Hero - Create Skill Up: Endurance and give it to A_SingleTarget
            • Else - Actions
              • Game - Display to (Player group((Owner of A_SingleTarget))) the text: |cffff0000Maximum v...
              • Hero - Modify unspent skill points of A_Caster: Add 1 points
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned Hero Skill) Equal to Attribute Bonus: Knowledge
        • Then - Actions
          • Unit - Set level of Attribute Bonus: Knowledge for (Learning Hero) to 1
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Intelligence of A_SingleTarget (Exclude bonuses)) Less than 99
            • Then - Actions
              • Hero - Create Skill Up: Knowledge and give it to A_SingleTarget
            • Else - Actions
              • Game - Display to (Player group((Owner of A_SingleTarget))) the text: |cffff0000Maximum v...
              • Hero - Modify unspent skill points of A_Caster: Add 1 points
        • Else - Actions
(The backpack gains 3 skill points when gaining levels. And when it skills up in one of the stats available: endurance, dexterity and knowledge, it will give a tome to the Hero.
This somehow does not crash the game.)

What is the difference? What makes the 1. trigger crash the game, while the 2. trigger works fine?
 
Last edited:
This event
  • Unit - A unit Loses an item
is fired before your hero actually has droped the item.

If you now use this Action
  • Item - Move (Item being manipulated) to A_Point
in an "drop event based" trigger the game will handle the item move as another "drop an item"-Event.

resulting in an further trigger run. -> endless recursive loop.


To prevent this you have to surround the group action block with an disable/enable Trigger action block

  • Trigger - Turn off (This trigger)
  • Trigger - Turn on(This trigger)
 
Level 8
Joined
Jun 13, 2010
Messages
344
I truly can't understand anything without the Trigger tags. Specialy the If/Then/Else conditions which are very important.
There we go. (y)
I haven't really made a post since the Hive got updated.


This event
  • Unit - A unit Loses an item
is fired before your hero actually has droped the item.

If you now use this Action
  • Item - Move (Item being manipulated) to A_Point
in an "drop event based" trigger the game will handle the item move as another "drop an item"-Event.

resulting in an further trigger run. -> endless recursive loop.


To prevent this you have to surround the group action block with an disable/enable Trigger action block

  • Trigger - Turn off (This trigger)
  • Trigger - Turn on(This trigger)
So what you say is whenever it moves the item, it will "lose an item" and start the event all over?
Is it because I chose the wrong event or is it simply just the turn off/on actions I need?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,204
So what you say is whenever it moves the item, it will "lose an item" and start the event all over?
Yes the trigger is infinitely recursive. The crash is a result of the game running out of resources to run triggers.
Is it because I chose the wrong event or is it simply just the turn off/on actions I need?
The event is fine. You either need to structure the trigger such that a condition prevents it running actions if it fires itself or it is turned off to stop itself from firing.
 
Status
Not open for further replies.
Top