Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
[Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 1
3 participantes
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Tutoriais
Página 1 de 1
[Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 1
Bom, estava no trabalho sem nada pra fazer (graças a deus ) entoa decidi mecher com RMXP. baixei o NetPlay Master v3.0 e comecei a editar ate que me veio a ideia de criar um sistema de Banco em que pode-se guardar e retirar dinheiro!
Nome: SBNPM (Sistema de Banco Netplay Master)
Criador: Nanzin
Data: 28/11/2011
Dificuldade: Medio
Equipe Desenvolvedora: Wolf dragon Makers
1º Script: Game_Party
- Screenshot:
substitua o seu por esse:
- Código:
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 处理同伴的类。包含金钱以及物品的信息。本类的实例
# 请参考 $game_party。
# Modified BY: Nanzin
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :actors # 角色
attr_reader :gold # 金钱
attr_reader :steps # 步数
attr_reader :conta
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 建立角色序列
@actors = []
# 初始化金钱与步数
@conta = 0
@gold = 0
@steps = 0
# 生成物品、武器、防具的所持数 hash
@items = {}
@weapons = {}
@armors = {}
end
#--------------------------------------------------------------------------
# ● 设置初期同伴
#--------------------------------------------------------------------------
def setup_starting_members
@actors = []
for i in $data_system.party_members
@actors.push($game_actors[i])
end
end
#--------------------------------------------------------------------------
# ● 设置战斗测试用同伴
#--------------------------------------------------------------------------
def setup_battle_test_members
@actors = []
for battler in $data_system.test_battlers
actor = $game_actors[battler.actor_id]
actor.level = battler.level
gain_weapon(battler.weapon_id, 1)
gain_armor(battler.armor1_id, 1)
gain_armor(battler.armor2_id, 1)
gain_armor(battler.armor3_id, 1)
gain_armor(battler.armor4_id, 1)
actor.equip(0, battler.weapon_id)
actor.equip(1, battler.armor1_id)
actor.equip(2, battler.armor2_id)
actor.equip(3, battler.armor3_id)
actor.equip(4, battler.armor4_id)
actor.recover_all
@actors.push(actor)
end
@items = {}
for i in 1...$data_items.size
if $data_items[i].name != ""
occasion = $data_items[i].occasion
if occasion == 0 or occasion == 1
@items[i] = 99
end
end
end
end
#--------------------------------------------------------------------------
# ● 同伴成员的还原
#--------------------------------------------------------------------------
def refresh
# 游戏数据载入后角色对像直接从 $game_actors
# 分离。
# 回避由于载入造成的角色再设置的问题。
new_actors = []
for i in 0...@actors.size
if $data_actors[@actors[i].id] != nil
new_actors.push($game_actors[@actors[i].id])
end
end
@actors = new_actors
end
#--------------------------------------------------------------------------
# ● 获取最大等级
#--------------------------------------------------------------------------
def max_level
# 同伴人数为 0 的情况下
if @actors.size == 0
return 0
end
# 初始化本地变量 level
level = 0
# 求得同伴的最大等级
for actor in @actors
if level < actor.level
level = actor.level
end
end
return level
end
#--------------------------------------------------------------------------
# ● 加入同伴
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# 获取角色
actor = $game_actors[actor_id]
# 同伴人数未满 4 人、本角色不在队伍中的情况下
if @actors.size < 4 and not @actors.include?(actor)
# 添加角色
@actors.push(actor)
# 还原主角
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# ● 角色离开
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
# 删除觉得
@actors.delete($game_actors[actor_id])
# 还原主角
$game_player.refresh
end
#--------------------------------------------------------------------------
# ● 增加金钱 (减少)
# n : 金额
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = [[@gold + n, 0].max, 9999999].min
end
def guarda_conta(n)
@conta = [[@conta +n,0].max,999999].min
end
#--------------------------------------------------------------------------
# ● 减少金钱
# n : 金额
#--------------------------------------------------------------------------
def lose_gold(n)
# 调用数值逆转 gain_gold
gain_gold(-n)
end
def retira_conta(n)
guarda_conta(-n)
end
#--------------------------------------------------------------------------
# ● 增加步数
#--------------------------------------------------------------------------
def increase_steps
@steps = [@steps + 1, 9999999].min
end
#--------------------------------------------------------------------------
# ● 获取物品的所持数
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_number(item_id)
# 如果 hash 个数数值不存在就返回 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取武器所持数
# weapon_id : 武器 ID
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
# 如果 hash 个数数值不存在就返回 0
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取防具所持数
# armor_id : 防具 ID
#--------------------------------------------------------------------------
def armor_number(armor_id)
# 如果 hash 个数数值不存在就返回 0
return @armors.include?(armor_id) ? @armors[armor_id] : 0
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# ● 减少物品
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# 调用 gain_item 的数值逆转
gain_item(item_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少武器
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_weapon(weapon_id, n)
# 调用 gain_weapon 的数值逆转
gain_weapon(weapon_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少防具
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_armor(armor_id, n)
# 调用 gain_armor 的数值逆转
gain_armor(armor_id, -n)
end
#--------------------------------------------------------------------------
# ● 判断物品可以使用
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_can_use?(item_id)
# 物品个数为 0 的情况
if item_number(item_id) == 0
# 不能使用
return false
end
# 获取可以使用的时候
occasion = $data_items[item_id].occasion
# 战斗的情况
if $game_temp.in_battle
# 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
return (occasion == 0 or occasion == 1)
end
# 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
return (occasion == 0 or occasion == 2)
end
# -------------------------------------------------------------------------
# ● 是否可以装备判定
# -------------------------------------------------------------------------
def item_can_equip?(actor,item)
if actor.level<item.need_lv or
actor.str<item.need_str or
actor.dex<item.need_dex or
actor.agi<item.need_agi or
actor.int<item.need_int
return false
end
return true
end
# -------------------------------------------------------------------------
# ● 是否可以装备的详细判定(颜色设定)
# -------------------------------------------------------------------------
def item_can_equip01?(actor,item)
if actor.level < item.need_lv
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip02?(actor,item)
if actor.str < item.need_str
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip03?(actor,item)
if actor.dex < item.need_dex
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip04?(actor,item)
if actor.agi < item.need_agi
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
def item_can_equip05?(actor,item)
if actor.int < item.need_int
return Color.new(255, 0, 0)
end
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ● 清除全体的行动
#--------------------------------------------------------------------------
def clear_actions
# 清除全体同伴的行为
for actor in @actors
actor.current_action.clear
end
end
#--------------------------------------------------------------------------
# ● 可以输入命令的判定
#--------------------------------------------------------------------------
def inputable?
# 如果一可以输入命令就返回 true
for actor in @actors
if actor.inputable?
return true
end
end
return false
end
#--------------------------------------------------------------------------
# ● 全灭判定
#--------------------------------------------------------------------------
def all_dead?
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
return false
end
# 同伴中无人 HP 在 0 以上
for actor in @actors
if actor.hp > 0
return false
end
end
# 全灭
return true
end
#--------------------------------------------------------------------------
# ● 检查连续伤害 (地图用)
#--------------------------------------------------------------------------
def check_map_slip_damage
for actor in @actors
if actor.hp > 0 and actor.slip_damage?
actor.hp -= [actor.maxhp / 100, 1].max
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
$game_temp.gameover = $game_party.all_dead?
end
end
end
#--------------------------------------------------------------------------
# ● 对像角色的随机确定
# hp0 : 限制为 HP 0 的角色
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# 初始化轮流
roulette = []
# 循环
for actor in @actors
# 符合条件的场合
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
# 获取角色职业的位置 [位置]
position = $data_classes[actor.class_id].position
# 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
n = 4 - position
# 添加角色的轮流 n 回
n.times do
roulette.push(actor)
end
end
end
# 轮流大小为 0 的情况
if roulette.size == 0
return nil
end
# 转轮盘赌,决定角色
return roulette[rand(roulette.size)]
end
#--------------------------------------------------------------------------
# ● 对像角色的随机确定 (HP 0)
#--------------------------------------------------------------------------
def random_target_actor_hp0
return random_target_actor(true)
end
#--------------------------------------------------------------------------
# ● 对像角色的顺序确定
# actor_index : 角色索引
#--------------------------------------------------------------------------
def smooth_target_actor(actor_index)
# 取得对像
actor = @actors[actor_index]
# 对像存在的情况下
if actor != nil and actor.exist?
return actor
end
# 循环
for actor in @actors
# 对像存在的情况下
if actor.exist?
return actor
end
end
end
#--------------------------------------------------------------------------
# ● 完整鼠标系统
#--------------------------------------------------------------------------
def update
mouse_x, mouse_y = Mouse.get_mouse_pos
@mtp_x = mouse_x
@mtp_y = mouse_y
unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
#得到鼠标图标方向
$mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y) if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
else
#令鼠标图标为正常
$mouse_icon_id = 0 if @mouse_sta != 2
end
#单击鼠标时进行判断寻路或跟随
if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
unless $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
#初始化
@mouse_sta = 1
p_direction = 5
#检查鼠标处能否开启事件
event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
#若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
@mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
if @mouse_sta != 2
#鼠标状态不为跟随状态则取数据并初始化路径
trg_x = (mouse_x + $game_map.display_x / 4) / 32
trg_y = (mouse_y + $game_map.display_y / 4) / 32
@paths = []
@paths_id = 0
if event_start == 0 #若不能开启事件
if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
find_path = Find_Path.new
@paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
end
else #若能开启事件则改变角色朝向
@direction = p_direction
end
end
end
end
#开始移动
if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #排除无效情况
if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
case @paths[@paths_id] #判断路径
when 6
@last_move_x = true
move_right
@paths_id += 1
@direction = 6
when 4
@last_move_x = true
move_left
@paths_id += 1
@direction = 4
when 2
@last_move_x = false
move_down
@direction = 2
@paths_id += 1
when 8
@last_move_x = false
move_up
@direction = 8
@paths_id += 1
end
end
end
elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
if Mouse.press?(Mouse::LEFT) #持续按住鼠标
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing #排除无效情况
#跟随方向判断并跟随
if @mtp_x > self.screen_x
if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
@mtp_y - self.screen_y < @mtp_x - self.screen_x
move_right
$mouse_icon_id = 16
@direction = 6
end
if @mtp_y - self.screen_y > @mtp_x - self.screen_x
move_down
$mouse_icon_id = 12
@direction = 2
end
if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
move_up
$mouse_icon_id = 18
@direction = 8
end
end
if @mtp_x < self.screen_x
if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
@mtp_y - self.screen_y < self.screen_x - @mtp_x
move_left
$mouse_icon_id = 14
@direction = 4
end
if @mtp_y - self.screen_y > self.screen_x - @mtp_x
move_down
$mouse_icon_id = 12
@direction = 2
end
if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
move_up
$mouse_icon_id = 18
@direction = 8
end
end
end
else #没状态的情况
$mouse_icon_id = 0
@mouse_sta = 0
@paths_id = @paths.size #终止寻路移动
end
end
self_update
end
end
#Mouse.init
#END { Mouse.exit }
Explicaçao 1
-> linha 16:
- Código:
attr_reader :conta
-> linha 24
- Código:
@conta = 0
-> linha 138
- Código:
def guarda_conta(n)
@conta = [[@conta +n,0].max,999999].min
end
ex:$game_party.guarda_conta(100)
se voce utilizar o comando: print($game_party.conta) o valor mostrado será 100, por que voce aumento 100 na variavel @conta!
-> linha 151
- Código:
def retira_conta(n)
guarda_conta(-n)
end
ex: $game_party.retira_conta(100)
agora o @conta valerá 0!
Parts:
2ª Part
Última edição por Nanzin em Seg Nov 28, 2011 8:44 pm, editado 1 vez(es)
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Re: [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 1
\oooo/
Muito bom Nanzin, a tempos procurava por isto, pedi a vários mas ninguém fez pra mim..
Tu é fera!
1º A postar \o
Muito bom Nanzin, a tempos procurava por isto, pedi a vários mas ninguém fez pra mim..
Tu é fera!
1º A postar \o
_________________
Ninguém pode ser perfeito, mas todos podem ser melhores.
Satheios- Aldeia Friend
- Medalhas :
Mensagens : 1248
Créditos : 306
Re: [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 1
Aee nanzin mt bom valeu po postar *-*
_________________
- Pessoas que admiro:
- RD12 - Por ele sempre ajudar os outros e ser um cara mt foda.
Cidiomar - O melhor Scripter que conheço
Felix Blayder - The Best
emilyoly- Diva
- Mensagens : 526
Créditos : 83
Re: [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 1
@emily > espero que façam bom Proveito!
_________________
Para Aqueles que gostam de Min e de meu Trabalho;
Upem Meu Pet nao custa nda!!
- Pet:
Nanzin- Membro de Honra
- Mensagens : 1550
Créditos : 252
Tópicos semelhantes
» [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 2
» [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 3 Final
» [Tutorial/AULA] SSFSNPM {Script System Fome Sede NetPlay Master}
» [Tutorial/AULA] Criando TAG's para o NP Master V3.0 ou superior
» [Aula/Tutorial] Sistema de Ferreiro
» [Tutorial/AULA] SBNPM (Sistema de banco Netplay Master) Part 3 Final
» [Tutorial/AULA] SSFSNPM {Script System Fome Sede NetPlay Master}
» [Tutorial/AULA] Criando TAG's para o NP Master V3.0 ou superior
» [Aula/Tutorial] Sistema de Ferreiro
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Tutoriais
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos