XAS: Keeping Enemies From Fading Away (SOLVED)

Discussion in 'RGSSx Script Support' started by TheKeeper, Aug 30, 2019.

  1. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    Heyla, again!

    For reference, the original-language version of the XAS ABS scripts I'm working with can be found here: https://xasabs.wordpress.com/vx-ace/
    The English translation of the XAS ABS scripts--which is the version I'm using--can be found here: https://www.gdunlimited.net/scripts/rpg-maker-vx-ace/custom-battle-scripts/xas-abs-0-5-english

    So, thanks to this thread https://forums.rpgmakerweb.com/inde...-on-or-modification-for-xas-abs-script.89895/, I was able to figure out how to get the enemy event to trigger a self-switch on death. However, there still remains a problem: instead of immediately triggering the self-switch, the enemy event will fade away. So, for example, if I set up an enemy event to leave behind a body when it dies, instead of triggering the self-switch so it goes immediately to the graphic showing the event's death pose, the event just disappears. I have to leave the map and return, in order to see the body. So it's like there's something in the code that's temporarily erasing the event, even as it's executing the self-switch. The trouble is that I haven't figured out where, in the core script, this code happens to be. I'm thinking it might be somewhere in the following:

    Code:
     
      #--------------------------------------------------------------------------
      # ● Execute Enemy Defeaed Process
      #--------------------------------------------------------------------------         
       def execute_enemy_defeated_process
           self.battler.defeated = true
           self.through = true
           @knock_back_duration = 121
           enemy = $data_enemies[self.battler.enemy_id]
           @collapse_duration = 120
           execute_gain_exp_gold(enemy) 
           execute_active_switch(enemy)
           execute_active_selfsw(enemy) #ghostino
           execute_defeated_animation(enemy)
           execute_defeated_sound_effect(enemy)
           execute_final_shoot(enemy)
       end   
    
      #--------------------------------------------------------------------------
      # ● Execute Defeated Sound Effect
      #--------------------------------------------------------------------------             
      def execute_defeated_sound_effect(enemy)
          return if self.battler.no_damage_pop
          Sound.play_enemy_collapse   
      end 
     
      #--------------------------------------------------------------------------
      # ● Execute Final Shoot
      #--------------------------------------------------------------------------             
      def execute_final_shoot(enemy)
          enemy.note  =~ /<Final Action ID = (\d+)>/ 
          action_id = $1.to_i
          return if action_id == nil
          self.shoot(action_id)     
      end 
     
      #--------------------------------------------------------------------------
      # ● Execute Gain Exp Gold
      #--------------------------------------------------------------------------           
      def execute_gain_exp_gold(enemy) 
          exp = self.battler.exp
          case XAS_BA::EXP_TYPE
             when 0
                actor = $game_party.members[0]
                actor.gain_exp(exp)
             when 1
                for i in 0...$game_party.members.size
                   actor = $game_party.members[i]           
                   actor.gain_exp(exp)
                end   
             when 2 
                exp = exp / $game_party.members.size 
                for i in 0...$game_party.members.size
                   actor = $game_party.members[i]           
                   actor.gain_exp(exp)
                end             
          end 
          $game_party.gain_gold(self.battler.gold)
      end 
     
      #--------------------------------------------------------------------------
      # ● Execute_Active Switch
      #--------------------------------------------------------------------------           
      def execute_active_switch(enemy)       
          enemy.note  =~ /<Active Switch = (\d+)>/     
          switch_id = $1.to_i 
          if switch_id != nil
             $game_switches[switch_id] = true
             $game_map.need_refresh = true     
          end
      end
     
      #---------------------------------------------------------------------------
      # ● Execute Active Self Switch (Addon by ghostino)
      #---------------------------------------------------------------------------
      def execute_active_selfsw(enemy)
        if enemy.note =~ /<Active Self-Switch>/ 
        $game_self_switches[[@map_id, @id, 'C']] = true
        end
      end
     
      #--------------------------------------------------------------------------
      # ● Execute Defeated Animation
      #--------------------------------------------------------------------------             
      def execute_defeated_animation(enemy)
          enemy.note  =~ /<Defeated Animation = (\d+)>/     
          anime_id = $1.to_i     
          if anime_id != nil
             self.animation_id = anime_id
          end 
      end 
     
    end   
     
    But I'm not entirely sure. I'm hoping that someone who actually understands Ruby (I don't; I just kind of guess at what does what and hope that I get the results I'm looking for) can point me in the proper direction of which code to comment out to prevent the event from being erased--assuming that's what's happening, here.

    Thanks, in advance, for any light you can shed on this puzzle,
    TheKeeper
     
    #1
  2. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thought I'd give this a bump in the hopes that someone can lend a hand with this.
     
    #2
  3. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    309
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    I take it that you want bodies left behind to loot. You 'WILL' want them to vanish eventually, else the map can get filled up pretty badly.

    Speaking as one who has his own ABS, it is possible to have such a feature as mine allows for both collapse deaths and lootable body options. However, it won't be a small job, and won't be small code.

    Hopefully, someone with knowledge of the VXAce version of XAS will show as I'm an RMXP coder with some XAS 3.91 knowledge. (This code is nothing like Xax 3.91's)
     
    #3
  4. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    Yes, that's what I'm looking to do, among other things. I'm definitely hoping that someone familiar with the code can help.
     
    #4
  5. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    309
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    Sounds more like a Script Request that belongs within the RGSS3 Scripts (RMVX Ace) board instead of merely support.

    A title like "XAS ABS Lootable Body Request" might be more direct and to the point. But be thorough in your request. As I suggest, a time limit might be a good option for your game. In some big ones like Skyrim or Oblivion, some bodies may remain (NPCs that are main characters) while other bodies vanish over time (respawnable enemies).

    And I wouldn't post immediately, but consider writing down options you may need like.... do you receive a popup window with all the items snarfed, or do you get a window to take select items from the body or put others back... ;) Take your time.
     
    #5
  6. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    Well, at the moment, I'm just focused on figuring out what code is making the enemies fade away. That is what I need help with. I figure, if I really want anything fancy, after that, I can put in a request in the request forums. But, right now, I just want to figure out what's making the bodies disappear, and disable it.
     
    #6
  7. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    309
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    This is within the first method you posted. It is the collapse system that makes enemies fade out when in battle. And here, Mog made a default duration for the collapse to be 120 ... frames? I guess 2 seconds. :tongue: Wanna have fun and make the collapse set to 1? That'll make them flash out altogether.

    Mind you, that value sets how long a collapse lasts. Somewhere else is a section that USES it. Even though I don't have RPGMaker VXAce, I do have a listing of all VXAce scripts. @collapse_duration is not there, so moggy made it up.
     
    #7
  8. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    Hm. So I want to look for code that handles what happens when the enemy collapses? Basically, the keyword I'm looking for is "collapse?"
     
    #8
  9. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    309
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    Yep. In RPGMaker XP, the bulk of the collapse system was within a more-hidden RPG::Sprite class. Since RPGMaker VX, the RPG::Sprite class was renamed Sprite_Base and thrown into the visible Scripts Library. Still, that version of collapse is used for the battlers in the battlesystem. What Mog (and anyone making an ABS would do) would be to make a separate collapse system that works upon the map events and Sprite_Character graphics.
     
    #9
  10. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    All right! Let's see what I can find!
     
    #10
  11. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    So I searched for the keyword "collapse" in that particular script, and they all pointed to commands that had to do with handling special effects when the enemy or player character dies. There was nothing there that actually dealt with the enemy death, directly. I tried searching the other scripts in the XAS bundle of scripts, but I couldn't find anything there, either. Now, I'm back to feeling more than a little confused. xD I really thought I was on to something, but it fizzled out.
     
    #11
  12. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    509
    Likes Received:
    364
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    The collapsing is dealt with across multiple methods, and there's also a method in the Anti Lag add-on that erases events with dead battlers outside the screen. This add-on should help, but I've only tested it in the XAS demo, and not super extensively. If you set the battler to toggle self-switch C, then you'll need to manually turn self-switch C off in the event pages, as well as erase the event, etc.

    Code:
    =begin
    #==============================================================================#
    #   AMN XAS Add-on
    #   Version 1.01
    #   Author: AMoonlessNight
    #   Date: 25 Oct 2019
    #   Latest: 25 Oct 2019
    #==============================================================================#
    #   An add-on for X A S  - Xiderowng Action System (For Advanced Users)
    #   Created by XIDEROWNG  (XMS / XRXS / ちいさな本屋 / 森穂(もりほ) 
    #     http://xrxs.at-ninja.jp/
    #==============================================================================#
    #   UPDATE LOG
    #------------------------------------------------------------------------------#
    # 25 Oct 2019 - created the script
    #==============================================================================#
    #   TERMS OF USE
    #------------------------------------------------------------------------------#
    # - Please credit Xiderowng and follow their terms and conditions on the
    #   original script
    # - Please credit AMoonlessNight or A-Moonless-Night
    # - I'd love to see your game if you end up using one of my scripts
    #==============================================================================#
    
    This script is an add-on for the XAS Xiderowng Action System for advanced users.
    This script makes it so that you can set enemies to not disappear after they
    are defeated, as well as triggering a self-switch on the event.
    
    Use the following in the enemy's notes:
    
    
        <active self switch = X>
    where X is a letter corresponding to the event's self-switches (e.g. A, B, C, D)
    
    This will make it so that the enemy triggers self-switch X on their event
    when they are defeated.
    
     
        <do not collapse>
    
    This will make it so that the enemy does not disappear once they die.
    
    
    If you use  <do not collapse>   and   <active self switch = X>  together, you
    will need to manually turn self-switch X off in the event pages and erase the
    event (if you want them to respawn when you leave the map).
    
    
    =end
    
    #==============================================================================
    #  Please do not edit below this point unless you know what you are doing.
    #==============================================================================
    
    unless $xas
      msg = "                                      IMPORTANT:\n"
      msg += "   X A S  - Xiderowng Action System add-on by A-Moonless-Night\n"
      msg += " \n"
      msg += "This script requires X A S  - Xiderowng Action System script.\n"
      msg += "Please download it from https://xasabs.wordpress.com/vx-ace/"
      msgbox(msg)
      exit
    end
    
    class Game_Character < Game_CharacterBase
    
      # alias the original method and add in method for triggering self-switch
      alias amn_xas_gamechara_executeendefproc  execute_enemy_defeated_process
      def execute_enemy_defeated_process
        amn_xas_gamechara_executeendefproc
        execute_active_selfsw($data_enemies[self.battler.enemy_id])
      end
     
      # add new method for triggering self switch using <active self switch = X>
      def execute_active_selfsw(enemy)
        enemy.note =~ /<active[ -_]*self[ -_]*switch\s+=\s+(\w)>/i
        sw_id = $1
        unless sw_id.nil?
          $game_self_switches[[@map_id, @id, sw_id.upcase]] = true
          $game_map.need_refresh = true
        end
      end
     
      # does the enemy battler have <do not collapse> in its notes?
      def do_not_collapse?
        return false if self.battler.nil? || !self.battler.is_a?(Game_Enemy)
        return $data_enemies[self.battler.enemy_id].note =~ /<do[ -_]*not[ -_]*collapse>/i
      end
     
      # checks if Mog's Anti Lag script exists
      if $mog_rgss3_xas_anti_lag
        
        # overwrite method for erasing events with dead battlers
        def execute_effects_out_screen
          return if erased
          if self.battler != nil
            self.erase if self.battler.dead? && !do_not_collapse?
            # the event will only erase if the event's battler is dead and it does
            # NOT have <do not collapse> in the notes
          end
          if self.tool_id > 0
            self.action.duration = 1
            $game_system.tools_on_map.delete(self.tool_id)
            self.erase
          end 
        end
        
      end
     
    end
    
    class Sprite_Character < Sprite_Base 
    
      # no collapsing effects will happen if the event's battler has <do not collapse>
      # in the notes
      alias amn_xas_spritechara_cancollapseeffects  can_collapse_effects?
      def can_collapse_effects?
        return false if @character.do_not_collapse?
        amn_xas_spritechara_cancollapseeffects
      end
     
      alias amn_xas_spritechara_updatecoldur  update_collapse_duration
      def update_collapse_duration
        if @character.do_not_collapse?
          @character.collapse_duration -= 1
          @character.through = false if @character.collapse_duration <= 0
          return
        else
          amn_xas_spritechara_updatecoldur
        end
      end
     
    end
     
    #12
  13. TheKeeper

    TheKeeper Veteran Veteran

    Messages:
    69
    Likes Received:
    20
    Location:
    California
    First Language:
    English
    Primarily Uses:
    RMVXA
    OMG! Thank you, so much! It works, like a charm!
     
    #13
    A-Moonless-Night likes this.

Share This Page