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.
[06:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[06:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[06:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[06:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[06:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[06:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[06:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
[06:45 pm]
NudeRaider -- Vrael
Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
beats me, but I'd make sure to pick the epitome of excellence and nothing less.
[06:41 pm]
Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
[06:38 pm]
Vrael -- I need a go-to solution and someone who understands that Carpets are more than just decorative elements in my home.
Please log in to shout.


Members Online: Roy