Project1

标题: 好久没做游戏了,上来请教个问题~~~ [打印本页]

作者: z2214557w    时间: 2016-9-22 08:32
标题: 好久没做游戏了,上来请教个问题~~~
我想做个类似于商人的职业,只要有该职业的人在队伍里,买东西都能半价。
或者做个类似于降价的被动技能,只要有这个技能,买东西都半价。
请问这个该怎么解决。
谢谢大家~~~~
作者: 鸟猫    时间: 2016-9-22 08:49
购买之前进行角色判断然后修改商品价格
作者: z2214557w    时间: 2016-9-22 09:27
鸟猫 发表于 2016-9-22 08:49
购买之前进行角色判断然后修改商品价格

可是我看了一下好像没有修改价格的选项
作者: hys111111    时间: 2016-9-22 13:25
本帖最后由 hys111111 于 2016-9-22 13:57 编辑

先加入这个判断队伍里是否存在该职业的ID
  1. class Game_Party
  2.   
  3.   def have_actor_class?(id) # 商人职业ID
  4.     return false if @actors.size == 0
  5.     for actor in @actors
  6.       return true if actor.class_id == id
  7.     end
  8.     return false
  9.   end
  10.   
  11. end
复制代码


然后在根据队伍中是否存在职业ID来修改价格
  1. class Scene_Shop
  2.   
  3.   alias discount_update update
  4.   def update
  5.     if @_old_data == nil
  6.       @_old_data = [$data_items.clone,$data_weapons.clone,$data_armors.clone]
  7.     end
  8.     if $game_party.have_actor_class?(职业ID) and @buy_window.active # 职业ID在这里设置
  9.       for item in $data_items
  10.         item.price = (@_old_data[0][item.id].price / 2).to_i
  11.       end
  12.       for item in $data_weapons
  13.         item.price = (@_old_data[1][item.id].price / 2).to_i
  14.       end
  15.       for item in $data_items
  16.         item.price = (@_old_data[2][item.id].price / 2).to_i
  17.       end
  18.     else
  19.       for item in $data_items
  20.         item.price = @_old_data[0][item.id].price
  21.       end
  22.       for item in $data_weapons
  23.         item.price = @_old_data[1][item.id].price
  24.       en
  25.       for item in $data_items
  26.         item.price = @_old_data[2][item.id].price
  27.       end
  28.     end
  29.     discount_update
  30.   end
  31.   
  32. end
复制代码

作者: z2214557w    时间: 2016-9-22 15:00
hys111111 发表于 2016-9-22 13:25
先加入这个判断队伍里是否存在该职业的ID

好厉害!
这两个脚本要放哪?放脚本编辑器里,还是放商店NPC事件上?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1