Mage Lv.11
Age : 26 Avertissements : 3 Inscrit le : 03/04/2010 Messages : 512
| Sujet: [VX] Arbre de compétences Ven 17 Juin 2011 - 12:12 | |
| Script: Arbre de compétences Créateur:Deity Utilité: Permet de créer un arbre de compétences. Je n'ai pas trouvé ce script dans la liste de script "héros". Prévenez-moi s'il existe déjà. Possibilités : . Un arbre avec pour maximum 99 compétences . Un arbre pour chaque personnage . Cache les compétences si les conditions ne sont pas remplies Facile d'utilisation, aussi. Utilisation: Les instructions au début du script sont en anglais, voici une brève traduction de Coco' : Pour utiliser l'arbre, il faut un appel de script : - Code:
-
$scene = Scene_SkillTree.new(party_member_id) Si vous utilisez : - Code:
-
add_skill_points(party_member_id,points) précisez l'ID, le personnage gagnera x points pour l'arbre des compétences. Quant au compétences, vous devez préciser dans leurs commentaires, dans la BDD : - Code:
-
<skills> needed_skill_id,needed_skill_id <skills_end> <costs> skillpoint_costs_to_learn <costs_end> <coords> x-coordinate,y-coordinate <coords_end> .skills correspond aux conditions pour obtenir cette compétence (par exemple en avoir une telle autre en précisant l'ID) .cost correspond au coût du sort .coord correspond à la position des sorts sur l'écran. Vous avez une fenêtre de 272*328 px pour placer tous vos sorts. Le plus grand "x" que vous pourrez utiliser est 244, et le plus grand "y" est 300. Et voici le script: - Code:
-
#════════════════════════════════════════════════════════════════# # script: Deity's SkillTree # # by Deity # # v. 1.2 # #════════════════════════════════════════════════════════════════# # Description: # # This script allow you tu use your own individual SkillTree for # # your Game. # #════════════════════════════════════════════════════════════════# # Using: # # As first you have to setup the Settings as you wish. # # To call the SkillTree you have to write this in the "Call ..." # # $scene = Scene_SkillTree.new(party_member_id) # # If you use this line: # # add_skill_points(party_member_id,points) # # the partymember with the id (party_member_id) get points # # skillpoints. # # Just add the skills an actor can learn as ever in the database.# # Now you have following notes which you can place into the note # # of a skill. # # <skills> needed_skill_id,needed_skill_id <skills_end> # # <costs> skillpoint_costs_to_learn <costs_end> # # <coords> x-coordinate,y-coordinate <coords_end> # # <hide> Let the skill only apear if the condiotions are # # sufussed. # # If you skip <skills> the script notice that there no skills # # which the actor need to learn this skill. # # If you skip <costs> the script give the skill automaticaly # # the cost of 1 skillpoint. # # The coordinates are important so dont skip them. # # You have a window of 272*328 pxl to place you skills(icons). # # So you can place about 99 Skills in you skilltree # # The biggst x-ccordinate you should use is: 244 # # The biggst x-ccordinate you should use is: 300 # #▼════════════════════════ Settings ════════════════════════════▼# # true = jes / false = no # module Deity module SkillTree #Color Settings # Color of the Edge from the Slot SLOT_COLOR1 = Color.new(255,255,255,200) # Backgroundcolor of the Icon SLOT_COLOR2 = Color.new(10,10,10,200) # Color of the Cursor CURSOR_COLOR = Color.new(255,0,0,255) # Color of learned skills and lines LEARNED_SKILL_COLOR = Color.new(0,255,0,255) # Color of not learned skills and lines NOT_LEARNED_SKILL_COLOR = Color.new(255,0,0,255) # Commands to confirm or cancel CONFIRM_WINDOW_TEXT = ["Jes.","No."] # Text for conditions CONDITIONS = "Conditions" # Text for needed level SKILL_LEVEL = "Level:" # Text if skill deal damage SKILL_DAMAGE = "Damage:" # Text if skill heal SKILL_RECOVER = "Heal:" # Name of the skillpoints SKILL_POINTS = "Skillpoints" # Short name of the skillpoints SHORT_SP_NAME = "SP" # BGM-Title for the Scene BGM_NAME = "Field1" # Text for MP-Cost SKILL_COST = "MP-Cost:" # Header for Element SKILL_ELEMENTS = "Elements of the Skill" # Header for Status SKILL_STATE = "Statuseffects" # Header for + States SKILL_ADD_STATE = "Add" # Header for - States SKILL_SUB_STATE = "Sub" # Text if skill already learned SKILL_LEARNED = "Already learned." # Text if no skills lernable NO_LERNABLE_SKILLS = "This character doesn't have any skills." # Text for cost to learn this skill SKILL_COST = "Skillcost:" # Text if user wants to learn the skill LEARN_SKILL = "Want to learn this skill?" # Text for big information window INFO_TEXT = "Informations" # Should the script open Biginformationwindow if press Shift? ALLOW_BIG_INFO = true # Should the script use the level conditions of the skills? LEVEL_CONDITIONS = false # Should the script draw connectionlines between the skills? USE_CONNECTION_LINES = true # How many pxl should be skipped? in pxl SKIPPED_PXL = 0 # 0 = not skipping # Linewidth/height in pxl # it sounds confusing but with 2 parameter you are able # to make an better looking line. LINES_WIDTH = 1 LINES_HEIGHT = 1 # Use Scene_Skil Addon? USE_SKILL_SCENE = true # Use Scene_Status Addon? USE_STATUS_SCENE = true # How many level have the player to reach to get skillpoints? POINTS_LEVEL_RANGE = 3 # How many skillpoints the actor get if he become a higher level? LEVEL_UP_POINTS = 1 # The name of the returning scene LAST_SCENE = "Scene_Map" end end # Don't change anything above this lines except you know what # # you do. # #▲═════════════════════════════════════════════════════════════▲# include Deity::SkillTree
class Game_Actor attr_accessor :skill_points alias initialize_skilltree initialize if !$@ def initialize(actor_id) initialize_skilltree(actor_id) @skills = [] @skill_points = (@level / POINTS_LEVEL_RANGE).to_i @skill_point_range = @level - (@skill_points * POINTS_LEVEL_RANGE).to_i end def level_up @level += 1 @skill_point_range += 1 if @skill_point_range == POINTS_LEVEL_RANGE @skill_point_range = 0 @skill_points += LEVEL_UP_POINTS end end end
class SkillTree_Skill def initialize(skill_id,actor_id,level) @skill_id = skill_id @skill = $data_skills[skill_id] @level = level @actor = $game_party.members[actor_id] end def id return @skill_id end def hidden? notes = @skill.note.split if notes.include?("<hide>") && !conditions_suffused return true else return false end end def conditions_suffused state = true for i in conditions if !@actor.skill_learn?($data_skills[i.to_i]) state = false end end return state end def level return @level end def costs notes = @skill.note.split if notes.include?("<costs>") indexes = [notes.index("<costs>"),notes.index("<costs_end>")] string = "" for i in indexes[0]...indexes[1] string += notes[i] end string = string.gsub("<costs>","") string = string.gsub("<costs_end>","") cost = string.to_i else cost = 1 end return cost end def conditions notes = @skill.note.split if notes.include?("<skills>") indexes = [notes.index("<skills>")+1,notes.index("<skills_end>")] string = "" for i in indexes[0]...indexes[1] string += notes[i] end string = string.gsub(","," ") skillids = string.split else skillids = [] end return skillids end def place notes = @skill.note.split if notes.include?("<coords>") indexes = [notes.index("<coords>")+1,notes.index("<coords_end>")] string = "" for i in indexes[0]...indexes[1] string += notes[i] end string = string.gsub(","," ") coords = string.split coords[0] = coords[0].to_i coords[1] = coords[1].to_i else coords = [10,10] end return coords end end
class SkillTree_Cursor < Sprite def initialize(x,y,viewport) super(viewport) self.x = x self.y = y self.bitmap = Bitmap.new(28,28) @bitmap = self.bitmap refresh end def refresh @bitmap.fill_rect(0,0,28,28,CURSOR_COLOR) @bitmap.clear_rect(2,2,24,24) end end
class Window_SkillTree < Window_Base def initialize(x,y,width,heigth,actor_id,skills) super(x,y,width,heigth) @actor = $game_party.members[actor_id] @actor_id = actor_id @skills = skills refresh end def refresh self.contents.clear if @skills.size > 0 if USE_CONNECTION_LINES sprite = Sprite.new(Viewport.new(self.x + 16,self.y + 16,self.width - 32,self.height - 32)) sprite.x = self.x + 16 sprite.y = self.y + 16 sprite.bitmap = Bitmap.new(self.width - 32,self.height - 32) sprite.visible = false for skill in @skills next if skill.hidden? for cond in skill.conditions cond = cond.to_i if @actor.skills.include?($data_skills[cond]) sprite.bitmap.draw_line(skill.place[0]+13,skill.place[1]+13,@skills[search_id(cond)].place[0]+13,@skills[search_id(cond)].place[1]+13,LEARNED_SKILL_COLOR,LINES_WIDTH,LINES_HEIGHT,SKIPPED_PXL) else sprite.bitmap.draw_line(skill.place[0]+13,skill.place[1]+13,@skills[search_id(cond)].place[0]+13,@skills[search_id(cond)].place[1]+13,NOT_LEARNED_SKILL_COLOR,LINES_WIDTH,LINES_HEIGHT,SKIPPED_PXL) end end end rect = Rect.new(0,0,sprite.width,sprite.height) self.contents.blt(0,0,sprite.bitmap,rect) end icons = [] for i in @actor.class.learnings next if SkillTree_Skill.new(i.skill_id,@actor_id,i.level).hidden? skill = [i.skill_id,@actor.skill_learn?($data_skills[i.skill_id])] icons.push(skill) end for i in 0...icons.size x = @skills[i].place[0].to_i y = @skills[i].place[1].to_i self.contents.fill_rect(x,y,26,26,SLOT_COLOR1) self.contents.fill_rect(x+1,y+1,24,24,SLOT_COLOR2) draw_icon($data_skills[icons[i][0]].icon_index, x+1, y+1, icons[i][1]) end end end def search_id(skill_id) id = 0 for i in 0...@skills.size if @skills[i].id == skill_id id = i end end return id end end
class Window_SkillTreeInformationSmall < Window_Base def initialize(x,y,width,heigth,skill_id,skills,actor_id) super(x,y,width,heigth) @bitmap = self.contents @skills = skills @actor = $game_party.members[actor_id] refresh(skill_id) if skill_id != 0 end def change_actor_id(actor_id) @actor = $game_party.members[actor_id] end def refresh(skill_id) if @skills.size > 0 @bitmap.clear @bitmap.draw_text(0,0,self.width-32,24,@actor.name,0) draw_actor_level(@actor, self.width-32-56, 0) self.contents.font.color = system_color @bitmap.draw_text(0,24,self.width-32,24,SKILL_POINTS + ":",0) @bitmap.draw_text(0,84,self.width-32,24,SKILL_COST,0) self.contents.font.color = normal_color @bitmap.draw_text(0,24,self.width-32,24,@actor.skill_points.to_s,2) @bitmap.draw_text(0,84,self.width-32,24,@skills[search_id(skill_id)].costs.to_s,2) @bitmap.draw_text(0,54,self.width-32,24,$data_skills[skill_id].name,1) @bitmap.draw_text(0,114,self.width-32,24,CONDITIONS,1) y = 134 for i in @skills if i.id == skill_id @bitmap.font.color = NOT_LEARNED_SKILL_COLOR if LEVEL_CONDITIONS if @actor.level >= i.level @bitmap.font.color = LEARNED_SKILL_COLOR end @bitmap.draw_text(0,y,self.width-32,24,SKILL_LEVEL + " " + i.level.to_s,0) y += 22 end for o in i.conditions @bitmap.font.color = NOT_LEARNED_SKILL_COLOR if @actor.skill_learn?($data_skills[o.to_i]) @bitmap.font.color = LEARNED_SKILL_COLOR end @bitmap.draw_text(0,y,self.width-32,24,$data_skills[o.to_i].name,0) y += 22 end end end @bitmap.font.color = Font.default_color end end def search_id(skill_id) for i in 0...@skills.size if @skills[i].id == skill_id return i end end end end
class Window_SkillTreeInformationBig < Window_Base def initialize(x,y,width,heigth,skill_id,actor_id) super(x,y,width,heigth) self.visible = false @bitmap = self.contents @actor = $game_party.members[actor_id] refresh(skill_id) if skill_id != 0 end def change_actor_id(actor_id) @actor = $game_party.members[actor_id] end def refresh(skill_id) @bitmap.clear skill = $data_skills[skill_id] @bitmap.font.bold = true @bitmap.draw_text(0,0,self.width-32,24,skill.name,1) @bitmap.font.bold = false @bitmap.draw_text(0,24,self.width-32,24,skill.description) if skill.base_damage > 0 text = SKILL_DAMAGE + " " + skill.base_damage.to_s else text = SKILL_RECOVER + " " + (skill.base_damage * -1).to_s end @bitmap.draw_text(0,50,self.width/2-16,24,text,0) @bitmap.draw_text(self.width/2-16,50,self.width/2,24,SKILL_COST + " " + skill.mp_cost.to_s,0) eles = [] for i in skill.element_set eles.push($data_system.elements[i]) end @bitmap.font.bold = true @bitmap.draw_text(0,74,self.width-32,24,SKILL_ELEMENTS,1) @bitmap.font.bold = false y = 74 for i in 0...eles.size if i % 2 == 0 x = 0 y = y + 24 else x = self.width/2 end @bitmap.draw_text(x,y,self.width/2-16,24,eles[i],1) end y = y + 26 @bitmap.font.bold = true @bitmap.draw_text(0,y,self.width-32,24,SKILL_STATE,1) @bitmap.font.bold = false y += 24 @bitmap.font.bold = true @bitmap.draw_text(0,y,self.width/2-16,24,SKILL_ADD_STATE,1) @bitmap.draw_text(self.width/2-16,y,self.width/2,24,SKILL_SUB_STATE,1) @bitmap.font.bold = false y += 24 z = y for i in skill.plus_state_set @bitmap.draw_text(0,z,self.width/2-16,24,$data_states[i].name,1) z += 24 end for i in skill.minus_state_set @bitmap.draw_text(self.width/2-16,y,self.width/2,24,$data_states[i].name,1) y += 24 end end end
class Scene_SkillTree < Scene_Base def initialize(actor_id) @viewport = Viewport.new(0,0,544,416) @actor_id = actor_id @actor = $game_party.members[actor_id] @skills = [] @index = 0 for i in @actor.class.learnings skill = SkillTree_Skill.new(i.skill_id,actor_id,i.level) @skills.push(skill) end @info = Window_Help.new if @actor.skills.include?($data_skills[@skills[@index].id]) @info.set_text(SKILL_LEARNED,1) else @info.set_text(LEARN_SKILL,1) end @skilltree = Window_SkillTree.new(0,56,544-240,416-56,actor_id,@skills) if @skills.size > 0 @info_small = Window_SkillTreeInformationSmall.new(544-240,56,240,416-56,@skills[0].id,@skills,actor_id) @cursor = SkillTree_Cursor.new(@skills[0].place[0] + 15,@skills[0].place[1] + 71,@viewport) @info_big = Window_SkillTreeInformationBig.new(0,56,544,416-56,@skills[0].id,actor_id) else @info.set_text(NO_LERNABLE_SKILLS,1) @info_small = Window_SkillTreeInformationSmall.new(544-240,56,240,416-56,0,@skills,actor_id) @cursor = SkillTree_Cursor.new(25,81,@viewport) @cursor.visible = false @info_big = Window_SkillTreeInformationBig.new(0,56,544,416-56,0,actor_id) end @confirm = Window_Command.new(160,CONFIRM_WINDOW_TEXT,2) @confirm.x = 544 - @confirm.width @confirm.visible = false @confirm.opacity = 0 @confirm.active = false @info_small.viewport = @viewport @info.viewport = @viewport @skilltree.viewport = @viewport @info_big.viewport = @viewport @confirm.viewport = @viewport @info_small.z = 100 @info.z = 100 @skilltree.z = 100 @cursor.z = 150 @info_big.z = 200 @confirm.z = 201 end def start Audio.bgm_play("Audio/BGM/"+BGM_NAME,100,100) end def update @confirm.update if @confirm.active update_skill_confirm else update_cursor if @skills.size > 0 update_big_window if ALLOW_BIG_INFO && @skills.size > 0 if Input.trigger?(Input::C) && @skills.size > 0 if @skills[@index].conditions_suffused and !@actor.skills.include?($data_skills[@skills[@index].id]) and @skills[@index].costs <= @actor.skill_points if LEVEL_CONDITIONS if @skills[@index].level <= @actor.level @confirm.active = true @confirm.visible = true @info.set_text(LEARN_SKILL,0) Sound.play_decision else Sound.play_buzzer end else @confirm.active = true @confirm.visible = true @info.set_text(LEARN_SKILL,0) end else Sound.play_buzzer end end if Input.trigger?(Input::R) Sound.play_cursor @actor_id += 1 if @actor_id > $game_party.members.size - 1 @actor_id = 0 end $scene = Scene_SkillTree.new(@actor_id) elsif Input.trigger?(Input::L) Sound.play_cursor @actor_id -= 1 if @actor_id < 0 @actor_id = $game_party.members.size - 1 end $scene = Scene_SkillTree.new(@actor_id) elsif Input.trigger?(Input::B) && !@confirm.active Sound.play_cancel $scene = Scene_Map.new end end end def terminate Audio.bgm_stop @info_small.dispose @info.dispose @skilltree.dispose @info_big.dispose @confirm.dispose @cursor.dispose @viewport.dispose end def update_big_window if Input.trigger?(Input::A) if @info_big.visible == true refresh_windows(@skills[@index].id) if @skills[@index] != nil @info_big.visible = false @info_small.visible = true @skilltree.visible = true @cursor.visible = true else @info.set_text(INFO_TEXT,1) @info_big.visible = true @info_small.visible = false @skilltree.visible = false @cursor.visible = false end end end
def update_cursor if Input.trigger?(Input::LEFT) search_nearst_skill("left") Sound.play_cursor refresh_windows(@skills[@index].id) if @skills[@index] != nil refresh_cursor(@skills[@index].place) if @skills[@index] != nil elsif Input.trigger?(Input::RIGHT) search_nearst_skill("right") Sound.play_cursor refresh_windows(@skills[@index].id) if @skills[@index] != nil refresh_cursor(@skills[@index].place) if @skills[@index] != nil elsif Input.trigger?(Input::UP) search_nearst_skill("up") Sound.play_cursor refresh_windows(@skills[@index].id) if @skills[@index] != nil refresh_cursor(@skills[@index].place) if @skills[@index] != nil elsif Input.trigger?(Input::DOWN) search_nearst_skill("down") Sound.play_cursor refresh_windows(@skills[@index].id) if @skills[@index] != nil refresh_cursor(@skills[@index].place) if @skills[@index] != nil end end
def search_nearst_skill(direction) sid = 0 skills = {} for i in @skills sid += 1 if i == @skills[@index] next if i == @skills[@index] case direction when "up" if i.place[1] < @skills[@index].place[1] skills[sid] = ((i.place[0] - @skills[@index].place[0]).abs+(i.place[1] + 24 - @skills[@index].place[1]).abs).abs end when "down" if i.place[1] > @skills[@index].place[1] skills[sid] = ((i.place[0] - @skills[@index].place[0]).abs+(i.place[1] - @skills[@index].place[1] + 24).abs).abs end when "right" if i.place[0] > @skills[@index].place[0] skills[sid] = ((i.place[0] - @skills[@index].place[0] + 24).abs+(i.place[1] - @skills[@index].place[1]).abs).abs end when "left" if i.place[0] < @skills[@index].place[0] skills[sid] = ((i.place[0] + 24 - @skills[@index].place[0]).abs+(i.place[1] - @skills[@index].place[1]).abs).abs end end sid += 1 end if !skills.empty? skill = skills.invert.sort id = 0 while @skills[skill[id][1]].hidden? do id += 1 end skill = skill[id][1] @index = skill return skill else return @index end end def update_skill_confirm if Input.trigger?(Input::C) case @confirm.index when 0 $game_party.members[@actor_id].learn_skill(@skills[@index].id) @confirm.active = false @confirm.visible = false @actor.skill_points -= @skills[@index].costs Sound.play_decision refresh_windows(@skills[@index].id) if @skills[@index] != nil when 1 @confirm.active = false @confirm.visible = false Sound.play_cancel end end end def refresh_windows(skill_id) if @skills.size > 0 @info_small.refresh(skill_id) @skilltree.refresh @info_big.refresh(skill_id) if @actor.skills.include?($data_skills[@skills[@index].id]) && !@info_big.visible @info.set_text(SKILL_LEARNED,1) else @info.set_text(LEARN_SKILL,1) end else @info.set_text(NO_LERNABLE_SKILLS,1) end end def return_scene $scene = LAST_SCENE + ".new" end def refresh_cursor(place) if place != nil @cursor.x = place[0] + 15 @cursor.y = place[1] + 71 else @cursor.x = 25 @cursor.y = 81 end end end
class Game_Interpreter def add_skill_points(party_member_id,points) $game_party.members[party_member_id].skill_points += points end end
class Window_Base def draw_actor_sp(actor,x,y) self.contents.font.color = system_color self.contents.draw_text(x, y, 32, WLH, Deity::SkillTree::SHORT_SP_NAME) self.contents.font.color = normal_color self.contents.draw_text(x + 32, y, 24, WLH, actor.skill_points, 2) end end
if Deity::SkillTree::USE_SKILL_SCENE
class Window_SkillStatus < Window_Base def refresh self.contents.clear draw_actor_name(@actor, 0, 0) draw_actor_level(@actor, 120, 0) draw_actor_hp(@actor, 200, 0, 100) draw_actor_mp(@actor, 310, 0, 100) draw_actor_sp(@actor, 430, 0) end end end
if Deity::SkillTree::USE_SKILL_SCENE class Window_Status alias refresh_skilltree_status refresh unless $@ def refresh refresh_skilltree_status draw_actor_sp(@actor,300,0) end end end ScreensBon making. Gela
Dernière édition par gelamine le Ven 17 Juin 2011 - 12:21, édité 1 fois |
|