Question about Events via Script.

Kathis

Warper
Member
Joined
Jan 31, 2016
Messages
3
Reaction score
0
First Language
English
Primarily Uses
Hello I am having some difficulty with my project.


I'll be honest I don't know how to ask this without getting common game making terms confused, but I'll do my best. 


How I know how to say it: I desire to create dynamic events by simply finding whatever function is in charge of the draw cycle as well as the update cycle, and pushing them into their scope. 
I want to do this so my clients are able to render new sprites based on the data that they fetched from the server. Thus allowing them to see another instance of players on their screen.
The only thing I require is either of the following
a ) drawing sprites via scripted events with their X Y coords,
b ) Make a single event, and simply copy and push it into the array so when the next render // draw cycle commences it will include the secondary player's sprites.


c ) Follow step b, exclude the single event, that would be a carbon copy, and code it all from scratch via scripts. 


I already have the code to store their location, as well as READ from the database, so that's not the issue. What I don't know is how to render the desired sprite, or even change a sprite's X Y via code. 


yes I have already read the script list. I have even started going through sceanManager's 129 different properties, as well as each of those 129 properties down to 5 levels. :/ and yet they still go deeper. 


---------------------------------------------------------------


How do you draw a sprite from the sprite sheet at the desired X and Y Coord, via code?


I know about that I need a bitmap, as well as the Sprite, and that it must be pushed up to the _scean however I don't understand how to change the information from there. :/


If you have questions about my question on how to be clearer please ask. I'll try my best to clarify further.


Further for those whom are interested in seeing sceanManager's stuff and how far down the rabbit hole it goes. To use this. 
 

var string = "";


var count = 0; var count2 = 0; var count3 = 0; var count4 = 0; var count5 = 0;


for (var add in SceneManager._scene) {count ++; string += String(count) +":&nbsp;" + add + "<br>"; for (var add2 in SceneManager._scene[add])


{count2 ++; string += "&nbsp;&nbsp;" + String(count2) +": " + add2 + "<br>"; for (var add3 in SceneManager._scene[add][add2]){count3 ++;


string += "&nbsp;&nbsp;&nbsp;&nbsp;" + String(count3) +": " + add3 + "<br>"; for (var add4 in SceneManager._scene[add][add2][add3]){


count4 ++; string += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;" + String(count4) +": " + add4 + "<br>";


for (var add5 in SceneManager._scene[add][add2][add3][add4]){count5 ++; string += "&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;" + String(count5) +": " + add5 + "<br>";


} count5 = 0;} count4 = 0;} count3 = 0;}count2 = 0;}


document.getElementById('iframe_id').contentWindow.document.body.innerHTML = string;


You will need an iframe added to your index. 
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
This is not easy, and so far almost everyone went for a slightly different way.


The engine only handles either events (which usually have sprites assigned to them) or pictures, and pictures allow no interaction. Drawing a sprite on the map would basically be the same as making a picture - it won't have any interaction possible if it isn't part of an event, and if it is part of an event you don't need to draw it manually.


However, creating events from scratch by script is extremely tedious - For Ace, Tsukihime once wrote an Event Wrapper Script that provided the methods to create events by script, and it was almost never used due to the complexity involved. And I don't think that such a plugin will be written for MV for the same reasons.


The solution almost everyone used instead is to clone/copy events. They make a mastermap with all the events they might need, and use a copy/clone script (and yes, there are already one or two plugins for MV that do exactly that) to place that event elsewhere. If neccessary, the events commands or script commands can be used to modify the base event, but the important difference is that this way the base structure is already created by the editor and linked inside the engine, so there is no need to take care of that problem manually any more.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
However, creating events from scratch by script is extremely tedious - For Ace, Tsukihime once wrote an Event Wrapper Script that provided the methods to create events by script, and it was almost never used due to the complexity involved. And I don't think that such a plugin will be written for MV for the same reasons.


My OrangeCustomEventCreator can do that and it's been available since launch :)


https://github.com/Hudell/OrangeCustomEvents


Even if you don't want to use events, drawing things to screen is really not that hard (if you're a scripter). Just look at the default classes to see how things are added and do the same thing.
 

Kathis

Warper
Member
Joined
Jan 31, 2016
Messages
3
Reaction score
0
First Language
English
Primarily Uses
I will not lie Hudell, I was hoping to avoid plugins.


I should be able to do this without the use of one, since all the function should be included already. 


If I have learned anything from Game Programing and Game design is that all engines follow basicly 5 phases of a game.


1. Declaration,2. Initialization, 3. Update, 4. Draw, 5. End


I want to know how to manipulate the update step so that it influences the draw step. 


Ander, creating the event is not the hard part, it's drawing the event. I was able to edit an event's x and y $dataMap.event[ID].Property


{"id":4,"name":"EV004","note":"","pages":[{"conditions" "actorId":1,"actorValid":false,"itemId":1,"itemValid":false,"selfSwitchCh":"A","selfSwitchValid":false,"switch1Id":1,"switch1Valid":false,"switch2Id":1,"switch2Valid":false,"variableId":1,"variableValid":false,"variableValue":0},"directionFix":false,"image":{"tileId":0,"characterName":"Monster","direction":2,"pattern":1,"characterIndex":4},"list":[{"code":355,"indent":0,"parameters":["$gameMap.event(3).x = 6"]},{"code":0,"indent":0,"parameters":[]}],"moveFrequency":3,"moveRoute":{"list":[{"code":0,"parameters":[]}],"repeat":true,"skippable":false,"wait":false},"moveSpeed":3,"moveType":0,"priorityType":1,"stepAnime":false,"through":false,"trigger":0,"walkAnime":true}],"x":3,"y":7}


These are events from the json. If I wanted to make this event in javascript quickly I could have done the following


For this quick example we'll assume that I have an event already set up and we are just cloning it, with a different x and y


var temp = $dataMap.event[4];


temp[id] = 5; temp[x] = 6; temp[y] =6; temp[name] = "Clone";


$dataMap.event.push(temp);


the code will recognize this I have tested that much. But $dataMap seems to be only a temporary holding ground for loading maps, once loaded, the update disregards it till


a new map needs to be loaded, as it will pull it from the Map###.json again. 

So what I need to know is what holds the events in the current map, and tells Draw where to place them, as well as perhaps their pages.


(I also read 




)

However it looked like it was more focusing on a plugin creation oppose to just scripting.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
Well, plugins are nothing more than scripting :p


If you look at the code of that plugin, you'll see everything you need to do that, but basically:


* The method Game_Map.setupEvents creates the Game_Event instances.


* The method Spriteset_Map.createCharacters creates the sprites of the events (keeping a reference to the Game_Event instance);


* The method Sprite_Character.update will update the sprite with the information from the Game_Event instance.


On the OrangeCustomEventCreator plugin, I created a class called CustomEventData, it is basically a class that simulates the json object from a regular event. You can simply instantiate a CustomEventData object an fill it's properties, then add the event to the map.
 

Kathis

Warper
Member
Joined
Jan 31, 2016
Messages
3
Reaction score
0
First Language
English
Primarily Uses
I FOUND it


All events that are drawn are stored in the $gameMap._events Area 


Now to make a Deep copy and not a shallow copy :/ Forgot that = in javascript is technically a shallow copy, making a reference to a variable oppose to the value of the variable.


... when it involves an array of objects that is. XD


Thank you Yanfly for  "Spawning an event, huh? That's a bit more complex. You'd have to push the new event into the $gameMap.events() array with the new event data. Though, if it's another player sprite, I'm actually unsure if I can help you there since I haven't made multiplayer for MV before."


Close but not quite the right one. :/ 


For those who stumble across this.


https://docs.google.com/document/d/1Q-eyHUWpNn2Agrom3izBLy4-NTzJ9_MrjblP4tEryk0/edit  


This is my charting of $gameMap It is slow and incomplete because I cannot chart it all in one go. :/ its not that I cannot, it's that I cannot copy it because it's too large. 


When I figure out how to Deep copy with the current methods and libraries I'll post it here since it will be considered relevant. 

JsonEx.makeDeepCopy = function(object) {
    return this.parse(this.stringify(object));
};   


From the rpg_core.js Line 7741


JsonEx.makeDeepCopy.   Found the clue in Hudell's scripts. Haven't reached this line in my notes


https://docs.google.com/document/d/1j5hGZhmQZfMYEgnLvEDUb9M0xOeL9_TMdUL6ML0Iu-Y/edit?usp=sharing
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top