• 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.

How to make a unit unable to attack?

Status
Not open for further replies.
Im creating an ammunition system and it works so far.
except the point when the unit has no bullets left or is reloading because in this time it should be unable to attack!
What is the easiest way to "disable" the attack of a unit?

I tried some things but nothing works fine
(Ordering "stop" each time sucks)
(Banish has also other effects)
(I tried to remove the attack "ability" and found that the Id is `CmndAttack´ but it does not work)

Im quite sure that there must be an easy solution but i dont get it :S
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
Erm, you could try something like this. Make a skill with 100% damage reduction and add it to the unit when it attacked and has no mana.
Anyway why does the trigger to stop not work? If you need one that works this one should.
Event-
A unit is attacked.
Condition-
Mana of attacking unit equals to 0.
Attacking unit is a hero (or whatever)
Action-
Order attacking unit to stop.

Unless you use JASS then I have no idea what to do cos I don't know JASS :p
EDIT: Or you can make it when your hero gets to 0 mana you make a dummy unit cast an edited version of drunkn haze which disables attack and remove the buff when the hero has more than 0 mana(just change some values for drunken haze and it can disable attack).
 
Level 10
Joined
Jun 16, 2007
Messages
415
Zack, your way the unit would still do damage, e.g:

50-100dmg - 75 = -25 to 25 damage

You dont want that cause then the unit would heal or still deal damage with its attacks.

Simply create a trigger for the unit with
Event - Unit Is Attacked
Condition - Attacking Unit equal to YourUnit
Actions - Order Attacking Unit to stop immeadetly

Note, the Attacking not Attacked Unit! As condition you can simply make HeroAmmo[Player Number of Owner of Attacking Unit] less than or equal to 0, which is even better if you only have one unit with ammo per player.
This will make the unit stop before an attack is executed, not even the animation will be played, I use it to prevent people from team-killing.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
The topic can't be changed by regular member. Only moderators can change the topic prefix. All a member can change is the post title of the first post and manually type [Solved] there, but barely anyone will notice that unless you're searching for it.
By saying that Drunken Haze works and not asking further questions (also no other questions were asked in the first thread, and he even thanks those who helped him solve the problem), I think people can assume the problem is completely solved.
 
hm.. y , i already searched where to change the prefix to solved , this would be an explaination

The main question is already solved :)
But maybe ive got another
I want to order the Reload Ability if the unit has no bullets left. Its just the ordering of the Ability which is in a Spellbook the unit got , is there a trick to get this work instead of removng it from the Spellbook ability? (A simple triggered Order of the ability has no result)
It works with ForceUIKey but it requires that the player has selected the unit and could be messed up by Custom keys i think
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Do you use stackable items as bullets, or do you use mana?

In the mana case: I believe you can check if the unit's property (mana) is equal to 0.
In the stackable items case: Check if the buttons are in the inventory (that is if you remove the bullets item when it reaches 0 stack. in some games the item stays, it just shows 0 bullets). If the bullets are not in your inventory, you can remove or hide the ability (don't know if hiding it will also remove the hotkey and automatic usage of it).
 
huh? that was not an answer i expected

Maybe my question was a bit confusing.
The System itself works perfect. ther are no problems anymore.
The reload ability is castable and works.

If there are "0" bullets left i automaticly order the reload ability but the spell is not casted because it is in a spellbook ability the unit has.
Is there a trick to Order this Ability per trigger even it is in the Spellbook ?
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Oh, I get it. Yes, you can use the Action 'Force player to push ... key'. Let's say the hotkey for the spellbook is S, and the hotkey for reload is R. Then you'd get a trigger like:

  • Actions
    • Unit - Select UNIT for Player 1 (Red)
    • Player - Force Player 1 (Red) to press S key
    • Player - Force Player 1 (Red) to press R key
I don't have WE at the moment, but I'm 100% sure it's there.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I'm not familiar with custom key programs. Never knew they existed. They screw it up for themselves then I guess. All you got to do is warn that they should not use those programs, or they'll suffer the consequences.

And for the previous selection: would it be possible to make a unit group variable
  • Set SelectedUnits[1] = unit(s) selected by Player 1 (Red)
Don't know if such info exists to apply to a unit group variable, but if it does: The array is for each player.

Then you just take my previous trigger, remove selection of the unit with the spellbook, and then you select SelectedUnits[1]. It's like nothing happened except that the Reload ability is activated :smile:
 
Status
Not open for further replies.
Top