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

[Trigger] This trigger does some strange things

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi

When you have completed a dungeon and you purchase the "reward item", you are supposed to be teleported out of the dungeon and have random (1-4 different items) for each player teleported out. Also, each Hero gains a lumber (1 player has 1 hero, so its for each player).

I have tested with both 3 and 4 heroes.

The heroes are teleported out, but but are only granted 1 less item than the count of the heroes.

Can you seem to spot what the hell I am overseeing?

  • CotD Reward
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Dungeon: Cathedral of the Damned Reward
      • (Unit-type of (Selling unit)) Equal to Siege Lieutenant Sir. Stregford (Cathedral of the Damned)
    • Actions
      • Set A_Caster = (Buying unit)
      • Set A_Counter = 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Dungeon_TheSiege Equal to done
        • Then - Actions
          • Set Dungeon_TheSiege = notstarted
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in Dungeon CotD <gen>) and do (Actions)
            • Loop - Actions
              • Set Dungeon_Hero = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Dungeon_Hero is A Hero) Equal to True
                  • (Dungeon_Hero is dead) Not equal to True
                  • (Owner of Dungeon_Hero) Not equal to Neutral Passive
                  • (Owner of Dungeon_Hero) Not equal to Player 12 (Brown)
                  • (Unit-type of Dungeon_Hero) Not equal to Backpack
                • Then - Actions
                  • Unit - Move Dungeon_Hero instantly to (Random point in Item Loot Area <gen>)
                  • Unit - Set life of Dungeon_Hero to 100.00%
                  • Unit - Remove All buffs from Dungeon_Hero
                  • Camera - Pan camera for (Owner of Dungeon_Hero) to (Center of Item Loot Area <gen>) over 0.00 seconds
                  • Set Dungeon_Integer1 = (Random integer number between 1 and 100)
                  • Set A_Counter = (A_Counter + 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Dungeon_Integer1 Greater than 40
                    • Then - Actions
                      • Player - Add 1 to (Owner of Dungeon_Hero) Current lumber
                      • Game - Display to (All players controlled by a ((Owner of Dungeon_Hero) controller) player) the text: You have found 1 Ri...
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Dungeon_Integer1 Greater than 10
                          • Dungeon_Integer1 Less than or equal to 40
                        • Then - Actions
                          • Player - Add 2 to (Owner of Dungeon_Hero) Current lumber
                          • Game - Display to (All players controlled by a ((Owner of Dungeon_Hero) controller) player) the text: You have found 2 Ri...
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Dungeon_Integer1 Less than or equal to 10
                            • Then - Actions
                              • Player - Add 3 to (Owner of Dungeon_Hero) Current lumber
                              • Game - Display to (All players controlled by a ((Owner of Dungeon_Hero) controller) player) the text: You have found 3 Ri...
                            • Else - Actions
                • Else - Actions
          • For each (Integer A) from 1 to A_Counter, do (Actions)
            • Loop - Actions
              • Set Dungeon_Integer = (Random integer number between 1 and 4)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Dungeon_Integer Equal to 1
                • Then - Actions
                  • Item - Create Soulfire Carapace (A) at ((Center of Item Loot Area <gen>) offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00)))
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Dungeon_Integer Equal to 2
                • Then - Actions
                  • Item - Create Soul Soothe (T) at ((Center of Item Loot Area <gen>) offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00)))
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Dungeon_Integer Equal to 3
                • Then - Actions
                  • Item - Create Cleaver (MH) at ((Center of Item Loot Area <gen>) offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00)))
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Dungeon_Integer Equal to 4
                • Then - Actions
                  • Item - Create Master Key (T) at ((Center of Item Loot Area <gen>) offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00)))
                • Else - Actions
                  • Do nothing
        • Else - Actions
          • Game - Display to (Player group((Owner of A_Caster))) the text: |cffffcc00Sir Streg...
---------------------------------------------------------------------------------

Issue number 2:

I have a trigger which makes certain item pick ups increase the level of an ability.
But for some reason the item "Cleaver (MH)" will not increase the level of the ability. However, if I loot another item that would increase the level, it will increase the ability level to the correct amount calculated by both items.

This is super strange, because as you will see in the following trigger, "Cleaver (MH)" and "Tide Trident (MH)" both increase the ability level by 2. But for some reason there are no problems with the "Tide Trident (MH)"...

So if I loot "Cleaver (MH)" and loot ex. "Guardian's Mail (PA)" it will increase the amount to 4, which is correct. If I only loot "Cleaver (MH)" it will leave it at level 1 instead of 3.

  • Combat Skill Increase
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Backpack
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Scrapped Boots (PA)
          • (Item-type of (Item being manipulated)) Equal to Arcanite Cleaver (MH)
          • (Item-type of (Item being manipulated)) Equal to Guardian's Mail (PA)
          • (Item-type of (Item being manipulated)) Equal to Tide Trident (MH)
    • Actions
      • Set ItemCounter_Item = (Item being manipulated)
      • Set ItemCounter_PickUpUnit = (Triggering unit)
      • Set CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] = 1
      • Set ItemCounter_Inventory = (Size of inventory for ItemCounter_PickUpUnit)
      • -------- 1 --------
      • For each (Integer ItemCounter_Loop) from 1 to ItemCounter_Inventory, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Scrapped Boots (PA)
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Arcanite Cleaver (MH)
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Guardian's Mail (PA)
            • Then - Actions
              • Set CombatSkill[(Player number of (Owner of A_Unit))] = (CombatSkill[(Player number of (Owner of A_Unit))] + 1)
            • Else - Actions
      • -------- 2 --------
      • For each (Integer ItemCounter_Loop) from 1 to ItemCounter_Inventory, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Tide Trident (MH)
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Cleaver (MH)
            • Then - Actions
              • Set CombatSkill[(Player number of (Owner of A_Unit))] = (CombatSkill[(Player number of (Owner of A_Unit))] + 2)
            • Else - Actions
 
Last edited:
Level 8
Joined
Jun 13, 2010
Messages
344
It should count correct, hmm.
Do you have another trigger with the Event - Unit enters Item Loot Area or Player Score changes?
Which could be fired by the Teleportation​
If you use set A_Counter in such a trigger it might produce unwanted results.

Well it seems to work as I changed the Integer A value to start from 0. But is that incorrect procedure?

Also, I have edited the main post with another issue, if you'd like to check that out as well! :)
Thanks for the answer, means a lot.
 
Level 8
Joined
Jan 28, 2016
Messages
486
In the conditions of your second trigger, you don't have the Cleave item included. Other than that, the trigger should work properly.


You also have a few leaks and inefficiencies in your first trigger.

  • One Point Variable
    • Events
    • Conditions
    • Actions
      • Set TempLocation = (Random point in Item Loot Area <gen>)
      • Unit - Move Dungeon_Hero instantly to TempLocation
      • Custom script: call RemoveLocation( udg_TempLocation )
      • Unit - Set life of Dungeon_Hero to 100.00%
      • Unit - Remove All buffs from Dungeon_Hero
      • Set TempLocation = (Center of Item Loot Area <gen>)
      • Camera - Pan camera for (Owner of Dungeon_Hero) to TempLocation over 0.00 seconds
      • Custom script: call RemoveLocation( udg_TempLocation )
  • Two Point Variables
    • Events
    • Conditions
    • Actions
      • Set TempPoint1 = (Random point in Item Loot Area <gen>)
      • Set TempPoint2 = (Center of Item Loot Area <gen>)
      • Unit - Move Dungeon_Heroinstantly to TempPoint1
      • Unit - Set life of Dungeon_Hero to 100.00%
      • Unit - Remove All buffs from Dungeon_Hero
      • Camera - Pan camera for (Owner of Dungeon_Hero) to TempPoint2 over 0.00 seconds
      • Custom script: call RemoveLocation( udg_TempPoint1 )
      • Custom script: call RemoveLocation( udg_TempPoint2 )

  • For Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to A_Counter, do (Actions)
        • Loop - Actions
          • Set Dungeon_Integer = (Random integer number between 1 and 4)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dungeon_Integer Equal to LoopInteger
            • Then - Actions
              • Set TempPoint1 = (Center of Item Loot Area <gen>)
              • Set TempPoint2 = (TempPoint1 offset by ((Random real number between -200.00 and 200.00), (Random real number between (Random real number between -200.00 and 200.00) and 1.00)))
              • Item - Create Tome of Experience at Position
              • Custom script: call RemoveLocation( udg_TempPoint1 )
              • Custom script: call RemoveLocation( udg_TempPoint2 )
            • Else - Actions
Using the "Do Nothing" action actually does something (it's a Jass thing; I can explain it if you want to) so it's best to never use it and to leave the else actions empty. This way you can avoid all those If-Then-Else statements. You were also leaking 2 locations in each ITE statement.
 
You don't set A_Unit in the Trigger: Combat Skill Increase
so this action (Player number of (Owner of A_Unit) will likly produce wrong results -> save for wrong players the combat skill increase.

Well it seems to work as I changed the Integer A value to start from 0. But is that incorrect procedure?
If that works, its fine.
In Theory its wrong cause it will execute the loop ( Hero Count + 1 ) times. You could checkout what i said before by using Object Manager (F11), Tab Variables : Integer / A_Counter : check out the Triggers using A_Counter if one has the event Unit Leave/Enter Region and it sets A_Counter you might have found the problem's source.

Or easier solution, Change the Order your code does the stuff:

Save the Group tempomary
count Heros, others kick out
create Items
loop group again
teleport + Heal + Reward + Move camara
destroy Group
  • Demo
    • Ereignisse
    • Bedingungen
    • Aktionen
      • Set Counter = 0
      • Set Group = (Units in Dungeon <gen>)
      • Einheitengruppe - Pick every unit in Group and do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • your Filters
            • Then - Actions
              • Set Counter = (Counter + 1)
            • Else - Actions
              • Einheitengruppe - Remove (Picked unit) from Group
      • For each (Integer A) from 1 to Counter, do (Actions)
        • Schleifen - Aktionen
          • Item - Create item at (Center of (Playable map area))
      • Custom script: set bj_wantDestroyGroup=true
      • Einheitengruppe - Pick every unit in Group and do (Actions)
        • Schleifen - Aktionen
          • -------- Reward, Heal, Teleport, Cleanse --------
 
Last edited:
Level 8
Joined
Jun 13, 2010
Messages
344
In the conditions of your second trigger, you don't have the Cleave item included. Other than that, the trigger should work properly.


You also have a few leaks and inefficiencies in your first trigger.

Your examples are good, but why do locations leak when I'm using regions?

Also, I cannot use your last trigger, since I need it to pick a random item, not 1 specifik each time. A boss may drop different items.
 
Your examples are good, but why do locations leak when I'm using regions?
Cause you call the function Center of Region which returns/creates an Point Object.
BTW: Sometimes its a good idea to save often used not moving Locations in a permanent variable for easy usage.
JASS:
function GetRectCenter takes rect whichRect returns location
    return Location(GetRectCenterX(whichRect), GetRectCenterY(whichRect))
endfunction
Also, I cannot use your last trigger, since I need it to pick a random item, not 1 specifik each time. A boss may drop different items.
You could define the droping items at an init trigger with an Item-Type-Array. On Item Reward generation create random items by using this Item-Type array with create DropItem[random integer..].
  • Item Drop Init
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Set Drops[1] = Klauen des Angriffs +9
      • Set Drops[2] = Robe der Weisen +6
      • Set Drops[3] = Runen-Armschienen
      • Set Drops[4] = Ring des Schutzes +2
      • -------- Later Drop --------
      • Item - Create Drops[(Random integer number between 1 and 4)] at (Center of (Playable map area))
 
Level 8
Joined
Jun 13, 2010
Messages
344
You could define the droping items at an init trigger with an Item-Type-Array. On Item Reward generation create random items by using this Item-Type array with create DropItem[random integer..].
  • Item Drop Init
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Set Drops[1] = Klauen des Angriffs +9
      • Set Drops[2] = Robe der Weisen +6
      • Set Drops[3] = Runen-Armschienen
      • Set Drops[4] = Ring des Schutzes +2
      • -------- Later Drop --------
      • Item - Create Drops[(Random integer number between 1 and 4)] at (Center of (Playable map area))

Hey that's smart! Simple and easy. Thanks!
 
Status
Not open for further replies.
Top