Detect if 3+ events with the same notetag are next to each other

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
Hi,


So I'd like to do a little experiment in MV - a Match-3 game. Most of the game is easy to make (check if two events are next to each other and if so, allow the swapping of both events, for example) but the aspect of checking if 3 or more events with a given notetags are in the same axis and next to each other may be a more difficult task. 


Ideally, I would like the plugin to be able to read the notetag box for finding events that are next to each other on the same axis in a straight line (eg 17,13  17,14   17,15) and log these (put the corresponding event IDs that match into an array as well please) and fire a common event. With the array of events and the common event that fires, I can do the rest afterwards.


Thanks!
 

takashi1kun

spaghetti god code
Veteran
Joined
Jul 27, 2014
Messages
104
Reaction score
39
First Language
Spain Spanish
Primarily Uses
Hi,


So I'd like to do a little experiment in MV - a Match-3 game. Most of the game is easy to make (check if two events are next to each other and if so, allow the swapping of both events, for example) but the aspect of checking if 3 or more events with a given notetags are in the same axis and next to each other may be a more difficult task. 


Ideally, I would like the plugin to be able to read the notetag box for finding events that are next to each other on the same axis in a straight line (eg 17,13  17,14   17,15) and log these (put the corresponding event IDs that match into an array as well please) and fire a common event. With the array of events and the common event that fires, I can do the rest afterwards.


Thanks!
Kay im going to try to do it for you 
is going to consist in this:
a fuction that run on map load
it saves in an array the id of the events whit a notetag that yoy specify in the plugin commands
Then when has read that, runs a update like function that continually track the x and y axis of the events whit the id saved in the array of last function, and saves in a array
Other update like function is traking the axis x and y and detect what events in the arrays are in the same axys and save the info in a object array somthing like:
axis X1{ eventid 1, eventid 2, eventid3}
axis Y1= eventid 1, eventid 45, eventid 20
axis.......
and you can detect it by something like $gameMap.axisX[1] and it should return somethin like [1,2,3] or $gameMap.axisY[1] and it should return somthing like [1,45,20]
That is what do you want?
srry for my english

EDIT:
I started to re think all the process because the performance and i dont like to have autoupdate things running whitout need, so i remade the process, the code is made, in real paper, still need to put in a plugin.
Now it works on demmand, so for example when you call
$aitorEngine.axisEvents.x(xAxis)
it is going to execute the whole code on that demmand and return you the value, in this way is going to run smother because it dont need to process the wole update code everyframe, only when you request a value, it calculate it, too, it works to not abuse of variables
 
Last edited by a moderator:

izyCoder

Villager
Member
Joined
Dec 22, 2014
Messages
26
Reaction score
11
First Language
English
Primarily Uses
you want like this?








if so, here is how

You can use any Eval Condition plugin, In your case, you can use mine 





then save this code and enable it as plugin. You can save as anything.js



Spoiler





var Izy_CR = {};
Izy_CR.checkIsEventExistHere = function (eventData, x, y) {
for (i = 0; i < eventData.length; i++) {
if (eventData) {
if (eventData.x == x && eventData.y == y) {
return true;
}
}
}
return false;
}
Izy_CR.getEventDataByLocation = function (eventData, x, y) {
for (i = 0; i < eventData.length; i++) {
if (eventData) {
if (eventData.x == x && eventData.y == y) {
return eventData;
}
}
}
return false;
}

var alias_gameevent = Game_Event.prototype.initialize;
Game_Event.prototype.initialize = function (mapId, eventId) {
alias_gameevent.apply(this, arguments);
this._meta = $dataMap.events[eventId].meta
};




Then in your event notetag, you can put <tag:stone> to define it's as stone or something you want.


Then in your event, make a new page (this page will launch when it meets 3+ event vertically). This is the code to put:


This code check the event vertically, I think you can make your own code to check it horizontally. Just a little tweak :)

var haveAbove = false;
var HaveBelow = false;
var haveThreeAbove = false;
var haveThreeBelow = false;

if (Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y - 1)) {
var thatEvent = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y - 1);
if (thatEvent._meta.tag == this._meta.tag) {
haveAbove = true;
}
}

if (Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y + 1)) {
var thatEvent = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y + 1);
if (thatEvent._meta.tag == this._meta.tag) {
HaveBelow = true;
}
}

if (Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y - 1) && Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y - 2)) {
var thatEventFis = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y - 1);
var thatEventSec = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y - 2);
if (thatEventFis._meta.tag == this._meta.tag && thatEventSec._meta.tag == this._meta.tag) {
haveThreeAbove = true;
}
}

if (Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y + 1) && Izy_CR.checkIsEventExistHere($gameMap.events(), this._x, this._y + 2)) {
var thatEventFis = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y + 1);
var thatEventSec = Izy_CR.getEventDataByLocation($gameMap.events(), this._x, this._y + 2);
if (thatEventFis._meta.tag == this._meta.tag && thatEventSec._meta.tag == this._meta.tag) {
haveThreeBelow = true;
}
}

if (haveAbove && HaveBelow) {
condition = true;
} else if (haveThreeAbove) {
condition = true;
} else if (haveThreeBelow) {
condition = true;
} else {
condition = false;
}


NOTEEE since MV's comment only exceed 6 lines, you need to seperate it. This is the image example:



I'm a little busy right now, but I'm interest with your idea. If you need any help you can add me on facebook. https://www.facebook.com/Izyees.Fariz243728.act *Please not that now I'm not accepting any friend request, you need to message me that it's you then I will accept :D  But I will not guaranteed I will talk to you 24/7, I have work to do right now.
 
Last edited by a moderator:

takashi1kun

spaghetti god code
Veteran
Joined
Jul 27, 2014
Messages
104
Reaction score
39
First Language
Spain Spanish
Primarily Uses
Hi,


So I'd like to do a little experiment in MV - a Match-3 game. Most of the game is easy to make (check if two events are next to each other and if so, allow the swapping of both events, for example) but the aspect of checking if 3 or more events with a given notetags are in the same axis and next to each other may be a more difficult task. 


Ideally, I would like the plugin to be able to read the notetag box for finding events that are next to each other on the same axis in a straight line (eg 17,13  17,14   17,15) and log these (put the corresponding event IDs that match into an array as well please) and fire a common event. With the array of events and the common event that fires, I can do the rest afterwards.


Thanks!
Actually the plugin tells you various info of the events checked whit the notetag in the same axis, it can be, default info, id, x and y, only id, or full Game_Event info, i too include a fullScan feature that returns a grid like object 
Game_2016-07-04_15-48-00.png





the plugin functions can be accesed by:
AitorEngine.axisEvents
To check the x axis:
AitorEngine.axisEvents.X(xlinetocheck) it returns various info in the form of objects whit the id, x and y of events that match
AitorEngine.axisEvents.X.id(xlinetocheck) it only return a array whit the ids
example:
Game_2016-07-04_15-52-07.png
AitorEngine.axisEvents.X.events(xlinetocheck)->this returns the game_event info, example:


Game_2016-07-04_15-53-27.png


the same for the Y only change the X for the Y 

You aslo can customize the tag in the plugin options for maximum compatibility, this plugin should be compatible whit everything sience it doesn't touch any function of the game, i only made new functions.

View attachment AitorEngine_axisEvents.js
 

EternalShadow

Veteran
Veteran
Joined
Sep 16, 2012
Messages
5,781
Reaction score
1,041
First Language
English
Primarily Uses
Hey, thanks guys. Will give that a look and see if it meets my purposes. If not, I will chat with Takashi :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top