Staredit Network > Forums > Modding Assistance > Topic: Making spells require resources to cast
Making spells require resources to cast
Dec 16 2011, 1:49 am
By: xAngelSpiritx  

Dec 16 2011, 1:49 am xAngelSpiritx Post #1

eternal lurker

I really, really wish I was more proficient at C++. :P

Pretty self-explanatory though; I'm curious to know if there's a way to make spells cost resources to cast. Since you can't subtract resources from a player via iscript, I'd like to know if it's possible another way.

Although I'm guessing I'll need to script a plugin, what should I do in order to get it to work properly? Just detecting the order and subtracting the appropriate amount of resources won't work, since, if I'm not mistaken, it will cause the resources to be subtracted every frame that the order is being carried out instead of just once.



None.

Dec 16 2011, 2:57 am Biophysicist Post #2



This is an interesting question. There are a few ways it could be pulled off.
  • Hijack nobrkcode. nobrkcodestart sets a flag that can be read (and manipulated) via plugin; iirc, it's one bit of the status variable. So, if the unit doesn't use nobrkcodestart anywhere else in its iscript, you can put one in its casting animation. If the unit is executing the spell order and in a nobrkcode section, clear the nobrkcode and deduct resources.

  • Detect the unit's energy decreasing (assuming the unit isn't going to be hit by Feedback or EMP Shockwave). Specifically, you'd need to use some unused variable (such as shields for an unshielded unit, rally coordinates for a unit that doesn't rally, etc, or possibly one of the unknowns) in the unit struct, which will hold the energy value from the previous frame (or 0, if the unit was not executing this order in the previous frame), and, each frame, check if the value of this variable is greater than the unit's energy. If it is, then the unit cast the spell. Next, set this variable to the unit's energy. Finally, if the unit is /not/ executing the order for the spell, set this value to 0.

  • Spawn and detect a dummy unit. The obvious way is to make the unit cast Spawn Broodlings (and use BWAI's EXE Edit that makes Broodlings not kill its target and work on terrain if flagged to do so, and another edit to make it spawn only one Broodling) in the casting animation, via useweapon. If a player has a live Broodling, then one of his units cast that spell. Spider Mines could possibly work. Dweb, Dswarm, or Scanner Sweep could be hacked to do it, too.

  • If the spell in question is supposed to buff the caster, then it's easy. Use StimPacks or Burrow (or Cloaking or Siege Mode, possibly) as the trigger; they're easy to detect (and, with everything except Siege Mode, their normal effects can be removed instantly).

  • If the unit doesn't have shields, you could hypothetically use Mind Control as the trigger, and detect the shield decrease. (Though, iirc, you'd have to set the caster's shields to a non-zero value upon spawn and after casting - I don't think that nonshielded units regenerate shields.)

  • Lastly, certain spells that buff the caster can be done by using the Carrier or Reaver, or one of their heroes, and letting them train a dummy unit and doing interesting stuff in the IsWorking animation via imgol.

I'm sure pq or A(s,t) would have a better way with their fancy ubercoding, but that stuff completely flies over my head, and I don't know the memory locations, nor possess the means to find them, anyway.



None.

Dec 17 2011, 3:35 am poiuy_qwert Post #3

PyMS and ProTRG developer

You could check out the STF Plugin source. It has examples of how to do some stuff you might want. It is probably a little overwhelming when opening the source so to give you some direction, look at how kills (killCount) to cash is done.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:39 am]
Oh_Man -- how did u meet?
[09:39 am]
Oh_Man -- Vrael
Vrael shouted: VRAEL GOT MARRIED
legit? grats
[07:56 am]
TF- -- RUEAU RAFNAFAF
[03:58 am]
Generalpie -- Congrats Vrael
[03:01 am]
Vrael -- thank you :D
[03:00 am]
Ahli -- Vrael
Vrael shouted: VRAEL GOT MARRIED
Congratulations!
[02:34 am]
Vrael -- could throw Michele Pfeiffer in the mix too
[02:34 am]
Vrael -- though the 90's Selina > Hathaway (though she was still good)
[02:33 am]
Vrael -- depends on what we're talking, 2012 dark knight rises obviously Anne Hathaway/selina kyle, but if we're going 90's The Animated Series Talia all the way
[02:23 am]
KrayZee -- Is Selina Kyle or Talia al Ghul?
Please log in to shout.


Members Online: Roy, Moose, Zycorax