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

Building Problems

Status
Not open for further replies.
Level 2
Joined
Apr 1, 2019
Messages
156
Trying to get a building to cast Big Bad Voodoo, which also targets Structures but for some reason when I use it the buff and effect flickers on and off every second.

Trying to get a building to use pendent of energy using the Hero Inventory ability, works fine but when you upgrade the building the effect of pendent of energy is no longer there, even if you drop the item and pick it back up it still won't work.
However if you upgrade the building without the item then obtain the item it works fine. This doesn't seem to happen to any other items.
 
Level 8
Joined
May 21, 2019
Messages
435
Trying to get a building to cast Big Bad Voodoo, which also targets Structures but for some reason when I use it the buff and effect flickers on and off every second.

Trying to get a building to use pendent of energy using the Hero Inventory ability, works fine but when you upgrade the building the effect of pendent of energy is no longer there, even if you drop the item and pick it back up it still won't work.
However if you upgrade the building without the item then obtain the item it works fine. This doesn't seem to happen to any other items.

Those are some seriously specific issues, most certainly in the bug category...
I have no idea how to fix "Big Bad Voodoo", but I'd point out that you could easily recreate the ability using triggers, that would solve the problem.
What I'd do is run a periodic event with 2 unit groups. 1 group casting Big Bad Voodoo, and 1 group with units under the effect of the immunity. Then you keep removing those that get too far away from the building from the buff group and check for all the relevant variables and etc. You could also use a dummy aura that is granted when the dummy spell Big Bad Voodoo is being cast, that woul probably be easier to do.

As for the item thing. Definitely a bug, so we gotta treat it like a bug. How long does the structure take to upgrade? It would make sense to make a trigger that removes the item from the building when it starts the upgrade and stores it, preferably in a hashtable, but if you aren't using it for anything, unit custom value would be easier. Then you'd give the item back when it either finishes or cancels the upgrade, and drop the item on the ground if it dies during the upgrade.
 
Last edited:
Level 2
Joined
Apr 1, 2019
Messages
156
Thank you,

Was hoping there was a simple fix without triggers cause I'm a scrub

Edit:

For the item I did:
  • Building Upgrade
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Item-type of (Item carried by (Triggering unit) of type Potion of Mana)) Equal to Potion of Mana
      • (Race of (Triggering unit)) Equal to Human
    • Actions
      • Set ItemHumanIntLoop[1] = (ItemHumanIntLoop[1] + 1)
      • 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 (Triggering unit) in slot (Integer A))) Equal to Potion of Mana
            • Then - Actions
              • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
              • Set ItemHumanInt[ItemHumanIntLoop[1]] = (ItemHumanInt[ItemHumanIntLoop[1]] + 1)
            • Else - Actions
      • Wait 1.20 seconds
      • Set ItemHumanIntLoop[2] = (ItemHumanIntLoop[2] + 1)
      • For each (Integer A) from 1 to ItemHumanInt[ItemHumanIntLoop[2]], do (Actions)
        • Loop - Actions
          • Hero - Create Potion of Mana and give it to (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemHumanIntLoop[1] Equal to ItemHumanIntLoop[2]
        • Then - Actions
          • For each (Integer A) from 1 to ItemHumanIntLoop[1], do (Actions)
            • Loop - Actions
              • Set ItemHumanInt[(Integer A)] = 0
          • Set ItemHumanIntLoop[1] = 0
          • Set ItemHumanIntLoop[2] = 0
        • Else - Actions
And for the Big bad voodoo I just used a dummy unit, I guess it doesn't like it if u have a building casting it.
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
Thank you,

Was hoping there was a simple fix without triggers cause I'm a scrub

Edit:

For the item I did:
  • Building Upgrade
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Item-type of (Item carried by (Triggering unit) of type Potion of Mana)) Equal to Potion of Mana
      • (Race of (Triggering unit)) Equal to Human
    • Actions
      • Set ItemHumanIntLoop[1] = (ItemHumanIntLoop[1] + 1)
      • 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 (Triggering unit) in slot (Integer A))) Equal to Potion of Mana
            • Then - Actions
              • Item - Remove (Item carried by (Triggering unit) in slot (Integer A))
              • Set ItemHumanInt[ItemHumanIntLoop[1]] = (ItemHumanInt[ItemHumanIntLoop[1]] + 1)
            • Else - Actions
      • Wait 1.20 seconds
      • Set ItemHumanIntLoop[2] = (ItemHumanIntLoop[2] + 1)
      • For each (Integer A) from 1 to ItemHumanInt[ItemHumanIntLoop[2]], do (Actions)
        • Loop - Actions
          • Hero - Create Potion of Mana and give it to (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemHumanIntLoop[1] Equal to ItemHumanIntLoop[2]
        • Then - Actions
          • For each (Integer A) from 1 to ItemHumanIntLoop[1], do (Actions)
            • Loop - Actions
              • Set ItemHumanInt[(Integer A)] = 0
          • Set ItemHumanIntLoop[1] = 0
          • Set ItemHumanIntLoop[2] = 0
        • Else - Actions
I think I would have done it a bit differently, as there are some issues with this. This way, what happens if the unit dies while upgrading? Does the item get dropped in the center of the map? This will happen a certain point after death as the unit will be removed from the game's memory, although not likely 1.2 seconds after. What happens if multiple buildings upgrade within a 1.2 second timeframe? The loop variables are global, so it would increase the number to 2 and then give 2 items to 1 of them and 0 items to the other, since you have a wait function.

The "best practice" way to do this is to use a hashtable. The simplest way to do it is using a custom value.
If you were to go with a custom value, it's quite easy. When the unit starts an upgrade, remove the potion and assign a custom value to it that means that a mana potion was removed from it, like 42. That's it, 1 action, no variables.
Then you make a second trigger with 3 events. One is that the structure cancels the upgrade, another is that the structure dies, and the third is that it finishes the upgrade. Then, you add a condition checking if the custom value of the unit is 42 (in this example, again, any number works), and if it is, you give the unit a mana potion and set the custom value to 0.
In this case, I am fairly certain that the dead building will have the item dropped on it, as the trigger doesn't lose the location of the unit when there is no time gap such as wait in the trigger. This also works smoothly with any level of upgrade time on the building, in case you wanna use this on buildings with an upgrade time that's above 1 second.

With a hashtable, what you'd want to do is assign an item type to the unit handle at a given index and then go with that. Wouldn't interfere with Unit Indexing systems, but if you don't use that, then just use the custom value thing instead, it's simpler.

And for the Big bad voodoo I just used a dummy unit, I guess it doesn't like it if u have a building casting it.
Not a bad solution, but make sure of the following:
The dummy unit should be able to be at the center of the structure, likely flying.
The structure should have an effect attached to it, unless you manage to get the spell effect from the dummy down to the building.
You need to ensure that the building kills the dummy unit if it dies while the cast is up, that's the whole point of Big Bad Voodoo after all.
 
Level 2
Joined
Apr 1, 2019
Messages
156
I shoulda mentioned I tested it with a longer wait to check and see if the building dies where the item goes. It does just place it at the position of the building. I didn't use custom value cause I'm using it for other stuff. Yeah I should use Hashtables just not as familiar with them.
Triggers never trigger at the exact same time right? Just executed one after the other very rapidly.
How exactly do triggers execute with waits? If I have that 1.2 sec wait then more actions.
So I upgrade 10 buildings at once, the trigger would execute, 1 2...10 then hit the 1.2 sec wait then exectute the remaining actions in the same order.

So it should work right?
 
Status
Not open for further replies.
Top