View Full Version : Secondary Attacks
Flametrooper
01-04-2007, 5:36 PM
How would you make a unit have a secondary attack? I would think you would add a button in Memgraft, but there is no act for "attack with secondary weapon". So how would you do that?
DiscipleOfAdun
01-04-2007, 5:50 PM
Traditionally, secondary weapon weapons that attack are determined by range via iscript(i can't remember the command name) and either the attack25 command(where it uses the 'air' weapon), or by the useweapon command. If you want it to use weapons on command...you have to mess with spells and such. not fun.
TheNomad
01-04-2007, 6:33 PM
attack25 is attackwith which requires the weapon as param and attack26 is attack which has no param and determines it via range and flyer target flag.
Flametrooper
01-04-2007, 6:46 PM
attack25 is attackwith which requires the weapon as param and attack26 is attack which has no param and determines it via range and flyer target flag.
But how do I add a secondary attack again?
TheNomad
01-04-2007, 7:17 PM
IScript, of course ;)
SuiCidAl-KiSmEt
01-04-2007, 7:48 PM
It leaves only two ways it can be done. You can force a unit to use a certain weapon depending how far away the target is or you can have the script pick a random integer, depending on the number, to use another weapon.
Here are the codes:
trgtrangecondjmp <num> <label>
Remember IceCC uses pixels for range. If the unit is not in range, the weapon will not be used. I think 16pixels = 1 square (in the grid in StarEdit).
__1e_condjmp <num> <label>
num = highest random number it will generate. Say you make the num value to two. Make two __1e_condjmp codes; one for if num ends out being 1 and another if one ends out being 2.
label = code block, where you want the rest of the script to go if the conditions is true.
I might be wrong; it’s kind of a long time since I've done this. Read the Manual that came with IceCC for more info. :P
TheNomad
01-04-2007, 8:26 PM
remember that a new IceCC came out in the meantime :D
Flametrooper
01-04-2007, 8:46 PM
Oh man. How would all that be with the new IceCC?
So, for example, you could have a unit be so if he is a certain ammount of pixels away, he would throw a grenade instead of shoot? Or if he is really close, he would do a melee attack?
TheNomad
01-04-2007, 9:23 PM
you can do that with any IceCC, but the new one has intelligible opcodes...
Flametrooper
01-04-2007, 10:25 PM
Okay, the new syntax would be in the readme or whatever right?
TheNomad
01-05-2007, 6:15 AM
In a file called "Iscript opcodes.txt" :)
Flametrooper
01-05-2007, 10:14 AM
EDIT: Where would I put the set of code (trgtrangecondjmp)? Under which label heading?
So, I made a label called MarineSecAttkInit. That is the label I will have the trgtrangecondjmp go to if it is at a value of two. (The secondary attack is going to be a bop, or a melee attack.) If it is one, I will have it repeat and go back to the same label until it is a value of two. Is that right? Also, do I have to do any editing at the top? Up here?
#----------------------------------------------------------------------------- #
# This is a decompile of the iscript.bin file 'data\scripts\iscript.bin'
# created on: Fri Jan 05 09:17:47 2007
# ----------------------------------------------------------------------------- #
# ----------------------------------------------------------------------------- #
# This header is used by images.dat entries:
# 239 Marine (terran\marine.grp)
.headerstart
IsId 78
Type 12
Init MarineInit
Death MarineDeath
GndAttkInit MarineGndAttkInit
AirAttkInit MarineGndAttkInit
Unused1 [NONE]
GndAttkRpt MarineGndAttkRpt
AirAttkRpt MarineGndAttkRpt
CastSpell [NONE]
GndAttkToIdle MarineGndAttkToIdle
AirAttkToIdle MarineGndAttkToIdle
Unused2 [NONE]
Walking MarineWalking
WalkingToIdle MarineWalkingToIdle
SpecialState1 [NONE]
.headerend
# ----------------------------------------------------------------------------- #
Do I have to make a new header up there called SecAttkInit, SecAttkRpt, SecAttkToIdle?
MaxedOutBC
01-05-2007, 3:50 PM
Do I have to make a new header up there called SecAttkInit, SecAttkRpt, SecAttkToIdle?
no. If you do, you will get errors and stuff.
SuiCidAl-KiSmEt
01-05-2007, 6:46 PM
No, don't make a new heading, MaxedOutBC might be right and no need to do that. Just simply make new code block and call it from the original ones. Just do something like...
MarineGndAttkInit:
code
code
code
trgtrangecondjmp 16 2ndAttack
code
code
repeatattack
goto: marineother
2ndAttack:
code
code
code
repeatattack
goto: code
Just like that, the 2ndAttack is the new code block I just added just below all the other ones. Also, make sure you have that repeatattack code in the new one too if it's for attacking. Keep in mind, repeatattack is not the actual repeatattack code. If the trgtrangecondjmpn condition is true, it'll skip the rest of the MarineGndAttkInit and straightly go to the 2ndAttack.
Flametrooper
01-05-2007, 7:15 PM
Thank you very much. Last thing, how do I pick the weapon?
SuiCidAl-KiSmEt
01-05-2007, 8:38 PM
You could either use attack25 <num>. The num = the weapon ID identified in DatEdit or Arsenal III.
Or you could use attack26 which automatically appropriate weapon, depending what you gave the unit in DatEdit or Arsenal III.
MaxedOutBC
01-05-2007, 9:57 PM
attack25 1= attack with ground weapon (first weapon)
attack25 2 = attack with air weapon (second weapon)
attack 26 = attack with ground weapon if target is ground, and attack with air weapon if target is air.
use weapon <a> = use weapon number corresponding to weapon ID (ex. wepon ID 0 is guass rifle)
BTW if you have IceCC 1.3 (http://shadowflare.samods.org/dwnload.html), then "attack 25" is replaced with "attackwith." Not sure about what attack26 changes to, but the version has all the opocodes in a document anyway.
TheNomad
01-05-2007, 10:10 PM
attack25 1= attack with ground weapon (first weapon)
attack25 2 = attack with air weapon (second weapon)
attack 26 = attack with ground weapon if target is ground, and attack with air weapon if target is air.
use weapon <a> = use weapon number corresponding to weapon ID (ex. wepon ID 0 is guass rifle)
BTW if you have IceCC 1.3 (http://shadowflare.samods.org/dwnload.html), then "attack 25" is replaced with "attackwith." Not sure about what attack26 changes to, but the version has all the opocodes in a document anyway.
attack25 is attackwith which requires the weapon as param and attack26 is attack which has no param and determines it via range and flyer target flag.
Already few posts ahead of you ;)
Flametrooper
01-06-2007, 7:46 AM
Okay thanks guys, that was a lot of help.
Flametrooper
01-06-2007, 11:08 AM
Okay last thing, and I apologize fo rhte double posting. When I played the mod, and started up the game, it gave me an error message saying "script 289 does not exist." What did I do wrong?
SuiCidAl-KiSmEt
01-06-2007, 11:31 AM
You told IceCC to play a frame that didn't exist. Just kidding. I don't know, can you post your script?
Flametrooper
01-06-2007, 12:39 PM
I will just post the MPQ up.
TheNomad
01-06-2007, 12:44 PM
The script is easier since we wouldn't have to download, unpack, decompile and then read when we could just read it and be done
Flametrooper
01-06-2007, 12:57 PM
Very well, here it is.
----------------------------------------------------------------------------- #
# This is a decompile of the iscript.bin file 'C:\Documents and Settings\Owner\My Documents\Starcraft\scripts\iscript.bin'
# created on: Sat Jan 06 11:56:52 2007
# ----------------------------------------------------------------------------- #
# ----------------------------------------------------------------------------- #
# This header is used by images.dat entries:
# 239 Marine (terran\marine.grp)
.headerstart
IsId 78
Type 12
Init MarineInit
Death MarineDeath
GndAttkInit MarineGndAttkInit
AirAttkInit MarineGndAttkInit
Unused1 [NONE]
GndAttkRpt MarineGndAttkRpt
AirAttkRpt MarineGndAttkRpt
CastSpell [NONE]
GndAttkToIdle MarineGndAttkToIdle
AirAttkToIdle MarineGndAttkToIdle
Unused2 [NONE]
Walking MarineWalking
WalkingToIdle MarineWalkingToIdle
SpecialState1 [NONE]
.headerend
# ----------------------------------------------------------------------------- #
MarineInit:
imgul 240 0 0 # MarineShad (terran\tmaShad.grp)
MarineWalkingToIdle:
playfram 0x44 # frame set 4
MarineLocal04:
waitrand 63 75
randcondjmp 25 MarineLocal00
randcondjmp 128 MarineLocal03
goto MarineLocal04
MarineLocal00:
playfram 0x00 # frame set 0
wait 1
playfram 0x11 # frame set 1
wait 1
playfram 0x22 # frame set 2
randcondjmp 192 MarineLocal01
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
wait 6
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
wait 6
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
goto MarineLocal02
MarineLocal03:
playfram 0x55 # frame set 5
wait 1
playfram 0x66 # frame set 6
wait 1
turnrand 3
wait 1
playfram 0x55 # frame set 5
wait 1
goto MarineWalkingToIdle
MarineLocal01:
wait 13
MarineLocal02:
playfram 0x11 # frame set 1
wait 1
playfram 0x00 # frame set 0
wait 1
goto MarineWalkingToIdle
MarineDeath:
playsndbtwn 276 277 # Terran\MARINE\TMaDth00.WAV, Terran\MARINE\TMaDth01.WAV
setfldirect 0
playfram 0xdd # frame set 13
wait 2
playfram 0xde # frame set 13
wait 2
playfram 0xdf # frame set 13
wait 2
playfram 0xe0 # frame set 13
wait 2
playfram 0xe1 # frame set 13
wait 2
playfram 0xe2 # frame set 13
wait 2
playfram 0xe3 # frame set 13
wait 2
playfram 0xe4 # frame set 13
wait 2
lowsprul 236 0 0 # MarineDeath (terran\tmaDeath.grp)
wait 1
end
MarineGndAttkInit:
playfram 0x00 # frame set 0
wait 1
playfram 0x11 # frame set 1
wait 1
playfram 0x22 # frame set 2
MarineGndAttkRpt:
wait 1
trgtrangecondjmp 4 MarineLocal05
nobrkcodestart
playsnd 69 # Bullet\TMaFir00.wav
attackwith 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
nobrkcodeend
gotorepeatattk
ignorerest
MarineGndAttkToIdle:
playfram 0x11 # frame set 1
wait 1
playfram 0x00 # frame set 0
wait 1
goto MarineWalkingToIdle
MarineLocal05:
wait 1
attackwith 118
wait 1
attackwith 118
gotorepeatattk
goto MarineGndAttkToIdle
MarineWalking:
move 4
wait 1
playfram 0x55 # frame set 5
move 4
wait 1
playfram 0x66 # frame set 6
move 4
wait 1
playfram 0x77 # frame set 7
move 4
wait 1
playfram 0x88 # frame set 8
move 4
wait 1
playfram 0x99 # frame set 9
move 4
wait 1
playfram 0xaa # frame set 10
move 4
wait 1
playfram 0xbb # frame set 11
move 4
wait 1
playfram 0xcc # frame set 12
move 4
wait 1
playfram 0x44 # frame set 4
goto MarineWalking
TheNomad
01-06-2007, 2:08 PM
did you do any dat editing ?
StealthyDeath
01-06-2007, 3:38 PM
You didn't check "Merge with default iscript.bin."
Flametrooper
01-06-2007, 4:46 PM
I didn'twant to merge with default iscript.bin. I wanted to add it to a backup iscript fresh out of the Stardat.mpq.
Yes I did do dat editing. The file is in the MPQ.
StealthyDeath
01-06-2007, 5:47 PM
Merging with the default iscripts means adding all iscripts you didn't change to your iscript.bin. If you do not check it then the only iscript that exists is the ones you added to compile. Every other unit simply does not have any animation at all. That is why you get the error message "script # does not exist". Your Marine animation exists, but any other unit does not.
Flametrooper
01-06-2007, 6:08 PM
Oh. Okay thanks.
Once again, sorry for the double posting. It once again isn't working. I will give you the MPQ because I've edited Gauss Rifle 2 and the Psi Blades I think. Just someone figure out what's wrong please. The marine, when attacked at point blank by, say, a Zealot, just looks at the enemy, and doesn't do his secondary attack.
MaxedOutBC
01-06-2007, 8:51 PM
Define "Point Blank," becuase i have no idea what that is.
Hmmm it seems to be fine to me, although it will no animate (only the rifle hit will appear) and makes no sound. I dunno... maybe you should add a "play sound" to make sure.
Similar things have happened to me before. The marine attacks and then freezes up.
I haven't checked the .DATs, but what is your guass rifle two? It seems to be a "unused" guass rifle to me. Why don't you change it to Guass Rifle (Hero)?
Hrm ill come back tommarow if i have time to look into this in more detail.
Flametrooper
01-06-2007, 9:58 PM
Point Blank is right up close, like the Zealot does. I will try the hero thing. See the thing is, the marine doesn't even attack, he just sits there while getting annihalated.
Also, I changed some of the ranges. It is an "unused" guass rifle. I will change it.
Respond soon.
Thanks,
Flametrooper
TheNomad
01-07-2007, 7:30 AM
It doesn't matter if it is unused or not... I'll check the mpq later, but make sure the min range is 0
Flametrooper
01-07-2007, 9:31 AM
The min range is 0 and even if I put the max range at 0, it still does not work. I did the trgtrangecondjmp for every number from 0 to 12.
TheNomad
01-07-2007, 2:59 PM
The max range shouldn't be 0 except if you use "useweapon" in Iscript.
SuiCidAl-KiSmEt
01-07-2007, 3:51 PM
trgtrangecondjmp 4
Range 4 is too small. I said IceCC uses exact pixel lenght. If you want to do the range of 4, it will have to be (4x16=) 64.
MaxedOutBC
01-07-2007, 7:16 PM
Are you trying to get the actual range of 12 or 6? Because Datedit uses the weapon range in the weapons.dat as 2x longer than what it really is. Nonetheless, i have provided code and attached the mpq (no dat changes, however):
# ----------------------------------------------------------------------------- #
# This is a decompile of the iscript.bin file 'data\scripts\iscript.bin'
# created on: Sun Jan 07 18:39:56 2007
# ----------------------------------------------------------------------------- #
# ----------------------------------------------------------------------------- #
# This header is used by images.dat entries:
# 239 Marine (terran\marine.grp)
.headerstart
IsId 78
Type 12
Init MarineInit
Death MarineDeath
GndAttkInit MarineGndAttkInit
AirAttkInit MarineGndAttkInit
Unused1 [NONE]
GndAttkRpt MarineGndAttkRpt
AirAttkRpt MarineGndAttkRpt
CastSpell [NONE]
GndAttkToIdle MarineGndAttkToIdle
AirAttkToIdle MarineGndAttkToIdle
Unused2 [NONE]
Walking MarineWalking
WalkingToIdle MarineWalkingToIdle
SpecialState1 [NONE]
.headerend
# ----------------------------------------------------------------------------- #
MarineInit:
imgul 240 0 0 # MarineShad (terran\tmaShad.grp)
MarineWalkingToIdle:
playfram 0x44 # frame set 4
MarineLocal04:
waitrand 63 75
randcondjmp 25 MarineLocal00
randcondjmp 128 MarineLocal03
goto MarineLocal04
MarineLocal00:
playfram 0x00 # frame set 0
wait 1
playfram 0x11 # frame set 1
wait 1
playfram 0x22 # frame set 2
randcondjmp 192 MarineLocal01
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
wait 6
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
turncwise 2
wait 3
wait 6
turnccwise 2
wait 3
turnccwise 2
wait 3
turnccwise 2
wait 3
goto MarineLocal02
MarineLocal03:
playfram 0x55 # frame set 5
wait 1
playfram 0x66 # frame set 6
wait 1
turnrand 3
wait 1
playfram 0x55 # frame set 5
wait 1
goto MarineWalkingToIdle
MarineLocal01:
wait 13
MarineLocal02:
playfram 0x11 # frame set 1
wait 1
playfram 0x00 # frame set 0
wait 1
goto MarineWalkingToIdle
MarineDeath:
playsndbtwn 276 277 # Terran\MARINE\TMaDth00.WAV, Terran\MARINE\TMaDth01.WAV
setfldirect 0
playfram 0xdd # frame set 13
wait 2
playfram 0xde # frame set 13
wait 2
playfram 0xdf # frame set 13
wait 2
playfram 0xe0 # frame set 13
wait 2
playfram 0xe1 # frame set 13
wait 2
playfram 0xe2 # frame set 13
wait 2
playfram 0xe3 # frame set 13
wait 2
playfram 0xe4 # frame set 13
wait 2
lowsprul 236 0 0 # MarineDeath (terran\tmaDeath.grp)
wait 1
end
MarineGndAttkInit:
playfram 0x00 # frame set 0
wait 1
playfram 0x11 # frame set 1
wait 1
playfram 0x22 # frame set 2
MarineGndAttkRpt:
wait 1
trgtrangecondjmp 16 MarineSecondAttk
trgtrangecondjmp 32 MarineSecondAttk
trgtrangecondjmp 48 MarineSecondAttk
trgtrangecondjmp 64 MarineSecondAttk
trgtrangecondjmp 80 MarineSecondAttk
trgtrangecondjmp 96 MarineSecondAttk
trgtrangecondjmp 112 MarineSecondAttk
trgtrangecondjmp 128 MarineSecondAttk
trgtrangecondjmp 144 MarineSecondAttk
trgtrangecondjmp 160 MarineSecondAttk
trgtrangecondjmp 176 MarineSecondAttk
trgtrangecondjmp 192 MarineSecondAttk
nobrkcodestart
playsnd 69 # Bullet\TMaFir00.wav
attackwith 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
nobrkcodeend
gotorepeatattk
ignorerest
MarineGndAttkToIdle:
playfram 0x11 # frame set 1
wait 1
playfram 0x00 # frame set 0
wait 1
goto MarineWalkingToIdle
MarineWalking:
move 4
wait 1
playfram 0x55 # frame set 5
move 4
wait 1
playfram 0x66 # frame set 6
move 4
wait 1
playfram 0x77 # frame set 7
move 4
wait 1
playfram 0x88 # frame set 8
move 4
wait 1
playfram 0x99 # frame set 9
move 4
wait 1
playfram 0xaa # frame set 10
move 4
wait 1
playfram 0xbb # frame set 11
move 4
wait 1
playfram 0xcc # frame set 12
move 4
wait 1
playfram 0x44 # frame set 4
goto MarineWalking
MarineSecondAttk:
wait 1
playsnd 69 # Bullet\TMaFir00.wav
attackwith 2
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playsnd 69 # Bullet\TMaFir00.wav
attackwith 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
playfram 0x33 # frame set 3
wait 1
playfram 0x22 # frame set 2
wait 1
gotorepeatattk
goto MarineGndAttkToIdle
There! It should work but i only tested it with a firebat, so you'll have to see the zealot still causes freezing.
I remember having this problem with an SCV doing a melee flamethrower once. I though the code was wrong or something, but then my SCV did a flamethrower against an air unit it was directly over it. It turned out i incorrectly interpreted 4 pixels = 1 unit :rolleyes:.
I'm not sure whats wrong with your script, i mean putting the wrong ranges shouldn't cause freezeup (after all, my SCV did fine). I think it could be some incorrect "goto" command. I remeber that you set it to goto idle after attacking. If you don't add a "gotorepeatattk," then weird things which i don't know about (cause i never forgot to put it ;)) will happen.
IMPORTANT:
In the code, i made the marine use its air attack rather than make it use a weapon with the "use weapon" code. So in DatEdit, change its air attack to what you want (because otherwise its secondary attack is the same as its normal ground weapon), and edit that.
Or, if you want, you can change the code from "attackwith 2" into "useweapon <ID number>"
Flametrooper
01-08-2007, 7:24 PM
Thanks a lot. I think I finally got it.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.