• 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 attack, each of attack cost gold/lumber?

Status
Not open for further replies.
Level 2
Joined
Feb 17, 2009
Messages
13
Is there possible to make a unit do a normal attacking will cost of gold or lumber, or even mana?

Example: A unit attack, will need 1 lumber for each attack(shot/hit)
When the player run out of lumber, the unit wont attack(just like gun with no ammo)

Is there anyway to do this?

I was looking of the forum about this problem but its too large to find so I make a tread here and hope someone might feel free to help me.
thx
 
Level 11
Joined
Feb 16, 2009
Messages
760
Or use this, it substracts lumber and stopt it if it doesn't have lumber
  • Lumber ammo
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (((Owner of (Attacking unit)) Current lumber) Greater than 0) then do (Player - Set (Owner of (Attacking unit)) Current lumber to (((Owner of (Attacking unit)) Current lumber) - 1)) else do (Unit - Order (Attacking unit) to Stop)
 
Level 2
Joined
Feb 17, 2009
Messages
13
sry for the delay, at start what u told me was not working, I keep checking n i found a mistaked bug
after I fixed it, now this was working great, thx lots

but there is a weird thing
when Im run out of lumber, stop attacking, monster stop attacking too lol

can i make it example player has lumber, he allow to attack, no lumber no attack
for monster, thy can attack unlimit just like normal
can anyone mind sharing me, how to fix this? thx
 
Level 2
Joined
Feb 17, 2009
Messages
13
oh, I just add this n it works, but I have no idea there is a bug or not
=>Conditions
(Attacking unit) Equal to 'the player'

If there is any bug will happen pls let me know, thx =\

If i use this, I need to create this trigger for 1 time X number of player
If 10 player it need 10 time =.=
Is there any better way?
 
Level 2
Joined
Feb 17, 2009
Messages
13
Events
**Unit - A unit Is attacked
Conditions
((owner of (triggering unit)) controller equal to user
Actions
If (((Owner of (Attacking unit)) Current lumber) Greater than 0) then do (Player - Set (Owner of (Attacking unit)) Current lumber to (((Owner of (Attacking unit)) Current lumber) - 1)) else do (Unit - Order (Attacking unit) to Stop)

thx. but it still has 1 need to fix, er...
at start with 0 lumber, we cant attack, after we have lumber, we can start attacking
but when run out of lumber, when 0 lumber, the unit wont stop attacking
anyway to fix this? thx..

I had try create new trigger example..
Events
Unit - A unit Is attacked
Conditions
((owner of (triggering unit)) controller equal to user
Actions
If (((Owner of (Attacking unit)) Current lumber) Equal to 0) then do (Unit - Order (Attacking unit) to Stop) else do (Do nothing)

Both trigger is works when i try each by each, but when i enabled both,
it seems like only the 1st trigger works
must use 1 trigger for all?
 
Status
Not open for further replies.
Top