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

Project1

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

[有事请教] MZ明雷式敌人的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
182
在线时间
74 小时
注册时间
2022-10-19
帖子
36
跳转到指定楼层
1
发表于 2022-10-26 23:31:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
10星屑
单纯的事件靠近玩家然后开始战斗我会做

我想要的增加效果是这样的:

1.玩家靠近敌人(事件)后,敌人头顶出现一个感叹号,然后开始追击玩家
2.当玩家等级达到一定程度后,这些敌人就不好主动追击玩家,甚至开始逃跑

最佳答案

查看完整内容

参考脚本 MOG_EventSensor.js。这个是当玩家距离事件步数为X时,事件将自动开启独立开关Y,X在事件中设置,Y在脚本插件中设置。

Lv3.寻梦者

梦石
0
星屑
1268
在线时间
160 小时
注册时间
2022-9-17
帖子
101
2
发表于 2022-10-26 23:31:08 | 只看该作者
参考脚本 MOG_EventSensor.js。这个是当玩家距离事件步数为X时,事件将自动开启独立开关Y,X在事件中设置,Y在脚本插件中设置。
  1. //=============================================================================
  2. // MOG_EventSensor.js
  3. //=============================================================================

  4. /*:
  5. * @target MZ
  6. * @plugindesc (v1.0) Sistema de distância de eventos.
  7. * @author Moghunter
  8. *
  9. * @param Self Switch Key
  10. * @desc Definição da Letra da SelfSwitch
  11. * @default D
  12. *
  13. * @help  
  14. * =============================================================================
  15. * +++ MOG - Event Sensor (v1.0) +++
  16. * By Moghunter
  17. * https://atelierrgss.wordpress.com/
  18. * =============================================================================
  19. * Sistema de distância de eventos.
  20. * Dependendo da distância entre o jogador e o evento a página pré determinada
  21. * do evento poderá ser ativada ou não.
  22. * =============================================================================
  23. * Para definir a distância do sensor do evento coloque este comentário no
  24. * evento.
  25. *
  26. * event sensor : X
  27. *
  28. */

  29. //=============================================================================
  30. // ** PLUGIN PARAMETERS
  31. //=============================================================================
  32.   var Imported = Imported || {};
  33.   Imported.MOG_EventSensor = true;
  34.   var Moghunter = Moghunter || {};

  35.    Moghunter.parameters = PluginManager.parameters('MOG_EventSensor');
  36.     Moghunter.sensor_range_key = String(Moghunter.parameters['Self Switch Key'] || "D");

  37. //=============================================================================
  38. // ** Character Base
  39. //=============================================================================

  40. //==============================
  41. // * Init Members
  42. //==============================
  43. var _alias_mog_evensensor_cbase_initMembers = Game_CharacterBase.prototype.initMembers;
  44. Game_CharacterBase.prototype.initMembers = function() {
  45.     _alias_mog_evensensor_cbase_initMembers.call(this);
  46.         this._sensor_range = [false,0];
  47. };

  48. //=============================================================================
  49. // ** Sprite Character
  50. //=============================================================================

  51. //==============================
  52. // * Initialize
  53. //==============================
  54. var _alias_mog_evensensor_schar_initialize = Sprite_Character.prototype.initialize;
  55. Sprite_Character.prototype.initialize = function(character) {
  56.     _alias_mog_evensensor_schar_initialize.call(this,character);
  57.         if (this._character && this._character._eventId) {this._character.check_event_sensor()};
  58. };

  59. //=============================================================================
  60. // ** Scene Map
  61. //=============================================================================

  62. //==============================
  63. // * Terminate
  64. //==============================
  65. var _alias_mog_evensensor_terminate = Scene_Map.prototype.terminate;
  66. Scene_Map.prototype.terminate = function() {
  67.         _alias_mog_evensensor_terminate.call(this);
  68.     $gameMap.events().forEach(function(event) {
  69.         if (event._sensor_range[0]) {$gameSelfSwitches.setValue(event.sensor_key(),false)};
  70.     }, this);       
  71. };

  72. //=============================================================================
  73. // ** Game Event
  74. //=============================================================================

  75. //==============================
  76. // * Setup Page
  77. //==============================
  78. var _alias_mog_evensensor_gevent_setupPage = Game_Event.prototype.setupPage;
  79. Game_Event.prototype.setupPage = function() {
  80.         _alias_mog_evensensor_gevent_setupPage.call(this);
  81.     this.check_event_sensor();
  82. };

  83. //==============================
  84. // * Check Event Sensor
  85. //==============================
  86. Game_Event.prototype.check_event_sensor = function() {
  87.         if (!this._erased && this.page()) {this.list().forEach(function(l) {
  88.                if (l.code === 108) {var comment = l.parameters[0].split(' : ');
  89.                            if (comment[0].toLowerCase() == "event sensor"){
  90.                  this._sensor_range = [true,Number(Math.abs(comment[1]))];
  91.                                  this._need_clear_sensor = false;                          
  92.                            };
  93.                 };
  94.         }, this);};
  95. };

  96. //==============================
  97. // * Update
  98. //==============================
  99. var _mog_event_sensor_gev_update = Game_Event.prototype.update;
  100. Game_Event.prototype.update = function() {
  101.         _mog_event_sensor_gev_update.call(this);
  102.         if (this.needUpdateSensor()) {this.update_sensor()};
  103. };

  104. //==============================
  105. // * Need Update Sensor
  106. //==============================
  107. Game_Event.prototype.needUpdateSensor = function() {
  108.         if (!this._sensor_range[0]) {return false};       
  109.         return true;
  110. };

  111. //==============================
  112. // * Sensor Dis
  113. //==============================
  114. Game_Event.prototype.sensor_dis = function() {
  115.   return Math.abs($gamePlayer.x - this.x) + Math.abs($gamePlayer.y - this.y);
  116. };

  117. //==============================
  118. // * Sensor Key
  119. //==============================
  120. Game_Event.prototype.sensor_key = function() {
  121.    return [this._mapId, this._eventId, Moghunter.sensor_range_key];
  122. };

  123. //==============================
  124. // * Update Sensor
  125. //==============================
  126. Game_Event.prototype.update_sensor = function() {
  127.       var enable   = (this.sensor_dis() <=  this._sensor_range[1]);
  128.       var last_enable = $gameSelfSwitches.value(this.sensor_key());
  129.       if (enable != last_enable) {this.sensor_effect(enable)};
  130. };

  131. //==============================
  132. // * Sensor Effect
  133. //==============================
  134. Game_Event.prototype.sensor_effect = function(enable) {
  135.         $gameSelfSwitches.setValue(this.sensor_key(),enable);
  136. };
复制代码
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1268
在线时间
160 小时
注册时间
2022-9-17
帖子
101
3
发表于 2022-10-27 13:53:32 | 只看该作者




简单举例,【事件页1】就是普通事件,然后加个注释 event sensor : 4   代表距离玩家4步时切换为独立开关D(D是我在脚本插件中设定的)
然后【事件页2】就是玩家距离4步的时候,这个页面就可以设置成 靠近主角 或者是其他移动路径了。

核心就是这样。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
182
在线时间
74 小时
注册时间
2022-10-19
帖子
36
4
 楼主| 发表于 2022-10-27 15:27:25 | 只看该作者
古树旋律 发表于 2022-10-27 13:53
简单举例,【事件页1】就是普通事件,然后加个注释 event sensor : 4   代表距离玩家4步时切换为独立开 ...

明白了!感谢
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-11 03:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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