赞 409
VIP 0
好人卡 11
积分 391
经验 242285
最后登录 2025-1-7
在线时间 5735 小时
Lv5.捕梦者
梦石 0
星屑 39131
在线时间 5735 小时
注册时间 2006-11-10
帖子 6633
本帖最后由 灯笼菜刀王 于 2018-4-30 01:44 编辑
理直气壮的连贴
其实SailCat前辈的技能依赖1.2里就已经可以实现你要的基本效果了
具体做法 : 第一步,先"填弹". 让技能和变量勾搭. 在你要填弹的技能备注#的后面补上 cv={1=>5} 表示使用这个技能要消耗1号变量5点.变量数值不够不让使用, 你的目标3就实现了.
这样1号变量就是这个技能/武器的残弹.
---------------------------------------------------------------------------------
然后就是把它显示出来, 到 window_skill,
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 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, bitmap, Rect.new(0, 0, 32, 32), opacity)
self.contents.draw_text(x + 32, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
if skill._cv != nil
a = skill._cv.keys[0]
self.contents.draw_text(x + 200, y, 80, 32, "残弹" + $game_variables[a].to_s, 2)
end
end
填上红色的部分就OK, 位置可以自己调整, 只要有"填弹"的技能, 就会显示出这个, 没设置填弹不显示.
上面蓝色的那句是"SP消耗" 如果你的热兵器不消耗SP,那可以把上面红色句子改造下
if skill._cv != nil
XXXXX
else
蓝色句子移到这里来
end
这样显示残弹就不显示SP了.
------------------------------------------------------------------------------
然后, 塞上这个脚本, 用汉字当做函数名的应该就不会冲突了吧~~~
WEAPON_AMMO = { 10 => [ 1 ,1 ] , 28 => [ 99 ,5 ] } # 武器ID => [残弹变量, 普通攻击消耗的子弹数量]
MAX_AMMO = { 1 =>[ 10 ,100 ] , 2 =>[ 30 ,101 ] } # 残弹变量 =>[装填上限,需要的道具ID]
class Game_Actor < Game_Battler
def 残弹
if WEAPON_AMMO[ @weapon_id] != nil
return $game_variables [ WEAPON_AMMO[ @weapon_id] [ 0 ] ]
else
return -1
end
end
def 上弹
if WEAPON_AMMO[ @weapon_id] != nil
a = WEAPON_AMMO[ @weapon_id] [ 0 ]
b = $game_party .item_number ( MAX_AMMO[ a] [ 1 ] )
if $game_variables [ a] < MAX_AMMO[ a] [ 0 ] && b > 0
$game_party .lose_item ( MAX_AMMO[ a] [ 1 ] , [ MAX_AMMO[ a] [ 0 ] -$game_variables[ a] ,0 ] .max )
$game_variables [ a] = [ MAX_AMMO[ a] [ 0 ] ,b] .min
$game_variables [ 50 ] = "子弹装填完毕"
elsif b <= 0
$game_variables [ 50 ] = "子弹不足"
elsif $game_variables [ a] >= MAX_AMMO[ a] [ 0 ]
$game_variables [ a] = MAX_AMMO[ a] [ 0 ]
$game_variables [ 50 ] = "子弹已经满了"
end
else
$game_variables [ 50 ] = "这个武器没办法装子弹"
end
end
end
def 满弹
for i in MAX_AMMO.keys
a = $game_party .item_number ( MAX_AMMO[ i] [ 1 ] )
if $game_variables [ i] < MAX_AMMO[ i] [ 0 ] && a > 0
$game_party .lose_item ( MAX_AMMO[ i] [ 1 ] , [ MAX_AMMO[ i] [ 0 ] -$game_variables[ i] ,0 ] .max )
$game_variables [ i] = [ MAX_AMMO[ i] [ 0 ] ,a] .min
end
end
end
WEAPON_AMMO = { 10 => [ 1 ,1 ] , 28 => [ 99 ,5 ] } # 武器ID => [残弹变量, 普通攻击消耗的子弹数量]
MAX_AMMO = { 1 =>[ 10 ,100 ] , 2 =>[ 30 ,101 ] } # 残弹变量 =>[装填上限,需要的道具ID]
class Game_Actor < Game_Battler
def 残弹
if WEAPON_AMMO[ @weapon_id] != nil
return $game_variables [ WEAPON_AMMO[ @weapon_id] [ 0 ] ]
else
return -1
end
end
def 上弹
if WEAPON_AMMO[ @weapon_id] != nil
a = WEAPON_AMMO[ @weapon_id] [ 0 ]
b = $game_party .item_number ( MAX_AMMO[ a] [ 1 ] )
if $game_variables [ a] < MAX_AMMO[ a] [ 0 ] && b > 0
$game_party .lose_item ( MAX_AMMO[ a] [ 1 ] , [ MAX_AMMO[ a] [ 0 ] -$game_variables[ a] ,0 ] .max )
$game_variables [ a] = [ MAX_AMMO[ a] [ 0 ] ,b] .min
$game_variables [ 50 ] = "子弹装填完毕"
elsif b <= 0
$game_variables [ 50 ] = "子弹不足"
elsif $game_variables [ a] >= MAX_AMMO[ a] [ 0 ]
$game_variables [ a] = MAX_AMMO[ a] [ 0 ]
$game_variables [ 50 ] = "子弹已经满了"
end
else
$game_variables [ 50 ] = "这个武器没办法装子弹"
end
end
end
def 满弹
for i in MAX_AMMO.keys
a = $game_party .item_number ( MAX_AMMO[ i] [ 1 ] )
if $game_variables [ i] < MAX_AMMO[ i] [ 0 ] && a > 0
$game_party .lose_item ( MAX_AMMO[ i] [ 1 ] , [ MAX_AMMO[ i] [ 0 ] -$game_variables[ i] ,0 ] .max )
$game_variables [ i] = [ MAX_AMMO[ i] [ 0 ] ,a] .min
end
end
end
WEAPON_AMMO = {10 => [1,1], 28 => [99,5]} # 武器ID => [残弹变量, 普通攻击消耗的子弹数量]
MAX_AMMO = {1 =>[10,100], 2 =>[30,101]} # 残弹变量 =>[装填上限,需要的道具ID]
在这里设置武器对应的变量和要使用的弹药就可以了, 按格式, 把要新加的组合塞进大括号里
那个随便弹药都能用的炮先别管......
-----------------------------------------------------------
然后就是用法
要补充满弹药, 就脚本写 满弹 就好了,注意别用繁体... 可以事件脚本用,也可以塞到任意脚本里.
比如战斗结束后,
#--------------------------------------------------------------------------
# ● 战斗结束
# result : 結果 (0:胜利 1:失败 2:逃跑)
#--------------------------------------------------------------------------
def battle_end(result)
# 清除战斗中标志
$game_temp.in_battle = false
# 清除全体同伴的行动
$game_party.clear_actions
# 解除战斗用状态
for actor in $game_party.actors
actor.remove_states_battle
end
# 清除敌人
$game_troop.enemies.clear
# 调用战斗返回调用
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# 切换到地图画面
满弹
$scene = Scene_Map.new
end
这样战斗结束自动补满弹药.
要单独补子弹. 就用事件脚本 $game_actors[编号].上弹 这样就给装备的武器补子弹了. 提示用默认的50号变量, 要改的话就到脚本里改编号就行, 比如最简单最绿色的 显示对话: \V[50]
$game_actors[编号].残弹, 这个可以用来得到所持武器的残弹量, 没子弹设置的话,得到的是 -1.
最后, 普通攻击消耗弹药, 没子弹的时候, 选择攻击会一直提示错误音效
找到这个地方, 默认脚本是在 scene battle3里
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 基本命令)
#--------------------------------------------------------------------------
def update_phase3_basic_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 转向前一个角色的指令输入
phase3_prior_actor
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 角色指令窗口光标位置分之
case @actor_command_window.index
when 0 # 攻击
if @active_battler.残弹 >= 0
if @active_battler.残弹 == 0
$game_system.se_play($data_system.buzzer_se)
return
else
a = WEAPON_AMMO[@active_battler.weapon_id][0]
$game_variables[a] -= WEAPON_AMMO[@active_battler.weapon_id][1]
end
end
# 演奏确定 SE
$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 # 特技
塞上红色部分即可