Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

XAS Heroes No Enemy Re-spawn

Hello everyone of HBGames, I'm working on a game using the script XAS Heroes.

I've been working on this project for some time and haven't had any troubles so far. However I've stumbled on a problem that I can't get my head around.

Basically once I've killed a certain enemy in the game I want it to stay dead, so when a player returns to the previous map he isn't faced with the same enemies again. I've notice that the script already locates the event and uses an equivalent of the "erase event" event command, if that helps.

I don't want to use the 'Script Editor' -> 'BATTLER' -> 'DEFEAT_SWITCH_IDS' because they aren't bosses and I have hundreds of them around the map. Is there a way to perhaps turn on a self switch for certain enemies in regards to the same way a defeat_switch_id works?

Something like how the Defeat Switch IDs work as in example below

DEFEAT_SWITCH_IDS = {
7=>57,
18=>116,
26=>106,
27=>114,
31=>131,
35=>135,
39=>139,
42=>144,
40=>205,
45=>202,
46=>203
}

But turning on Self Switch instead depending on the enemy as in example below...

DEFEAT_SELF_SWITCH_IDS = {
7=>A,
18=>B ,
26=>B,
27=>B,
31=>B
}

I wouldn't like this for all monsters just certain ones I add to the list (similar to how DEFEAT_SWITCH_IDS work)

If anyone has any suggestions or know of a solution that I would have over looked I would greatly appreciate it.

Your friend rpg-dutch
 
Hi, I don't have the script at hand nor am I familiar with it, however you might want to do Ctrl+F and type "game_switches" and try and find where the switch is set on or off, and paste it here. That would give us something to work with. It should be possible, there will be something like this:

# if defeat
$game_switches[DEFEAT_SWITCH_IDS[enemy_id] == true

Instead you'd want to replace with something like:

# if defeat
$game_self_switches[map_id, event_id, DEFEAT_SELF_SWITCH_IDS[enemy_id]] == true
 
Ahh, I had the exact same thoughts-- and here's the perfect solution for you (similar to como's example).

Under the "Battler" script, find "DEFEAT_SWITCH_IDS" and underneath add a new section called "DEFEAT_SELFSWITCH_IDS". Use the same format as before, except instead of the ID of the switch state the letter in quotations. (example below)
Code:
DEFEAT_SELFSWITCH_IDS = {

  1=>"A",

  2=>"C"

}

Now under "System" find "XAS_BA_ENEMY::DEFEAT_SWITCH_IDS" (it should be around line 2100, tho it depends on the version). Under the "if switch_id != nil" chunk (after "end"), add the following code:
Code:
selfswitch_id = XAS_BA_ENEMY::DEFEAT_SELFSWITCH_IDS[self.enemy_id]

if selfswitch_id != nil

  $game_self_switches[[$game_map.map_id, self.id, selfswitch_id]] = true

  $game_map.refresh

end

And that should do the trick.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top