4 Questions/Problems

TDN

New Member
Reaction score
3
Right, so I've got a number of game-breaking problems, and can't make much more progress on my project without figuring these out:

Problem #1: Here I have a neutral passive building, that I want any selected units to attack if you right-click on it. Unfortunately I can't seem to find the correct right-click order.

Trigger:
  • Right Click
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(right click))
      • (Unit-type of (Target unit of issued order)) Equal to Farm
    • Actions
      • Unit - Order (Ordered unit) to Attack (Target unit of issued order)


Problem #2: The whole trigger is a bit long but this is the part that isn't working. It's a basic loop that checks whether the hero is carrying a list of items. If the hero is carrying any of those items, display an error message and skip remaining actions. Problem is, the error message is showing, but the trigger does not skip the remaining actions, it seems to ignore that line and continue with its actions regardless.

Trigger:
  • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
    • Loop - Actions
      • For each (Integer InventorySwapSpellBookCheck) from 1 to 6, 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 carried by (Picked unit) in slot InventorySwapSpellBookCheck) Equal to (Item carried by (Picked unit) of type Book of Blink Stomp)
                  • (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck) Equal to (Item carried by (Picked unit) of type Book of Blizzard)
                  • (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck) Equal to (Item carried by (Picked unit) of type Book of Explosive Potion)
                  • (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck) Equal to (Item carried by (Picked unit) of type Book of Fireblast)
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Cannot transfer spe...
              • Skip remaining actions
            • Else - Actions


Problem #3: I have a spell that is duplicated upon casting. In this case it is duplicated 30 times. The problem is that the trigger only duplicates it once, meaning instead of doing 30 times the damage, it only does 2 times as much.

edit: added the missing conditions
Trigger:
  • Fireblast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item carried by (Triggering unit) of type |cff66cc00Toviac|r) is owned) Equal to True
        • Then - Actions
          • Set SpellMultiplier = ToviacMultiplier
        • Else - Actions
          • Set SpellMultiplier = 1
          • Skip remaining actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Fireblast lvl 1
        • Then - Actions
          • For each (Integer A) from 1 to (SpellMultiplier - 1), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Sheep (Dummy Unit) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
              • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Fireblast lvl 1 to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Pandaren Brewmaster - Breath Of Fire (Target point of ability being cast)
        • Else - Actions


Problem #4: This one should be more simple. I have implemented a command to swap between three different inventories. I looked on thehelper.net for triggers to do this but the methods I found were either in Jass or not to my liking, so I ended up coding it myself, and so far it is working flawlessly. Except for one thing: Transferring a multi-charge item (potion, for instance) causes the number of charges to drop to 1 when you return to that inventory. It would be really cool if someone could help me figure out how to allow multi-charge items to transfer correctly. Here is the trigger:

Trigger:
  • Inventory Swap
    • Events
      • Player - Player 1 (Red) types a chat message containing swap as A substring
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • Inventory[(Player number of (Triggering player))] Not equal to (Integer((Substring((Entered chat string), 6, 1))))
          • (Integer((Substring((Entered chat string), 6, 1)))) Greater than or equal to 1
          • (Integer((Substring((Entered chat string), 6, 1)))) Less than or equal to 3
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set Slot_1[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 1))
          • Set Slot_2[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 2))
          • Set Slot_3[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 3))
          • Set Slot_4[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 4))
          • Set Slot_5[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 5))
          • Set Slot_6[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 6))
          • Item - Remove (Item carried by (Picked unit) in slot 1)
          • Item - Remove (Item carried by (Picked unit) in slot 2)
          • Item - Remove (Item carried by (Picked unit) in slot 3)
          • Item - Remove (Item carried by (Picked unit) in slot 4)
          • Item - Remove (Item carried by (Picked unit) in slot 5)
          • Item - Remove (Item carried by (Picked unit) in slot 6)
          • Hero - Create Slot_1[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_2[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_3[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_4[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_5[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_6[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
      • Set Inventory[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 6, 1))))
 

Moridin

Snow Leopard
Reaction score
144
Answer #1: The order string is "smart".

2: I don't know why it isn't working, but you could try something. Make it run another trigger and then switch itself off. Then have the other trigger have actions to wait for 0.1 seconds and then switch the first trigger back on. This might work?

3: Is your variable SpellMultiplier being used anywhere else? Edit: Infinite loop :/.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
#1: The order you're looking for is "smart" ;)

#2: Hmm... :S That is weird.
Why not set a boolean variable to false after that "Skip remaining actions" line and try to put everything that is after that line in an "If" checking if the false boolean is true, if it's true it'll keep doing it's business, else it won't ;)

#3: Well, I'm surprised the trigger actually works, as I'd believe it would cause an infinite loop...
Try turning the trigger Off as the very first action in the trigger, and then On again as the last action and see if that does anything :S

#4: Well, try using another variable of the type "Integer" (With an array too, of course) which will save some more data, namingly like this:
Trigger:
  • Set TempInt = (Charges remaining in (Item carried by (Picked unit) in slot 1))


Then use this to set the amount of charges when swapped again:
Trigger:
  • Item - Set charges remaining in (Item carried by (Picked unit) in slot 1) to TempInt
 

Azylaminaz

Vox Populi
Reaction score
91
#1, As the above said, the action is 'smart'.

#2, Skip Remaining Actions does not work in group actions (Unit Group or Force Group). Use a variable trigger instead (IE, set a trigger to true, then after the group loop you can check if the variable is true and then do skip remaining actions).

#3, Not sure, but it could be the fact that it is spawning an infinite loop (having an action that triggers the event). You can try to fix that (make a check to make sure the caster is not Dummy unit). Also, it creates an insane amount of leaks, though this isn't a problem as of now.

#4, I would suggest moving the physical item (instead of recreating). Besides this, you would need another variable to store the number of charges.
 

TDN

New Member
Reaction score
3
Besides this, you would need another variable to store the number of charges.

Any idea how to do this?

#1 - works great - thanks guys :)

#2 - I will experiment more and give feedback soon

#3 - Does not give an infinite loop, sorry I shortened the trigger removing what seemed like excessive lines just to give you an idea of what it looks like, but I missed the one essential condition. The full trigger looks like this:

Trigger:
  • Fireblast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item carried by (Triggering unit) of type |cff66cc00Toviac|r) is owned) Equal to True
        • Then - Actions
          • Set SpellMultiplier = ToviacMultiplier
        • Else - Actions
          • Set SpellMultiplier = 1
          • Skip remaining actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Fireblast lvl 1
        • Then - Actions
          • For each (Integer A) from 1 to (SpellMultiplier - 1), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Sheep (Dummy Unit) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
              • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Fireblast lvl 1 to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Pandaren Brewmaster - Breath Of Fire (Target point of ability being cast)
        • Else - Actions
 

TDN

New Member
Reaction score
3
#2 - Fixed and working correctly now.

Changed it to use a variable for the check as Komaqtion & Azylaminaz suggested, and it works now. However there was another bug in the trigger, I had to change all the item checks from this:

Trigger:
  • (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck) Equal to (Item carried by (Picked unit) of type Book of Blink Stomp)


To this:

Trigger:
  • (Item-type of (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck)) Equal to Book of Blink Stomp



#3 and #4 still no luck...
 

TDN

New Member
Reaction score
3
Ah yes, I used that method and it seemed to work fine. Charges were carrying over correctly.

Then I tried moving the potion with several charges in slot 1 to an empty slot. Long story short, things got a bit messed up: potions ended up with unlimited charges and a permanent item suddenly had 'charges'.
 

TDN

New Member
Reaction score
3
Update: Inventory swap system is fully working now, with multiple charges & all. I discovered the answer as I was lying in bed last night :D

Here is the full trigger, including variable info:

Variables used--

ItemCharges_Slot1 = integer (array size 13)
ItemCharges_Slot2 = integer (array size 13)
ItemCharges_Slot3 = integer (array size 13)
ItemCharges_Slot4 = integer (array size 13)
ItemCharges_Slot5 = integer (array size 13)
ItemCharges_Slot6 = integer (array size 13)

Inventory = integer (array size 13)
SpellBookCheck = integer

Slot_1 = Item-Type (array size 13)
Slot_2 = Item-Type (array size 13)
Slot_3 = Item-Type (array size 13)
Slot_4 = Item-Type (array size 13)
Slot_5 = Item-Type (array size 13)
Slot_6 = Item-Type (array size 13)

Trigger:
  • Inventory Swap
    • Events
      • Player - Player 1 (Red) types a chat message containing swap as A substring
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • Inventory[(Player number of (Triggering player))] Not equal to (Integer((Substring((Entered chat string), 6, 1))))
          • (Integer((Substring((Entered chat string), 6, 1)))) Greater than or equal to 1
          • (Integer((Substring((Entered chat string), 6, 1)))) Less than or equal to 3
    • Actions
      • Set SpellBookCheck = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • For each (Integer InventorySwapSpellBookCheck) from 1 to 6, 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 (Picked unit) in slot InventorySwapSpellBookCheck)) Equal to Book of Blink Stomp
                      • (Item-type of (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck)) Equal to Book of Blizzard
                      • (Item-type of (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck)) Equal to Book of Explosive Potion
                      • (Item-type of (Item carried by (Picked unit) in slot InventorySwapSpellBookCheck)) Equal to Book of Fireblast
                • Then - Actions
                  • Set SpellBookCheck = 1
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpellBookCheck Equal to 1
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Cannot transfer spe...
          • Skip remaining actions
        • Else - Actions
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • If ((Item carried by (Picked unit) in slot 1) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • If ((Item carried by (Picked unit) in slot 2) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • If ((Item carried by (Picked unit) in slot 3) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • If ((Item carried by (Picked unit) in slot 4) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • If ((Item carried by (Picked unit) in slot 5) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • If ((Item carried by (Picked unit) in slot 6) Equal to No item) then do (Hero - Create Placeholder Item and give it to (Picked unit)) else do (Do nothing)
          • Set Slot_1[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 1))
          • Set Slot_2[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 2))
          • Set Slot_3[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 3))
          • Set Slot_4[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 4))
          • Set Slot_5[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 5))
          • Set Slot_6[Inventory[(Player number of (Triggering player))]] = (Item-type of (Item carried by (Picked unit) in slot 6))
          • Set ItemCharges_Slot1[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 1))
          • Set ItemCharges_Slot2[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 2))
          • Set ItemCharges_Slot3[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 3))
          • Set ItemCharges_Slot4[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 4))
          • Set ItemCharges_Slot5[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 5))
          • Set ItemCharges_Slot6[Inventory[(Player number of (Triggering player))]] = (Charges remaining in (Item carried by (Picked unit) in slot 6))
          • Item - Remove (Item carried by (Picked unit) in slot 1)
          • Item - Remove (Item carried by (Picked unit) in slot 2)
          • Item - Remove (Item carried by (Picked unit) in slot 3)
          • Item - Remove (Item carried by (Picked unit) in slot 4)
          • Item - Remove (Item carried by (Picked unit) in slot 5)
          • Item - Remove (Item carried by (Picked unit) in slot 6)
          • Trigger - Turn off Potion Merging <gen>
          • Hero - Create Slot_1[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_2[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_3[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_4[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_5[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Hero - Create Slot_6[(Integer((Substring((Entered chat string), 6, 1))))] and give it to (Picked unit)
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 1) to ItemCharges_Slot1[(Integer((Substring((Entered chat string), 6, 1))))]
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 2) to ItemCharges_Slot2[(Integer((Substring((Entered chat string), 6, 1))))]
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 3) to ItemCharges_Slot3[(Integer((Substring((Entered chat string), 6, 1))))]
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 4) to ItemCharges_Slot4[(Integer((Substring((Entered chat string), 6, 1))))]
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 5) to ItemCharges_Slot5[(Integer((Substring((Entered chat string), 6, 1))))]
          • Item - Set charges remaining in (Item carried by (Picked unit) in slot 6) to ItemCharges_Slot6[(Integer((Substring((Entered chat string), 6, 1))))]
          • If (Slot_1[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • If (Slot_2[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • If (Slot_3[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • If (Slot_4[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • If (Slot_5[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • If (Slot_6[(Integer((Substring((Entered chat string), 6, 1))))] Equal to Placeholder Item) then do (Item - Remove (Item carried by (Picked unit) of type Placeholder Item)) else do (Do nothing)
          • Trigger - Turn on Potion Merging <gen>
      • Set Inventory[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 6, 1))))




Problem #3 remains unsolved, I hope someone can help find the answer :confused:
 

HeX.16

Isn't Trollin You Right Now
Reaction score
131
Trigger:
  • Fireblast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item carried by (Triggering unit) of type |cff66cc00Toviac|r) is owned) Equal to True
        • Then - Actions
          • Set SpellMultiplier = ToviacMultiplier
        • Else - Actions
          • Set SpellMultiplier = 1
          • Skip remaining actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Fireblast lvl 1
        • Then - Actions
          • For each (Integer A) from 1 to (SpellMultiplier - 1), do (Actions)
            • Loop - Actions
              • Unit - Create 1 Sheep (Dummy Unit) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
              • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Fireblast lvl 1 to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Pandaren Brewmaster - Breath Of Fire (Target point of ability being cast)
        • Else - Actions

Where do you set "ToviacMultiplier"? And what do you set it to.
 

TDN

New Member
Reaction score
3
Problem #3: I have a spell that is duplicated upon casting. In this case it is duplicated 30 times. The problem is that the trigger only duplicates it once, meaning instead of doing 30 times the damage, it only does 2 times as much.

The variable is set to 30 on map initialization.
 

mapguy

New Member
Reaction score
46
The variable is set to 30 on map initialization.

the trigger only runs twice, right?

for each integer from 1 to (toviac - 1)

you probably (du'h!) set toviac to 3 instead of 30 by mistake.

3 - 1 = 2
your spell runs 2 times

:DIf I am right, this is funny:D
 

TDN

New Member
Reaction score
3
Uh... no.

Trigger:
  • Set ToviacMultiplier = 30


I do have other spells that work correctly (run 30 times) however many also only work twice, like this fireblast spell. I've just posted the fireblast spell here since if we can figure out why it is not running 30 times, I could duplicate the fix for the other spells that don't run 30 times.
 

TDN

New Member
Reaction score
3
Problem #3 remains unsolved, I hope someone can help find the answer :confused:

This, and I'll put forwards another question which should be easy. I'm trying to find out if it's possible to switch a unit's model after the unit has been created. Example: assume I have a swordsman and want to switch the model to a high-elven swordsman without actually replacing the entire unit. Would this be possible?
 

Moridin

Snow Leopard
Reaction score
144
This, and I'll put forwards another question which should be easy. I'm trying to find out if it's possible to switch a unit's model after the unit has been created. Example: assume I have a swordsman and want to switch the model to a high-elven swordsman without actually replacing the entire unit. Would this be possible?

I believe there's an ability called Chaos or somesuch that does this. Or if you want to give him different abilities while keeping his items intact you can use one of the various morph abilities like Bear Form.
 

TDN

New Member
Reaction score
3
Doesn't bear form require another unit, so the original unit can transform into the new unit type? I need a way to change the model without using another unit type.

The unit won't have any items.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Why do you need it not to change unit-type ? :S
And no, there is no such way to just change the model...
 

TDN

New Member
Reaction score
3
Because I'm randomizing between about 20 unit models, and it would take up much less map resources to modify the model rather than create 20 unique units. There should be a way to change the model, unless doing that is yet another obvious function that the WE is missing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top