Hi, I wanted to add traps to my game like fear&hunger game.
For people who didn't play fear&hunger it's rpg maker game(Warning it have some +18 stuff) that have a system when player use the trap item it set on the ground, when enemy stand on it it cut his legs but that a mechanic I am not gonna use.
What I wan for the trap is:
-To be set on the ground/map when player click on trap item and it stay at that location even if player left the map.
-When enemy npc/event stand on it he change? I am not sure how they done it but my goal is for the enemy to not be able to move, the trap to be lost and the enemy have debuff states.
How to make traps like fear&hunger?
● ARCHIVED · READ-ONLY
-
-
you'll need a plugin for clone event, and depending on its functions maybe a remember event position plugin (although that should be part of the clone event in most cases).
remember that events only exists on the current map - the game will remember if you cloned a trap on a different map, but neither will that trap event trigger nor any other event move while the player is on a different map. -
You can do this either by events or tiles/regions. In either case you'll need an event spawner or tile changer.
-
Thank you, I saw yanfly video about event spawner, what the differance between spawned event and copied event?you'll need a plugin for clone event, and depending on its functions maybe a remember event position plugin (although that should be part of the clone event in most cases).
remember that events only exists on the current map - the game will remember if you cloned a trap on a different map, but neither will that trap event trigger nor any other event move while the player is on a different map.
My idea is to spawn the event using item and I want it to stay on map, and yes I understand if player is not at that map nothing happens in it, but I could find a way to have something fall in trap by chance or maybe don't need to.
I think event spawner or copy event will work well for what I need.You can do this either by events or tiles/regions. In either case you'll need an event spawner or tile changer.
but now thinking about it tile changer also can do something similar if I do par event that check if enemies are on a tile with a tag, but also could be laggy that way. -
If you're doing it by events you might want to use a combination of these two plugins
MV Event Spawner [RMMV] Event Trigger Event by CT_BoltSome plugin authors make a differentiation, some don't. Event spawners typically have all the template events on a different map that you copy from onto the current map and you spawn fresh copies during the game.differance between spawned event and copied event -
I used Yanfly events spawner to spawn the traps but I am not sure if CT bolt plugin work with it or not, I didn't buy the plugin yet.
Also is ther other ways to trigger events by other events? -
Why don't you actually try it instead of dismissing it and asking for alternatives? The CT_Bolt plugin is free. Yanfly's spawner costs money but Galv's one that I linked is free (and better IMO)
-
Sorry I thought it was not free.Why don't you actually try it instead of dismissing it and asking for alternatives? The CT_Bolt plugin is free. Yanfly's spawner costs money but Galv's one that I linked is free (and better IMO)
I am testing it right now but It need coding to trigger the other events and I have no idea how to do that.
Is there a good tutorial for this plugin? -
var event = $gameMap.eventsXyNt(x, y)[0];
if (!$dataMap.events[event._eventId].meta.noEventTrigger){
event._triggeredBy = this;
$gameSelfSwitches.setValue([$gameMap._mapId, event._eventId, 'A'],true);
};
It worked with this code but if the triggered event is below character it don't work.
If it same as character it work.
Working on trap I prefare if it was below character.
Is there anything in this code I can change to make it work if the triggered event is below character? -
Hmm, I looked at the code and it's being triggered by the event not being able to pass when moving forward, so if the other event is a different priority it can pass. So yes, it would require editing that part.
Could you try editing on line 100
Change this block
Code:To thisif (this.isMovementSucceeded()) { } else { this.checkEventTriggerEventTouchFront(d); } };
Code:this.checkEventTriggerEventTouchFront(d); }; -
Thank you it worked below character but the problem is it didn't work as I intend for it to work.Hmm, I looked at the code and it's being triggered by the event not being able to pass when moving forward, so if the other event is a different priority it can pass. So yes, it would require editing that part.
Could you try editing on line 100
Change this block
Code:To thisif (this.isMovementSucceeded()) { } else { this.checkEventTriggerEventTouchFront(d); } };
Code:this.checkEventTriggerEventTouchFront(d); };
The trigger happen not when the character is on top of the trap but when he face the trap like it is "same as character" because maybe that how the plugin was build on.
I can kinda fix this if I make the character/enemy in the switch I will activate do 1 step forward so it look like they fall into the trap, if there is a better fix that would be better for me or others who will want to use it in the same function as me.
I have other question because I don't understand coding, how in the comment can I change the self switch of the triggered events?
The code I use do change only the trigger events, but in code only when the event have a trriger tag change the event that have the code/comment triggered.
So in my case I made the enemy is the trigger to activate the trap self switch A who is the triggered.
But I will need to activate self switch for both events so I can change the enemy to be rooted and damaged and I can discard the trap.
Again thank you very much for your help.
Edit: I found how to change the triggered event self switch
var currentEvent = $gameMap.event(this._eventId); $gameSelfSwitches.setValue([$gameMap._mapId, currentEvent._eventId, 'A'], true);
Edit2: I can't explain this but there is something wrong and I understand it based on the script, this video can explain better.
When the event trigger I change the event to self switch A to make it move forward to the trap.
But you can see if the event step on the trap without facing it the event don't trigger. -
Thank you it worked below character but the problem is it didn't work as I intend for it to work.
The trigger happen not when the character is on top of the trap but when he face the trap like it is "same as character" because maybe that how the plugin was build on.
I can kinda fix this if I make the character/enemy in the switch I will activate do 1 step forward so it look like they fall into the trap, if there is a better fix that would be better for me or others who will want to use it in the same function as me.
I have other question because I don't understand coding, how in the comment can I change the self switch of the triggered events?
The code I use do change only the trigger events, but in code only when the event have a trriger tag change the event that have the code/comment triggered.
So in my case I made the enemy is the trigger to activate the trap self switch A who is the triggered.
But I will need to activate self switch for both events so I can change the enemy to be rooted and damaged and I can discard the trap.
Again thank you very much for your help.
Edit: I found how to change the triggered event self switch
var currentEvent = $gameMap.event(this._eventId); $gameSelfSwitches.setValue([$gameMap._mapId, currentEvent._eventId, 'A'], true);
Edit2: I can't explain this but there is something wrong and I understand it based on the script, this video can explain better.
When the event trigger I change the event to self switch A to make it move forward to the trap.
But you can see if the event step on the trap without facing it the event don't trigger.
The problem with making more changes to the plugin to fit the use case you want is that it will break the original functionality.
You would have to do something like:
If the second event is in front of the first event and the second event's priority is below player, make the first event move forward.
Is that what you want? -
I don't understand coding but more of if the event with code on top of the trigger or same map coordinates (x,y) the triggered event activate.The problem with making more changes to the plugin to fit the use case you want is that it will break the original functionality.
You would have to do something like:
If the second event is in front of the first event and the second event's priority is below player, make the first event move forward.
Is that what you want?
I can keep it like this, maybe like the enemy "escaped" the trap or something if they didn't face it.
So far this is the best thing I can achive at least. -
Sadly this crash if the trap event is spawned.
I tried to spawn the trap event with Galv spawner with new project it also crash.
I guess I am gonna give up on this concept. -
Could you try overwriting this block
JavaScript:Game_Event.prototype.checkEventTriggerEventTouchFront = function(d) { var x2 = $gameMap.roundXWithDirection(this._x, d); var y2 = $gameMap.roundYWithDirection(this._y, d); this.checkEventTriggerEventTouch(x2, y2); };
With this
JavaScript:Game_Event.prototype.checkEventTriggerEventTouchFront = function(d) { if (!this.isMovementSucceeded()){ var x2 = $gameMap.roundXWithDirection(this._x, d); var y2 = $gameMap.roundYWithDirection(this._y, d); this.checkEventTriggerEventTouch(x2, y2); } else{ this.checkEventTriggerEventTouch(this._x, this._y); } };
Also can you set spawn overlap to true on the Galv plugin? -
Sorry for late response I think I will give up on this,Could you try overwriting this block
JavaScript:Game_Event.prototype.checkEventTriggerEventTouchFront = function(d) { var x2 = $gameMap.roundXWithDirection(this._x, d); var y2 = $gameMap.roundYWithDirection(this._y, d); this.checkEventTriggerEventTouch(x2, y2); };
With this
JavaScript:Game_Event.prototype.checkEventTriggerEventTouchFront = function(d) { if (!this.isMovementSucceeded()){ var x2 = $gameMap.roundXWithDirection(this._x, d); var y2 = $gameMap.roundYWithDirection(this._y, d); this.checkEventTriggerEventTouch(x2, y2); } else{ this.checkEventTriggerEventTouch(this._x, this._y); } };
Also can you set spawn overlap to true on the Galv plugin?
I don't know why but when I use the trap as spawned item and enemy step on it the game crash.
And when I tried to use Galv spawn plugin it didn't work, I try the plugin in new project it worked but when I added the event trigger event plugin and when enemy step on the trap the game in the new project crash.
But I will try this code, I could use it without spawn, just make it specefic location the trap can be set in so I do hide event and when player put trap change self switch.
Edit: I tried to change the code you sended but the event that have the comment code change if it have a trigger tag on it, before that it didn't.
I also removed the part I added to change the event that trigger the trap.
var currentEvent = $gameMap.event(this._eventId); $gameSelfSwitches.setValue([$gameMap._mapId, currentEvent._eventId, 'A'], true);
But when It walked on the trap it didn't change it but that could because I removed the trigger tag, and when I keep it it change to self switch.
I also tried to keep the trigger tag and removed the self switch pages but it didn't trigger the trap. -
Alternatively you could look into tracking the event position of your enemy on the map and the event position of your trap/s.
Then check if the event positions overlap and there you have it.
This is more or less how it's done in F&H. -
I thought about it but this could be so much hard to do to track all enemies pose in every map, like how many variable I will need to use for each enemy Y and X, also it could cause frame rate problems.Alternatively you could look into tracking the event position of your enemy on the map and the event position of your trap/s.
Then check if the event positions overlap and there you have it.
This is more or less how it's done in F&H. -
If the traps were tiles with regionIds this would be easier, because you could just loop through every event on the map to see if it had an <enemy> tag and if it were on that region id. If the trap is another event then you would have to do the above, check if the tile it's on has another event in it, then get that other event's id, then check if it has a <trap> tag.
That would be in a parallel common event running every 10 frames or so and would be less efficient than the plugin that only checks when the enemy event is actually moving. -
Can I give tag to events?If the traps were tiles with regionIds this would be easier, because you could just loop through every event on the map to see if it had an <enemy> tag and if it were on that region id. If the trap is another event then you would have to do the above, check if the tile it's on has another event in it, then get that other event's id, then check if it has a <trap> tag.
That would be in a parallel common event running every 10 frames or so and would be less efficient than the plugin that only checks when the enemy event is actually moving.
That could work but it also hard to cheack what the events that I will need to change their self switch like if event with enemy tag step on the trap, what the id of the event that did step on it.
But if this is possible someway I can do it, but I will also need to make the event trap change the region id or better the terrain tag because I use YEP RegionRestriction for my par maps.