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

Gold ammo

Status
Not open for further replies.
Level 10
Joined
Oct 2, 2014
Messages
215
Mana ammo

So i used the trigger that rulerofiron99 gave me, but i can't allow the mana to minus one each time i shoot. Everything else is good, i just can't make the triggers do minus one, it says the minimum is 0 only adding one mana.
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
-_- mana != gold

What rulerofiron99 said is the easiest way but there is one glitch.
You can stop your attack after you "attacked" a unit because that event fires when you wind up your attack.
So you can remove gold/mana or whatever without attacking.

For melee units you can use a Damage Detection System to detect when he has attacked an enemy... however that does not work for ranged units and you mentioned ammo so...

For ranged units, you must change their attack type to instant so they will deal damage when the arrow is fired.
Then you have to remove the damage done (best is via a DDS) and create a missile (Missile/Projectile System). You save the damage dealt by the basic attack to the damage that must be dealt on the missile when it hits it target...

I use this same way to create my own custom ranged basic attacks.
When you do this for one unit, you don't need much but when this will be applied on all ranged units then you have to register their unit-type and missile-art etc.

EDIT: You do indeed also need another trigger that stops the unit from attacking when he starts attacking a unit.
 
If you want to use this for a clip-type mechanic, you can stop a units attack by giving it a disabled spellbook containing "orc burrow" and "cargo hold". This is a much better solution than constantly giving the unit stop orders, since it will disable it's attack altogether and not try to reaquire the target. Just make a copy of the "spellbook" ability, put the mentioned abilities in it, and disable it using triggers for all players. This way, it will not show up in the command card, yet the effect still applies due to a bug in warcraft.

As for substracting gold, the easy way is to use a "unit is attacked" event and subtract gold from "owner of attacking unit". This is not a completely safe method however, since the event will fire wether the unit completes the attack or not. There is a delay between when a unit starts the attack animation and when it deals damage, and there is a chance that the unit will die or recieve another order within that short span.

The hard way is something similar to what Wietlol is suggesting. If you're not planning to have a huge number of units in your map, you can get away with making your own lazy-mans damage detection system and ignore event leaks, as they are neglible. In that case, you just have a single trigger with no events, which deals with when a unit takes damage. Whenever a unit enters the map, you add the event "entered unit takes damage" to the trigger. Then, you do something similar to what Wietlol suggested. You don't need to actually stop the damage, instead you can use a special attack type for all ranged units, which has its damage tables set to zero in the gameplay constants. That way the damage will display correctly, yet not apply to the target. If you want, you can even use this to make your own simple missile system, which could be kinda cool.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
If you are using the unit is attacked approach you might wish to add some kind of cooldown timer to it. This might not work as well as an attack damage detection system however it will allow you to expend the ammo immediately and catch many cases that would normally waste ammo (such as re-targeting). The timer timeout should be set to the fastest possible rate the unit can attack, which is the maximum period between 1/5 the initial attack speed period (maxed out attack speed at +400% faster attack speed) and the animation backswing duration. This insures that if the trigger fires faster than technically possible no ammo will be wasted.

Unless ammo is a really scarce resource on your map (which is not recommended for auto-attack anyway, such maps usually end up lowly rated) then the odd error with ammo counting is insignificant. After all if it registers 1,000 rounds fired but in reality you only fired 950 few people will care if getting another 1,000 rounds is not that hard.

Ironically this is ultra easy to do in SC2 where you just give the weapon a cost. SC2 engine then handles everything including attack prevention and does so highly accurately (no issue with shot counting error).
 
Level 10
Joined
Oct 2, 2014
Messages
215
I love all these replies, but my map is waiting on two things. Ammo and food. What i was more searching for was just a trigger i could make, i thought maybe someone could help me with it. You all have helped me, and i am very appreciative of that, but does anyone know how to actually make one?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
You all have helped me, and i am very appreciative of that, but does anyone know how to actually make one?
This guy gave you some ideas...
rulerofiron99 said:
Event - unit is attacked
if real - mana of attacking unit greater than or equal to 1
then set mana of attacking unit to mana of attacking unit - 1
else order attacking unit to stop
Instead of modifying unit mana, modify the gold for the owner of the attacking (triggering?) unit.

This is the most basic way to implement it and will probably result in some wasted ammo due to miss-fires (as attacking does not necessarily result in an attack being fired).
 
Level 10
Joined
Oct 2, 2014
Messages
215
This guy gave you some ideas...

Instead of modifying unit mana, modify the gold for the owner of the attacking (triggering?) unit.

This is the most basic way to implement it and will probably result in some wasted ammo due to miss-fires (as attacking does not necessarily result in an attack being fired).
Well i am most likely going to make mana the ammo and gold the food, i'll probably try that.
 
Status
Not open for further replies.
Top