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.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: RIVE, Roy