Staredit Network > Forums > Modding Assistance > Topic: Siege Mode ability for 3+ unit types
Siege Mode ability for 3+ unit types
Jul 17 2020, 10:18 am
By: Netbek  

Jul 17 2020, 10:18 am Netbek Post #1



In my mod I want ~5 unit types to be able to switch between using a sword and a bow. The weapon switching should be an ability, similar to "bearform" in WC3.

Siege Mode-based abilities seem like the best option here. But how can I add more than the default 2? (=normal tank+duke)
Firegraft only let's me edit 2 fields: screenshot
I just downloaded the "general-plugin-template-project-master", but in it, I only found the files for editing zerg morph abilites so far. I don't want to use morph, because it has a progress bar that seems unavoidable.




Jul 17 2020, 1:27 pm Voyager7456 Post #2

Responsible for my own happiness? I can't even be responsible for my own breakfast

What I ended up doing in my mod was faking it using the replaceUnitWithType function and some iscripting tricks:

Code
void doAPCSiegeBehavior(CUnit* unit) {
    if(unit->mainOrderId == OrderId::CarrierStop) {
                    unit->sprite->playIscriptAnim(IscriptAnimation::LiftOff, true);
                }
                if(unit->sprite->mainGraphic->animation == IscriptAnimation::LiftOff) {
                    if(unit->sprite->mainGraphic->frameIndex == 0) {
                        s32 oldShields = unit->shields;
                        replaceUnitWithType(unit, UnitId::apc_mobile);
                        unit->orderToIdle();
                        unit->shields = oldShields;
                    }
                }
                else if(unit->orderSignal & 0x04)
                {
                    unit->orderSignal = 0;                
                }
}


Code
void doAPCMobileBehavior(CUnit* unit) {
    if(unit->mainOrderId == OrderId::CarrierStop) {
        s32 oldShields = unit->shields;
        replaceUnitWithType(unit, UnitId::apc_sieged);
        unit->orderToIdle();
        unit->shields = oldShields;
       
    }
}


Code
APCSiegedInit:
    imgul               255 0 0     # PsiDisruptorShad (neutral\tpdShad.grp)
    playsnd             319     # Terran\TANK\TTaTra01.WAV
    playfram           0
    wait               5
    playfram           1
    wait               5
    playfram           2
    wait               5
    playfram           3
    wait               5
    playfram           4
    wait               5
    playfram           5
    sigorder         4
   
APCSiegedBuilt:
    wait             1    
    goto               APCSiegedIsWorking
   
APCSiegedLiftOff:
    playsnd             319     # Terran\TANK\TTaTra01.WAV
    playfram           4
    wait               5
    playfram           3
    wait               5
    playfram           2
    wait               5
    playfram           1
    wait               5
    playfram           0
    wait               5
    goto             APCSiegedIsWorking




EDIT: If you're just looking to switch weapons without an animation, then replaceUnitWithType() by itself should be good enough.

Code
    if(unit->mainOrderId == OrderId::CarrierStop) {
        s32 oldShields = unit->shields;
        replaceUnitWithType(unit, UnitId::apc_mobile);
        unit->orderToIdle();
        unit->shields = oldShields;
}


Post has been edited 1 time(s), last time on Jul 17 2020, 1:35 pm by Voyager7456.



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Jul 19 2020, 4:05 pm Netbek Post #3



How do I compile a plugin? So far I've only worked with PythonModdingSuite + Firegraft.
I've got all these .cpp files in "general-plugin-template-project-master"... but how do I make them into a .qdp that can be integrated via Firegraft like this?

Post has been edited 5 time(s), last time on Jul 19 2020, 5:02 pm by Netbek.




Jul 19 2020, 10:19 pm Lagi Post #4



go to /debug/patch/ there you should find some .gdp file

my start:
http://www.staredit.net/topic/17683/



None.

Jul 30 2020, 6:41 pm Netbek Post #5



I have zero experience with C++ and compiling/decomiling plugins. I know other languages, so C++ is not the main problem, but the compiling.
My questions:
1) I need sth like Visual Studio in order to compile plugins, correct?
2) When compiling stuff from "general-plugin-template-project-master", what exactly do I need to compile? All? Just files I changed/added? Just the GPTP-Folder?
3) I need to compile to .gdp, correct?
4) Is there a good tutorial for plugin creation?

Quote from Lagi
go to /debug/patch/ [...]
there is no such directory in the "general-plugin-template-project-master".




Jul 31 2020, 6:31 pm UndeadStar Post #6



Even if you're using a very old version, there should be .sln or .vcproj or .vcxproj files, that you open with Visual C++ 2010, Visual Studio 2008 (for another version), or just a more recent version of Visual Studio (some changes may be needed to make old versions projects work).
If all goes well, you should be able to compile immediately after opening the project, thus creating the debug/patch folder.




Aug 14 2020, 1:27 pm Netbek Post #7



Good news! I now know how to compile plugins (thanks to your comments).
But so far I only found (& successfully changed) the zerg morph, but not siege mode... :wtfage:
Remaining questions:
  • Where do I find the siege mode code in the general-plugin-template?
  • Into which file in general-plugin-template would I have to put code blocks 1,2, and 4 that Voyager7456 showed?


--------------
In case someone who also doesn't know how to make plugins ever reads this, I will show step-by-step:
1) BASIC SC1 PLUGIN CREATION
https://www.coh2.org/file/19170/visual-studio-compile-test1.png
https://www.coh2.org/file/19171/visual-studio-compile-test2.png
https://www.coh2.org/file/19172/visual-studio-compile-test3-cut.png
https://www.coh2.org/file/19173/visual-studio-compile-test4.png
https://www.coh2.org/file/19174/visual-studio-compile-test5.png
https://www.coh2.org/file/19175/visual-studio-compile-test6.png
https://www.coh2.org/file/19176/visual-studio-compile-test7.png
2) LET ULTRALISK MORPH TO GUARDIAN
https://www.coh2.org/file/19177/visual-studio-ultralisk-test0a.png
https://www.coh2.org/file/19178/visual-studio-ultralisk-test0b.png
https://www.coh2.org/file/19182/w-firegraft-step1.png
https://www.coh2.org/file/19180/w-firegraft-step2.png
https://www.coh2.org/file/19181/w-firegraft-step3.png

edit: this image guide can also be found here




Aug 14 2020, 1:46 pm Voyager7456 Post #8

Responsible for my own happiness? I can't even be responsible for my own breakfast

In your game_hooks.cpp, you could try something similar to this:
(Yes it probably would make more sense to modify CMDRECV_CarrierStop() in CMDRECV_Stop.cpp instead but I don't think that hook existed when I was working on this mod so I don't have code on hand)

Code
//ReplaceUnitWithType helper definition
const u32 Func_ReplaceUnitWithType = 0x0049FED0;
void replaceUnitWithType(CUnit* unit, u16 newUnitId) {
    u32 newUnitId_ = newUnitId;
 __asm {
   PUSHAD
   PUSH newUnitId_
   MOV EAX, unit
   CALL Func_ReplaceUnitWithType
   POPAD
 }

};

...

bool nextFrame() {
...
        //Loop through all visible units in the game.
        for (CUnit *unit = *firstVisibleUnit; unit; unit = unit->link.next) {
           if(unit->id == UnitId::apc_sieged && unit->mainOrderId == OrderId::CarrierStop) {
               s32 oldShields = unit->shields;
               replaceUnitWithType(unit, UnitId::apc_mobile);
               unit->orderToIdle();
               unit->shields = oldShields;
          }
        }
...


Then you will need to add a button to the unit in FireGraft with the Carrier Stop order and modify the order requirements of Carrier Stop to include the new unit as well.



If you'd still like to take a look at the siege mode code, it is in siege_transform.cpp



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Aug 15 2020, 8:57 am Netbek Post #9



ISSUE 1
I now have a newer "plugin-template-project" that actually contains "siege_transform.cpp", but compiling it in Visual 2019 gives an Error:
IMAGE
Does sb know what causes this? I also found a visual 2008 version of it (also contains "siege_transform.cpp"), will try it later.


^^EDIT: I can now modify "siege_transform.cpp". I have successfully made a Hydralisk that can turn into a Lurker (and back) with siege mode. I had to give them the siege tank turrets (Hydra=Normal turret; lurker=siege mode turret), but that is not a problem, I can make those invisible later.
My Problem is: The Lurker can't move. When I order it to move, the turret on top turns a tiny bit, and game crashes. It's probablly an iscript thing, because it's that typcial error. Then again, in a quick test, I was not able to make the default siege tank in siege mode able to move...

ISSUE 2
@Voyager7456
I tried your code. I used the 1st block from post #2 because I want a transition animation. It works, BUT when the ability is used while the unit is moving, it just stops & nothing happens. Here's the code & firegraft settings:
image_1
image_2
image_3

Post has been edited 6 time(s), last time on Aug 15 2020, 6:19 pm by Netbek.




Aug 19 2020, 6:42 am UndeadStar Post #10



Quote from Netbek
I now have a newer "plugin-template-project" that actually contains "siege_transform.cpp", but compiling it in Visual 2019 gives an Error:
IMAGE
Does sb know what causes this?
Thanks for reporting, look like an update bugged, will fix it quickly and edit this post when it's done.

edit: should work now, damn copy-paste that sometimes go weird on me.




Aug 20 2020, 12:37 am Voyager7456 Post #11

Responsible for my own happiness? I can't even be responsible for my own breakfast

Let's try this...

Change the game_hooks.cpp part as follows:

Code
            if (unit->id == UnitId::marine && unit->orderSignal & 0x04) {
                replaceUnitWithType(unit, UnitId::hydralisk);
                unit->orderToIdle();
                unit->orderSignal = 0;
            }


Then in CMDRECV_Stop.cpp:

Code
...
        else
        if(     current_unit->id == UnitId::ProtossDarkArchon &&
            current_unit->mainOrderId == OrderId::CompletingArchonSummon
        )
            *u32_0066FF60 = 0x08;
        else
        if (current_unit->id == UnitId::marine)
            current_unit->sprite->playIscriptAnim(IscriptAnimation::SpecialState1, true);
...




all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Aug 20 2020, 1:38 pm Netbek Post #12



The issue has been resolved. I modified siege_transform.ccp and CMDRECV_SiegeTank.ccp from the "general-plugin-template-project-master". I used the general-plugin-template-project version for visual Studio 2008.

I documented my steps with screenshots. I will attach them for future searchers. It is a very detailed step-by-step, the only pre-knowledge required is the basics from Pr0nogos broodwar modding tutorials.

Attachments:




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
[2024-4-17. : 1:08 am]
O)FaRTy1billion[MM] -- i'll trade you mineral counts
[2024-4-16. : 5:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[2024-4-16. : 4:31 pm]
Zoan -- where's the option to delete my account
[2024-4-16. : 4:30 pm]
Zoan -- goodbye forever
Please log in to shout.


Members Online: Ultraviolet