10-31-2024, 01:07 AM 
(This post was last modified: 10-31-2024, 01:28 AM by kyonides.
 Edit Reason: Version 0.3.0
)
	
	
	KEnemyStates XP
by Kyonides
Introduction
This scriptlet simply lets you set a given state to any enemy by passing the enemy position and a state ID or name to the KEnemy.set_state method.
The Script
Code:
# * KEnemyStates XP * #
#   Scripter : Kyonides
#   v0.3.0 - 2024-10-30
# * Script Call * #
# - Set a State, Requires an Index (1 through MAX) & a State ID or Name
# KEnemy.set_state(EnemyIndex, State ID or Name)
module KEnemy
  extend self
  attr_reader :states
  def set_state(enemy_pos, id_or_name)
    id_or_name = get_state_id(id_or_name) if id_or_name.is_a?(String)
    @states[enemy_pos - 1] = id_or_name if id_or_name
  end
  def get_state_id(name)
    regex = /#{name.downcase}/i
    state = $data_states.find {|state| state.name[regex] }
    state ? state.id : nil
  end
  def clear_states
    @states = {}
  end
  clear_states
end
class Game_Temp
  alias :kyon_enemy_state_gm_tmp_init :initialize
  def initialize
    kyon_enemy_state_gm_tmp_init
    $data_states[0] ||= RPG::State.new
  end
end
class Game_Troop
  alias :kyon_enemy_state_gm_trp_setup :setup
  def setup(troop_id)
    kyon_enemy_state_gm_trp_setup(troop_id)
    KEnemy.states.each {|pos, sid| @enemies[pos].add_state(sid) }
  end
end
class Scene_Battle
  alias :kyon_enemy_state_btl_end :battle_end
  def battle_end(result)
    kyon_enemy_state_btl_end(result)
    KEnemy.clear_states
  end
endTerms & Conditions
Free for non commercial games.
Due credit is mandatory.
Mention this forum as well.
That's it!
 
	
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
	
	
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE

 
 
 KEnemyStates XP
 KEnemyStates XP
 

