Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
It is quite easy. Just make a trigger that drains mana per attack, and makes unit stop when it has 0 mana. Very simple, it can easily be done in GUI, too.
Damage

Events


Unit - A unit enters (Playable map area)

Conditions

Actions


Trigger - Add to Ammo <gen> the event (Unit - (Triggering unit) Takes damage)
Ammo

Events

Conditions

Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Mana of (Damage source)) Greater than 0.00



Then - Actions




Unit - Set mana of (Damage source) to ((Mana of (Damage source)) - 1.00)



Else - Actions




Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
If you're looking for a GUI triggerer, I'm your man.
The reason why I involved life, Mr Lucent, is because that my system is based on damage, but if you have no mana, then you will deal no damage...
Events

Unit - A unit Is attacked
Events

Unit - <YOUR UNIT> Is attacked
Trigger - Add to GUI Ammo Shoot <gen> the event (Unit - TheHeroDude Is attacked)
Actions

-------- Do not touch the Custom script, or the having no ammo branch will bug --------

Custom script: local trigger clean

If (All Conditions are True) then do (Then Actions) else do (Else Actions)


If - Conditions



(Mana of (Attacking unit)) Less than 0.50


Then - Actions



-------- This is the branch for having no ammunition. Add whatever you like, but please leave the Custom Scripts untouched als long as you dont know what they do --------



-------- 'Cargo Hold' does nothing bad to your units except disabling the Attack Button. --------



Unit - Add Cargo Hold (Orc Burrow) to (Attacking unit)



Unit - Remove Cargo Hold (Orc Burrow) from (Attacking unit)



Custom script: set clean=CreateTrigger()



Custom script: call TriggerRegisterUnitStateEvent( clean, GetAttacker(),UNIT_STATE_MANA, GREATER_THAN, 0.50 )


Else - Actions



-------- This is the branch for having ammunition left. You can do everything here. --------



Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) - 1.00)
In fact, i did not the same thing as you, because your unit continues to attack (without dealing damage or showing a missile) without having ammo, while mine stops attacking (and even flees) until the mana is refilled. And please, show me the wait i am using, i want to learn how to improve my codeBut your second paragraph is wrong. I tested it, and it does work, same as the damage thing I posted previously. The thing is, it works immediately, so it will stop the unit from attacking immediately, and immediately remove it the slightest nanosecond after.
And even still, you did the same thing as me, except in two triggers and with some stupid 1 second wait after it. I don't even understand why you included custom script and put 'Less than 0.5' instead of '1.0'.
.Given the attack speed of a machine gun, the screen then would somehow look like this:Well, just use a simple Player Message.
imagninary screen
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.
You run out of ammunition, please reload.

