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

Serpent Ward Trigger

Status
Not open for further replies.
Level 10
Joined
Nov 5, 2008
Messages
536
I use Summon Serpent Ward spell to summon a unit.
The unit is not summoned for free, a trigger removes a set amount of gold and lumber every time a unit is summoned. But if a player has 50 gold in his bank and the spell "costs" 100 gold, the spell is casted anyway and only the 50 gold is removed.

I want this spell to be cast only if:
- Casting player has required amount of gold
- Casting player has required amount of lumber
- Casting player has enough food

So players can not summon units this way if they dont have enough gold and lumber to pay for the unit. Same goes with food, they need to have farms etc.

Any ideas how to make this?
 
Level 8
Joined
Nov 9, 2008
Messages
502
No problem.

make this trigger:

  • YOUR TRIGGER
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to YOURABILITY
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current gold) Less than 100
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
          • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Matching player))) the text: Not enough gold!
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Triggering unit)) Food used) Greater than (((Owner of (Triggering unit)) Food max) - 5)
            • Then - Actions
              • Unit - Order (Triggering unit) to Stop
              • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Matching player))) the text: Not enough food!
            • Else - Actions
Change the ability in the first IF to your summon ability.
In the last IF
  • "((Owner of (Triggering unit)) Food used) Greater than (((Owner of (Triggering unit)) Food max) - 5)"
Change 5 to the TOTAL food cost of the spell.
 
Level 2
Joined
Mar 7, 2005
Messages
23
hm.. i dont know if i undrestood ur mean correctly but . i have an aidea.
1 ) make a integer var to save the level of ur spell of ur unit.
2 ) make a dummy passive spell (which does nothing ) also play with this new spell tooltips to add what kind of resource is required as a string.
3 ) set ur dummy spell icon similar to ur main spell but with black border and a little more dark...so it looks like a disabled icon .

// i dont know how ur unit earn golds.. or lumber or food..

but anyhow via some triggers
check if u dont have enough resources
---- set the integer u made before to level of ur main ability of ur unit
---- remove ur main ability from ur unit
---- add ur dummy ability to ur unit
// so he cant cast now becuase his spell is a disbaled spell

then
check when u have greatthan or equal than the amount of resources u want
---- remove ur dummy spell from ur unit
---- add ur main spell to ur unit
---- set level of ur main spell of ur unit to the integer u saved before.

i hope it be close to what u r looking for.
this is kinda better than ordering unit to stop casting becuase his spell is still click able ;P i more like to see players cant click on their spells if they dont have what that spell required.
 
Status
Not open for further replies.
Top