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.
[11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
[2024-4-17. : 1:08 am]
O)FaRTy1billion[MM] -- i'll trade you mineral counts
[2024-4-16. : 5:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[2024-4-16. : 4:31 pm]
Zoan -- where's the option to delete my account
[2024-4-16. : 4:30 pm]
Zoan -- goodbye forever
Please log in to shout.


Members Online: Roy, Judcfrffvf