• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] how to meke a spell/ability that cost gold insted of mana

Status
Not open for further replies.
Level 28
Joined
Jan 26, 2007
Messages
4,789
This should work:

  • Trigger
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Spell
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current gold) Greater than or equal to 250
        • Then - Actions
          • Player - Add -250 to (Owner of (Triggering unit)) Current gold
        • Else - Actions
          • Set tempForce = (Player group((Triggering player)))
          • Game - Display to tempForce for 10.00 seconds the text: Not enough gold.
          • Unit - Order (Triggering unit) to Stop
          • Custom script: call DestroyForce(udg_tempForce)
 
Level 1
Joined
Jul 20, 2010
Messages
3
i cannot find the If - Conditions
((Owner of (Triggering unit)) Current gold) Greater than or equal to 250

and the whole else action :S.

Set tempForce = (Player group((Triggering player)))
Game - Display to tempForce for 10.00 seconds the text: Not enough gold.
Unit - Order (Triggering unit) to Stop
Custom script: call DestroyForce(udg_tempForce)
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Conditoin if im not mistaken should be in integer players property - current gold

Actions:
create variable called tempforce and choose type player group
use action Set variable and do as written.
Second action is in action's subgroup called 'Game' and then search for Game - display text.
Next one, find Unit actions, select Issued unit order No target, and choose 'Stop' in order field.
Last one is custom script, as called, its your custom code line. Select actions, find Custom Script (at the begining of the list) and write given sentence.
Done.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Do you know how variables work? (The most useful things when coding).
Well, since I do not know what you do and what you don't know, here is a full step-by-step guide:

Condition:
  • New condition.
  • Integer comparison.
  • First value: Player - player property.
  • Player 1 (Red): Owner of Unit
  • Hit "OK" twice (it should now show: ((Owner of (Triggering Unit)) Current gold) Equal to 0).
  • Equal to: greater than or equal to.
  • 0: the gold cost of the spell.

Actions:
  • Press CTRL + B to open the variable window.
  • Press CTRL + N to create a new variable.
  • Variable name: "tempForce", variable type: Player Group - press "OK" twice.
  • New action.
  • Set Variable
  • Select the red "Variable" and choose "tempForce" (which you just created).
  • Select the red "Value" and choose the last option ("Convert Player to Player Group").
  • Player 1 (Red): Owner of Unit.
  • Press "OK" three times.
  • New action.
  • Action Type: Game.
  • Select the second action: Text Message (Explicitly Timed).
  • Select "(All Players)" and change it with the variable "tempForce"
  • Change the "30.00" to the time (in seconds) you want the message to be visible (in my example: 10.00).
  • Change the red "Text" to what you want to appear when the player doesn't have enough gold to cast the spell (in my example: "Not enough gold.").
  • Hit "OK" twice.
  • New action.
  • Action type: Unit.
  • Issue Order with No Target.
  • Select the red "Unit" and change it with "Event Response - Triggering Unit".
  • Hit "OK" twice.
  • New action.
  • Custom script (this is not GUI anymore: it uses JASS directly).
  • Select the red "Script Code" and copy/paste this: call DestroyForce(udg_tempForce)
  • Hit "OK" twice and you're done.

That should cover it.
The only part that may be tricky is the custom script, the reason is that the custom script uses the real coding language Blizzard made (namely JASS), which is Case Sensitive and (like all scripting languages I know) uses a strict syntax where a typo results in an error.
 
Status
Not open for further replies.
Top