June 11, 2014, 05:54:27 pm

I'm gonna be that guy who asks a question without having the program even open but I am at work and digress. I've been fiddling with scripting entities lately to create a bit of foundation for a little project. Anyway everytime a try to create a new test "person" [using createperson()], it ends up on top of the main character and reducing movement. Am I supposed to not be using the same sprite animation for two characters? Is there a better way to call npcs and enemies into the fray besides the gui method?

Now, there is one exception, you cannot place enemies before the map engine loads (I have no clue why, there is no reason for this). So in the case of starting up a new game, you'll have to get tricky:

It looks hackish, but that's like one of three methods of trying to place entities as the map engine loads. This is the easiest solution, equivalent solutions would require you to use SetDelayScript, or SetDefaultMapEngineScript. But this is the safest what I showed above since it doesn't overwrite any existing scripts.

The function CreateMapPerson is a bit advanced, it takes properties in it's input rather than the standard style of input. This is so you can pick and choose what parameters you want to use. In this way you can decide to only choose an x position, or only a layer, or decide whether or not to persist the created entity. (Persisting an entity means: will he live to see a map change? Since changing maps kills all entities. Setting persist to true keeps the entity).

Last Edit: June 11, 2014, 10:17:09 pm by Radnen

If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Awesome! This makes a lot more sense and is lot easier than what I thought I was going to have to do. I figured it kind of make sense you can't set enemy positions pre-map, the map doesn't exist before you set it as the engine, so if one plots the X,Y before hand, its really plotting in a negative space. if this is the case, then the best way to set a location is to do it when the map does exist . But since the map engine is basically a loop, any location commands placed in Main class after MapEngine() isn't executed (which is what I stupidly did. I spent like 20 minutes shaking my head in shame). I thought I was going to have to make an update script for setting enemies then one for actual gameplay.Thank you!

But since the map engine is basically a loop, any location commands placed in Main class after MapEngine() isn't executed (which is what I stupidly did.

We all stupidly do that in Sphere! Even though the map hasn't loaded yet, the reason why you would want to set people before it loads is because you know where they'll be ahead of time. Sure the map hasn't loaded yet, but neither have they. But having the ability set up what the map will look like before it loads is always nice. I mean you can do this perfectly fine with ChangeMap() It's just that MapEngine() as you are aware, goes into an infinite map-loop, and so is no good to put code before or after it.

Setting a person script, a delay or map script just means we are running that code while the map engine runs. The person script is the best choice since we know it runs only once and since it's the first script attached to the entity, it'll happen right as the map loads. The last parameter 'true' means the code will happen immediately. It's better than any other method, even though a person scripts were added not to necessarily do that (lol).

Sphere should have an eventing system like in RPGMaker, the closest we have is LordEnglish's Scenario script, but it lacks from the fact it's not tightly integrated to the map engine, so it must piggy-back off of it to do work and some bootstrapping means it's still not ideal for all situations. I think he resorts to a delay script to get it up and running. Having an easy to script, in-map-engine eventing system would really provide fresh air to Sphere, and solve all of these problems of writing your own event functionality (such as the spawning of other entities, etc).

If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Awesome! This makes a lot more sense and is lot easier than what I thought I was going to have to do. I figured it kind of make sense you can't set enemy positions pre-map, the map doesn't exist before you set it as the engine, so if one plots the X,Y before hand, its really plotting in a negative space. if this is the case, then the best way to set a location is to do it when the map does exist . But since the map engine is basically a loop, any location commands placed in Main class after MapEngine() isn't executed (which is what I stupidly did. I spent like 20 minutes shaking my head in shame). I thought I was going to have to make an update script for setting enemies then one for actual gameplay.Thank you!

... yup... I did this too a few years back... even now still on occasion

But alas, thats why we are here to help. Sometimes it just requires a "different" set of eyes