| | Systême de combat : Bodypart Attack | |
| | Auteur | Message |
---|
mikami Admin
Messages : 25 Date d'inscription : 12/12/2007
| Sujet: Systême de combat : Bodypart Attack Mer 12 Déc - 21:04 | |
| script 1, 1ere partie #=============================================================================== # ■ RMXP Bodypart Attack #------------------------------------------------------------------------------- # Auteur : Åvygeil #------------------------------------------------------------------------------- # Ce script permet de diviser le corps des combattants en 6 parties # (tête, torse, bras droit, bras gauche, jambe droite, jambe gauche) qui ont # leurs points de vie propres. # Les attaques simples n'attaquent donc qu'une partie du corps d'un combattant, # alors que les attaques globales attaquent toutes les parties du corps de tous # les combattants. # Un combattant meurt si toutes ses parties sont mortes. #------------------------------------------------------------------------------- # Utilisation : # # - Placer ce script juste au dessus du script main. # # - Mettre la constante BODYPART_ATTACK_INSTALL = false # à true. # # - Dans le répertoire de base de votre jeu, créer un nouveau répertoire # "Bodyparts Data" où l'on placera les fichiers txt servant à la création # des fichiers rxdata contenant les points de vie des différentes parties du # corps des combattants. # # - Pour chaque combattant, créer dans le répertoire "Bodyparts Data" # un fichier txt du même nom que le fichier du battler, sous la forme # Tete : hp_pourcent # Torse : hp_pourcent # Bras droit : hp_pourcent # Bras gauche : hp_pourcent # Jambe droite : hp_pourcent # Jambe gauche : hp_pourcent # Chaque membre aura ses hp fixés au pourcentage par rapport # aux hp du combattant. # Si un membre est inexistant, mettre hp_rate à 0. # # - Générer les fichiers rxdata à partir des fichiers txt # en mettant la constante GENERE_BODYPARTS_DATA = false # à true, et en lançant le jeu. # Une fois les fichiers générés, on peut supprimer les fichiers txt # et remettre GENERE_BODYPARTS_DATA à false. # # - ATTENTION ! Ce script redéfinit un bon nombre de méthodes et peut donc # provoquer des incompatibilités avec d'autres scripts de combat ! #===============================================================================
# Ce systême de combat n'est mis en place que si # BODYPART_ATTACK_INSTALL est égal à true if BODYPART_ATTACK_INSTALL
#=============================================================================== # ● Bodypart #------------------------------------------------------------------------------- # Cette classe sert à modéliser une partie du corps. # Elle dérive de Game_Battler pour bénéficier des méthodes # de changement de hp, de test de mort, de status etc... #=============================================================================== class Bodypart < Game_Battler attr_reader :battler attr_reader :hp_rate # Méthode d'initialisation de la partie du corps. # battler : combattant à qui appartient la partie # hp_rate : pourcentage de hp par rapport aux hp du battler def initialize(battler, hp_rate) super() @battler = battler @hp_rate = hp_rate @hp = @battler.hp * @hp_rate / 100 @hidden = true if @hp == 0 end # Cette méthode sert à donner l'index de la partie # dans le tableau bodyparts du battler. def index return @battler.bodyparts.index(self) end def base_maxhp return @battler.base_maxhp * @hp_rate / 100 end # Les méthodes qui suivent ont été redéfinies # pour retourner des valeurs spécifiques non pas à la partie du corps # mais au combattant comme la force, l'agilité etc... def maxsp return @battler.maxsp end def str return @battler.str end def dex return @battler.dex end def agi return @battler.agi end def int return @battler.int end def pdef return @battler.pdef end def mdef return @battler.mdef end def eva return @battler.eva end def state_guard?(i) return @battler.state_guard?(i) end def state_ranks return @battler.state_ranks end def element_rate(i) return @battler.element_rate(i) end # Effet d'une attaque normale. def attack_effect(attacker) self.critical = false hit_result = (rand(100) < attacker.hit) if hit_result == true atk = [attacker.atk - self.pdef / 2, 0].max self.damage = atk * (20 + attacker.str) / 20 self.damage *= elements_correct(attacker.element_set) self.damage /= 100 if self.damage > 0 if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end if @battler.guarding? self.damage /= 2 end end if self.damage.abs > 0 amp = [self.damage.abs * 15 / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end eva = 8 * self.agi / attacker.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) end if hit_result == true @battler.remove_states_shock @battler.damage = 0 self.damage = [self.damage, self.hp].min self.hp -= self.damage @battler.state_changed = false @battler.states_plus(attacker.plus_state_set) @battler.states_minus(attacker.minus_state_set) else self.damage = "Miss" self.critical = false end return true end # Effet d'une technique. def skill_effect(user, skill) self.critical = false if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1) return false end effective = false effective |= skill.common_event_id > 0 hit = skill.hit if skill.atk_f > 0 hit *= user.hit / 100 end hit_result = (rand(100) < hit) effective |= hit < 100 if hit_result == true power = skill.power + user.atk * skill.atk_f / 100 if power > 0 power -= self.pdef * skill.pdef_f / 200 power -= self.mdef * skill.mdef_f / 200 power = [power, 0].max end rate = 20 rate += (user.str * skill.str_f / 100) rate += (user.dex * skill.dex_f / 100) rate += (user.agi * skill.agi_f / 100) rate += (user.int * skill.int_f / 100) self.damage = power * rate / 20 self.damage *= elements_correct(skill.element_set) self.damage /= 100 if self.damage > 0 if @battler.guarding? self.damage /= 2 end end if skill.variance > 0 and self.damage.abs > 0 amp = [self.damage.abs * skill.variance / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end eva = 8 * self.agi / user.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100 hit = @battler.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) effective |= hit < 100 end if hit_result == true if skill.power != 0 and skill.atk_f > 0 @battler.remove_states_shock effective = true end last_hp = self.hp @battler.damage = 0 self.damage = [self.damage, self.hp].min self.hp -= self.damage effective |= self.hp != last_hp @battler.state_changed = false effective |= @battler.states_plus(skill.plus_state_set) effective |= @battler.states_minus(skill.minus_state_set) if skill.power == 0 self.damage = "" unless @battler.state_changed self.damage = "Miss" end end else self.damage = "Miss" end unless $game_temp.in_battle self.damage = nil end return effective end # Effet d'un objet. def item_effect(item) self.critical = false if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or ((item.scope == 5 or item.scope == 6) and self.hp >= 1) return false end effective = false effective |= item.common_event_id > 0 hit_result = (rand(100) < item.hit) effective |= item.hit < 100 if hit_result == true recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp if recover_hp < 0 recover_hp += self.pdef * item.pdef_f / 20 recover_hp += self.mdef * item.mdef_f / 20 recover_hp = [recover_hp, 0].min end recover_hp *= elements_correct(item.element_set) recover_hp /= 100 recover_sp *= elements_correct(item.element_set) recover_sp /= 100 if item.variance > 0 and recover_hp.abs > 0 amp = [recover_hp.abs * item.variance / 100, 1].max recover_hp += rand(amp+1) + rand(amp+1) - amp end if item.variance > 0 and recover_sp.abs > 0 amp = [recover_sp.abs * item.variance / 100, 1].max recover_sp += rand(amp+1) + rand(amp+1) - amp end if recover_hp < 0 if @battler.guarding? recover_hp /= 2 end end @battler.damage = 0 self.damage = [-recover_hp, self.hp].min last_hp = self.hp last_sp = self.sp self.hp += recover_hp @battler.sp += recover_sp effective |= self.hp != last_hp effective |= self.sp != last_sp @battler.state_changed = false effective |= @battler.states_plus(item.plus_state_set) effective |= @battler.states_minus(item.minus_state_set) if item.parameter_type > 0 and item.parameter_points != 0 case item.parameter_type when 1 @maxhp_plus += item.parameter_points when 2 @battler.maxsp_plus += item.parameter_points when 3 @battler.str_plus += item.parameter_points when 4 @battler.dex_plus += item.parameter_points when 5 @battler.agi_plus += item.parameter_points when 6 @battler.int_plus += item.parameter_points end effective = true end if item.recover_hp_rate == 0 and item.recover_hp == 0 self.damage = "" if item.recover_sp_rate == 0 and item.recover_sp == 0 and (item.parameter_type == 0 or item.parameter_points == 0) unless @battler.state_changed self.damage = "Miss" end end end else self.damage = "Miss" end unless $game_temp.in_battle self.damage = nil end return effective end # Méthode de gain de hp. def hp=(hp) @hp = [[hp, maxhp].min, 0].max end # Méthode de régénération totale de la partie du corps. def recover_all @hp = maxhp end # Effet du poison def slip_damage_effect self.damage = self.maxhp / 10 if self.damage.abs > 0 amp = [self.damage.abs * 15 / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end @battler.damage = 0 self.hp -= self.damage return true end end #=============================================================================== # ● Game_Battler #------------------------------------------------------------------------------- # On ajoute à la classe Game_Battler des méthodes de sélection des parties # du corps et une méthode pour savoir si l'une des parties est à 0 hp. # On redéfinit également les méthodes de changement de hp, et la méthode exist? #=============================================================================== class Game_Battler attr_accessor :state_changed # Existe si non caché et non mort. def exist? return (not @hidden and not dead?) end # Méthode qui renvoie un tableau avec les parties du corps. def bodyparts return [tete, torse, bras_droit, bras_gauche, jambe_droite, jambe_gauche] end # Méthode qui renvoie la somme des hp de toutes les parties du corps. def total_hp total = 0 for bodypart in bodyparts total += bodypart.hp end return total end # Méthode qui renvoie la somme des hp maximum de toutes les parties du corps. def total_maxhp total = 0 for bodypart in bodyparts total += bodypart.maxhp end return total end # Méthode qui renvoie au hasard une partie du corps. def random_target_bodypart(hp0 = false) roulette = [] for bodypart in bodyparts if (not hp0 and bodypart.exist?) or (hp0 and bodypart.hp0?) roulette.push(bodypart) end end if roulette.size == 0 return nil end return roulette[rand(roulette.size)] end
# Méthode qui renvoie au hasard une partie du corps à 0 hp. def random_target_bodypart_hp0 return random_target_bodypart(true) end
# Méthode qui renvoie une partie du corps selon son index. def smooth_target_bodypart(bodypart_index) bodypart = bodyparts[bodypart_index] if bodypart != nil and bodypart.exist? return bodypart end for bodypart in bodyparts if bodypart.exist? return bodypart end end end # Méthode qui retourne si l'une des parties est à O hp. def bodypart_hp0? return (not @hidden and (tete.hp0? or torse.hp0? or bras_droit.hp0? or bras_gauche.hp0? or jambe_droite.hp0? or jambe_gauche.hp0?)) end # Les hp gagnés sont réparties entre les différentes parties du corps. def hp=(hp) for bodypart in bodyparts bodypart.hp = hp * bodypart.hp_rate / 100 end for i in 1...$data_states.size if $data_states[i].zero_hp if self.dead? add_state(i) else remove_state(i) end end end end # Méthode de régénération complète. def recover_all for bodypart in bodyparts bodypart.recover_all end @sp = maxsp for i in @states.clone remove_state(i) end end # Effet du poison pour chaque partie. def slip_damage_effect for bodypart in bodyparts bodypart.slip_damage_effect if bodypart.exist? end return true end end | |
| | | mikami Admin
Messages : 25 Date d'inscription : 12/12/2007
| Sujet: Re: Systême de combat : Bodypart Attack Mer 12 Déc - 21:05 | |
| script 1, 2eme partie #=============================================================================== # ● Game_Actor et Game_Enemy #------------------------------------------------------------------------------- # On redéfinit dans ces 2 classes les méthodes initialize et dead? # Elles n'ont pas été redéfinies dans Game_Battler car Bodypart dérive # de Game_Battler. #===============================================================================
class Game_Actor < Game_Battler attr_reader :tete attr_reader :torse attr_reader :bras_droit attr_reader :bras_gauche attr_reader :jambe_droite attr_reader :jambe_gauche alias bpatk_initialize initialize def initialize(actor_id) bpatk_initialize(actor_id) fichier_rxdata = File.new("Bodyparts Data/"+battler_name+".rxdata", 'rb') bodyparts_data = Marshal.load(fichier_rxdata) fichier_rxdata.close @tete = Bodypart.new(self, bodyparts_data[0]) @torse = Bodypart.new(self, bodyparts_data[1]) @bras_droit = Bodypart.new(self, bodyparts_data[2]) @bras_gauche = Bodypart.new(self, bodyparts_data[3]) @jambe_droite = Bodypart.new(self, bodyparts_data[4]) @jambe_gauche = Bodypart.new(self, bodyparts_data[5]) end # Mort si toutes les parties du corps sont mortes. def dead? return (tete.dead? and torse.dead? and bras_droit.dead? and bras_gauche.dead?and jambe_droite.dead? and jambe_gauche.dead? and not @immortal) end end
class Game_Enemy < Game_Battler attr_reader :tete attr_reader :torse attr_reader :bras_droit attr_reader :bras_gauche attr_reader :jambe_droite attr_reader :jambe_gauche alias bpatk_initialize initialize def initialize(troop_id, member_index) bpatk_initialize(troop_id, member_index) fichier_rxdata = File.new("Bodyparts Data/"+battler_name+".rxdata", 'rb') bodyparts_data = Marshal.load(fichier_rxdata) fichier_rxdata.close @tete = Bodypart.new(self, bodyparts_data[0]) @torse = Bodypart.new(self, bodyparts_data[1]) @bras_droit = Bodypart.new(self, bodyparts_data[2]) @bras_gauche = Bodypart.new(self, bodyparts_data[3]) @jambe_droite = Bodypart.new(self, bodyparts_data[4]) @jambe_gauche = Bodypart.new(self, bodyparts_data[5]) end # Mort si toutes les parties du corps sont mortes. def dead? return (tete.dead? and torse.dead? and bras_droit.dead? and bras_gauche.dead?and jambe_droite.dead? and jambe_gauche.dead? and not @immortal) end # Existe si non caché et non mort. def exist? return (not @hidden and not dead?) end end
#=============================================================================== # ● Game_BattleAction #------------------------------------------------------------------------------- # On ajoute à Game_BattleAction un nouvel attribut bodypart_index # servant à déterminer la partie du corps visée. # On redéfinit également les méthodes de détermination de la cible # pour que l'action de combat cible des parties du corps. #=============================================================================== class Game_BattleAction attr_accessor :bodypart_index alias bpatk_clear clear def clear bpatk_clear @bodypart_index = -1 end # Méthode qui détermine au hasard une cible pour une action d'un acteur. def decide_random_target_for_actor battler = nil bodypart = nil if for_one_friend_hp0? battler = $game_party.random_target_actor_hp0 bodypart = battler.random_target_bodypart_hp0 if battler != nil elsif for_one_friend? battler = $game_party.random_target_actor bodypart = battler.random_target_bodypart if battler != nil else battler = $game_troop.random_target_enemy bodypart = battler.random_target_bodypart if battler != nil end if battler != nil and bodypart != nil @target_index = battler.index @bodypart_index = bodypart.index else clear end end
# Méthode qui détermine au hasard une cible pour une action d'un ennemi. def decide_random_target_for_enemy battler = nil bodypart = nil if for_one_friend_hp0? battler = $game_troop.random_target_enemy_hp0 bodypart = battler.random_target_bodypart_hp0 if battler != nil elsif for_one_friend? battler = $game_troop.random_target_enemy bodypart = battler.random_target_bodypart if battler != nil else battler = $game_party.random_target_actor bodypart = battler.random_target_bodypart if battler != nil end if battler != nil and bodypart != nil @target_index = battler.index @bodypart_index = bodypart.index else clear end end # Méthode qui renvoie la dernière cible pour un acteur. def decide_last_target_for_actor battler = nil bodypart = nil if @target_index == -1 or @bodypart_index == -1 battler = nil elsif for_one_friend? battler = $game_party.actors[@target_index] bodypart = battler.bodyparts[@bodypart_index] if battler != nil else battler = $game_troop.enemies[@target_index] bodypart = battler.bodyparts[@bodypart_index] if battler != nil end if battler == nil or bodypart == nil or not battler.exist? or not bodypart.exist? clear end end # Méthode qui renvoie la dernière cible pour un ennemi. def decide_last_target_for_enemy battler = nil bodypart = nil if @target_index == -1 or @bodypart_index == -1 battler = nil elsif for_one_friend? battler = $game_troop.enemies[@target_index] bodypart = battler.bodyparts[@bodypart_index] if battler != nil else battler = $game_party.actors[@target_index] bodypart = battler.bodyparts[@bodypart_index] if battler != nil end if battler == nil or bodypart == nil or not battler.exist? or not bodypart.exist? clear end end end
#=============================================================================== # ● Game_Party et Game_Troop #------------------------------------------------------------------------------- # On redéfinit dans Game_Party et Game_Troop les méthodes random_target_actor # et random_target_enemy pour qu'elles renvoient non pas un combattant avec 0 hp # mais avec une partie à 0 hp. # On redéfinit également dans Game_Party la méthode all_dead? pour qu'elle # corresponde mieux au systême. #===============================================================================
class Game_Party # Méthode de ciblage aléatoire d'un acteur. def random_target_actor(hp0 = false) roulette = [] for actor in @actors if (not hp0 and actor.exist?) or (hp0 and actor.bodypart_hp0?) position = $data_classes[actor.class_id].position n = 4 - position n.times do roulette.push(actor) end end end if roulette.size == 0 return nil end return roulette[rand(roulette.size)] end # Méthode qui vérifie si tout le monde est mort. def all_dead? if $game_party.actors.size == 0 return false end for actor in @actors if not actor.dead? return false end end return true end end
class Game_Troop
# Méthode de ciblage aléatoire d'un ennemi. def random_target_enemy(hp0 = false) roulette = [] for enemy in @enemies if (not hp0 and enemy.exist?) or (hp0 and enemy.bodypart_hp0?) roulette.push(enemy) end end if roulette.size == 0 return nil end return roulette[rand(roulette.size)] end end
#=============================================================================== # ● Scene_Battle #------------------------------------------------------------------------------- # On redéfinit dans Scene_Battle les méthodes qui assurent le # ciblage définitif pour qu'ils ciblent des parties du corps. #=============================================================================== class Scene_Battle def make_basic_action_result if @active_battler.current_action.basic == 0 @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy target = target.random_target_bodypart if target != nil elsif @active_battler.restriction == 2 target = $game_party.random_target_actor target = target.random_target_bodypart if target != nil else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) index = @active_battler.current_action.bodypart_index target = target.smooth_target_bodypart(index) end end if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor target = target.random_target_bodypart if target != nil elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy target = target.random_target_bodypart if target != nil else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) index = @active_battler.current_action.bodypart_index target = target.smooth_target_bodypart(index) end end @target_battlers = [target] for target in @target_battlers target.attack_effect(@active_battler) end return end if @active_battler.current_action.basic == 1 @help_window.set_text($data_system.words.guard, 1) return end if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 @help_window.set_text("Escape", 1) @active_battler.escape return end if @active_battler.current_action.basic == 3 $game_temp.forcing_battler = nil @phase4_step = 1 return end end def set_target_battlers(scope) if @active_battler.is_a?(Game_Enemy) case scope when 1 index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) index = @active_battler.current_action.bodypart_index @target_battlers.push(target.smooth_target_bodypart(index)) when 2 for actor in $game_party.actors if actor.exist? for bodypart in actor.bodyparts @target_battlers.push(bodypart) if bodypart.exist? end end end when 3 index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) index = @active_battler.current_action.bodypart_index @target_battlers.push(target.smooth_target_bodypart(index)) when 4 for enemy in $game_troop.enemies if enemy.exist? for bodypart in enemy.bodyparts @target_battlers.push(bodypart) if bodypart.exist? end end end when 5 index = @active_battler.current_action.target_index enemy = $game_troop.enemies[index] index = @active_battler.current_action.bodypart_index bodypart = enemy.bodyparts[index] if bodypart != nil and bodypart.hp0? @target_battlers.push(bodypart) end when 6 for enemy in $game_troop.enemies for bodypart in enemy.bodyparts @target_battlers.push(bodypart) if bodypart != nil and bodypart.hp0? end end when 7 index = @active_battler.current_action.bodypart_index @target_battlers.push(@active_battler.smooth_target_bodypart(index)) end end if @active_battler.is_a?(Game_Actor) case scope when 1 index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) index = @active_battler.current_action.bodypart_index @target_battlers.push(target.smooth_target_bodypart(index)) when 2 for enemy in $game_troop.enemies if enemy.exist? for bodypart in enemy.bodyparts @target_battlers.push(bodypart) if bodypart.exist? end end end when 3 index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) index = @active_battler.current_action.bodypart_index @target_battlers.push(target.smooth_target_bodypart(index)) when 4 for actor in $game_party.actors if actor.exist? for bodypart in actor.bodyparts @target_battlers.push(bodypart) if bodypart.exist? end end end when 5 index = @active_battler.current_action.target_index actor = $game_party.actors[index] index = @active_battler.current_action.bodypart_index bodypart = enemy.bodyparts[index] if bodypart != nil and bodypart.hp0? @target_battlers.push(bodypart) end when 6 for actor in $game_party.actors for bodypart in actor.bodyparts @target_battlers.push(bodypart) if bodypart != nil and bodypart.hp0? end end when 7 index = @active_battler.current_action.bodypart_index @target_battlers.push(@active_battler.smooth_target_bodypart(index)) end end end end
#=============================================================================== # ● Scene_Title #------------------------------------------------------------------------------- # On définit dans la classe Scene_Title une nouvelle # méthode genere_bodyparts_data qui génère les fichiers rxdata # contenant les hp des parties du corps des ennemis. # Cette méthode ne s'execute que si GENERE_BODYPARTS_DATA est égal à true. #===============================================================================
class Scene_Title def genere_bodyparts_data Dir.foreach("Bodyparts Data") do |nom_fichier| if nom_fichier.include?(".txt") fichier_txt = File.open("Bodyparts Data/"+nom_fichier, 'r') bodyparts_data = [] bodyparts_data.push(fichier_txt.readline.delete('Tete : ').to_i) bodyparts_data.push(fichier_txt.readline.delete('Torse : ').to_i) bodyparts_data.push(fichier_txt.readline.delete('Bras droit : ').to_i) bodyparts_data.push(fichier_txt.readline.delete('Bras gauche : ').to_i) bodyparts_data.push(fichier_txt.readline.delete('Jambe droite : ').to_i) bodyparts_data.push(fichier_txt.readline.delete('Jambe gauche : ').to_i) fichier_txt.close fichier_rxdata = File.open("Bodyparts Data/"+nom_fichier.chomp(".txt")+".rxdata", 'wb') Marshal.dump(bodyparts_data, fichier_rxdata) fichier_rxdata.close end end end alias bpatk_main main def main genere_bodyparts_data if GENERE_BODYPARTS_DATA == true bpatk_main end end
end | |
| | | mikami Admin
Messages : 25 Date d'inscription : 12/12/2007
| Sujet: Re: Systême de combat : Bodypart Attack Mer 12 Déc - 21:08 | |
| script 2 : #=============================================================================== # ■ Battle System Exemple #------------------------------------------------------------------------------- # Auteur : Åvygeil #===============================================================================
#=============================================================================== # ● Window_Bodypart_Select #------------------------------------------------------------------------------- # Un composant graphique utilisé dans la nouvelle Scene_Battle qui permet # de cibler un partie du corps précise. #===============================================================================
if BODYPART_ATTACK_INSTALL class Window_Bodypart_Select < Window_Command # Méthode d'initialisation de la fenêtre # enemy : l'ennemi ciblé def initialize(battler) super(160, ["Tete", "Torse", "Bras droit", "Bras gauche", "Jambe droite", "Jambe gauche"]) # On désactive la sélection des parties mortes ou inexistantes. disable_item(0) if battler.tete.dead? disable_item(1) if battler.torse.dead? disable_item(2) if battler.bras_droit.dead? disable_item(3) if battler.bras_gauche.dead? disable_item(4) if battler.jambe_droite.dead? disable_item(5) if battler.jambe_gauche.dead? end end
class Scene_Battle # La méthode update_phase3 gère à présent l'étape # de sélection de partie du corps. def update_phase3 if @enemy_arrow != nil update_phase3_enemy_select elsif @bodypart_select_window != nil update_phase3_bodypart_select elsif @actor_arrow != nil update_phase3_actor_select elsif @skill_window != nil update_phase3_skill_select elsif @item_window != nil update_phase3_item_select elsif @actor_command_window != nil update_phase3_basic_command end end def update_phase3_basic_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) phase3_prior_actor return end if Input.trigger?(Input::C) case @actor_command_window.index when 0 $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 start_enemy_select when 1 $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 1 start_skill_select when 2 $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 phase3_next_actor when 3 $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 2 start_item_select end return end end # La sélection de l'ennemi est à présent suivie # de l'étape de sélection de la partie du corps def update_phase3_enemy_select @enemy_arrow.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) end_enemy_select return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @active_battler.current_action.target_index = @enemy_arrow.index end_enemy_select if @skill_window != nil end_skill_select end if @item_window != nil end_item_select end start_bodypart_select end end # La sélection de l'acteur est à présent suivie # de l'étape de sélection de la partie du corps def update_phase3_actor_select @actor_arrow.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) end_actor_select return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @active_battler.current_action.target_index = @actor_arrow.index end_actor_select if @skill_window != nil end_skill_select end if @item_window != nil end_item_select end start_bodypart_select end end # Les 3 méthodes qui suivent gère l'étape de # sélection de la partie du corps. def update_phase3_bodypart_select @bodypart_select_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) end_bodypart_select return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @active_battler.current_action.bodypart_index = @bodypart_select_window.index end_bodypart_select if @skill_window != nil end_skill_select end if @item_window != nil end_item_select end phase3_next_actor end end
def start_bodypart_select @actor_command_window.active = false @actor_command_window.visible = false current_action = @active_battler.current_action if current_action.for_one_friend? or current_action.for_one_friend_hp0? battler = $game_party.actors[current_action.target_index] else battler = $game_troop.enemies[current_action.target_index] end @bodypart_select_window = Window_Bodypart_Select.new(battler) @bodypart_select_window.back_opacity = 160 @bodypart_select_window.active = false @bodypart_select_window.visible = false @bodypart_select_window.y = 96 @bodypart_select_window.x = @actor_index * 160 @bodypart_select_window.active = true @bodypart_select_window.visible = true end def end_bodypart_select @bodypart_select_window.dispose @bodypart_select_window = nil if @actor_command_window.index == 0 @actor_command_window.active = true @actor_command_window.visible = true @help_window.visible = false end end # Les 2 méthodes suivantes règlent la gestions # des animations d'attaque. def update_phase4_step4 for target in @target_battlers target.battler.animation_id = @animation2_id target.battler.animation_hit = (target.damage != "Raté") end @wait_count = 8 @phase4_step = 5 end def update_phase4_step5 @help_window.visible = false @status_window.refresh for target in @target_battlers if target.damage != nil target.battler.damage_pop = true end end @phase4_step = 6 end
end
end | |
| | | mikami Admin
Messages : 25 Date d'inscription : 12/12/2007
| Sujet: Re: Systême de combat : Bodypart Attack Mer 12 Déc - 21:08 | |
| script 3, 1ere partie if BODYPART_ATTACK_INSTALL
module RPG class Sprite < ::Sprite @@_animations = [] @@_reference_count = {} def initialize(viewport = nil) super(viewport) @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0 @_collapse_duration = 0 @_damage_duration = 0 @_animation_duration = 0 @_blink = false end def dispose dispose_damage dispose_animation dispose_loop_animation super end def whiten self.blend_type = 0 self.color.set(255, 255, 255, 128) self.opacity = 255 @_whiten_duration = 16 @_appear_duration = 0 @_escape_duration = 0 @_collapse_duration = 0 end def appear self.blend_type = 0 self.color.set(0, 0, 0, 0) self.opacity = 0 @_appear_duration = 16 @_whiten_duration = 0 @_escape_duration = 0 @_collapse_duration = 0 end def escape self.blend_type = 0 self.color.set(0, 0, 0, 0) self.opacity = 255 @_escape_duration = 32 @_whiten_duration = 0 @_appear_duration = 0 @_collapse_duration = 0 end def collapse self.blend_type = 1 self.color.set(255, 64, 64, 255) self.opacity = 255 @_collapse_duration = 48 @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0 end def damage(battler) dispose_damage value = battler.tete.damage critical = battler.tete.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_tete_damage_sprite = ::Sprite.new(self.viewport) @_tete_damage_sprite.bitmap = bitmap @_tete_damage_sprite.ox = 80 @_tete_damage_sprite.oy = 90 @_tete_damage_sprite.x = self.x @_tete_damage_sprite.y = self.y - self.oy / 2 @_tete_damage_sprite.z = 3000 value = battler.torse.damage critical = battler.torse.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_torse_damage_sprite = ::Sprite.new(self.viewport) @_torse_damage_sprite.bitmap = bitmap @_torse_damage_sprite.ox = 80 @_torse_damage_sprite.oy = 50 @_torse_damage_sprite.x = self.x @_torse_damage_sprite.y = self.y - self.oy / 2 @_torse_damage_sprite.z = 3000 value = battler.bras_droit.damage critical = battler.bras_droit.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_bras_droit_damage_sprite = ::Sprite.new(self.viewport) @_bras_droit_damage_sprite.bitmap = bitmap @_bras_droit_damage_sprite.ox = 130 @_bras_droit_damage_sprite.oy = 50 @_bras_droit_damage_sprite.x = self.x @_bras_droit_damage_sprite.y = self.y - self.oy / 2 @_bras_droit_damage_sprite.z = 3000 value = battler.bras_gauche.damage critical = battler.bras_gauche.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_bras_gauche_damage_sprite = ::Sprite.new(self.viewport) @_bras_gauche_damage_sprite.bitmap = bitmap @_bras_gauche_damage_sprite.ox = 30 @_bras_gauche_damage_sprite.oy = 50 @_bras_gauche_damage_sprite.x = self.x @_bras_gauche_damage_sprite.y = (self.y - self.oy / 2) @_bras_gauche_damage_sprite.z = 3000 value = battler.jambe_droite.damage critical = battler.jambe_droite.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_jambe_droite_damage_sprite = ::Sprite.new(self.viewport) @_jambe_droite_damage_sprite.bitmap = bitmap @_jambe_droite_damage_sprite.ox = 110 @_jambe_droite_damage_sprite.oy = 20 @_jambe_droite_damage_sprite.x = self.x @_jambe_droite_damage_sprite.y = self.y - self.oy / 2 @_jambe_droite_damage_sprite.z = 3000 value = battler.jambe_gauche.damage critical = battler.jambe_gauche.critical if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) end @_jambe_gauche_damage_sprite = ::Sprite.new(self.viewport) @_jambe_gauche_damage_sprite.bitmap = bitmap @_jambe_gauche_damage_sprite.ox = 50 @_jambe_gauche_damage_sprite.oy = 20 @_jambe_gauche_damage_sprite.x = self.x @_jambe_gauche_damage_sprite.y = self.y - self.oy / 2 @_jambe_gauche_damage_sprite.z = 3000 @_damage_duration = 40 end def animation(animation, hit) dispose_animation @_animation = animation return if @_animation == nil @_animation_hit = hit @_animation_duration = @_animation.frame_max animation_name = @_animation.animation_name animation_hue = @_animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_animation_sprites = [] if @_animation.position != 3 or not @@_animations.include?(animation) for i in 0..15 sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_animation_sprites.push(sprite) end unless @@_animations.include?(animation) @@_animations.push(animation) end end update_animation end def loop_animation(animation) return if animation == @_loop_animation dispose_loop_animation @_loop_animation = animation return if @_loop_animation == nil @_loop_animation_index = 0 animation_name = @_loop_animation.animation_name animation_hue = @_loop_animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_loop_animation_sprites = [] for i in 0..15 sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_loop_animation_sprites.push(sprite) end update_loop_animation end | |
| | | mikami Admin
Messages : 25 Date d'inscription : 12/12/2007
| Sujet: Re: Systême de combat : Bodypart Attack Mer 12 Déc - 21:10 | |
| script 3, 2eme partie def dispose_damage if @_tete_damage_sprite != nil @_tete_damage_sprite.bitmap.dispose @_tete_damage_sprite.dispose @_tete_damage_sprite = nil end if @_torse_damage_sprite != nil @_torse_damage_sprite.bitmap.dispose @_torse_damage_sprite.dispose @_torse_damage_sprite = nil end if @_bras_droit_damage_sprite != nil @_bras_droit_damage_sprite.bitmap.dispose @_bras_droit_damage_sprite.dispose @_bras_droit_damage_sprite = nil end if @_bras_gauche_damage_sprite != nil @_bras_gauche_damage_sprite.bitmap.dispose @_bras_gauche_damage_sprite.dispose @_bras_gauche_damage_sprite = nil end if @_jambe_droite_damage_sprite != nil @_jambe_droite_damage_sprite.bitmap.dispose @_jambe_droite_damage_sprite.dispose @_jambe_droite_damage_sprite = nil end if @_jambe_gauche_damage_sprite != nil @_jambe_gauche_damage_sprite.bitmap.dispose @_jambe_gauche_damage_sprite.dispose @_jambe_gauche_damage_sprite = nil end @_damage_duration = 0 end def dispose_animation if @_animation_sprites != nil sprite = @_animation_sprites[0] if sprite != nil @@_reference_count[sprite.bitmap] -= 1 if @@_reference_count[sprite.bitmap] == 0 sprite.bitmap.dispose end end for sprite in @_animation_sprites sprite.dispose end @_animation_sprites = nil @_animation = nil end end def dispose_loop_animation if @_loop_animation_sprites != nil sprite = @_loop_animation_sprites[0] if sprite != nil @@_reference_count[sprite.bitmap] -= 1 if @@_reference_count[sprite.bitmap] == 0 sprite.bitmap.dispose end end for sprite in @_loop_animation_sprites sprite.dispose end @_loop_animation_sprites = nil @_loop_animation = nil end end def blink_on unless @_blink @_blink = true @_blink_count = 0 end end def blink_off if @_blink @_blink = false self.color.set(0, 0, 0, 0) end end def blink? @_blink end def effect? @_whiten_duration > 0 or @_appear_duration > 0 or @_escape_duration > 0 or @_collapse_duration > 0 or @_damage_duration > 0 or @_animation_duration > 0 end def update super if @_whiten_duration > 0 @_whiten_duration -= 1 self.color.alpha = 128 - (16 - @_whiten_duration) * 10 end if @_appear_duration > 0 @_appear_duration -= 1 self.opacity = (16 - @_appear_duration) * 16 end if @_escape_duration > 0 @_escape_duration -= 1 self.opacity = 256 - (32 - @_escape_duration) * 10 end if @_collapse_duration > 0 @_collapse_duration -= 1 self.opacity = 256 - (48 - @_collapse_duration) * 6 end if @_damage_duration > 0 @_damage_duration -= 1 case @_damage_duration when 38..39 @_tete_damage_sprite.y -= 4 @_torse_damage_sprite.y -= 4 @_bras_droit_damage_sprite.y -= 4 @_bras_gauche_damage_sprite.y -= 4 @_jambe_droite_damage_sprite.y -= 4 @_jambe_gauche_damage_sprite.y -= 4 when 36..37 @_tete_damage_sprite.y -= 2 @_torse_damage_sprite.y -= 2 @_bras_droit_damage_sprite.y -= 2 @_bras_gauche_damage_sprite.y -= 2 @_jambe_droite_damage_sprite.y -= 2 @_jambe_gauche_damage_sprite.y -= 2 when 34..35 @_tete_damage_sprite.y += 2 @_torse_damage_sprite.y += 2 @_bras_droit_damage_sprite.y += 2 @_bras_gauche_damage_sprite.y += 2 @_jambe_droite_damage_sprite.y += 2 @_jambe_gauche_damage_sprite.y += 2 when 28..33 @_tete_damage_sprite.y += 4 @_torse_damage_sprite.y += 4 @_bras_droit_damage_sprite.y += 4 @_bras_gauche_damage_sprite.y += 4 @_jambe_droite_damage_sprite.y += 4 @_jambe_gauche_damage_sprite.y += 4 end @_tete_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32 if @_damage_duration == 0 dispose_damage end end if @_animation != nil and (Graphics.frame_count % 2 == 0) @_animation_duration -= 1 update_animation end if @_loop_animation != nil and (Graphics.frame_count % 2 == 0) update_loop_animation @_loop_animation_index += 1 @_loop_animation_index %= @_loop_animation.frame_max end if @_blink @_blink_count = (@_blink_count + 1) % 32 if @_blink_count < 16 alpha = (16 - @_blink_count) * 6 else alpha = (@_blink_count - 16) * 6 end self.color.set(255, 255, 255, alpha) end @@_animations.clear end def update_animation if @_animation_duration > 0 frame_index = @_animation.frame_max - @_animation_duration cell_data = @_animation.frames[frame_index].cell_data position = @_animation.position animation_set_sprites(@_animation_sprites, cell_data, position) for timing in @_animation.timings if timing.frame == frame_index animation_process_timing(timing, @_animation_hit) end end else dispose_animation end end def update_loop_animation frame_index = @_loop_animation_index cell_data = @_loop_animation.frames[frame_index].cell_data position = @_loop_animation.position animation_set_sprites(@_loop_animation_sprites, cell_data, position) for timing in @_loop_animation.timings if timing.frame == frame_index animation_process_timing(timing, true) end end end def animation_set_sprites(sprites, cell_data, position) for i in 0..15 sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 160 else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end sprite.x += cell_data[i, 1] sprite.y += cell_data[i, 2] sprite.z = 2000 sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end def animation_process_timing(timing, hit) if (timing.condition == 0) or (timing.condition == 1 and hit == true) or (timing.condition == 2 and hit == false) if timing.se.name != "" se = timing.se Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch) end case timing.flash_scope when 1 self.flash(timing.flash_color, timing.flash_duration * 2) when 2 if self.viewport != nil self.viewport.flash(timing.flash_color, timing.flash_duration * 2) end when 3 self.flash(nil, timing.flash_duration * 2) end end end def x=(x) sx = x - self.x if sx != 0 if @_animation_sprites != nil for i in 0..15 @_animation_sprites[i].x += sx end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].x += sx end end end super end def y=(y) sy = y - self.y if sy != 0 if @_animation_sprites != nil for i in 0..15 @_animation_sprites[i].y += sy end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].y += sy end end end super end end end
class Sprite_Battler < RPG::Sprite
def update super if @battler == nil self.bitmap = nil loop_animation(nil) return end if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height if @battler.dead? or @battler.hidden self.opacity = 0 end end if @battler.damage == nil and @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end if @battler.is_a?(Game_Actor) and @battler_visible if $game_temp.battle_main_phase self.opacity += 3 if self.opacity < 255 else self.opacity -= 3 if self.opacity > 207 end end if @battler.blink blink_on else blink_off end unless @battler_visible if not @battler.hidden and not @battler.dead? and (@battler.damage == nil or @battler.damage_pop) appear @battler_visible = true end end if @battler_visible if @battler.hidden $game_system.se_play($data_system.escape_se) escape @battler_visible = false end if @battler.white_flash whiten @battler.white_flash = false end if @battler.animation_id != 0 animation = $data_animations[@battler.animation_id] animation(animation, @battler.animation_hit) @battler.animation_id = 0 end if @battler.damage_pop damage(@battler) for part in @battler.bodyparts part.damage = nil part.critical = false end @battler.damage = nil @battler.damage_pop = false end if @battler.damage == nil and @battler.dead? if @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) else $game_system.se_play($data_system.actor_collapse_se) end collapse @battler_visible = false end end self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z end end
end | |
| | | Contenu sponsorisé
| Sujet: Re: Systême de combat : Bodypart Attack | |
| |
| | | | Systême de combat : Bodypart Attack | |
|
Sujets similaires | |
|
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |