No one seems to have the same problem as me? I use coordinates to determine the player's range of attacks, and execute certain commands if there is a target event in the range.
However, in the actual test, as long as the NPC moves, even if the player is in front of the NPC, there is no successful judgment.(NPCS that do not move are 100% successful.)
Is this a mistake?
Altimit Pixel Movement [0.50β]
● ARCHIVED · READ-ONLY
-
-
I encounter this particular error:
Any help? -
can you show the code? It's possible the issue is that it is looking for an exact integer location, and since NPCs spawn on exact integer locations, that would make static npcs work and ones that move not.No one seems to have the same problem as me? I use coordinates to determine the player's range of attacks, and execute certain commands if there is a target event in the range.
However, in the actual test, as long as the NPC moves, even if the player is in front of the NPC, there is no successful judgment.(NPCS that do not move are 100% successful.)
Is this a mistake? -
can you show the code? It's possible the issue is that it is looking for an exact integer location, and since NPCs spawn on exact integer locations, that would make static npcs work and ones that move not.
Sorry, I am a Chinese user, so the above screenshot has Chinese.
The general approach is to get the coordinates in front of the player through variables, and then determine the effect according to the above script.
Maybe there's something wrong with this coordinate acquisition. -
Your work is truly amazing. This is by far the best pixel movement to RPG Maker i've ever seen. Copy and paste and everything becomes fluid and as you intended, like it has always been part of RPG Maker movement. Just tested some moments ago.
Unfortunately is not compatible with Yanfly's chase event and move core extra (hug wall for example). -
View attachment 138686
Sorry, I am a Chinese user, so the above screenshot has Chinese.
The general approach is to get the coordinates in front of the player through variables, and then determine the effect according to the above script.
Maybe there's something wrong with this coordinate acquisition.
I still don't understand how you're getting targetIds in the first place. Is it something like
Code://find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()]+$gamePlayer.x var mapy = vecy[$gamePlayer.direction8()]+$gamePlayer.y //loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) { // check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { //Do what you want it to do here } } -
I don't know anything about code, so I use the default "Get Position Info" button to get the current player's coordinates.I still don't understand how you're getting targetIds in the first place. Is it something like
Code://find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()] var mapy = vecy[$gamePlayer.direction8()] //loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) { // check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { //Do what you want it to do here } }
Then, according to this rectangular coordinate, the player is facing the direction and whether he is attacking or not. If the attack occurs, the coordinates in the area facing the player's face are obtained, and the event is determined with the script in the above screenshot.(I learned this script from some Japanese game templates.)
I only understand the comments in the code you gave. Is it the solution to the problem? -
@Zeldashu just to tell you that altimit and region restriction dont work together unless you modify the plugin,
in either one, also, altimit should be under region restriction. do you have other plugins and are those in
the correct order? -
All I do is take the coordinates to determine if there is an event on them, and then decide what's going to happen next. So I don't quite understand what you mean by region restriction, because it doesn't seem to have anything to do with coordinates, right?@Zeldashu just to tell you that altimit and region restriction dont work together unless you modify the plugin,
in either one, also, altimit should be under region restriction. do you have other plugins and are those in
the correct order?
Forgive me if I'm wrong.
When testing plug-ins, I deliberately set all other plug-ins to OFF, so it should not be caused by other plug-ins.
I think the problem is the coordinate fetch, the plugin changes the movement so that the regular method of getting the coordinates doesn't work. -
YEP_RegionRestriction is a nice plugin, but block movents as region ID dont have affect when altimit pixelmovement
is on, also, I notice some other stuff that dont trigger it that comes with that plugin unless its modified.
using region id's outside that plugin can work, but not the region id's set up with region restriction plugin.
Even if I wanted altimit plugin, it doesn't work together and some others as well.
but that plugin is also the best pixelmovement that there is atm. modify it in the way you need is the best
part to get it to work nicely with all the plugins you like :) -
Are you storing the event's X,Y coordinates in one of the RMMV-provided variable slots?
RMMV rounds variables into integers.
Can you explain what the pink text does? My attempt at machine translation wasn't very successful. Is it a method which calls $gameMap.eventIdXy()? If so, the problem is that .eventIdXy only does exact matches (it doesn't scan a radius).
For instance, if your monster is at [2,5.1], then putting in $gameMap.eventIdXy(2,5) will return nothing. If the monster were at EXACTLY [2,5], then $gameMap.eventIdXy would return the event ID.
If you want to scan an AOE, my code above should give you a framework for doing that. Let me expand on it:
Code://find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()]+$gamePlayer.x var mapy = vecy[$gamePlayer.direction8()]+$gamePlayer.y //loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) { // check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { targetID= eventList(i).eventId()
Code:} } -
I get the general idea of what's going on.Are you storing the event's X,Y coordinates in one of the RMMV-provided variable slots?
RMMV rounds variables into integers.
Can you explain what the pink text does? My attempt at machine translation wasn't very successful. Is it a method which calls $gameMap.eventIdXy()? If so, the problem is that .eventIdXy only does exact matches (it doesn't scan a radius).
For instance, if your monster is at [2,5.1], then putting in $gameMap.eventIdXy(2,5) will return nothing. If the monster were at EXACTLY [2,5], then $gameMap.eventIdXy would return the event ID.
If you want to scan an AOE, my code above should give you a framework for doing that. Let me expand on it:
Code://find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()] var mapy = vecy[$gamePlayer.direction8()] //loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) { // check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { targetID= eventList(i).eventId()
Code:} }
The pink part means: get the event ids corresponding to x and y on the map and store them into the variable 04 (object ID).
The following code then determines whether the comment bar for the corresponding event has the word [敌人], and if so, opens the specified self - switch.
If I understand you correctly, the code you give is to define two characters as an array and add face orientation. I didn't understand the rest of it very well.
How can I make this script work for me? It doesn't seem to be the same as my current method of getting coordinates. Should I write it as a js file? If so, how do I call it? -
If I understand you correctly, the code you give is to define two characters as an array and add face orientation. I didn't understand the rest of it very well.
How can I make this script work for me? It doesn't seem to be the same as my current method of getting coordinates. Should I write it as a js file? If so, how do I call it?
This segment
Code:Calls the altimit ".direction8()" function, which gives the 8 directional facing of the player (so upper-left is 7, upper right is 9, down is 2, etc)//find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()]+$gamePlayer.x var mapy = vecy[$gamePlayer.direction8()]+$gamePlayer.y
It converts that to a coordinate relative to the player (so upper left is [-1,-1], upper right is [1,-1], and down is [0,1]). Then it adds the player's location (whoops, forgot to include that in the first draft). That gives the coordinate of the tile that the player is facing.
This segment
Code:gets all the events on the map, and loops through them.//loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) {
Note:I am NOT looping through "$gameMap.event(i)", because event numbers aren't necessarily sequential (you can have event 1, event 35, and event 56 on the same map with nothing else).
Code:// check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { targetID= eventList(i).eventId()
Once we're looping through them all, we check each event on the map to see how far they are from the tile the player is facing (using the standard sqrt(dx^2 + dy^2) formula ). If the event is within 1 tile of our coordinate, we save the targetID of that event. Then just proceed processing as normal
I haven't tested this guy but you should be able to just put it in a script block. -
Thanks for your patience, I have fully understood how this code works. But then came two questions:This segment
Code:Calls the altimit ".direction8()" function, which gives the 8 directional facing of the player (so upper-left is 7, upper right is 9, down is 2, etc)//find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()]+$gamePlayer.x var mapy = vecy[$gamePlayer.direction8()]+$gamePlayer.y
It converts that to a coordinate relative to the player (so upper left is [-1,-1], upper right is [1,-1], and down is [0,1]). Then it adds the player's location (whoops, forgot to include that in the first draft). That gives the coordinate of the tile that the player is facing.
This segment
Code:gets all the events on the map, and loops through them.//loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) {
Note:I am NOT looping through "$gameMap.event(i)", because event numbers aren't necessarily sequential (you can have event 1, event 35, and event 56 on the same map with nothing else).
Code:// check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { targetID= eventList(i).eventId()
Once we're looping through them all, we check each event on the map to see how far they are from the tile the player is facing (using the standard sqrt(dx^2 + dy^2) formula ). If the event is within 1 tile of our coordinate, we save the targetID of that event. Then just proceed processing as normal
I haven't tested this guy but you should be able to just put it in a script block.
1.MV's default "script" button has a 12-line word limit, so I can't fit all of the above code in. And segmenting it doesn't seem to work. It seems possible to write this script as a js file, but I don't know how I can call it by doing so.
2. If I understand correctly, the current judgment method can only judge the range of one tile in front of the player. How do I rewrite this code if I want to set a weapon with an arbitrary attack range?
The previous way to get coordinates was to add and subtract player coordinates to achieve different weapon attack ranges. But this new method I don't know which way to do it.
Code:I'm not sure if I'm calling it the wrong way or scripting it the wrong way. The actual test did not work as expected.(The self switch is not turned on)//find the coordinate in front of the player //first, we map from the direction8 to a map coordinate var vecx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1]; var vecy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1]; var mapx = vecx[$gamePlayer.direction8()]+$gamePlayer.x var mapy = vecy[$gamePlayer.direction8()]+$gamePlayer.y //loop through all events var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++) { // check if an event is within a range of 1 of the tile we selected earlier if ( ( eventlist[i].x - mapx)*( eventlist[i].x - mapx) +( eventlist[i].y - mapy)*( eventlist[i].y - mapy) <1) { targetID= eventList(i).eventId() if(targetID != 0 && ~$dataMap.events[targetID].note.indexOf("[敌人]")){ var mapID = this._mapId; if(!$gameSelfSwitches.value([mapID, targetID, "B"])){ $gameSelfSwitches.setValue([mapID, targetID, "A"], true); } } } }
(The current effect)
(Original effect)
-
More compact version (and fixed a capitalization typo). TBH when I personally write scripts I usually just wrap everything that's more than one or two lines into a function and then put it into a big unorganized MyPlugin.js
Code:var mapx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1][$gamePlayer.direction8()]+$gamePlayer.x var mapy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1][$gamePlayer.direction8()]+$gamePlayer.y var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++){ if ( ( eventList[i].x - mapx)*( eventList[i].x - mapx) +( eventList[i].y - mapy)*( eventList[i].y - mapy) <100) {targetID= eventList[i].eventId() if(targetID != 0 && ~$dataMap.events[targetID].note.indexOf("[敌人]")){ var mapID = this._mapId; if(!$gameSelfSwitches.value([mapID, targetID, "B"])){$gameSelfSwitches.setValue([mapID, targetID, "A"], true);} } } }
You will probably want to experiment a bit with the radius / exact coordinates of the center of the effect. -
Thanks for your help! The code is working.More compact version (and fixed a capitalization typo). TBH when I personally write scripts I usually just wrap everything that's more than one or two lines into a function and then put it into a big unorganized MyPlugin.js
Code:var mapx = [0 , -1 , 0 , 1 , -1 , 0 , 1 , -1, 0 , 1][$gamePlayer.direction8()]+$gamePlayer.x var mapy = [0 , 1 , 1 , 1, 0 ,0 ,0 ,-1 ,-1 ,-1][$gamePlayer.direction8()]+$gamePlayer.y var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++){ if ( ( eventList[i].x - mapx)*( eventList[i].x - mapx) +( eventList[i].y - mapy)*( eventList[i].y - mapy) <100) {targetID= eventList[i].eventId() if(targetID != 0 && ~$dataMap.events[targetID].note.indexOf("[敌人]")){ var mapID = this._mapId; if(!$gameSelfSwitches.value([mapID, targetID, "B"])){$gameSelfSwitches.setValue([mapID, targetID, "A"], true);} } } }
You will probably want to experiment a bit with the radius / exact coordinates of the center of the effect.
I made a few small changes to the code for my own needs and added some comments that I hope will help others as well.
Code:var mapx = $gamePlayer.x //Based on the player coordinates, increase or decrease this value to achieve the attack range of any weapon.Of course, if you only need to determine the tile in front of the player, it's easier to use the original array. var mapy = $gamePlayer.y //The formula in the lower square bracket, n is used to detect the value of the tile (perhaps). Setting it to 100 will result in half the screen (about 10 tiles) being in the detection range. var eventList=$gameMap.events(); for (var i = 0; i < eventList.length; i++){ if ( ( eventList[i].x - mapx)*( eventList[i].x - mapx) +( eventList[i].y - mapy)*( eventList[i].y - mapy) <1) {targetID= eventList[i].eventId() if(targetID != 0 && ~$dataMap.events[targetID].note.indexOf("[敌人]")){ var mapID = this._mapId; if(!$gameSelfSwitches.value([mapID, targetID, "B"])){$gameSelfSwitches.setValue([mapID, targetID, "A"], true);} } } } -
Altimit doesn't have a stock way of asking 'do these two characters have colliders that touch'?
This implementation is ugly but does the job.
Put it into Altimit right under the Game_Map.prototype.touchesCharacters function
Code:Game_Map.prototype.isTouchingAB = function( characterA, characterB ) { var x=characterA.x; var y=characterA.y; var collider = characterA.collider(); var bboxTests = this.getAABBoxTests( characterA, 0, 0 ); // Gather any solid characters within the movement bounding box var loopMap = {}; var characters = [characterB].filter( function( entry ) { if ( characterA.collidableWith( entry ) ) { for ( var ii = 0; ii < bboxTests.length; ii++ ) { if ( Collider.aabboxCheck( bboxTests[ii].x, bboxTests[ii].y, bboxTests[ii].aabbox, entry._x, entry._y, entry.collider().aabbox ) ) { loopMap[entry] = bboxTests[ii].type; return true; } } } return false; } ); // Test collision with characters for ( var ii = 0; ii < characters.length; ii++ ) { var entryX = characters[ii]._x; var entryY = characters[ii]._y; if ( loopMap[characters[ii]] == 1 ) { entryX += this.width(); } else if ( loopMap[characters[ii]] == 2 ) { entryX -= this.width(); } else if ( loopMap[characters[ii]] == 3 ) { entryY += this.height(); } else if ( loopMap[characters[ii]] == 4 ) { entryY -= this.height(); } else if ( loopMap[characters[ii]] == 5 ) { entryX += this.width(); entryY += this.height(); } else if ( loopMap[characters[ii]] == 6 ) { entryX -= this.width(); entryY += this.height(); } else if ( loopMap[characters[ii]] == 7 ) { entryX += this.width(); entryY -= this.height(); } else if ( loopMap[characters[ii]] == 8 ) { entryX -= this.width(); entryY -= this.height(); } if ( Collider.intersect( x, y, collider, entryX, entryY, characters[ii].collider() ) ) { return true; } } return false; }; -
I tried the plugin and it's really great! But how to change the movement speed?
-
Should be the same as in base RPG maker? What issue are you having?I tried the plugin and it's really great! But how to change the movement speed?
-
I'm trying to use this plugin with TileD, I read that I have to modify the character colliders, but I don't know how I should do it, I'm a beginner. thanks for the plugin.