• 🏆 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!

Spy Ability

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
Are you talking about spy ability in object editor?As far as I know it doesn't work in frozen throne.
 
Level 12
Joined
May 20, 2009
Messages
822
The Spy Ability basically worked like this:

For every building your opponent(s) own, the Gold Cost to use Spy increases by 100. When you use Spy, you get vision of all your opponents buildings for 30 seconds.

It was configurable to change the duration, even to last forever, and you could change both the Gold and Lumber cost.

But there are other ways to make this spell. Except the only thing that cannot be recreated is increasing Gold/Lumber cost with each building without making A LOT of the same ability.

Unless Charge Gold & Lumber can have it's cost increased per level. In which case you can have 1 object with 100s of levels...Not a much better idea, but it is a better idea.

Basically, I wanted the Age of Empires/Mythology ability that lets you see your opponents. Which now that I think about it, it capped out at 500,000 I think.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
I suppose you could create an invisible dummy unit at each building?

Not necessary as there is a native which gives a player shared vision of a specific unit. AFAIK it also works with buildings (this is perhaps how Faerie Fire works?).

native UnitShareVision takes unit whichUnit, player whichPlayer, boolean share returns nothing


Your best bet would just be to trigger the ability.

Simply make a custom ability based off channel, detect when its cast and then iterate through an opponent's buildings. For each building they control, add 100 to the total cost. If the player has that much gold or more, then iterate through the buildings again and give shared vision of each building to the player. Then use a timer, after which you undo all the shared vision, based on the duration of the spy spell.

So for configurable parameters we have

(1) Base cost per building (cost)

(2) Duration (how long vision lasts)

If you want infinite duration, simply use a flag that says not to start a timer, so the player gets permanent vision of an enemy's buildings, or pass in a bogus value for the duration (e.g. a negative value means it lasts forever).

You probably would want to make it a target ability that targets a specific player (cast on a building perhaps?).

You shouldn't have to make 100 copies or levels of the ability at all if it's triggered properly. In fact you could do your own level up system in code, though the only downside is the tooltip wouldn't change.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
I see. I don't see an object editor based solution, unless the native ability Spy updates its tooltip accordingly?

I believe there is a way to detect when the mouse is held over the ability and then using some clever tricks you could display a custom tooltip box which reflects the current cost.

But a problem of scope, is it an instant cast ability that targets all enemy players' buildings? This would be relevant to displaying the correct cost, since if it's a target ability the tooltip update / display needs to be done when the player holds the spell on a target.

If we can detect when a player is holding the cursor above a target (e.g. debating which unit to use Charm on), then you could display a text message that reveals to the player the cost of using the ability.

Alternatively, and probably far easier, is that the player has to cast the spell twice. The first cast is an estimate and tells the player how much it will cost. The second then executes the spell. Obvious there would be some needed tweaks (e.g. the enemy builds a new building in between the observation and the actual spell execution). This could be amended by reverting the state of the spell back to observation if the enemy's building count has changed before the execution call (a simple conditional check in the spell execution code).

JASS:
function main takes nothing returns false
  if execute then
    //check to make sure the building count hasn't changed
    if currbuildingCount != prevBuildingCount then
      //go back to observation
      call observationExec(…)
      set execute = false
   else //run the code for doing the spell
    …
    set execute = false //revert the state
  else //we are observing
    call observationExec(…)
    set execute = true
  endif
  return false
endfunction

Note we'd probably do the changing of the boolean variable inside observationExec and also the spyExec, but I just showed it to illustrate how it could be done.
 
Status
Not open for further replies.
Top