• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Detecting Projectile Launch

Status
Not open for further replies.
Level 9
Joined
Jul 8, 2013
Messages
249
In a map I'm making, there are towers which have limited ammo and fire only when ordered to Attack Ground (and which are given a Stop order to make sure they only fire once per Attack Ground order).

The issue I have is that to make it work properly, I need to subtract from their ammo count precisely when they actually fire. If I subtract when they're merely ordered to fire, then the ammo is deducted for nothing if the player gives another order before the tower actually shoots.

If the towers had Combat - Weapon Type : Missile, I could just give them Searing Arrows or something and track when the mana is subtracted easily enough. However, the towers need to have Artillery weapon type, which means Searing Arrows won't work for them. Is there another good way to detect precisely when the projectile fires?


Failing that, another option which would work nearly as well would be to make the tower unresponsive to further orders for, say, half a second after getting the initial Attack Ground order. In that case, I could just subtract ammo when the order is given and the hapless player couldn't waste ammunition by issuing another order before the shot actually happens.

However, I don't want to prevent further orders by doing things like changing the turret's owner temporarily or deselecting it and making it temporarily unselectable. It's important that the interface be as convenient as possible for firing several shots in quick succession, so I'd need the tower to stay selected but just ignore all new orders until it finished firing. Is there a way to do that?
 
Level 10
Joined
Apr 4, 2010
Messages
509
Solutions:
  1. Use a Damage detection system. Whenever a projectile hits a target, subtract ammo.
  2. Continue with the searing arrow idea and just trigger the additional splash damage. (Probably need a DDS for this too)
  3. Lose the attack ground completely and make a custom channeling spell that fires projectiles every second and stops when ammo is zero. Base the spell off channel and make set Data - Disable other abilities - True (This will make the firing continuous and ignore other orders). Accompany this with a trigger like this: If tower attacks and tower is an ammo tower, make attacking unit cast "Shoot" at position of attacked unit.
 
Level 9
Joined
Jul 8, 2013
Messages
249
Solutions:
  1. Use a Damage detection system. Whenever a projectile hits a target, subtract ammo.
  2. Continue with the searing arrow idea and just trigger the additional splash damage. (Probably need a DDS for this too)
  3. Lose the attack ground completely and make a custom channeling spell that fires projectiles every second and stops when ammo is zero. Base the spell off channel and make set Data - Disable other abilities - True (This will make the firing continuous and ignore other orders). Accompany this with a trigger like this: If tower attacks and tower is an ammo tower, make attacking unit cast "Shoot" at position of attacked unit.

Of those only 3 could work since ammo must be subtracted on missed shots too and since searing arrows must be unit targeted rather than point targeted.

As far as I can recall though, Channel can't actually have projectile art. So what I would have to do with Channel would be something really clumsy like create a dummy unit target at the point Channel is aimed on, create a dummy unit launcher at the turret's point, and have the launcher make an attack or cast a spell that launches a projectile at that target unit and then trigger AoE damage when the target unit dies. And I'd need to get the animations synched up to look like it's an actual attack by the turret. There's got to be a less kludgy way.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Well... You could make the tower have instant damage (like melee units) and nullify the damage with triggers, then use a dummy unit to attack the target with 0 damage point or cast a missile ability with 0 cast point or use a missile system if that is what you want to simulate the real attack.
 
Level 9
Joined
Jul 8, 2013
Messages
249

The towers are perfectly capable of turning to attack (they're based on ancient protectors) and they did that just fine when they were actually attacking ground rather than casting Channel. The trouble is that they don't seem to turn to cast spells in particular.

Edit: That guide does solve the problem, though the tower doesn't turn quite the way it did when it turned naturally to attack. Still, it looks good enough.
 
Last edited:
The way I went about detecting projectile launch would be to use a DDS with a custom projectile system. The unit's own projectile is set to no model, and the projectile speed to the maximum value (10,000), and the projectile type or w/e it's called (I don't have the editor open right now) to either Missile or Instant. Then you detect when damage is dealt, damage type, and whether it's spell damage or not, and then create your missile with the custom projectile system and trigger the splash damage yourself. You can see it in action here. Granted, for just 1 unit that may be a bit excessive, so if you found another way, that's probably for the best.

Another thing you might want to do, would be to set the backswing point and the other one to 0.00 both so that the missile fires the second the unit attacks, so there's no hope of stopping it from launching. Then you can just use 'a unit is attacked' event. Doing this does mean your tower will fire at the start of it's animation though, and can look weird.
 
Level 5
Joined
May 12, 2014
Messages
133
Have you tried making a pretend attack ground spell?
Instead of setting the tower's attack type to artillary, just disable it entirely. From what I read, this tower will only attack when ordered to do so, and will only do it once.
So my idea would be to make a spell based off of Blizzard or Rain of Fire and make it look like the attack ground thing. This way, the tower only "attacks" when ordered to cast the spell. Have the spell cost 1 mana, and that should work somewhat like you want. (I think?)

Edit: Ok, everything I just said has already been mentioned. This is why I need to learn to read.
 
Level 15
Joined
Aug 14, 2007
Messages
936
Trick solution, when unit is attacked event, after that record the tower in variable Unit.
Trigger 2: every 0.05 second, use a variable Real to track the attack swing time.
Trigger 3: Detect stop/hold commands + any spell or thing that will prevent tower from attack, etc freezing breath or attack slow by liquid fire and alter the attack swing values from here, this will work flawlessly with any bugs.
 
Level 9
Joined
Jul 8, 2013
Messages
249
Another thing you might want to do, would be to set the backswing point and the other one to 0.00 both so that the missile fires the second the unit attacks, so there's no hope of stopping it from launching. Then you can just use 'a unit is attacked' event. Doing this does mean your tower will fire at the start of it's animation though, and can look weird.

Yeah, I tried and rejected that idea before posting since it looked too silly. Plus I actually like there being a slight delay and thus time to cancel the order and reconsider one's aim without penalty.


Trick solution, when unit is attacked event, after that record the tower in variable Unit.
Trigger 2: every 0.05 second, use a variable Real to track the attack swing time.
Trigger 3: Detect stop/hold commands + any spell or thing that will prevent tower from attack, etc freezing breath or attack slow by liquid fire and alter the attack swing values from here, this will work flawlessly with any bugs.

I'm not quite sure what you're proposing here. Trigger 1 and 3 are simple enough of course, but what do you mean by "track the attack swing time"?
 
Level 15
Joined
Aug 14, 2007
Messages
936
When the attack is been ordered there is a animation time before firing, attack delay for entertainment and realistic purpose, by removing it you will be able to do it easily but sacrificing this fun element. In triggee 1 turn on Trigger 2, at Trigger 3 still change value of attack swing value also you can stop trigger 2 if you want.
 
He's saying start a timer when the 'a unit is attacked' event that ends when the backswing time is reached. Aka, you manually time for the duration between the attack and the launch and use the end of the timer as the moment you reduce the ammo count. Any order change during the timer other than attack would result in the timer ending prematurely, and thus the ammo not being deducted.
 
Status
Not open for further replies.
Top