#════════════════════════════════════════════════════════════════# # 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. # # needed_skill_id,needed_skill_id # # skillpoint_costs_to_learn # # x-coordinate,y-coordinate # # Let the skill only apear if the condiotions are # # sufussed. # # If you skip the script notice that there no skills # # which the actor need to learn this skill. # # If you skip 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
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
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
Ooouh il est pas mal ! Je crois que je vais l'utiliser aussi, merci pour le petit tuto, Zanghter, mais en event sa serait pas mal tout de même, mai j'ai la "flemme" moi aussi
Si je te dis que les events sont mieux pour ton niveau c'est qu'il y a une raison... En plus pour ce que tu veux faire ( de l'affichage entre autres ) une simple image suffirait. Pourquoi se tuer a vouloir un script surtout quand on arrive même pas a le faire marcher ?