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

Upgrade to give unit a new attack or modify the range of only one attack

Level 3
Joined
Apr 21, 2024
Messages
14
Hi, so I'm working on a custom unit that I want to give the Liquid Fire ability to. I found in another thread that Liquid Fire only works if the attacking unit's attack has a range of 300+, but my custom unit is a melee unit.

My next idea for a solution was to create an upgrade that gives the custom unit a second attack type once the Liquid Fire upgrade is researched. This second attack type would be ranged (which I'm OK with) and only be able to target buildings. However, I don't know of any existing upgrades in WC3 that gives a unit a second attack. Is there one?

Another idea I had was to create an upgrade that increases the range of my custom unit. If the unit's range was increased to a value of 300+ then presumably Liquid Fire would start working. My issue with this is that I still want the unit to use melee attacks against non-building units. Is there a way to have an upgrade that affects attack range apply to one one of a unit's two attack types?

Basically, I want a unit that can both use Liquid Fire against buildings (melee or ranged) and use melee attacks against all other units. I would appreciate any suggestions on how to accomplish this, thank you!
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,700
You could rely on a Dummy unit to apply the Liquid Fire like so:
  • Liquid Fire Melee
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Unit-type of (Damage source)) Equal to Knight
      • (Current research level of Liquid Fire for (Owner of (Damage source))) Greater than 0
    • Actions
      • Set VariableSet LFM_Target = (Damage Target)
      • -------- --------
      • Set VariableSet LFM_Point = (Position of LFM_Target)
      • Unit - Create 1 Liquid Fire Dummy for (Owner of (Damage source)) at LFM_Point facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_LFM_Point )
      • -------- --------
      • Set VariableSet LFM_Dummy = (Last created unit)
      • Unit - Add a 0.20 second Generic expiration timer to LFM_Dummy
      • Unit - Order LFM_Dummy to Attack Once LFM_Target
 

Attachments

  • Liquid Fire Melee.w3m
    18.1 KB · Views: 2
Level 3
Joined
Apr 21, 2024
Messages
14
Thank you for the advice. When I try to load the .w3m file I get an error "level info data missing or invalid". I think I get the idea of it though, I just have a few follow-up questions

1. Will this work if multiple of this unit are attacking at once? My worry is that in one instance the custom script "call RemoveLocation..." will execute right before another instance creates the Liquid Fire Dummy unit. I don't know if that will cause a crash or if it will simply make the unit not spawn (hopefully the latter).

2. Can you explain what the Liquid Fire Dummy should be exactly? I understand that a dummy unit is basically an invisible, uninteractable flying unit that just shows up to cast an ability, but I don't know all of the specifics.

Thanks again for your help!
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,700
Thank you for the advice. When I try to load the .w3m file I get an error "level info data missing or invalid". I think I get the idea of it though, I just have a few follow-up questions

1. Will this work if multiple of this unit are attacking at once? My worry is that in one instance the custom script "call RemoveLocation..." will execute right before another instance creates the Liquid Fire Dummy unit. I don't know if that will cause a crash or if it will simply make the unit not spawn (hopefully the latter).

2. Can you explain what the Liquid Fire Dummy should be exactly? I understand that a dummy unit is basically an invisible, uninteractable flying unit that just shows up to cast an ability, but I don't know all of the specifics.

Thanks again for your help!
1) That's not exactly how triggers work. Whenever an Event occurs, all of the triggers that have "registered" that Event will run. When a trigger runs, a new instance of it is created which is it's own unique entity. These entities are put in a queue, with each one executing separately in an orderly fashion.

In other words, if you somehow managed to land 3 hits in the same exact game frame (very unlikely) then 3 instances of the trigger would be created. The first instance would run through the Conditions/Actions, then the second instance, and finally the third. They execute within the same game frame but they happen in a sequential order.

Imagine a queue of people waiting in line at the grocery store, each person in line is waiting to checkout. They're like the triggers waiting to be executed. It's just that checkout happens "instantly" in the case of the triggers.

(Note that Wait actions can complicate things since the trigger is no longer "instant")

The issue you should be concerned about is rather rare and has to do with Actions causing other triggers to run. The Event "A unit Dies" doesn't like to follow the trigger queue rule I described before. In the case of this Event, it's Actions are instead injected into the trigger that caused it to run, potentially causing trouble if they share variables. You can avoid this pitfall by making sure your "A unit Dies" triggers always have their own unique variables.

2) Copy and paste the Locust, set it's Model = None, Shadow = None, Acquisition and Attack Range = 300, Damage Base = -1, Dice = 1, Movement Type = None, and Speed Base = 0. Make sure it has your custom Liquid Fire ability and the Requirements on said ability are removed.
1715816442914.png
 
Last edited:
Level 3
Joined
Apr 21, 2024
Messages
14
Thank you so much for the detailed help, I appreciate it! My map seems to be working the way I want it to now. I'm curious though, is there a reason you used the "A unit Takes damage" event rather than the "A unit is attacked" event? I couldn't find a "A unit Takes damage" even anywhere, but using the "A unit is attacked" event seems to work just fine unless I'm overlooking something. That, combined with the fact that I couldn't open the map you shared earlier, makes me think that maybe I need to update my game haha...
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,700
Thank you so much for the detailed help, I appreciate it! My map seems to be working the way I want it to now. I'm curious though, is there a reason you used the "A unit Takes damage" event rather than the "A unit is attacked" event? I couldn't find a "A unit Takes damage" even anywhere, but using the "A unit is attacked" event seems to work just fine unless I'm overlooking something. That, combined with the fact that I couldn't open the map you shared earlier, makes me think that maybe I need to update my game haha...
You need to be on version 1.31+ to get access to the generic "damage event". Otherwise, you need to use an older version of a system like Damage Engine.

"A unit is attacked" occurs before any damage is dealt and before your unit has even begun playing it's attack animation. It's easily abused and occurs way more often than you'd like. For instance, try spamming a Stop order when your unit is attacking something and you'll apply Liquid Fire 10+ times per second.
 
Level 40
Joined
Feb 27, 2007
Messages
5,091
Call me ignorant but isn’t this a use case for Attack1 and Attack2 on the unit? Make Attack1 unable to target structures while Attack2 can only target structures and has 300 range. The unit should automatically use Attack2 on structures only allowing you to use liquid fire without any triggers.
 
Top