查看: 7300|回复: 18

[已经解决] 如此简单的一个跳跃事件怎样用纯脚本完美地重现??

[复制链接]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2021-3-3 16:25:36 | 显示全部楼层 |阅读模式
悬赏99星屑已解决
本帖最后由 alexncf125 于 2021-3-3 20:47 编辑


试着用Yanfly的滑冰图块改一下215行[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Slippery Tiles v1.00
# -- Last Updated: 2011.12.03
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-SlipperyTiles"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.03 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Want slippery tiles without needing to make hundreds of events? Now you can!
# This script binds slippery tile properties to individual tiles through usage
# of notetags and terrain tags.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Tileset Notetags - These notetags go in the tileset notebox in the database.
# -----------------------------------------------------------------------------
# <slippery: x>
# <slippery: x, x>
# Sets the tiles marked with terrain tag x to be slippery for that particular
# tileset. When the player walks over a slippery terrain, the player will keep
# moving forward until stopped by an object or until the player lands on ground
# without slippery properties.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module SLIPPERY_TILES
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Sliding Animation -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # Set what sliding frame you want characters to use when they're on
    # slippery tiles. Standing frame is 1.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    SLIDE_FRAME = 2
   
  end # SLIPPERY_TILES
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module TILESET
   
    SLIPPERY = /<(?:SLIPPERY|slippery tile):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # TILESET
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_st load_database; end
  def self.load_database
    load_database_st
    load_notetags_st
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_st
  #--------------------------------------------------------------------------
  def self.load_notetags_st
    groups = [$data_tilesets]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_st
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Tileset
#==============================================================================

class RPG::Tileset
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :slippery
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_st
  #--------------------------------------------------------------------------
  def load_notetags_st
    @slippery = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::TILESET::SLIPPERY
        $1.scan(/\d+/).each { |num|
        @slippery.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Tileset

#==============================================================================
# ■ Game_Map
#==============================================================================

class Game_Map
  
  #--------------------------------------------------------------------------
  # new method: slippery_floor?
  #--------------------------------------------------------------------------
  def slippery_floor?(dx, dy)
    return (valid?(dx, dy) && slippery_tag?(dx, dy))
  end
  
  #--------------------------------------------------------------------------
  # new method: slippery_tag?
  #--------------------------------------------------------------------------
  def slippery_tag?(dx, dy)
    return tileset.slippery.include?(terrain_tag(dx, dy))
  end
  
end # Game_Map

#==============================================================================
# ■ Game_CharacterBase
#==============================================================================

class Game_CharacterBase
  
  #--------------------------------------------------------------------------
  # new method: on_slippery_floor?
  #--------------------------------------------------------------------------
  def on_slippery_floor?; $game_map.slippery_floor?(@x, @y); end
  
  #--------------------------------------------------------------------------
  # new method: slippery_pose?
  #--------------------------------------------------------------------------
  def slippery_pose?
    return false unless on_slippery_floor?
    return false if @step_anime
    return true
  end
  
end # Game_CharacterBase

#==============================================================================
# ■ Game_Player
#==============================================================================

class Game_Player < Game_Character
  
  #--------------------------------------------------------------------------
  # alias method: dash?
  #--------------------------------------------------------------------------
  alias game_player_dash_st dash?
  def dash?
    return false if on_slippery_floor?
    return game_player_dash_st
  end
  
  #--------------------------------------------------------------------------
  # alias method: update
  #--------------------------------------------------------------------------
  alias game_player_update_st update
  def update
    game_player_update_st
    update_slippery
  end
  
  #--------------------------------------------------------------------------
  # new method: update_slippery
  #--------------------------------------------------------------------------
  def update_slippery
    return if $game_map.interpreter.running?
    return unless on_slippery_floor?
    return if moving?
#~     move_straight(@direction)
    ##########
    case @direction
    when 2
      jump(0, 1)
    when 4
      jump(-1, 0)
    when 6
      jump(1, 0)
    when 8
      jump(0, -1)
    end
    ##########
  end
  
  #--------------------------------------------------------------------------
  # new method: pattern
  #--------------------------------------------------------------------------
  def pattern
    return YEA::SLIPPERY_TILES::SLIDE_FRAME if slippery_pose?
    return @pattern
  end
  
end # Game_Player

#==============================================================================
# ■ Game_Follower
#==============================================================================

class Game_Follower < Game_Character
  
  #--------------------------------------------------------------------------
  # new method: pattern
  #--------------------------------------------------------------------------
  def pattern
    return YEA::SLIPPERY_TILES::SLIDE_FRAME if slippery_pose?
    return @pattern
  end
  
end # Game_Follower

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

但其跳跃的时机我做不到与事件制的跳跃时机同个样子
求问怎样弄如同事件制的的跳跃时机

最佳答案

查看完整内容

这个不是事件脚本的问题,查阅一下Game_CharacterBase 396-400行,工程中跳跃事件被触发时,实际上角色并没有走到跳跃图块上 而Jumping Tiles中是这样写的 [s]等我想一下解决方法[/s] 有了,注意不止修改了脚本,还修改了地图通行
梦石
2
星屑
13779
在线时间
2319 小时
注册时间
2011-6-4
回帖
586
发表于 2021-3-3 16:25:37 | 显示全部楼层
本帖最后由 真·可乐 于 2021-3-3 20:19 编辑

这个不是事件脚本的问题,查阅一下Game_CharacterBase 396-400行,工程中跳跃事件被触发时,实际上角色并没有走到跳跃图块上
  1.   def check_event_trigger_touch_front
  2.     x2 = $game_map.round_x_with_direction(@x, @direction)
  3.     y2 = $game_map.round_y_with_direction(@y, @direction)
  4.     check_event_trigger_touch(x2, y2)
  5.   end
复制代码

而Jumping Tiles中是这样写的
  1.   def update_jumping
  2.     return if $game_map.interpreter.running?
  3.     return unless on_jumping_floor? #角色需走到跳跃图块上才会执行下面的内容
  4.     return if moving?
  5. #~     move_straight(@direction)
  6.     ##########
  7.     case @direction
  8.     when 2
  9.       jump(0, 1)
  10.     when 4
  11.       jump(-1, 0)
  12.     when 6
  13.       jump(1, 0)
  14.     when 8
  15.       jump(0, -1)
  16.     end
  17.     ##########
  18.   end
复制代码


等我想一下解决方法
有了,注意不止修改了脚本,还修改了地图通行
Data改.zip (186.2 KB, 下载次数: 81)

点评

这个也不用改地图通行,而且改了也没用,改改脚本注释掉相关地形向上跳的判定就可以了。  发表于 2021-3-3 20:21
改好了  发表于 2021-3-3 20:20
宝可梦还真没玩过,不过这个很好改  发表于 2021-3-3 20:16
相同=>相信  发表于 2021-3-3 19:35
啊这...相同大大也玩过宝可梦吧...斜坡是不能从下往上跳的...所以那个地图通行能不能不改...  发表于 2021-3-3 19:35

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

BUG反馈请加QQ 529283039
水友群 917854767

回复

使用道具 举报

梦石
2
星屑
13779
在线时间
2319 小时
注册时间
2011-6-4
回帖
586
发表于 2021-3-3 17:25:54 | 显示全部楼层
本帖最后由 真·可乐 于 2021-3-3 17:29 编辑

附图太小了。想要和事件跳跃效果一模一样的话,直接用事件脚本呗

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

BUG反馈请加QQ 529283039
水友群 917854767

回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-3-3 18:04:23 | 显示全部楼层
真·可乐 发表于 2021-3-3 17:25
附图太小了。想要和事件跳跃效果一模一样的话,直接用事件脚本呗

更新了一下附图, 应该大了...
事件脚本的方法我按我会的试过了, 跳跃时机还是不相同...

点评

跳跃时机具体是指?  发表于 2021-3-3 18:20
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-3-3 18:44:59 | 显示全部楼层
真·可乐 发表于 2021-3-3 17:25
附图太小了。想要和事件跳跃效果一模一样的话,直接用事件脚本呗

不太好说明...
做了个范例https://share.weiyun.com/2uZCFJBn
应该可以看到"左方事件制的斜坡"与"右方脚本制的斜坡"
从上往下跳的时机是不同的
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-3-3 20:44:13 | 显示全部楼层
本帖最后由 alexncf125 于 2021-3-3 20:45 编辑

@真·可乐
谢谢大大~先认可答案~
不过其实呢...在数据库图块设定那里, 那格斜坡周边是有其他几种斜坡的说...
所以其实呢...之后是会有"从左向右跳而不能右向左通行的斜坡"和"从右向左跳而不能左向右通行的斜坡"的说...
因此呢...如果地图通行一定得按大大的修改的话...左/右斜坡好像无法制作了...

点评

我想也是, 貌似得改不少地方, 我先自己研究一下, 不行的话可能又得麻烦大大您了, 晚安~  发表于 2021-3-3 20:54
我画个图吧  发表于 2021-3-3 20:54
改,都可以改,但是都不是图块通行的问题,用地形标志区分开,再修改脚本就可以了  发表于 2021-3-3 20:48
回复

使用道具 举报

梦石
2
星屑
13779
在线时间
2319 小时
注册时间
2011-6-4
回帖
586
发表于 2021-3-3 21:03:24 | 显示全部楼层
本帖最后由 真·可乐 于 2021-3-3 21:32 编辑

TT.jpg
触发跳跃的时候,角色并不用站在地形上,所以地形设置为不可通行

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 塞糖

查看全部评分

BUG反馈请加QQ 529283039
水友群 917854767

回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-3-3 21:45:08 | 显示全部楼层
真·可乐 发表于 2021-3-3 21:03
触发跳跃的时候,角色并不用站在地形上,所以地形设置为不可通行


我试著加上下面这么一段脚本和"补回when468"和"图块设置为单向通行"后, 好像可以了...
但不知道为什么那通行度得设成原本的相反方向...
原本(5L)的:

现在(https://share.weiyun.com/74efrPyQ)的:

  1. class Game_Player < Game_Character
  2.   alias move_straight_frontzcl202133 move_straight
  3.   def move_straight(d, turn_ok = true)
  4.     x2 = $game_map.round_x_with_direction(@x, d)
  5.     y2 = $game_map.round_y_with_direction(@y, d)
  6.     if $game_map.jumping_floor?(x2, y2)
  7.       return set_direction(d) unless passable?(x2, y2, d)
  8.     end
  9.     move_straight_frontzcl202133(d, turn_ok)
  10.   end
  11. end
复制代码

点评

牛的,这样设置通行度,角色也在地形格子之前触发跳跃,比我想的方法简单多了。  发表于 2021-3-3 22:13
牛的,这样设置通行度,角色也在地形格子之前触发跳跃,比我想的方法简单多了。  发表于 2021-3-3 22:13
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部