Hi guys,
do you happen to know how you can have a plugin adding an NPC to the map? I guess the NPC should be a Game_Event object, having an image and a position set, but I'm not sure about what goes next.
I saw plugins moving Game_Event from one map to another, but nothing creating them from scratch.
Snippets are welcome.
Thank you in advance 🙂
that is because it is much easier to clone an existing event from somewhere than to enter all event data by code.
and in both cases the developer has to provide the data for the event, so it's usually easier to enter correct data in a map that is never used in the game itself, to be able to copy those templates.
And that includes ideas like a "random NPC generator" - it's usually easier to make the event itself with internal randomness to display different NPCs than to have a program create random data for a simpler event.
If you're still interested, search for tsukihime's blog - she had a script for creating events in VXA. I do not know if she wrote something like that for MV however, especially considering that the script for VXA was rarely if ever used. But the instructions for that script should give you some ideas of what is neccessary even in MV, because MV has the same event structure (the commands and properties in javascript are completely different however)
Off of the top of my head, I would use Yanfly's Event Spawner/Event Cloner to clone an event; then, utilizing the pre/post copy codes, those npc's could have some level of randomization applied to them. Or an easier method with the clone script is to clone an event that has it's own parallel process that it uses to determine what it should be.
Example:
We'll call an event RNPC, which is a parallel process that checks the map number of the current map. If it is a "farm" type map from a list of ID's that is identified as a "farm," then it will roll a random number and based on that it could be a farmhand, a rancher, a milkmaid, customer, or plain villager. That random would flip an associated self-switch to convert the event to an NPC (that is not parallel) to a predefined setting for, in this case "farmhand."
Now that we have a farmhand, let's assume it is a generic NPC that walks and really only has conversational usage. Our farmhand template would have a lengthy set of "if statements" (or if you're clever, a secondary script based on interaction). In the course of most games, people will use system switches that can be tested against to adjust the dialoge, or even force another NPC change to something more challenging like a vampire.
To make graphically unique NPC's would be more challenging, since that would require some custom coding. I would start at SRD's youtube channel, looking for his character builder (a plugin that lets the player make their sprites themselves).
Whew, this was a longer post than I expected to make.
Cheers! I wish you luck on your project!