Post new topic    
Page 1, 2  »
Slime
Send private message
So NPCs can't leave the map 
 PostMon May 22, 2017 5:10 pm
Send private message Reply with quote
What's the best way to work around the fact NPCs can't walk out of the map? I know tags can make a NPC disappear and I can use that so they reappear in the other map but what other options are there?

Though the only reason why I want the NPC to leave is because I want to trigger an event after a battle but already have a different event scripted in the current map. I know scripts can be triggered after text boxes, entering a map, and after a battle on a certain map. Any better ways to trigger the event so I can keep it all on the same map?
Liquid Metal Slime
Send private message
 
 PostMon May 22, 2017 6:04 pm
Send private message Reply with quote
Could you clarify what it is you're asking? I'm a bit confused as to what you are requiring.

In regards to NPCs exiting a map, no this is not a built-in feature of the engine. This can however be coded to happen like you said "using tags." If you want some sort of sophisticated NPC-door-using script you could write an autorun script that checks if any given NPC steps on a door (which can be represented by a zone). If the zone is stepped on then the NPC is deleted from the current map and then the tag is turned on to make it appear on the subsequent map. This type of script would bet really complex if you are handling many NPCs, if this script is only being used for a few NPCs then there shouldn't be any issues.

If you are looking for a better alternative solution this is what I suggest. Instead of making many maps and using tags why not use one giant map that consists of all of your smaller maps. This way you can make the maps all appear to be separate but in reality it is just one big map. Doing this will allow you to use an autorun script like I mentioned above which will check if any NPC steps on a door (zone) then teleports that NPC to a new part of the map. The hero will still use the doors as they normally would but rather then routing the hero from map to map, they are instead routed to doors within the same big map. This is the simplest option as it does not require handling a massive amount of tags. The downside is that you will be limited to the maptile sets you have chosen for this big map. You can of course use a similar zone comparison script to display a wider range of maptiles as you jump from door to door. This could become tedious though so you'll have to decide if this sort of option is right for your game.

Hopefully that makes sense.

I'm not sure what you're really asking in your second paragraph. You can call as many scripts and have as many events as you want in a single map and there are many more ways to trigger events then you have listed. You can trigger events through menus, each time the hero steps, in an autorun every tick, every time a timer does stuff, on key press, every time a condition is met in any of these as well.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Slime
Send private message
 
 PostMon May 22, 2017 7:30 pm
Send private message Reply with quote
What I'm trying to do is have an NPC leave the map after a battle then have a different event occur after a different battle. In General Map Data scripts can be triggered after a battle but it seems like it happens after every battle on that map so if I want a different script to occur after battle I'll have to use a different map. What I don't know is if there are better methods to trigger these two events after a battle as I don't fully grasp how to use tags. Sorry for not being clearer.

How would I go about making the NPC disappear when they step in the zone? I don't want to make their sprite invisible either as the player is meant to follow them through the door.
Liquid Metal King Slime
Send private message
 
 PostMon May 22, 2017 8:46 pm
Send private message Reply with quote
After-battle scripts run after every battle on the map. This is usually used for doing special stuff after random battles.

If you want a plot event to happen after a battle, then the after-battle script trigger is probably the wrong way to trigger the script.

Tell us more about the battle?

Is it a boss battle that happens when you talk to an NPC?

Or is this script with the NPC leaving the map actually supposed to be after a random battle?
Liquid Metal Slime
Send private message
 
 PostMon May 22, 2017 10:15 pm
Send private message Reply with quote
As Bob stated, an after battle script happens after every battle. If you wanted the script to happen after only one battle (for instance a boss battle) you could carry it out a few different ways.

1) If you are dealing with an NPC you could have a textbox trigger the event to happen. Notice that textboxes don't have to be displayed to trigger a script. In the CUSTOM editor there is an option to have the script carry out without displaying the textbox.

2) You could still use the after battle script but add a condition to the script. For example, you talk to an NPC (the boss) and it turns on tag #3. Now you can make an after battle script that checks if tag #3 is on. If it's on then the NPC walks to the door and disappears (or whatever you want to happen). The script then turns tag #3 off so this event doesn't happen in subsequent battles on this map. This would allow you to have different after battle events based on whether tags are on or off after that battle ends.

3) I think you can also use the battle editor to turn on/off tags allowing you to do the same thing as (2) without the need for an NPC or textboxes.

...theres even more ways to go about this. If you give a detailed play-by-play list of what you want to happen then someone in the forums will surely recommend the best way to go about it.

In regards to the NPC disappearing, you can instead use "destroy NPC" in your script to permanently remove it from the map. No need to have an invisible NPC. Or you can teleport the NPC to a unaccessible location on the map area if that suits your needs better.

The NPC step on zone type script can be done by making an autorun script. Within the autorun script create a while-loop. In the while loop you can check if NPC X and NPC Y position are on top of a zone by using the function "read zone (zone id, x, y)." Change x and y so that they are checking whether the NPC X and Y are over top of the zone, like "read zone (zone id, NPC X, NPC Y)." This probably is overcomplicating what you need accomplished though so definitely look in to the simpler suggestions first.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Slime
Send private message
 
 PostMon May 22, 2017 10:58 pm
Send private message Reply with quote
What happens is the hero talks to NPC commencing a plot important battle (as in if the battle doesn't happen then the plot wouldn't make sense), after battle the script making the NPC walk out of the map activates, then in the next map (when the player chooses to follow) another battle occurs with its own after battle script.

Getting tags for specific moments would be nicer as I have a script that also occurs whenever the hero enters the map but I only want it to occur the first time they enter instead of every single time since I want them to revisit the map instead of using a clone of the it without that script.

I used the destroy NPC script but it destroyed the NPC at the beginning of the scripted event despite it being the last thing listed before resume player.

Thanks for your support.
Liquid Metal Slime
Send private message
 
 PostTue May 23, 2017 12:11 am
Send private message Reply with quote
Okay, based on your requirements I suggest you do this:

1) Have the NPC that you speak to turn tag 1 on then commence the battle.
2) Have an after battle script that checks if tag 1 == on. If this condition is true then make the NPC walk to the door and destroy them. Also in the same script turn tag 1 off so it doesn't carry out in later battles. Turn tag 2 on (this tag will represent whether or not the NPC appears on map 2).
3) Upon entering map 2 have a map autorun script condition which checks if tag 2 == on. If this condition is true then create that NPC on the map area in whatever position you want.

Note: If you want this NPC to only be in Map 2 the first time you enter map 2 but not at later times then you will also have to turn tag 2 off in the autorun script after the NPC has been spawned. This will make that NPC not appear on re-entry. I suspect this isn't actually what you want though. What you probably want is for that NPC to stay on Map 2 until you have engaged them again or defeated them, in which case you will have tag 2 turned off after battling them in Map 2.

Also don't use tag #1 as I think it has some sort of built-in functionality, using tags #2 and higher is fine though.

Regarding the issue you're having with the NPC being destroyed instantly, I think what is happening is that you forgot to use "wait for NPC (who)." The script is not waiting for the NPC to stop moving before destroying it. You'll want to arrange your code to look something like follows:

-Suspend Hero
-Walk NPC 5 tiles right
-Wait for NPC
-Walk NPC 2 tiles up
-Wait for NPC
-Destroy NPC
-Resume Hero

(Obviously where your NPC walks depends on where the door is located)
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Slime
Send private message
 
 PostTue May 23, 2017 12:47 am
Send private message Reply with quote
My script for the NPC walking is
-suspend player
-walk NPC (2, north, 3)
-wait for NPC (2)
-wait (10)
-walk NPC (2, west, 4)
-wait for NPC (2)
-destroy NPC (2)
-resume player

and it still destroys them early.

The script for the autorun would be independent to interacting with the NPC. So by using tags I can have the script turn itself off permanently after being used once? Sorry I don't know how to use tags well.
Metal King Slime
Send private message
 
 PostTue May 23, 2017 3:41 am
Send private message Reply with quote
That script looks correct. There's probably something else going on.
Probably you didn't give the NPC a non-zero movement speed, which will cause any attempt to move it to do nothing.
Is the NPC set to "useable only once"?
Do you have other scripts which destroy an NPC?

Following from Sheam's suggest to set a special tag before entering the map: Let's suppose your tag is called "trigger map 2 battle". Checking it and clearing it in the map autorun script looks like:

Code:
plotscript, map 2 autorun, begin
  if (check tag(tag: trigger map 2 battle)) then (
    set tag(tag: trigger map 2 battle, off)
    # ... do stuff here
  )
end


Or you can do it the other way around: have the tag start off, and turn it on to indicate that the special event has happened. ("if (checktag(...) == off)"). on and off are just synonyms for true and false.
Slime
Send private message
 
 PostTue May 23, 2017 8:10 pm
Send private message Reply with quote
The movement speed is 2 and was working fine before the destroy NPC script was added, though they would bump into the edge of the map instead of walking off the map. There weren't any other scripts set to destroy them and the NPC is set to be used repeatedly.

How would I set the tag to be on so it can be turned off later in the script? The script autoruns when you enter the map so I can't have the tag be tied to talking to the NPC.
Chemical Slime
Send private message
 
 PostTue May 23, 2017 8:29 pm
Send private message Reply with quote
Hide your NPC instead of destroying it
Perhaps you could walk your NPC under an obscuring tile or graphic instead of having them destroyed?

For example, you could have your NPC walk under a certain tile (it could appear that they are using a door or something, perhaps?)
You could place a graphic on a layer above heroes/NPCs or change the passability of an NPC so it can move through walls.


Deleting NPCs is not permanent.
When the map is loaded, NPCs will be loaded again too! You will have to use a tag or variable to make sure they stay gone.


Load your NPC for the one time you need it
I think you could use your script to load your NPC for the one time needed.
Something like this

Code:
plotscript, yourscript, begin

IF(check tag (x) == OFF)
THEN(
create NPC
run your script here or make it triggered by activating the NPC
set tag (x, ON)
)

end


On future occasions, your NPC will not be there, as NPCs loaded by a script are not persistent (they have to be loaded each time)

Triggering the event
You could also have this event triggered when the hero steps on a tile, zone, invisible NPC etc., instead of being autorun.

This is useful if you want to keep your scripts separate from the map.
However, the above example will still work if you put other stuff in there, and it's probably neater to put it in one big script with branches to run conditional events.

I like sheamkennedy's suggestion of having it on one big map. It's a really good idea and a common technique of game design.

You can use 1 global variable instead of many tags
Finally, consider storing the state of your events in a global variable.
(It has to be a global variable so it persists after the script is finished, and can be called by another script)

You could change it after every cutscene and it only uses one global variable, as opposed to multiple tags.

The only downside is that you won't be able to check for multiple tags at once, only 1 global variable.
That's okay if you want things to progress linearly, but not if you want to have branching events and things like that
(actually, you can do some complicated stuff, like a different variable value for every combination of values)
Liquid Metal Slime
Send private message
 
 PostTue May 23, 2017 8:48 pm
Send private message Reply with quote
You sure it's not a movement zone issue?
My pronouns are they/them
Ps. I love my wife
Slime
Send private message
 
 PostTue May 23, 2017 10:03 pm
Send private message Reply with quote
How would the NPC disappearing to early in the script despite being set to a movement speed greater than 0 and having the wait for NPC command be a movement zone issue?

How do I use a global variable or any variable really so an event ends permanently after its used?

I also have trouble placing layers as the Wiki only says to use paging up or down to select between them but I'm stuck on layer 0 when working on the tilemap editor no matter what I press and pressing F1 for more help only activates my computer's help screen.
Chemical Slime
Send private message
 
 PostTue May 23, 2017 11:21 pm
Send private message Reply with quote
You have to use PGUP and PGDN in the map editor to change layers

I believe it's '+' to create a layer.


Using a variable works like this (assuming you don't know):

Code:
Global variable (this goes outside of the script, before "plotscript, name, begin")
 global variable (1, somevariable)

Local variable (this goes inside a script. It gets lost when the script ends!)
 variable(somevariable)

Set the variable to 'value'
 somevariable := value

Adds 1 to the variable
 somevariable += 1

Subtracts 3 from the variable
 somevariable -= 3

etc.,


variables start at 0. So in the first script, make it run only if your variable is 0, and make sure to change the variable to the next value for your next script.

IF (somevariable == 0) THEN (run first script and change the variable to 1)
IF (somevariable ==1) THEN (run second script and change the variable to the next value)
IF (somevariable == nextvalue) THEN (run another script)

It works like tags. check that the variable is the right value to run your script, then change that value within the script.
Metal King Slime
Send private message
 
 PostWed May 24, 2017 3:10 am
Send private message Reply with quote
Oh yes, I meant to mention movement zones but forgot. If the NPC can't move then the script will be skipped through quickly; you would only see the wait(10) and destroynpc happen.

Try removing the destroynpc again and checking that the rest of the script works.

Try adding "show value(1)" etc to parts of the script to verify that it's running . That will show a number at the bottom-left corner.

Make sure you reimported the script and restarted the game (quit out of game.exe/ohrrpgce-game, which I refer to as Game).

Sometimes there's a problem due to double-triggering a script (having two copies of it running at once), althoguh I don't think that's possible in this case.
One way to check this is to use script trigger logging (press F9 (Edit: F8) to reach the debug menu and you'll find it there; it creates a file called script_log.txt which shows all scripts that are triggered and how long they run for), or to put trace/tracevalue statements in the script, which will be written to g_debug.txt, which you can then inspect.


To clarify what VSword said: you have to go to the Layers and Tilesets menu in the map editor and add more layers. (You can also access that menu by pressing Ctrl-L in tilemap editing mode.) I guess that this isn't mentioned in the HowTo? I'll have a look.


M-nite wrote:
pressing F1 for more help only activates my computer's help screen.

Wow! Which OS are you using? On Mac the function keys by default are tied to other stuff (I don't think F1 brings up system help though), but you can also press Cmd-Shift-? instead, or just use the Help item on the menu bar.
Regardless of your OS, pressing Fn-F1 probably works, if you have a Fn key.

Yes, using a global variable is another alternative to using a tag. Notice that you put the "global variable(...)" outside of any script, and the rest of what VSword posted goes inside a script.
Display posts from previous:
Page 1, 2  »