Staredit Network > Forums > Modding Assistance > Topic: Implementing a New Spell and Distance Attacks
Implementing a New Spell and Distance Attacks
Dec 12 2011, 12:47 am
By: Pr0nogo  

Dec 12 2011, 12:47 am Pr0nogo Post #1



Hello, everyone. I have a few issues regarding weapons and spells and the like.

Issue #1. Implementing a New Spell
I have a weapons.dat entry that is essentially a high-powered frag grenade that I want to implement as a spell. Under techdata.dat, I have implemented a Technology for it (replacing Unknown Tech 26), and under FireGraft the DAT Requirements for using such a technology is listed as 'Must be Brood War' 'Is Hero and Enabled' 'Current Unit is... Jim Raynor (Marine)'. However, when my Jim Raynor unit clicks on the button that has also been grafted to his new button set, nothing happens (as if it were Hold Position or something similar). Is this a result of the DAT Requirements not functioning, or do I need to do something else to make it work? To clarify, I want it to work either like Psi Storm (target terrain) or Consume (target unit), although I'd prefer if it targeted terrain (more freedom).

Issue #2. Distance-Dependent Attacks
For the Torrasque (Ultralisk) unit, I want to give it two attacks; one that attacks air and ground if the enemies are farther than 3 weapons.dat range units away, and one that acts as a melee attack against ground units if they're closer than 3 weapons.dat range units. For this to work, I could easily just restrict the air and ground attack with a minimum range of 3, but I'm afraid that means that the Torrasque wouldn't be able to attack air units that were closer than 3 weapons.dat range units. How would I get by this? iscripts?

That's all for now, although I'll post here if I have any more mod-related issues (which I'm sure I will). Thanks in advance, everybuddy!




Dec 12 2011, 2:40 am Sand Wraith Post #2

she/her

issue 2

There is an opcode that checks if a target is within X range and if so, jumps to a codeblock, but I forgot what it was.

Use this:

For both Air and Ground, use the same code for attacking - both will use the ranged attack.

However, the difference between the two will be made by adding the within-range code to the beginning of the Ground attack script. The within-range code will jump to a special codeblock that uses the close-range weapon.

The unit will always use the Air attack script against air units, and since the Air attack script does not have the within-range code, it will never use the close-range weapon. Instead, it will always use the ranged attack.

Against ground units, the unit will first check if the unit is within X range, and if so, it will jump to the special codeblock and attack with the close-range weapon. If not, the unit will continue on with the Ground attack script and use the default ranged weapon.

-

I might not have addressed the issue correctly.

Presently, I am interpreting your desire as wanting a unit to attack all air units with the ranged attack, with a condition-based attack only against ground units.

Above is the solution for the desire I have interpreted. Please ask if you need clarification.

But don't ask for actual code, 'cause my HDD is dead. I can give pseudocode though.

-

Pseudocode follows.

Code
AttackAir:
attackwith 2

AttackGround
withinrange 3 jumpto AttackMelee
attackwith 2

AttackMelee
attackwith 1





Dec 12 2011, 3:11 am Biophysicist Post #3



The opcode is trgtrangecondjmp.

Afaik, defining new spells can't exactly be done. However, you can instead turn an existing spell into a new spell (on a unit-by-unit basis) through iscript. There are two ways, depending on if you need a projectile or not. Both work by using some existing spell, but messing with Raynor's CastSpell animation to use the frag grenade weapon instead of casting. This will /not/ affect the base spell when the normal caster uses it. (Note that "CastSpell" is an animation label - "MarineCastSpell" or w/e - while "castspell" is the iscript opcode that executes a spell).

If you don't need a projectile: Give your Raynor Marine any of the following: Storm, Dweb, Swarm, Stasis, EMP, Maelstrom, Ensnare, or Plague. (Pick one that has the same cost as you want the custom spell to have.) Then, in the Raynor Marine's iscript, give him a CastSpell animation, but don't put the castspell opcode anywhere in the script. Instead, useweapon something appropriate.

If you do want a projectile: Change some unused weapon into a clone of Raynor's Gauss Rifle. Then, give it an appropriate graphic, spash, and, if desired, a different damage type. Give the weapon a different (unused) iscript ID, and copy its original iscript into the new iscript, but duplicate domissiledmg several times. Then, do everything mentioned in the first method, but with attackwith 2 instead of useweapon ?. This does have the obvious drawbacks, but its the only way to get a projectile, iirc.

A step-by-step explanation of the second method, if I wasn't clear enough.




None.

Dec 12 2011, 4:19 am Pr0nogo Post #4



Man, this stuff's more confusing than a rubber hose bottle of foot.

Alright, so I understand the solution to the second issue. Let me see if I understand the first (I don't think I do).

1. I already modified Raynor's Gauss Rifle. Problem?
2. Anyhow, I copy and paste that entry into one of the several unused ones. For graphics, I set it to Acid Drip or something and fill in the rest of the weapon details (not sure why I needed Raynor's rifle as a base) and set this weapon as Raynor's second weapon in units.dat.
3. Find the Fragmentation Grenade iscript and paste it into the Acid Drip or something iscript. Add domissiledmg clones until I am content.
4. Swap out the 'castspell' opcode in Raynor's iscript for an 'attackwith 2' one.

Voila? How do I make it cost energy? Is that linked like a normal spell for all intents and purposes? Would technology requirements still hold up?

Thanks for the quick assistance, by the way. I owe you two. Complimentary voice acting or music production on your next project. :P




Dec 12 2011, 5:02 am Sand Wraith Post #5

she/her

I accept mineral payments.

Also, if YOU need voice work done, contact me! I LOVE TRYING TO VOICE ACT.

I TRY TO DO GROWLS AND SCREAMS. So recruit me for your insane, chaotic-evil, orderly-evil characters!




Dec 12 2011, 5:10 am Pr0nogo Post #6



Lol, you might be more at home helping me with my death/thrash metal vocal covers. I'll keep that in mind, however, as this project could use some more vocal dynamics.




Dec 12 2011, 5:18 am Sand Wraith Post #7

she/her

Quote from Pr0nogo
Lol, you might be more at home helping me with my death/thrash metal vocal covers. I'll keep that in mind, however, as this project could use some more vocal dynamics.

LOLOLOL I actually can't sing/death growl for shit (but I really wish I could, and that's why I've been practicing for a few years now), but you can hear my pitiful attempts and decide on your own whether my voice is appropriate or not :D




Dec 12 2011, 5:31 am Pr0nogo Post #8



PM me your MSN or whatever and we can voice chat it out later on.




Dec 12 2011, 9:26 am Biophysicist Post #9



I had you copy the ground weapon so that it would look less stupid when Raynor is selected.

Quote
Voila? How do I make it cost energy? Is that linked like a normal spell for all intents and purposes? Would technology requirements still hold up?
It is a normal spell, though Raynor's iscript reacts differently. I'm assuming Raynor is a hero here, or at least has access to the spell without research. I'm also assuming that he has no other spells. If either is not the case, it's still possible, but a bit more complicated; I neglected to deal with those possibilities.

EDIT: Actually, there's a better solution, probably. How much energy do you want this to cost?



None.

Dec 12 2011, 11:06 am Pr0nogo Post #10



He's a hero hero with no other spells and I want it to cost 100 energy.




Dec 13 2011, 12:19 am Biophysicist Post #11



Okay. This is a better way to do it. ;0 Though I'm going from memory; I might have misremembered something, but if so, there's a workaround.

1) In weapons.dat, select some dummy weapon and copy the Stasis Field weapon over it.
2) Also in orders.dat, modify the Stasis Field weapon into your frag grenade.
3) In iscript.bin, give Raynor a CastSpell animation which calls castspell.
4) Also in iscript.bin, change the castspell opcode in the Arbiter's CastSpell animation to useweapon the dummy weapon from step 1.
5) In Firegraft, give Raynor Stasis Field, changing reqs as needed.

...This works because Recall does not use the CastSpell animation; ArbiterCastSpell is only used for Stasis Field (unless you give other spells to the Arbiter, ofc). So, Raynor uses the normal Stasis Field weapon, which we changed into a frag grenade, when ordered to cast Stasis Field. The Arbiter, however, uses a different weapon, which we gave the normal Stasis Field behavior to, so Stasis, as cast by Arbiters, works normally from a gameplay perspective.

I chose Stasis because it costs 100 energy and does not have a projectile. (You will probably want the frag grenade a projectile, which isn't a problem. The base spell not having a projectile matters because useweapon doesn't like projectiles, so if we had used EMP, it would lose its projectile when the Vessel cast it.)

Post has been edited 1 time(s), last time on Dec 19 2011, 8:29 pm by Biophysicist.



None.

Dec 13 2011, 1:58 am Pr0nogo Post #12



Alright, I think I understand. If not, I'll post back. I won't be able to test until tomorrow or Wednesday, though, so we'll see what's what when that day arrives. Thanks again for your help!

Edit: BAH HUMBUG how do I make it have different icons if it's the same spell?!




Dec 13 2011, 3:00 am Biophysicist Post #13



Hm? Like, the button on the command card? If that's what you meant, it's trivial, as the button (and strings thereof) are part of the command card, not of the spell. Just switch them on Raynor's command card in Firegraft.



None.

Dec 19 2011, 1:31 am Biophysicist Post #14



Did it work?



None.

Dec 19 2011, 6:53 am Pr0nogo Post #15



By 'button' I meant the weapon icon next to the armour icon. Will it be a Frag Grenade on both the Arbiter and the Raynor, or does it not show on the Arbiter? Also, for the useweapon opcode, how do I select the dummy weapon? (not in front of PyICE at the moment)




Dec 19 2011, 2:50 pm Jim_Raynor Post #16

My name is Church.

The weapon icon is attached to the weapon itself, not the unit, so if both units use the same weapon, it would use the same icon.
Useweapon uses the weapon ID, which is the number before the weapon in datedit. For example, useweapon 84 would create a psi storm. If Unknown117 is your dummy weapon, you'd use useweapon 117.



Anything that can go wrong, will go wrong.

Dec 19 2011, 8:28 pm Biophysicist Post #17



I'd posted a better method that doesn't involve stupid attackwith hacks. I would very much recommend using it instead. I'll copy-paste it here for convenience:

Spoilered for length.




None.

Dec 20 2011, 12:17 am Pr0nogo Post #18



Neither of you understood my problem. I want the icon to be a Frag for Raynor and not seem out of place on the Arbiter.




Dec 20 2011, 1:11 am Sand Wraith Post #19

she/her

The spell button, right?

I don't have any tools handy, but see if Firegraft can set a button's icon separate from its order.




Dec 20 2011, 2:43 pm Pr0nogo Post #20



...facepalm

The WEAPON ICON, that would read FRAG GRENADE or maybe GAUSS RIFLE next to TERRAN INFANTRY ARMOUR on the UNIT CARD that has its WIREFRAME and HIT POINTS and OTHER NOTABLE STATS Fx17Ux13




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are some real members mixed in those latter pages, but the *vast* majority are spam accounts
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- there are almost 3k pages
[2024-4-14. : 9:21 pm]
O)FaRTy1billion[MM] -- the real members stop around page 250
[2024-4-14. : 9:20 pm]
O)FaRTy1billion[MM] -- look at the members list
[2024-4-12. : 12:52 pm]
Oh_Man -- da real donwano
da real donwano shouted: This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
it's pretty common
[2024-4-11. : 9:53 pm]
da real donwano -- This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
[2024-4-11. : 4:18 pm]
IlyaSnopchenko -- still better than "Pakistani hookers in Sharjah" that I've seen advertised in another forum
[2024-4-11. : 4:07 pm]
Ultraviolet -- These guys are hella persistent
[2024-4-11. : 3:29 pm]
Vrael -- You know, the outdoors is overrated. Got any indoor gym and fitness equipment?
[2024-4-10. : 8:11 am]
Sylph-Of-Space -- Hello!
Please log in to shout.


Members Online: jun3hong, eksxo