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.

On map status effects.

1-You know how in a normal battle, there is stun? Well i was wondering if there was a script out there that can mimik that on map, so when your hit with the status: stun, you character will be paused for * seconds. *= look at two.
2-I need it so in the status database screen instead of: "After __ turns, __% chance" I need turns into seconds, so if you put in: "After 3 turns, 50% chance" that means every 3 seconds that go by on the map there is a 50% of losing that status effect.

Overall it is for XAS(ABS), http://www.atelier-rgss.com/RGSS/Battle/XAS_00a.html which means no SDK and its on map.

Thanks.
 

poccil

Sponsor

Put the script below in a new script section (before the last one in the script editor).  This effect will prevent the player from moving  (though he can still turn) for a number of seconds after any state in the STUNSTATES array (see top of the code) is inflicted on the first actor in the party.

Code:
class Game_Actor
################################
  STUNSTATES=[2,9]
################################
  if !defined?(petero_stun_Game_Actor_add_state)
    alias petero_stun_Game_Actor_add_state add_state
  end
  def add_state(state,force=false)
    if @addStateCalled
      petero_stun_Game_Actor_add_state(state,force)
      return
    end
    @addStateCalled=true
    if STUNSTATES.include?(state)
      oldhas=self.state?(state)
      petero_stun_Game_Actor_add_state(state,force)
      self.stun(state) if self.state?(state) && !oldhas
    else
      petero_stun_Game_Actor_add_state(state)
    end
    @addStateCalled=false
  end
  def stun(state)
    if !$game_temp.in_battle
      @stuntime=Graphics.frame_count
    end
    @stunstate=[] if !@stunstate
    @stunstate.push(state)
  end
  def hasAnyState?(states)
    for s in states
      return true if self.state?(s)
    end
    return false
  end
  def stunned?
    return hasAnyState?(STUNSTATES) && @stunstate && @stunstate.length>0
  end
  def stuncheck
    if stunned?
      @stuntime=Graphics.frame_count if !@stuntime
      seconds=(Graphics.frame_count-@stuntime)
      state=@stunstate[@stunstate.length-1]
      if seconds%Graphics.frame_rate==0
        seconds/=Graphics.frame_rate
        holdturn=$data_states[state].hold_turn
        holdturn=0 if !holdturn
        if seconds>=holdturn &&
           rand(100)<$data_states[state].auto_release_prob
          remove_state(state)
          @stunstate.pop
        end
      end
    end
  end
end
class Game_Player
  def stun
    @stuntime=Graphics.frame_count
  end
  if !defined?(petero_stun_Game_Player_passable?)
    alias petero_stun_Game_Player_passable? passable?
    alias petero_stun_Game_Player_update update
  end
  def passable?(*arg)
     if $game_party.actors[0].stunned?
       return false
     end
     return petero_stun_Game_Player_passable?(*arg)
  end
  def update
     if $game_party.actors[0].stunned?
       $game_party.actors[0].stuncheck
     end
     petero_stun_Game_Player_update
  end
end
 
Thanks Poccil  :thumb:, Question: is this both numbers?

BUG
Script 'Stun on Map' line 9: SystemStackError occurred.
stack level too deep.

I put another status 'weaken' on with 1% hp when your hit with it. 2 turns and 100% chance, it won't allow this status on my character.
 
Code:
class RPG::State
  # state_id => [frames, percent_chance_to_remove]
  Map_Time_Remove_State = {}
  def map_time_to_remove
    return Map_Time_Remove_State[@id]
  end
end

class Game_Battler
  attr_accessor :seph_statetimerremove
  alias_method :seph_statemaptime_gmbtlr_init, :initialize
  alias_method :seph_statemaptime_gmbtlr_as, :add_state
  def initialize
    seph_statemaptime_gmbtlr_init
    @seph_statetimerremove = {}
  end
  def add_state(state_id, force = false)
    seph_statemaptime_gmbtlr_asadd_state(state_id, force)
    if state?(state_id) && $data_states[state_id].map_time_to_remove != nil
      @seph_statetimerremove[state_id] = $data_states[state_id].map_time_to_remove
    end
  end
end

class Scene_Map
  alias_method :seph_mapstateremove_scnmap_update, :update
  def update
    seph_mapstateremove_scnmap_update
    $game_party.actors.each do |actor|
      actor.seph_statetimerremove.each do |state_id, timer|
        if actor.state?(state_id)
          if timer[0] > 0
            timer[0] -= 1
            next
          end
          if rand(100) < timer[1]
            actor.remove_state(state_id)
          else
            actor.seph_statetimerremove[state_id] = $data_states[state_id].map_time_to_remove
          end
        else
          actor.seph_statetimerremove.delete(state_id)
        end
      end
    end
  end
end

You can try that. Let me know if it doesn't work or you need help. Kinda just threw it together.
 
Script ' The name of the script' line 18: NoMethodError occured
undefined method 'seph statemaptime_gmbtlr_asadd_state' for #<Game_Actor:0x13b9870

Thats the error i got when i made an event that gives you the state mute (5 turns 100% chance)
 

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