After you have fixed up your spellcasting unit in Arsenal III and StarGraft, the last element of giving a unit the ability to use an existing spell is to update its iscript animation. Every time a unit is ordered to cast a spell, StarCraft will attempt to run its spellcasting animation. The problem is that, most units don't have a spellcasting animation, and if StarCraft tries to find the spellcasting animation on one of these units, it will not find one, causing StarCraft to crash.
Let's take a look at how StarCraft calls animations. The text-based form of IceCC has a way of allowing easier visualisation of how iscripts flow, and so for this tutorial, IceCC will be used. However, once you understand the concepts, the program you use is your choice. Below is the iscript code for the SCV, extracted using IceCC.
CODE
# ----------------------------------------------------------------------------- #
# This header is used by images.dat entries:
# 247 SCV (terran\SCV.grp)
.headerstart
IsId 84
Type 15
Init SCVInit
Death SCVDeath
GndAttkInit SCVGndAttkInit
AirAttkInit [NONE]
SpAbility1 [NONE]
GndAttkRpt SCVGndAttkInit
AirAttkRpt [NONE]
SpAbility2 [NONE]
GndAttkToIdle SCVGndAttkToIdle
AirAttkToIdle [NONE]
SpAbility3 [NONE]
Walking SCVWalking
Other SCVOther
BurrowInit [NONE]
ConstrctHarvst [NONE]
IsWorking SCVIsWorking
.headerend
# ----------------------------------------------------------------------------- #
SCVInit:
imgul09 248 0 7 # SCVShad (terran\SCV.grp)
playfram 0x00 # frame set 0
goto SCVOther
SCVOther:
wait 125
goto SCVOther
SCVDeath:
playsnd 369 # Terran\SCV\TSCDth00.WAV
imgol08 332 0 0 # TerranBuildingExplosionsmall (thingy\tBangS.grp)
wait 3
end
SCVGndAttkInit:
shvertpos 0
wait 1
playfram 0x22 # frame set 2
attack25 1
wait 1
playfram 0x11 # frame set 1
wait 1
gotorepeatattk
goto SCVOther
SCVGndAttkToIdle:
playfram 0x00 # frame set 0
goto SCVOther
SCVWalking:
playfram 0x00 # frame set 0
imgol08 249 0 0 # SCVGlow (thingy\tscGlow.grp)
shvertpos 0
goto SCVOther
SCVIsWorking:
shvertpos 0
wait 1
local00:
playfram 0x22 # frame set 2
useweapon 14 # Fusion Cutter
wait 1
playfram 0x11 # frame set 1
waitrand 8 10
goto local00
In IceCC, the scripts for each unit are made up of two parts. First, there is the header, which can be found between .headerstart and .headerend lines. Below the headers (usually) are the commands for the script, and throughout the commands are a series of labels, like "SCVWalking:" and statements, such as "attack25 1". To understand how animations are called in StarCraft, it is important to see how the header and the rest of the script are connected.
Each line in the header is made up of a keyword then a value, separated by a space. For instance, if we skip the first two lines of the header - they might be explained in another tutorial - there is the keyword "Init" and its value is "SCVInit". That is saying to StarCraft, when you have to run the "Init" animation for this image, execute the code starting from "SCVInit". Notice that a label name "SCVInit" is in the code, right below the header. Yes, take a look at it, don't take my word for it, go up there and look, it's fun to see it for yourself.
The Init animation will be run when the SCV unit is first created. So, StarCraft knows to call SCVInit when the SCV initialises because it is written in the iscript header. In the same way, StarCraft knows to call SCVGndAttkInit when the SCV needs to play its ground attack animation because it is written right next to the GndAttkInit keyword in the header.
As you can also see, some of the keywords in the header have the word [NONE] next to them, like AirAttkInit does. Guess what happens if StarCraft tries to play the SCV's air attack animation when it's got [NONE] for its code label? That's right, you guessed it, StarCraft will not know what code to run, and so it will crash. Perhaps you already knew that, but now that you can see the parts that are causing the crash, maybe you can guess how you would fix this.
For spellcasting, the concept is the same. If StarCraft tries to run the non-existent spellcasting animation, then it will crash. So you need to go to the spellcasting animation for your unit and change the [NONE] to a code block, which you might even write yourself. However, if you look at all the animation types the SCV has above, there is just one problem that could be stopping you from giving the SCV a spellcasting animation. Do you see it? Think about it.
Looking at the iscript for the SCV, there seem to be three spellcasting animations - SpAbility1, SpAbility2 and SpAbility3. Which one are you meant to change? I could tell you directly, but I'm going to teach you something even better - how to find out the answer for yourself.
Here's the Queen's iscript.
CODE
# ----------------------------------------------------------------------------- #
# This header is used by images.dat entries:
# 046 Queen (zerg\queen.grp)
.headerstart
IsId 27
Type 12
Init QueenInit
Death QueenDeath
GndAttkInit QueenGndAttkInit
AirAttkInit QueenGndAttkInit
SpAbility1 [NONE]
GndAttkRpt QueenGndAttkInit
AirAttkRpt QueenGndAttkInit
SpAbility2 QueenSpAbility2
GndAttkToIdle QueenGndAttkToIdle
AirAttkToIdle QueenGndAttkToIdle
SpAbility3 [NONE]
Walking QueenWalking
Other QueenGndAttkToIdle
BurrowInit [NONE]
.headerend
# ----------------------------------------------------------------------------- #
QueenInit:
imgul09 47 0 42 # QueenShad (zerg\queen.grp)
playfram 0x00 # frame set 0
waitrand 1 4
QueenGndAttkToIdle:
playfram 0x00 # frame set 0
wait 2
playfram 0x11 # frame set 1
wait 2
playfram 0x22 # frame set 2
wait 2
playfram 0x33 # frame set 3
wait 2
playfram 0x44 # frame set 4
wait 2
goto QueenGndAttkToIdle
QueenDeath:
playsndbtwn 925 927 # Zerg\Queen\ZQuDth00.WAV, Zerg\Queen\ZQuDth02.WAV
sprol0f 156 0 0 # QueenBirth (zerg\zquDeath.grp)
wait 1
end
QueenGndAttkInit:
shvertpos 0
playfram 0x55 # frame set 5
wait 1
playfram 0x66 # frame set 6
wait 1
playfram 0x77 # frame set 7
wait 1
playfram 0x88 # frame set 8
playsnd 90 # Bullet\ZQuFir00.wav
attack25 1
wait 1
playfram 0x99 # frame set 9
wait 1
playfram 0xaa # frame set 10
gotorepeatattk
goto QueenGndAttkToIdle
QueenSpAbility2:
shvertpos 0
playfram 0x55 # frame set 5
nobrkcodestart
wait 1
playfram 0x66 # frame set 6
wait 1
playfram 0x77 # frame set 7
wait 1
playfram 0x88 # frame set 8
castspell
sigorder 2
wait 1
playfram 0x99 # frame set 9
wait 1
playfram 0xaa # frame set 10
nobrkcodeend
gotorepeatattk
goto QueenGndAttkToIdle
QueenWalking:
playfram 0x00 # frame set 0
wait 1
playfram 0x11 # frame set 1
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x44 # frame set 4
wait 1
goto QueenWalking
Does the Queen use SpAbility1, SpAbility2 or SpAbility3 for its spellcasting animation? If you haven't worked it out yet, look again, it is quite obvious. Or highlight this text:
Correct answer: SpAbility2What you did there was look at something else which does what you want and learnt from it. Where you can, that's what you should do when you want to know the answer to something, it will expand your modding knowledge in a way that explanations or tutorials cannot, because you are actively seeking answers.
However, there are things that would take you weeks to understand yourself but only minutes for another experienced modder to explain. Writing the code for a spellcasting script might be one of these. So I've got a quick example of how I would write the spellcasting animation code for the SCV here to make sure all the important points are covered.
First, I would write the code for spellcasting to the SCV's script. In most cases, a good place to start for this is to just copy the code from one of the attack animations. This will be a good place for you to start if you are creating a spellcasting animation. So after copying the attack animation, here would be my first draft of the spellcasting code...
CODE
MyCastSpellAnimation:
shvertpos 0
wait 1
playfram 0x22 # frame set 2
attack25 1
wait 1
playfram 0x11 # frame set 1
wait 1
gotorepeatattk
goto SCVOther
Of course, spellcasting doesn't involve attacking, so I'd have to replace the attack command with the cast spell command. By looking at the Queen's (or any other spellcaster unit's) script I can see the commands that are used to cast the spell are these ones:
CODE
castspell
sigorder 2
The castspell command casts the spell, and the sigorder 2 command says to StarCraft "I'm finished casting the spell" and unactivates the button. If you want to see what it does exactly, try making a script without the sigorder 2 command.
CODE
MyCastSpellAnimation:
shvertpos 0
wait 1
playfram 0x22 # frame set 2
castspell
sigorder 2
wait 1
playfram 0x11 # frame set 1
wait 1
gotorepeatattk
goto SCVOther
And that's the complete script. You can edit this further if you want to have flares, spinning, jumping or whatever else before the spell is cast. The order of the different blocks in the script actually doesn't matter, so if this code was put at the top, bottom, or somewhere in the middle of the script it wouldn't make a difference, as long as it isn't put right in the middle of an existing block.
Like the spellcasting animation of the Queen, the spellcasting animation also should always have a gotorepeatattk command just before it goes to the idle animation of the unit. This signals StarCraft that the unit is
ready to repeat casting the spell, it's not actually a jump command like its name indicates.
Now that the spellcasting animation code is created, the header of course needs to be updated. As you now know, that means making SpAbility2 point to the new code block label, not just [NONE].
CODE
SpAbility2 MyCastSpellAnimation
So that is how I would give the SCV's spellcasting animation. This description is by no means a definitive set of steps that must be performed in a specific order, it is just the way I would go about achieving the required parts. In summary, the necessary parts you need to have for a spellcasting animation to work are:
- Change SpAbility2 to point to a spellcasting code block, not just [NONE]
- In your spellcasting code block, make sure you have a castspell, sigorder 2, gotorepeatattk and at the end of the block you jump to the idle animation part of the code.
As long as you got those two things, you can have a spellcaster unit. The way I would do the SCV might not be the best way to do it for you, play around and find out how you would do it.
If there's anything I want you take from this tutorial, it's not the part about how to give a unit a spellcasting animation. I hope you learn that the best way to find answers is to find them yourself, and one way to do this is to look at the way Blizzard have created an effect using the StarCraft engine. The only way someone can become an expert at modding is if they are willing to experiment, so don't be afraid to experiment.
[right][snapback]228386[/snapback][/right]
Whew...long-winded, but useful. Thank you. If only I could get IceCC to, you know, work, I'd use that. But, I'm stuck with ICE for now. But, once I figure out why it won't load load the ARR units file, I'll be set. Thank you. With this info, I should be capable of creating a good mod. Again, I thank all who have been, you know, helpful in my endeavors. If I can provide anyone with assistance, just let me know. *bows in respect*