Staredit Network > Forums > Modding Assistance > Topic: Need some help with scripting (probably)
Need some help with scripting (probably)
Apr 17 2011, 11:29 pm
By: colby  

Apr 17 2011, 11:29 pm colby Post #1



First off, I recently got back into playing SC after years... Remembered how much I used to like modding this game too. So I started messing with it again, got right back into the basics. Now, my actual problem... I'm trying to get the Terran Dropship to actually attack (which I know I did before). I've made changes to the .dat files for the dropship, which of course isn't all that needs to be done.

Essentially what I'm trying to do (at first) is just give dropships the same ground/air attacks as wraiths. I've been looking at the scripts for both and obviously there are some major differences. Clearly I need to add scripts for these to work. What would be the best way to accomplish this? Is it as simple as just adding some code? Also, since the dropship doesn't actually have an attack animation, will it work without one? Thoughts...



None.

Apr 17 2011, 11:40 pm Raitaki Post #2



This is a guide on how to make a new unit, including how to allow it to attack, fly and cast spells, with a list of needed programs inside. It's a little bit complicated, but if you are familiar with coding (even with some as simple as Pascal), you should be fine.

EDIT: If you want to implement new graphics, you can only add .grp sprites. Don't ask me how to make one.

Post has been edited 1 time(s), last time on Apr 18 2011, 12:40 am by Raitaki.



None.

Apr 18 2011, 12:18 am Dem0n Post #3

ᕕ( ᐛ )ᕗ

Talk to IskatuMesk about it. He's a modding god. In order to add an attack, you're going to have to edit the iscript for the unit. Do this by using IceCC. That's about as much as I can tell you; iscripts always confused the hell out of me. :P




Apr 18 2011, 2:16 am xAngelSpiritx Post #4

eternal lurker

It shouldn't be terribly difficult to add an attack to the Dropship. Since (most) air units don't animate when they fire, you won't need to change the GRP.

As far as actual attacking capabilities, simply copying and pasting the relevant code from the Wraith's iscript should be sufficient; however, even if you want to do it manually, it should be pretty simple:
(keep in mind, this is just an example, it may not actually work in-game)
Code
DropshipGndAttkInit:
    wait         1
    attackwith     1
    gotorepeatattk
    goto         DropshipWalkingToIdle

DropshipAirAttkInit:
    wait         1
    attackwith     2
    gotorepeatattk
    goto         DropshipWalkingToIdle


If you want full functionality, you'll also need to use FireGraft and add in an Attack button.



None.

Apr 18 2011, 4:13 am Derqua Post #5



And also make sure you fill out your headers correctly, if you don't your script will still crash.



None.

Apr 18 2011, 7:45 pm colby Post #6



Well, I'm not certain what exactly I'm missing here. At this point I've changed the units.dat to have the dropship have the same weapons & damage as a wraith. I've looked at the scripts for both and have modified the dropship's script. BTW, dropships already have an attack button for some reason... Odd seeing as they have no weapons, the command seems to want to work because a regular dropship will still fly right at the intended target. I guess the pilot is pointing her finger-pistol at the target, "pew, pew, pew!".

Anyway, after modding the script, the dropship still acts normally in-game. No burst lasers, no missiles, just flies towards the target until the dropship gets picked off like so much cannon fodder.

Here's what I added to the script (not including what was there already) :

Code
GndAttkInit         DropshipGndAttkInit    
AirAttkInit         DropshipAirAttkInit
GndAttkRpt         DropshipGndAttkInit
AirAttkRpt         DropshipAirAttkInit
GndAttkToIdle       DropshipWalkingToIdle
AirAttkToIdle       DropshipWalkingToIdle

DropshipGndAttkInit:
    wait               1
    attackwith         1
    gotorepeatattk    
    goto               DropshipWalkingToIdle

DropshipAirAttkInit:
    wait               1
    attackwith         2
    gotorepeatattk    
    goto               DropshipWalkingToIdle

Those are the only changes I made and they are literally straight out of the wraith script, obviously I changed "wraith" to "dropship". The one thing I changed from the wraith script is that last goto statement. Used to be, "goto wraithlocal00, which only seems to do a wait and then go back to itself.

So what am I missing here? I've done this before and I swear it feels like the answer is right in front of me (literally).



None.

Apr 18 2011, 7:51 pm Raitaki Post #7



Quote from colby
Well, I'm not certain what exactly I'm missing here. At this point I've changed the units.dat to have the dropship have the same weapons & damage as a wraith. I've looked at the scripts for both and have modified the dropship's script. BTW, dropships already have an attack button for some reason... Odd seeing as they have no weapons, the command seems to want to work because a regular dropship will still fly right at the intended target. I guess the pilot is pointing her finger-pistol at the target, "pew, pew, pew!".

Anyway, after modding the script, the dropship still acts normally in-game. No burst lasers, no missiles, just flies towards the target until the dropship gets picked off like so much cannon fodder.

Here's what I added to the script (not including what was there already) :

Code
GndAttkInit         DropshipGndAttkInit    
AirAttkInit         DropshipAirAttkInit
GndAttkRpt         DropshipGndAttkInit
AirAttkRpt         DropshipAirAttkInit
GndAttkToIdle       DropshipWalkingToIdle
AirAttkToIdle       DropshipWalkingToIdle

DropshipGndAttkInit:
    wait               1
    attackwith         1
    gotorepeatattk    
    goto               DropshipWalkingToIdle

DropshipAirAttkInit:
    wait               1
    attackwith         2
    gotorepeatattk    
    goto               DropshipWalkingToIdle

Those are the only changes I made and they are literally straight out of the wraith script, obviously I changed "wraith" to "dropship". The one thing I changed from the wraith script is that last goto statement. Used to be, "goto wraithlocal00, which only seems to do a wait and then go back to itself.

So what am I missing here? I've done this before and I swear it feels like the answer is right in front of me (literally).
From your descriptions, I believe what you actually did is turn a Wraith into a Dropship (but with the Wraith's graphics). You need to change the scripts for "Dropship", if you want the Dropship to have attacks. Additionally, you must add an attack button and attack order or only AI-controlled dropships can attack.

EDIT: More precisely, you turned the Wraith's display name to "Terran Dropship". Just that. And don't delete any scripts at all, you might end up deleting something important.



None.

Apr 18 2011, 8:08 pm colby Post #8



Let me clarify, I'm definitely working on the dropship. Haven't changed a thing on wraiths, merely using them as an example of what I would like to do with the dropship. I looked at the wraith in units.dat to see its weapons & settings, then changed the dropship to match. Then I looked at the script for wraith to see how the attacks and such were coded. Then I changed the script for the dropship as above. I didn't put the whole script, just the lines I added.

About the button... As I said, the dropship has an attack button normally, it just doesn't have any weapons. So, since there is a button there, perhaps there is simply no attack command attached to the button? I'm gonna check with FG, maybe that's my problem...



None.

Apr 18 2011, 8:29 pm colby Post #9



Checked it out in FG. The button set for the dropship looks just like the one for any other unit that can attack, except that it has the load/unload buttons unique to transports. The attack button is there, the action is there, it looks like it should work just fine... Well, back to the script. At least its not causing any crashes, yet.



None.

Apr 19 2011, 3:22 am Derqua Post #10



Make sure you change the right-click action in unit.dat under "AI Actions" tab.



None.

Apr 19 2011, 7:32 am colby Post #11



Alright, I just found something interesting. I loaded SC-BW normally, got to point of making Dropships. In-game normally, the Dropship does NOT have an attack button in its button set, which makes sense since it has no weapons, therefore no attack. However, when I load my modded version through MPQDraft and go to the exact same map and all that, the dropship HAS an attack button! Keep in mind, on the modded version I haven't done squat with FG other than look at the button set. And in FG it shows an attack button complete with the action and everything.

So, just for giggles I added a civilian into the mix since it also has no attack. I did not modify anything on the civilian and loaded the game normally, no attack button just as it should be. Next I loaded my modded version (still NO changes to civilian) and in-game it still had no attack button. When I look at the civilian in FG, it has the basic commands button set which includes an attack button with the attack action.

My theory then is this, normally SC knows that these units can't attack w/o weapons, so it doesn't give an attack button. FG doesn't seem to recognize this and shows an attack button anyway (not really a big deal, but perhaps useful to know for this example). With that in mind, I'm going to basically re-build the button set for dropships in FG and see if the "new" attack command works.

BTW, I changed the right-click action in units.dat as mentioned by Derqua. It doesn't appear to have made much difference. The cursor color changes to red over enemy units, but the dropship still can't attack.

Anywho, I'm gonna go try the button set deal with FG. Hopefully that will fix this...

If it helps anyone to help me, I can post the complete iscript for the dropship as I've changed it... Maybe I missed something?



None.

Apr 19 2011, 7:49 pm xAngelSpiritx Post #12

eternal lurker

Post the complete iscript. From what I've seen, it looks fine to me.

Did you also modify the AI actions? They should look something like this:




None.

Apr 19 2011, 10:49 pm colby Post #13



Using DatEdit I looked at the Wraith's AI tab, and it looks exactly like what Angel has posted. I went ahead and changed the Dropship's AI tab to match, saved & tested... Finally got the game to crash. Another note, before these changes the Dropship would fly right to the target. With these changes the Dropship actually stopped like it was gonna target & fire, then the dropship vanished and the game froze. But hey, at least it looked as if it was gonna try to fire finally.

I'm gonna try undoing the changes one at a time and see if I can at least figure out which one is causing the crash.

Also, I tried creating a new button set in FG for the dropship & it didn't make a bit of difference that I noticed.

TY for the help/advice thus far.



None.

Apr 19 2011, 10:54 pm colby Post #14



Here is the script, in case it helps...

Code
# This header is used by images.dat entries:
# 223 Dropship (terran\dropship.grp)
.headerstart
IsId               68
Type               12
Init               DropshipInit
Death               DropshipDeath
GndAttkInit         DropshipGndAttkInit    
AirAttkInit         DropshipAirAttkInit
Unused1             [NONE]
GndAttkRpt         DropshipGndAttkInit    
AirAttkRpt         DropshipAirAttkInit
CastSpell           [NONE]
GndAttkToIdle       DropshipWalkingToIdle
AirAttkToIdle       DropshipWalkingToIdle
Unused2             [NONE]
Walking             DropshipWalking
WalkingToIdle       DropshipWalkingToIdle
SpecialState1       [NONE]
.headerend
# ----------------------------------------------------------------------------- #

DropshipInit:
    imgul               224 0 42     # DropshipShad (terran\dropship.grp)
    playfram           0x00     # frame set 0
    goto               DropshipWalkingToIdle

DropshipWalkingToIdle:
    setvertpos         1
    waitrand           8 10
    setvertpos         2
    waitrand           8 10
    setvertpos         1
    waitrand           8 10
    setvertpos         0
    waitrand           8 10
    goto               DropshipWalkingToIdle

DropshipDeath:
    playsnd             210     # Terran\DROPSHIP\TDrDth00.wav
    imgol               332 0 0     # TerranBuildingExplosionsmall (thingy\tBangS.grp)
    wait               3
    end                

DropshipWalking:
    imgol               225 0 0     # DropshipGlow (thingy\tdrGlow.grp)
    setvertpos         0
    goto               DropshipLocal00

DropshipLocal00:
    wait               125
    goto               DropshipLocal00

DropshipGndAttkInit:
        wait            1
        attackwith      1
        gotorepeatattk    
        goto            DropshipWalkingToIdle

DropshipAirAttkInit:
        wait            1
        attackwith      2
        gotorepeatattk    
        goto            DropshipWalkingToIdle


Any suggestions?



None.

Apr 20 2011, 1:30 am xAngelSpiritx Post #15

eternal lurker

I think it's the iscript. I'm not sure exactly what it was, but I just did a quick fiddling around and got it to work perfectly*.
This is the iscript I used. Apparently I left out a wait that caused it to crash.
Code
# This header is used by images.dat entries:
# 223 Dropship (terran\dropship.grp)
.headerstart
IsId               68
Type               12
Init               DropshipInit
Death               DropshipDeath
GndAttkInit         DropshipGndAttkInit    
AirAttkInit         DropshipAirAttkInit
Unused1             [NONE]
GndAttkRpt         DropshipGndAttkInit    
AirAttkRpt         DropshipAirAttkInit
CastSpell           [NONE]
GndAttkToIdle       DropshipWalkingToIdle
AirAttkToIdle       DropshipWalkingToIdle
Unused2             [NONE]
Walking             DropshipWalking
WalkingToIdle       DropshipWalkingToIdle
SpecialState1       [NONE]
.headerend
# ----------------------------------------------------------------------------- #

DropshipInit:
   imgul               224 0 42     # DropshipShad (terran\dropship.grp)
   playfram           0x00     # frame set 0
   goto               DropshipWalkingToIdle

DropshipWalkingToIdle:
   setvertpos         1
   waitrand           8 10
   setvertpos         2
   waitrand           8 10
   setvertpos         1
   waitrand           8 10
   setvertpos         0
   waitrand           8 10
   goto               DropshipWalkingToIdle

DropshipDeath:
   playsnd             210     # Terran\DROPSHIP\TDrDth00.wav
   imgol               332 0 0     # TerranBuildingExplosionsmall (thingy\tBangS.grp)
   wait               3
   end                

DropshipWalking:
   imgol               225 0 0     # DropshipGlow (thingy\tdrGlow.grp)
   setvertpos         0
   goto               DropshipLocal00

DropshipLocal00:
   wait               125
   goto               DropshipLocal00

DropshipGndAttkInit:
       wait            1
       attackwith      1
        wait             1
       gotorepeatattk    
       goto            DropshipWalkingToIdle

DropshipAirAttkInit:
       wait            1
       attackwith      2
        wait             1
       gotorepeatattk    
       goto            DropshipWalkingToIdle


*When you right-click a ground unit you own, it won't automatically load the unit into the dropship. Having other units right-click the dropship works fine.

EDIT: I also figured out why the Attack button appeared on its own. For whatever reason, the attack button is present on the dropship's default button set; hwoever, due to the "Unit Has A Weapon" requirement, it'll only appear if you give the dropship a weapon.



None.

Apr 24 2011, 1:04 am ubermctastic Post #16



The civilian and the dropship have an attack button on firegraft because of the button lists they use.
It's interesting that the transport button set has an attack button because none of the transports have weapons.



None.

Apr 24 2011, 10:11 am colby Post #17



I had some extra drama to deal with at work the last few days. But I came back to this project and had another go at it. This time I just decided to start over and everything worked out just fine. Now have dropships that attack like wraiths...

Then I decided to take another step and made Supply Depots create Civilians with FG. Also changed the Civilian to mimic an Infested Terran attack. Actually its kinda funny to send them on suicide missions, just like the sappers from warcraft 2.

Anyways, I wanted to say thank you to everyone that offered assistance! Now, on to more elaborate projects. :D



None.

Apr 25 2011, 1:43 am Derqua Post #18



Good luck, your gonna need it.



None.

Apr 25 2011, 6:22 pm colby Post #19



Another question. Can anyone tell me how to change the wireframe that is displayed for a particular unit?

I decided to change one of the Battle Cruiser heroes into a Valkyrie hero, since the game doesn't have one. I have everything working just fine so far, it looks right, behaves right, etc. I just need to change the button set (so it no longer has the Yamato button) and change the wireframe that displays to show a Valkyrie instead of a Battle Cruiser. The button set is no problem, a few minutes with FG and that will be solved.

Changing the wire frame is the thing I'm not sure about.



None.

Apr 25 2011, 7:56 pm Dem0n Post #20

ᕕ( ᐛ )ᕗ

It's in either BroodWar.mpq or BroodDat.mpq, I think.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:02 am]
Oh_Man -- whereas just "press X to get 50 health back" is pretty mindless
[05:02 am]
Oh_Man -- because it adds anotherr level of player decision-making where u dont wanna walk too far away from the medic or u lose healing value
[05:01 am]
Oh_Man -- initially I thought it was weird why is he still using the basic pre-EUD medic healing system, but it's actually genius
[03:04 am]
Ultraviolet -- Vrael
Vrael shouted: I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
With the modern EUD editors, I don't think they're calculating nearly as many offsets as you might imagine. Still some fancy ass work that I'm sure took a ton of effort
[12:51 am]
Oh_Man -- definitely EUD
[09:35 pm]
Vrael -- I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
[09:35 pm]
Vrael -- that is insane
[09:35 pm]
Vrael -- damn is that all EUD effects?
[2024-5-04. : 10:53 pm]
Oh_Man -- https://youtu.be/MHOZptE-_-c are yall seeing this map? it's insane
[2024-5-04. : 1:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
Please log in to shout.


Members Online: jjf28, Roy