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:
screenshotI 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.

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:
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;
}
}
void doAPCMobileBehavior(CUnit* unit) {
if(unit->mainOrderId == OrderId::CarrierStop) {
s32 oldShields = unit->shields;
replaceUnitWithType(unit, UnitId::apc_sieged);
unit->orderToIdle();
unit->shields = oldShields;
}
}
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.
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.
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.
go to /debug/patch/ there you should find some .gdp file
my start:
http://www.staredit.net/topic/17683/
None.
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?
go to /debug/patch/ [...]
there is no such directory in the "general-plugin-template-project-master".
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.

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)//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
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_1image_2image_3
Post has been edited 6 time(s), last time on Aug 15 2020, 6:19 pm by Netbek.
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.

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:
if (unit->id == UnitId::marine && unit->orderSignal & 0x04) {
replaceUnitWithType(unit, UnitId::hydralisk);
unit->orderToIdle();
unit->orderSignal = 0;
}
Then in CMDRECV_Stop.cpp:
...
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);
...
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: