查看: 3246|回复: 0

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

[复制链接]
梦石
0
星屑
850
在线时间
601 小时
注册时间
2007-12-18
回帖
110
发表于 2019-3-12 14:35:23 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 VIPArcher 于 2022-6-2 14:08 编辑
  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: sumptuaryspade@live.ca
  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. JUMP_KEY = :Z
  38. #不可跳跃区域
  39. NO_JUMP_REGIONS = [10,11]
  40. #禁用跳跃的开关, 开关开启时,玩家无法跳跃
  41. TOGGLE_JUMP_SWITCH = 323
  42. #事件名中包含以下字符的,玩家可以跳跃过该事件
  43. JUMP_EVENT_STRING = "BG"

  44. class Game_Character < Game_CharacterBase
  45.   attr_accessor :carried
  46.   attr_accessor :through
  47.   attr_accessor :priority_type
  48.   attr_accessor :x
  49.   attr_accessor :y
  50.   attr_accessor :direction
  51.   attr_accessor :direction_fix
  52.   attr_accessor :move_succeed
  53.   alias env_screen_y screen_y
  54.   alias env_screen_x screen_x
  55.   def pick_up(event_id)
  56.     @carrying = event_id
  57.     @carrying = $game_map.events[event_id] if $game_map.events[event_id]
  58.     @carrying.through = true
  59.     @carrying.carried = self
  60.     @carrying.priority_type = 2
  61.   end
  62.   def throw
  63.     @carrying.moveto(@x,@y)
  64.     @carrying.direction = @direction
  65.     return unless @carrying.jump_forward_field
  66.     @carrying.thrown
  67.     @carrying.through = false
  68.     @carrying.priority_type = 1
  69.     @carrying.carried = nil
  70.     @carrying = nil
  71.   end
  72.   def screen_y
  73.     @carried ? @carried.screen_y - 24 : env_screen_y
  74.   end
  75.   def screen_x
  76.     @carried ? @carried.screen_x : env_screen_x
  77.   end
  78.   def can_jump?(x,y)
  79.     return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x/2,@y+y/2))
  80.     return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x,@y+y))
  81.     map_passable?(@x+x,@y+y,@direction) && !collide_with_characters?(@x+x,@y+y) &&
  82.       !sp_cwc(@x+x/2,@y+y/2)
  83.   end
  84.   def sp_cwc(x, y)
  85.     $game_map.events_xy_nt(x, y).any? do |event|
  86.       next if event.name.include?(JUMP_EVENT_STRING)
  87.       event.normal_priority? || self.is_a?(Game_Event)
  88.     end
  89.   end
  90.   def jump_forward_field
  91.     return jump_straight(0,2)  if @direction == 2
  92.     return jump_straight(-2,0) if @direction == 4
  93.     return jump_straight(2,0)  if @direction == 6
  94.     return jump_straight(0,-2) if @direction == 8
  95.   end
  96.   def jump_straight(x,y)
  97.     return false if jumping?
  98.     if can_jump?(x,y)
  99.       jump(x,y)
  100.       return true
  101.     else
  102.       jump(0,0)
  103.       return false
  104.     end
  105.   end
  106.   def thrown
  107.   end
  108. end

  109. class Game_Player < Game_Character
  110.   alias throw_cae check_action_event
  111.   alias throw_ms move_straight
  112.   alias throw_update update
  113.   def update
  114.     throw_update
  115.     if !Input.press?(:C) && @grabbed
  116.       @grabbed = nil
  117.       @direction_fix = false
  118.       @move_speed += 1
  119.     @move_frequency += 1
  120.     end
  121.   end
  122.   def move_by_input
  123.     allow = !$game_switches[TOGGLE_JUMP_SWITCH]
  124.     return jump_forward_field if Input.trigger?(JUMP_KEY) && !@grabbed && allow
  125.     return if !movable? || $game_map.interpreter.running?
  126.     return if jumping?
  127.     move_straight(Input.dir4) if Input.dir4 > 0
  128.   end
  129.   def check_action_event
  130.     if @carrying
  131.       throw
  132.       return true
  133.     end
  134.     throw_cae
  135.   end
  136.   def grab(event_id)
  137.     @grabbed = $game_map.events[event_id]
  138.     @move_speed -= 1
  139.     @move_frequency -= 1
  140.     @grabbed.move_speed = @move_speed
  141.     @grabbed.move_frequency = @move_frequency
  142.     @direction_fix = true
  143.   end
  144.   def move_straight(d, tok = true)
  145.     return throw_ms(d, tok) if @grabbed.nil?
  146.     return unless @direction == d || @direction == (d-10).abs
  147.     if @direction == d
  148.       @grabbed.move_straight(d,tok)
  149.       throw_ms(d, tok) if @grabbed.move_succeed
  150.     elsif @direction == (d-10).abs
  151.       throw_ms(d,tok)
  152.       @grabbed.move_straight(d,tok) if @move_succeed
  153.     end
  154.   end
  155. end

  156. class Game_Event < Game_Character
  157.   attr_accessor  :move_speed   
  158.   attr_accessor  :move_frequency
  159.   def thrown
  160.     super
  161.     $game_self_switches[[@map_id, @id, "D"]] = true
  162.   end
  163.   def update
  164.     super
  165.     check_event_trigger_auto
  166.     return unless @interpreter
  167.     @interpreter.setup(@list, @event.id) unless @interpreter.running?
  168.     @interpreter.update unless jumping?
  169.   end
  170.   def name
  171.     @event.name
  172.   end
  173. end

  174. class Game_Interpreter
  175.   def pickup
  176.     $game_player.pick_up(@event_id)
  177.   end
  178.   def grab
  179.     $game_player.grab(@event_id)
  180.   end
  181. end
复制代码


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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部