设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2543|回复: 0
打印 上一主题 下一主题

[已经过期] 关于多种地图能力脚本的问题

[复制链接]

Lv2.观梦者

梦石
0
星屑
795
在线时间
598 小时
注册时间
2007-12-18
帖子
173
跳转到指定楼层
1
发表于 2019-3-12 14:35:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 VIPArcher 于 2022-6-2 14:08 编辑

RUBY 代码复制
  1. # 多种地图能力 v1.1
  2. #----------#
  3. #特点: 我也不懂该叫什么。此脚本可以让玩家拥有跳跃,投掷和抓东西的能力。
  4. #
  5. #使用方法:    即插即用,在下面根据自己的需要进行设定
  6. #.
  7. #           跳跃:
  8. #            按跳跃键(A键)可以让玩家向前跳跃两格.
  9. #            不会跳到不可通行的图块上,也不会跳到"不可跳跃区域"的图块上.
  10. #            可以通过开关禁用此功能.
  11. #      
  12. #           投掷:
  13. #            使用脚本: pickup
  14. #            可以被捡起的事件会被玩家捡起.再次按下确认键后,事件会被投掷
  15. #            2图块远的位置,不会丢到不可通行的图块上。
  16. #            事件被投掷且落地后,会自动开启其D独立开关。
  17. #            (事件可以捡起其他事件,使用脚本:
  18. #             pick_up(事件_id) - 但只能在移动路线中使用.
  19. #             也可以被投掷,使用脚本:
  20. #             throw - 同样只能在移动路线中使用.)
  21. #
  22. #           抓取:
  23. #            使用脚本: grab
  24. #            事件可以被玩家抓取.抓取时,玩家只能向前或向后移动,再按下确定键后
  25. #            可以松手。
  26. #
  27. #----------#
  28. #-- Script by: V.M of D.T
  29. #
  30. #- Questions or comments can be:
  31. #    given by email: [email protected]
  32. #    provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
  33. #   All my other scripts and projects can be found here: [url]http://daimonioustails.weebly.com/[/url]
  34. #
  35. #- Free to use in any project with credit given, donations always welcome!
  36.  
  37. #跳跃键:
  38. JUMP_KEY = :Z
  39. #不可跳跃区域
  40. NO_JUMP_REGIONS = [10,11]
  41. #禁用跳跃的开关, 开关开启时,玩家无法跳跃
  42. TOGGLE_JUMP_SWITCH = 323
  43. #事件名中包含以下字符的,玩家可以跳跃过该事件
  44. JUMP_EVENT_STRING = "BG"
  45.  
  46. class Game_Character < Game_CharacterBase
  47.   attr_accessor :carried
  48.   attr_accessor :through
  49.   attr_accessor :priority_type
  50.   attr_accessor :x
  51.   attr_accessor :y
  52.   attr_accessor :direction
  53.   attr_accessor :direction_fix
  54.   attr_accessor :move_succeed
  55.   alias env_screen_y screen_y
  56.   alias env_screen_x screen_x
  57.   def pick_up(event_id)
  58.     @carrying = event_id
  59.     @carrying = $game_map.events[event_id] if $game_map.events[event_id]
  60.     @carrying.through = true
  61.     @carrying.carried = self
  62.     @carrying.priority_type = 2
  63.   end
  64.   def throw
  65.     @carrying.moveto(@x,@y)
  66.     @carrying.direction = @direction
  67.     return unless @carrying.jump_forward_field
  68.     @carrying.thrown
  69.     @carrying.through = false
  70.     @carrying.priority_type = 1
  71.     @carrying.carried = nil
  72.     @carrying = nil
  73.   end
  74.   def screen_y
  75.     @carried ? @carried.screen_y - 24 : env_screen_y
  76.   end
  77.   def screen_x
  78.     @carried ? @carried.screen_x : env_screen_x
  79.   end
  80.   def can_jump?(x,y)
  81.     return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x/2,@y+y/2))
  82.     return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x,@y+y))
  83.     map_passable?(@x+x,@y+y,@direction) && !collide_with_characters?(@x+x,@y+y) &&
  84.       !sp_cwc(@x+x/2,@y+y/2)
  85.   end
  86.   def sp_cwc(x, y)
  87.     $game_map.events_xy_nt(x, y).any? do |event|
  88.       next if event.name.include?(JUMP_EVENT_STRING)
  89.       event.normal_priority? || self.is_a?(Game_Event)
  90.     end
  91.   end
  92.   def jump_forward_field
  93.     return jump_straight(0,2)  if @direction == 2
  94.     return jump_straight(-2,0) if @direction == 4
  95.     return jump_straight(2,0)  if @direction == 6
  96.     return jump_straight(0,-2) if @direction == 8
  97.   end
  98.   def jump_straight(x,y)
  99.     return false if jumping?
  100.     if can_jump?(x,y)
  101.       jump(x,y)
  102.       return true
  103.     else
  104.       jump(0,0)
  105.       return false
  106.     end
  107.   end
  108.   def thrown
  109.   end
  110. end
  111.  
  112. class Game_Player < Game_Character
  113.   alias throw_cae check_action_event
  114.   alias throw_ms move_straight
  115.   alias throw_update update
  116.   def update
  117.     throw_update
  118.     if !Input.press?(:C) && @grabbed
  119.       @grabbed = nil
  120.       @direction_fix = false
  121.       @move_speed += 1
  122.     @move_frequency += 1
  123.     end
  124.   end
  125.   def move_by_input
  126.     allow = !$game_switches[TOGGLE_JUMP_SWITCH]
  127.     return jump_forward_field if Input.trigger?(JUMP_KEY) && !@grabbed && allow
  128.     return if !movable? || $game_map.interpreter.running?
  129.     return if jumping?
  130.     move_straight(Input.dir4) if Input.dir4 > 0
  131.   end
  132.   def check_action_event
  133.     if @carrying
  134.       throw
  135.       return true
  136.     end
  137.     throw_cae
  138.   end
  139.   def grab(event_id)
  140.     @grabbed = $game_map.events[event_id]
  141.     @move_speed -= 1
  142.     @move_frequency -= 1
  143.     @grabbed.move_speed = @move_speed
  144.     @grabbed.move_frequency = @move_frequency
  145.     @direction_fix = true
  146.   end
  147.   def move_straight(d, tok = true)
  148.     return throw_ms(d, tok) if @grabbed.nil?
  149.     return unless @direction == d || @direction == (d-10).abs
  150.     if @direction == d
  151.       @grabbed.move_straight(d,tok)
  152.       throw_ms(d, tok) if @grabbed.move_succeed
  153.     elsif @direction == (d-10).abs
  154.       throw_ms(d,tok)
  155.       @grabbed.move_straight(d,tok) if @move_succeed
  156.     end
  157.   end
  158. end
  159.  
  160. class Game_Event < Game_Character
  161.   attr_accessor  :move_speed   
  162.   attr_accessor  :move_frequency
  163.   def thrown
  164.     super
  165.     $game_self_switches[[@map_id, @id, "D"]] = true
  166.   end
  167.   def update
  168.     super
  169.     check_event_trigger_auto
  170.     return unless @interpreter
  171.     @interpreter.setup(@list, @event.id) unless @interpreter.running?
  172.     @interpreter.update unless jumping?
  173.   end
  174.   def name
  175.     @event.name
  176.   end
  177. end
  178.  
  179. class Game_Interpreter
  180.   def pickup
  181.     $game_player.pick_up(@event_id)
  182.   end
  183.   def grab
  184.     $game_player.grab(@event_id)
  185.   end
  186. end


这个脚本有关投掷物品的时候,拾取物品不投掷带到下个地图拾取的物品会消失,返回本地图时拾取的物体会归原位,但无法再次拾取物品了,请问如何解决
以下为案例
Project1.zip (1.43 MB, 下载次数: 93)
2007-2017.10年rpg制作生涯···
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-25 23:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表