Self-switch toggle in Khas SAS 4.4 script

Hello,

I cannot figure this out myself so I need your help :|

I need to add some basic functionality to Khas' SAS IV script. Enemies are present on the map as events in this system.

I would like the enemy event self-switch B to toggle when getting hit by the player.

I'm not sure if it helps but here is my research so far:

Spoiler
Khas used self-switch A (by default) to toggle enemies' death. From what I understand it looks like this:$game_self_switches[[$game_map.map_id, @id, 'A']] = trueIf I got it right, @id is a variable that stores event's ID.

I tried entering various things around line 1468 (where I think attacks are processed) and it worked properly.

Yet when I enter

$game_self_switches[[$game_map.map_id, @id, 'B']] = trueit doesn't work  :| I'm probably doing something wrong with that @id variable, but my Ruby-fu skills are not good enough to fix this.
Due to Khas' request I cannot post his script here directly...

Here is a thread he made:

http://forums.rpgmakerweb.com/index.php?/topic/4918-sapphire-action-system-iv/

If somebody is willing to help out, I have copies of Fez and Bastion on Steam and I will give you the one you want as a 'thank you'  🤘

+ I would already like to thank Shaz for giving me advice to use self-switches! I think this is the way to go 🙂
I've moved this thread to script support. Please be sure to post your threads in the correct forum next time. Thank you.
Spoiler
I'm afraid I won't be able to do this myself...

I studied the script a bit, tried various things and configurations and the furthest I got was crashing the game when the enemy receives damage. I also tried common event

$game_temp.reserve_common_event(id) but I don't know how could I use it to change only the sprite of enemy that got hit when there is multiple enemies on the map :|

EDIT: I somehow managed to change sprite and index with:

@char.set_graphic("People3", 0)Now I need to find out how to change index while keeping the sprite graphic file the same...
This post is no longer valid, I've been doing it wrong.
(In regard toy our report) Edit your opening post instead of creating a new thread 🙂
To change just the index, while keeping the same file name, use this:


@char.set_graphic(@char.character_name, index)


where index is, obviously, the new index you want to use.
Thank you Shaz 🙂 I can confirm this works!

However you made me realize in a different thread that I'm only making things more difficult for myself modifying the script this way.

If I got this self-switch thing to work, I could then just event everything else I need and this would actually solve all my other problems with this script.

EDIT: and I got the self-switch working too 😀

This is perfect. Thank you so much Shaz!
So is this resolved then? If not, what do you still need help with?
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/self-switch-toggle-in-khas-sas-4-4-script.19843/