Staredit Network > Forums > Modding Assistance > Topic: Cloak unit when switching into siege mode
Cloak unit when switching into siege mode
Aug 22 2020, 7:43 am
By: Netbek  

Aug 22 2020, 7:43 am Netbek Post #1



I want to create a 'sneak mode' ability, which makes a unit cloaked but slower & unable to attack.
I figured I'd base it on siege mode instead of cloak, because I want a transition animation, and I also want to be able to give the sneaking unit a different walk animation.
I modified 'siege_transform.cpp' from the general-plugin-template-project to set/unset UnitStatus::Cloaked, UnitStatus::RequiresDetection, and UnitStatus::CloakingForFree after the unit is replaced via replaceUnitWithType().

It works, BUT only after switching back and forth one time. So the first transform does NOT cloak the unit as intended, but all following do. Another problem is that the unit becomes invisible instantly upon hitting its 'siege mode' form, but I would prefer if it became cloaked at the end of the transform anim.

Attachment: Modified 'siege_transform.cpp'

Attachments:
siege_transform.cpp
Hits: 3 Size: 7.65kb




Aug 22 2020, 11:49 am UndeadStar Post #2



Based on recent research and Arbiter cloaking code, I think you need to set the CloakingForFree status on the unit (based on observing the Arbiter effect), and give OrderId::Cloak as secondaryOrderId to the unit (because the Arbiter force surrounding units to execute the content of that order), so that the unit cloak by itself.
Logically it should work like that, unless there's something that can turn the cloaking off somewhere.

edit: whoops, thinking back on that, decloaking may not be that simple if using that method...though it may seems to work at first.

edit2: somehow, to decloak, just setting secondaryOrderId to OrderId::Decloak should work, I guess most cloaking effects are actually cleared on every frame, which is why they are renewed either by the "cloak nearby" order of the arbiter, or the secondary order of the unit cloaking by itself.

edit3: I was rereading your code, what start the invisibility is in TankMode, and what remove it is in SiegeMode, you may have it backward?

Post has been edited 3 time(s), last time on Aug 22 2020, 12:05 pm by UndeadStar.




Aug 23 2020, 9:47 pm Netbek Post #3



Thank you, it has worked! :thumbup:
I ended up changing "game_hooks.cpp" instead of "siege_transform.cpp".
Here is the code I put in "game_hooks.cpp":
Code
//Loop through all visible units in the game.
for (CUnit *unit = *firstVisibleUnit; unit; unit = unit->link.next) {
    if(unit->id == UnitId::siege_tank_s) {
        if(unit->sprite->mainGraphic->animation == IscriptAnimation::SpecialState2) {
                unit->setSecondaryOrder(OrderId::Decloak);
        }
        if(unit->sprite->mainGraphic->animation == IscriptAnimation::Init) {
            if(unit->sprite->mainGraphic->frameIndex == 5) {
                unit->status |= UnitStatus::CloakingForFree;
                unit->setSecondaryOrder(OrderId::Cloak);
            }
        }
    }
}

Here's a video showing the result. The video shows the code in the beginning. The description also contains a detailed step-by-step for future searchers:
https://www.bitchute.com/video/TbEiYzbT3wVc/
It works exactly the way I want, even with the delay before cloak when entering siege mode. The Code is based on stuff Voyager taught me here (and on what you just told me ofc).

Post has been edited 1 time(s), last time on Aug 24 2020, 12:28 pm by Netbek.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:27 am]
m.0.n.3.y -- Maybe because it's an EUD map?
[03:27 am]
m.0.n.3.y -- Can't upload maps to the DB. Error says "The action you have performed caused an Error". Any word?
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
Please log in to shout.


Members Online: jun3hong