Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
Latest update (see end of thread): a short video demonstrating the visible view cone, that highlights map squares where a character could see another character. (No new downloads yet.)



This is a tiny thing, but putting it here in case it's of interest. (This functionality may be provided by some other plugin, I don't know.)

DESCRIPTION
Call within an event's script condition with

JavaScript:
this.playerInRange(this.eventId(), n)

where n is the range. Returns true if the player is within n squares of the
current event. (You can call it with any event ID, of course.)

TERMS OF USE
Do whatever you like with it.

COMPATIBILITY
Doesn't override anything so should be compatible with everything.
No dependencies.
 
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
you place that call inside the event?
and how will it work exacly?

does a text message popup? can regions be used? or any light change if its in range?
the description is kinda vague though.

provide a bit more information what stuff you do and what can trigger.
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
All it does is return true if the player is within the given range of the given event. So you can call it as a script in the condition of a conditional branch of an event (as seen in the description). If the player is within the given range, anything can happen that you can put in that conditional branch. It's just a test.

I've just made the obvious addition that it can make the test for any event, not just the player. It's trivial stuff, just a few lines of code, but I needed it and thought it might be of use to someone.
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
I turned this into a slightly more plausible plugin. (But not plausible enough for the plugin release board, it seems. :-D )

It provides two JavaScript functions:

JavaScript:
this.eventDistance(EVENT1, EVENT2)

Returns the distance in map squares between EVENT1 and EVENT2.
Use in the script box to set a variable, for example.

JavaScript:
this.eventInRange(EVENT1, EVENT2, RANGE)

Returns true if EVENT1 is within RANGE of EVENT2.
Use as a test in the script box of an event's conditional branch
condition.

Example:
Skärmklipp 2020-07-09 18.33.58.png

Event IDs can be -1 for player -2, -3, ... for followers,
or regular event IDs.
 

Attachments

  • Krons_EventDistance.js
    2.5 KB · Views: 23
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
that makes sense, now I understand more how yo ucan use this.
ideally for ghost running away or going to you :)

I see if I can make something with regions when it is in range, because I can base my HUD
on that for chest related stuff and other things.

ty for the explaination.
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
How about 0 for current event, does that work too?
I should fix that. The way I use it now I pass the current event ID in directly with
JavaScript:
this.eventId()
as seen in the example.

And the script could use some error handling as well. And perhaps some plugin commands that determine high-level behavior, like
Code:
STAY WITHIN range1 range2 OF event_id

I don't know how to do that yet, though. (I've only been playing with RMMV for a couple of days.)
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
I've added a new function:
JavaScript:
eventInSight(EVENT1, EVENT2, RANGE, [SLOPE])

Returns true if EVENT1 can see EVENT2 at a maximum range of RANGE and with a view cone of slope SLOPE (optional).

This is now officially Kron's AI Base v. a0.1. :^o
If you try it out, I'd be happy to hear of any problems, or things that can be done in a better way.

See the brief and crappy video below for a demo, or the attached file for more details.
 

Attachments

  • Krons_AI_base.js
    7.1 KB · Views: 28
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
do you have this tiny demo project so I can take a look at teh demo itself.
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
do you have this tiny demo project so I can take a look at teh demo itself.

The test thingies I've made are actually inside the game I'm trying to make (when I don't get distracted by coding generic stuff), but I should break them out so I could distribute them as examples. I'll be back!
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
Here's the demo game. I've updated the plugin as well. It now calculates line-of-sight in three dimensions, using region IDs for height information. The height of characters is set as a parameter. (This means that the demo video above is no longer correct.)

There is also a simple function that checks if one event/player/follower has "caught" another.

Here's the demo.
 
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
will check tomorrow or a bit later today quickly, so I have direct acces and play around with it.
thank you for the demo, can help me easier when needed ^^

If I find something liek a bug or glitch, I report back.
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
Cool! Btw, to test if height is really involved in the line-of-sight calculation, one can just increase the height of the characters in the parameter settings, and see what happens. :stickytongue:
 

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
I play a bit around (mostly watching the event, I dont understand the 0, 13, -1)
but I need to dive a bit deeper and helpfile (write some notes on how those works.

0 is probably event 1, 13 event 2, -1 the player probably.

I also see you use terrax lighting (I use khas, but going to Ocram_Lights so I hope those
will effect as well as for terrax lightning plugin.

I can find some ways to get it done, but you have 1 if you can get it (impossible), you need
to create a map where it wold be REALLY impossible, so you cant drive it into a corner to
catch the ghost.

I got tomorow more time ,and will play around (maybe add khas lightning plugin or
ocram_Lights to see if the effect stays the same.

you did a really nice job making plugin to open more possibilities and more dynamic
caught by knight, or when seen, more guards are coming to capture you ^^

thank for the demo :) you might post on the 1st post though, so others can download
it to learn from it how its setted up :)

EDIT:
when playing around on the tiny demo, you can corner the ghose between camp fire light and
lantern light :p but you cant win the battle when into it. but it is funny though.

is the scriptcall MOVE TO: PLAYER something inbuilt or from your script?
also the moveroute to 3.1, wait 30, move route 3.6 , you could do that in 1 moveroute though.
but there are other spots like the sign, 1 event instead of 2.

anyway, I can figure out guard a bit, but I cant understand the lantern yet.
will figure out later on.
 
Last edited:

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
I play a bit around (mostly watching the event, I dont understand the 0, 13, -1)

0 is current event, -1 is the player, -2, -3, ... are the followers. The other numbers are regular event IDs.

when playing around on the tiny demo, you can corner the ghose between camp fire light and
lantern light :p but you cant win the battle when into it. but it is funny though.

I wanted to make the demo as simple as possible. On my own test map the ghosts take damage from the light, and if you corner them in the light they soon "explode." That's also just a quick fix for the fact that they don't try to find a smart way (a path) to avoid the light, they just step away from the light source.

is the scriptcall MOVE TO: PLAYER something inbuilt or from your script?

No, that's from YEP_MoveRouteCore.js

there are other spots like the sign, 1 event instead of 2.

That's actually a thing. As far as I can see, someone who plays with a mouse can interact with an event that is located on top of an unpassable tile, but someone who plays only with the keys can't. So there are two event to make it possible both to click on the sign with the mouse, and to walk up to the sign and press the OK keyboard button (my preferred way of playing). I'm sure there is a smarter way of solving that, but...

Thanks for taking a look!
 

Solar_Flare

Regular
Regular
Joined
Jun 6, 2020
Messages
725
Reaction score
316
First Language
English
Primarily Uses
RMMV
That's actually a thing. As far as I can see, someone who plays with a mouse can interact with an event that is located on top of an unpassable tile, but someone who plays only with the keys can't. So there are two event to make it possible both to click on the sign with the mouse, and to walk up to the sign and press the OK keyboard button (my preferred way of playing). I'm sure there is a smarter way of solving that, but...
Can't you interact with an impassable event by facing it and pressing the interact key? I thought that was the case but I don't remember if I've actually done it before...
 

Kronicide

Regular
Regular
Joined
Jul 7, 2020
Messages
39
Reaction score
26
First Language
Swedish
Primarily Uses
RMMV
Can't you interact with an impassable event by facing it and pressing the interact key? I thought that was the case but I don't remember if I've actually done it before...

So I discovered now that if you set the event level to "same as character," then you can face the event and interact with it using the keyboard. Mine were set to the default "below character," and you have to stand on top of those to interact with them, it seems. I guess that makes sense. (But you can still interact with events that are below character and located on an impassable tile, by clicking them with the mouse.)
 
Last edited:

ShadowDragon

Realist
Regular
Joined
Oct 8, 2018
Messages
8,213
Reaction score
3,472
First Language
Dutch
Primarily Uses
RMMV
all events are below character by default, unless right click -> door, chest etc which become
same as character if not mistaken.

you always should check it. but sometimes its easier for 1 events, sometimes it works for both,
action button and click, sometimes for a specific reason (like a failsafe) just to make sure
it does work 100% at the time.

everyone has its reason, sometimes its a very different reason, like when on top and you click
it, a variable or switch is triggered, or to call something like that.

noone knows the exact reason, except for the dev that created the game :)
 

Icenick

Regular
Regular
Joined
Mar 28, 2012
Messages
420
Reaction score
70
First Language
English
Primarily Uses
Great plugin, exactly what I was looking for. Simple to use as well!

Im trying to make a detection mechanic that does a check if your within X distance of event. However I noticed the event will constantly be redoing the check if your within the distance independent of movement.
So if a guard is looking over a cliff if you sneak up a few tiles away and stand there, the event will keep checking over and over instantly.

I was wondering if there was a way to check distance only when you move?

BTW: Im using this.eventInRange(EVENT1, EVENT2, RANGE)
 

Latest Threads

Latest Posts

Latest Profile Posts

made a face sprite for the little guy using default cat for comparison, I'm rather pleased with how it turned out!

image.png
Playing arounnd with NUUN's Battle Result as a VS Victory Aftermath alternative. Loving it so far despite the learning curve (there are a LOT of parameters)

1701665328725.png

Just have to figure out how to addin sub class progress.
Partitito's story is supposed to be about defeating poverty while thinking he is a capitalist with socialist ideas. But it's really about stories of redemption and perseverance.
Who would have thought an idea like "I wanna put the character bio in the equip screen" would turn into a bunch of work and fun collaboration @Puppet Knight . Now my Equip/Character screen is the way I want it.
Screenshot 2023-12-03 194313.png
Just one more week of grinding through semester finals and I'll be able to actually work on some games and stuff. Hopefully I'll be able to work on my game document to actually have my ideas somewhere outside of my cranium of madness.

Forum statistics

Threads
136,730
Messages
1,269,262
Members
180,449
Latest member
anxlye
Top