Jump to content
Rpg²S Forum
  • 0

[RISOLTO] Apprendimento skill tramite punti (AP)


amivaleo
 Share

Question

Ciao a tutti,

ho cercato sia qui sia in altri siti uno script che permetta di apprendere un'abilità solo dopo che è stato raggiunto un determinato ammontare di punti.

ok, so che nessuno avrà capito. quei fortunati che hanno giocato a ffVI ricorderanno che per apprendere un'abilità, bisognava selezionarla nel menù e, dopo un tot di scontri, l'abilità veniva appresa ed era utilizzabile. ffX-2 sfrutta lo stesso sistema di apprendimento tramite AP (ability points).

 

per rendere chiaro a tutti di che sto parlando:

nel menù abilità seleziono l'abilità "SKILL", che richiede 20 AP per essere appresa.

esco dal menù e combatto in giro coi mostri, ogni mostro mi dà un tot di ap.

dopo aver sconfitto un certo numero di mostri, il personaggio ha acquisito 20 AP e l'abilità SKILL è stata appresa.

allora si ritorna nel menù abilità e si seleziona un'altra abilità. e così via.

 

qualcuno può aiutarmi con questo script? ho trovato qualcosa di simile con gli exp, ma non funziona o.o

 

 

EDIT:

ho trovato questo script di sleeping leonheart. andrebbe benissimo se non fosse per il fatto che io non voglio che il giocatore compri le abilità prima di apprenderle.

voglio che il giocatore abbia alcune abilità iniziali tra le quali scegliere quale apprendere. le altre abilità saranno aggiunte tramite oggetti (cioè common event).

vedo di cambiare lo script come interessa a me. intanto spero che spleeping leonheart (o chiunque abbia già usato e modificato questo script) noti questo topic!

in ogni caso, se avete già uno script già pronto, vi sarei grato se me lo passaste!

Edited by Marigno
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

si, solo quello. ho capito più o meno come hai impostato lo script, forse potrei riuscire a sistemarlo come voglio io in qualche giorno. però... se non ti porta via troppo tempo, potresti farlo tu? sei sicuramente più pratico di rgss di me, e poi è anche un tuo script.

se non puoi, dimmelo pure! proverò io e al massimo ti contatto se dovessi incontrare qualche problema.

Link to comment
Share on other sites

  • 0

Non ti preoccupare ci penso io, su per giu mi ricordo come è strutturato quindi nn ci dovrei mettere molto ;)

 

EDIT:

Eccotelo:

 

 

#===============================================================================

# TSL Skill Development System

#===============================================================================

# The Sleeping Leonhart

# Version 1.0

# 26-7-2007

#===============================================================================

# Per creare questo sistema mi sono ispirato a Final Fantasy XII e per certi versi

# è simile. In poche parole per apprendere le skill bisogna prima comprarle

# in un apposito negozio, una volta comprate appariranno nel menù sviluppo dove

# dovranno essere apprese attraverso l'uso dei punti abilità.

# Per richiamare un negozio si usa il comando $scene = Scene_SkillShop.new,

# ma attenzione perche prima del sudetto comando va inserito prima

# $game_temp.skill_goods[id eroe] = [id skill 1,id skill 2,etc...]

# questo comando dichiara le skill in vendita perciò

# $game_temp.skill_goods[1] = [4,5,6,7] vende ad Aluxes Remedy, Greater Remedy, Raise e Fire.

# Per richiamare invece la finestra di apprendimento skill va usato il comando

# $scene = Scene_SkillLearn.new.

# Per dichiarare i punti abilità che da ciascun mostro bisogna compilare l'hash

# ENEMY_AP_VALUES ne seguente modo {id mostro => quantità AP, etc..}

# per i mostri non dichiarati verrà assegnato il valore contenuto in DEFAULT_ENEMY_AP.

# Per dichiarare i punti AP necessari per apprendere una skill compilare l'hash

# SKILL_AP nel seguente modo {id skill => AP necessari} in maniera simile viene

# compilato quello per il prezzo, SKILL_PRICE = {id skill => Soldi necessari}.

# SKILL_AP.default e SKILL_PRICE.default viene dichiarato il valore assegnato alle

# skill non inserite megli hash.

#===============================================================================

 

module Leonhart_DS

ENEMY_AP_VALUES = {1 => 5, 2 => 2}

DEFAULT_ENEMY_AP = 1

SKILL_AP = {1=>10}

SKILL_AP.default = 5

end

 

 

class Game_Actor < Game_Battler

attr_reader :ap

attr_reader :temp_skills

alias tslds_gameactor_setup setup

def setup(actor_id)

@ap = 0

@temp_skills = []

@shop_skills = []

tslds_gameactor_setup(actor_id)

end

def ap=(ap)

@ap = [[ap, 9999999].min, 0].max

end

def learn_temp_skill(skill_id)

if skill_id > 0 and not temp_skill_learned?(skill_id)

@temp_skills.push(skill_id)

@temp_skills.sort!

end

end

def learn_skill(skill_id)

if skill_id > 0 and not skill_learn?(skill_id)

@skills.push(skill_id)

@skills.sort!

end

end

def temp_skill_learned?(skill_id)

return @temp_skills.include?(skill_id)

end

end

 

module RPG

class Skill

def ap

return Leonhart_DS::SKILL_AP[id]

end

end

end

 

class Window_SkillLearnCommand < Window_Selectable

def initialize

super(0, 64, 640, 64)

self.contents = Bitmap.new(width - 32, height - 32)

@item_max = 2

@column_max = 2

@commands = ["Apprendi", "Esci"]

refresh

self.index = 0

end

def refresh

self.contents.clear

for i in 0...@item_max

draw_item(i)

end

end

def draw_item(index)

x = 4 + index * 320

self.contents.draw_text(x, 0, 128, 32, @commands[index])

end

end

 

class Window_SkillLearn < Window_Selectable

def initialize(actor)

super(0, 128, 368, 352)

@actor = $game_party.actors[actor]

refresh

self.index = 0

end

def skill

return @data[self.index]

end

def refresh

if self.contents != nil

self.contents.dispose

self.contents = nil

end

@data = []

for i in 0...@actor.temp_skills.size

skill = $data_skills[@actor.temp_skills]

if skill != nil

@data.push(skill)

end

end

@item_max = @data.size

if @item_max > 0

self.contents = Bitmap.new(width - 32, row_max * 32)

for i in 0...@item_max

draw_item(i)

end

end

end

def draw_item(index)

if skill.ap > @actor.ap or @actor.skill_learn?(@actor.temp_skills[index])

self.contents.font.color = disabled_color

else

self.contents.font.color = normal_color

end

skill = @data[index]

x = 4

y = index * 32

rect = Rect.new(x, y, self.width / @column_max - 32, 32)

self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

bitmap = RPG::Cache.icon(skill.icon_name)

opacity = self.contents.font.color == normal_color ? 255 : 128

self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)

self.contents.draw_text(x + 232, y, 48, 32, skill.ap.to_s, 2)

end

def update_help

@help_window.set_text(self.skill == nil ? "" : self.skill.description)

end

end

 

class Window_SkillLearnStatus < Window_Base

def initialize(actor)

super(368, 480-352, 272, 352)

self.contents = Bitmap.new(width - 32, height - 32)

@actor = $game_party.actors[actor]

refresh

end

def refresh

self.contents.clear

draw_actor_graphic(@actor, 40, 112)

draw_actor_name(@actor, 4, 0)

draw_actor_class(@actor, 4 + 144, 0)

draw_actor_level(@actor, 0, 32)

draw_actor_state(@actor, 148, 32)

draw_actor_hp(@actor, 4, 112, 172)

draw_actor_sp(@actor, 4, 144, 172)

draw_actor_exp(@actor, 4,176)

draw_actor_ap(@actor, 4,208)

end

end

 

class Window_Base < Window

def draw_actor_ap(actor, x, y)

self.contents.font.color = system_color

self.contents.draw_text(x, y, 24, 32, "AP")

self.contents.font.color = normal_color

self.contents.draw_text(x + 24, y, 84, 32, actor.ap.to_s, 2)

end

end

 

class Window_BattleResult < Window_Base

def initialize(exp, gold, ap, treasures)

@exp = exp

@gold = gold

@ap = ap

@treasures = treasures

super(160, 0, 320, @treasures.size * 32 + 96)

self.contents = Bitmap.new(width - 32, height - 32)

self.y = 160 - height / 2

self.back_opacity = 160

self.visible = false

refresh

end

def refresh

self.contents.clear

x = 4

self.contents.font.color = normal_color

cx = contents.text_size(@exp.to_s).width

self.contents.draw_text(x, 0, cx, 32, @exp.to_s)

x += cx + 4

self.contents.font.color = system_color

cx = contents.text_size("EXP").width

self.contents.draw_text(x, 0, 64, 32, "EXP")

x += cx + 16

self.contents.font.color = normal_color

cx = contents.text_size(@gold.to_s).width

self.contents.draw_text(x, 0, cx, 32, @gold.to_s)

x += cx + 4

self.contents.font.color = system_color

self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)

y = 32

x = 4

self.contents.font.color = normal_color

cx = contents.text_size(@ap.to_s).width

self.contents.draw_text(x, y, cx, 32, @ap.to_s)

x += cx + 4

self.contents.font.color = system_color

self.contents.draw_text(x, y, 128, 32, "AP")

y = 64

for item in @treasures

draw_item_name(item, 4, y)

y += 32

end

end

end

 

class Scene_Battle

include Leonhart_DS

def start_phase5

@phase = 5

$game_system.me_play($game_system.battle_end_me)

$game_system.bgm_play($game_temp.map_bgm)

exp = 0

gold = 0

ap = 0

treasures = []

for enemy in $game_troop.enemies

unless enemy.hidden

exp += enemy.exp

gold += enemy.gold

ap += (ENEMY_AP_VALUES.has_key?(enemy.id) ? ENEMY_AP_VALUES[enemy.id] : DEFAULT_ENEMY_AP)

if rand(100) < enemy.treasure_prob

if enemy.item_id > 0

treasures.push($data_items[enemy.item_id])

end

if enemy.weapon_id > 0

treasures.push($data_weapons[enemy.weapon_id])

end

if enemy.armor_id > 0

treasures.push($data_armors[enemy.armor_id])

end

end

end

end

treasures = treasures[0..5]

@treasures = treasures

@exp = exp

@gold = gold

@ap = ap

for i in 0...$game_party.actors.size

actor = $game_party.actors

actor.ap += ap

end

$game_party.gain_gold(gold)

for item in treasures

case item

when RPG::Item

$game_party.gain_item(item.id, 1)

when RPG::Weapon

$game_party.gain_weapon(item.id, 1)

when RPG::Armor

$game_party.gain_armor(item.id, 1)

end

end

@result_window = Window_BattleResult.new(exp, gold, ap, treasures)

@phase5_wait_count = 10

end

end

 

class Scene_SkillLearn

def main

@help_window = Window_Help.new

@party = []

@id = []

for i in 0...$game_party.actors.size

@party.push($game_party.actors.name)

@id.push($game_party.actors.id)

end

@character_window = Window_Command.new(160,@party)

@character_window.y = 128

@character_window.z = 101

@character_window.active = @character_window.visible = false

@command_window = Window_SkillLearnCommand.new

@dummy_window = Window_Base.new(0, 128, 640, 352)

@buy_window = Window_SkillLearn.new(@character_window.index)

@buy_window.active = false

@buy_window.visible = false

@buy_window.help_window = @help_window

@status_window = Window_SkillLearnStatus.new(@character_window.index)

@status_window.visible = false

@actor = $game_party.actors[@character_window.index]

@skills = @actor.temp_skills[@buy_window.index]

Graphics.transition

loop do

Graphics.update

Input.update

update

if $scene != self

break

end

end

Graphics.freeze

@help_window.dispose

@character_window.dispose

@command_window.dispose

@dummy_window.dispose

@buy_window.dispose

@status_window.dispose

end

def update

@help_window.update

@character_window.update

@command_window.update

@dummy_window.update

@buy_window.update

@status_window.update

if @character_window.active

select_character

return

end

if @command_window.active

update_command

return

end

if @buy_window.active

update_buy

return

end

end

def update_command

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

$scene = Scene_Map.new

return

end

if Input.trigger?(Input::C)

case @command_window.index

when 0

$game_system.se_play($data_system.decision_se)

@command_window.active = false

@character_window.visible = @character_window.active = true

when 1

$game_system.se_play($data_system.decision_se)

$scene = Scene_Map.new

end

return

end

end

def select_character

@help_window.set_text("Seleziona un personaggio")

if Input.trigger?(Input::C)

$game_system.se_play($data_system.decision_se)

@character_window.visible = @character_window.active = false

@dummy_window.visible = false

@buy_window.dispose

@buy_window = Window_SkillLearn.new(@character_window.index)

@buy_window.active = true

@buy_window.visible = true

@buy_window.refresh

@buy_window.help_window = @help_window

@status_window.dispose

@status_window = Window_SkillLearnStatus.new(@character_window.index)

@status_window.visible = true

return

end

if Input.trigger?(Input::B)

$game_system.se_play($data_system.decision_se)

@command_window.active = @dummy_window.visible = true

@character_window.visible = @character_window.active = false

@help_window.set_text("")

return

end

end

def update_buy

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

@dummy_window.visible = true

@buy_window.active = false

@buy_window.visible = false

@status_window.visible = false

@character_window.visible = @character_window.active = true

return

end

if Input.trigger?(Input::C)

@item = @buy_window.skill

if @item == nil or @item.ap > $game_party.actors[@character_window.index].ap

$game_system.se_play($data_system.buzzer_se)

@help_window.set_text("Ap insufficenti")

$game_system.se_play($data_system.buzzer_se)

for i in 0..3

sleep i*0.1

Graphics.update

Input.update

end

return

end

@actor = $game_party.actors[@character_window.index]

@skills = @actor.temp_skills[@buy_window.index]

if not @actor.skill_learn?(@actor.temp_skills[@buy_window.index])

$game_system.se_play($data_system.decision_se)

$game_party.actors[@character_window.index].ap -= $data_skills[@skills].ap

@status_window.refresh

@actor.learn_skill(@actor.temp_skills[@buy_window.index])

@buy_window.refresh

else

@help_window.set_text("Hai gia appreso questa skill!")

$game_system.se_play($data_system.buzzer_se)

for i in 0..3

sleep i*0.1

Graphics.update

Input.update

end

return

end

end

end

end

 

 

Se vuoi aggiungere una skill da apprendere usa il comando

$game_actors[id_personaggio].learn_temp_skill(id_skill)

L'id del personaggio riferito all'id del database.

Se invece vuoi che le skill vengano aggiunte all'elenco ogni volta che sali di livello ci posso lavorare sopra(oppure puoi fartelo ad eventi come preferisci tu).

Spero sia tutto apposto :P

Edited by Sleeping Leonhart
Link to comment
Share on other sites

  • 0

ok, ti ringrazio davvero!

 

EDIT:

sei un grande! neanche il tempo di scriverti "grazie" perchè te ne saresti occupato tu...!

 

EDIT2:

ah ecco! allora non mi ero sbagliato quando ho pensato che avrei dovuto usare la funzione "learn_temp_skill"!

non riuscivo a metterla in un evento però...! >.<

bon, grazie mille! l'ho già provato e non mi dà alcun errore.

 

va bene così comunque! è così che mi serviva. non voglio che i giocatori apprendano alcuna abilità con il level up, al massimo tramite oggetti, ma so già come fare (basta un evento comune...).

grazie ancora! ;)

Edited by Ziel van Brand
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...