Weird request about click moving objects.

NinjaKittyProductions

Professional Murder Hobos
Veteran
Joined
Jul 9, 2013
Messages
403
Reaction score
352
First Language
English
Primarily Uses
RMMV
If a plugin exists, please point me in the right direction ^_^! I have looked and looked and cannot find anything for what I am wanting.

Here is the deal. We are working on a character that has the ability of telekinesis. We are wanting them to be able to move certain objects on the field (events that is), and move them to somewhere nearby... say within 2 to 3 squares from the original starting point of the event. While we know a whole lot about using script calls for check mouse point, hover, over and move, we cannot figure out how to move an event in-game with a mouse click and drag. Thus we come to you, community. Is this possible or will we need a plugin?
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
538
Reaction score
2,453
First Language
English
Primarily Uses
N/A
I've actually done this before. It's very possible. The code I wrote was temporary, it was just an experiment.
But I wound up putting a 'listener' on scene map update, that used a basic square collision box function I already had to detect the bounds for the clicks.

EDIT: Scene Map update was also where I used the Mouse cursors coordinates to re position the sprite as the cursor moved. I can't fully remember this next part, but I'm pretty sure their movement functions took over, so there was a little bit of 'delay' if I moved the mouse very quickly. I suspect you'd have to temporarily disable or override their movement functions to correct that, if it becomes an issue.

The only nuance was making sure that where I 'dropped' events auto-corrected to the nearest whole numbers for tiles in RM, otherwise they couldn't move after I released.

It's very possible and actually not too complicated, I'll wait to see if someone posts a link to an existing plugin, though
 

NinjaKittyProductions

Professional Murder Hobos
Veteran
Joined
Jul 9, 2013
Messages
403
Reaction score
352
First Language
English
Primarily Uses
RMMV
{MH}That seems a little over my head at the moment. JavaScript is not strong with me <_<.

@standardplayer If someone does not post a plugin or extension, would you mind sharing how you did that step by step?
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
538
Reaction score
2,453
First Language
English
Primarily Uses
N/A
@NinjaKittyProductions sure, I'll give it about a day or so ^^ If I check back and don't see any responses, I'll do some tests, remember how I did it all and then write a step by step

EDIT: @NinjaKittyProductions Alright, so I had a little bit of time here and there last night, and starting putting together a concept. I wanted to not deal with that delayed drag that happened to me last time, so I approached it a little differently.

Before I actually show any code, I'd like to explain what is happening and why, and make sure this is doing what you want it to do.

Here's the thing. You'd have to do a bit more work if you wanted to get the sprite to smoothly move along with the cursor. A Game Character's movement is actually initiated by incrementation. If you manually change their ._x property, they animate; they walk to that x location. The don't just appear there. You'll notice that when you manually change their x or y in this way, they also move at their current move speed.

Furthermore, unless you're using some special movement script, events won't activate with the regular Action Button trigger, or be able to respond to regular move commands if they are not properly within the tile grid. i.e. If you set their x to 4.3 and then do $gameMap.event(x).moveStraight(d), that event won't move. They'll turn in whatever direction you say, but they won't move, not with vanilla movement, anyway.

So I just went ahead coded my example so that the event moves between tiles, without animating as it's being dragged. You could still add step animation to it for this portion, btw.

Finally, the current code will only allow telekinesis if
1) an object that holds a .active boolean is currently set to true
2) the event has a specific notetag in it's notebox.

Anyway, here's a quick video of what I've worked on so far, pretty cut and dry.

 
Last edited:

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
538
Reaction score
2,453
First Language
English
Primarily Uses
N/A
@standardplayer that looks fantastic! From what I can tell, you can move the event only a few squares at a time from its original position.

Yeah, currently it's set to 2 as it's distance limit. Alright, I'll go back, comment the code and I'll explain what's happening.


EDIT alright, so first, I've attached a copy of the mini plugin I wrote to test this.
The code is commented, although there isn't a whole lot to comment on.

I don't know all the specifics of when/where you want telekinesis to be active. I'm also not huge fan of plugin commands, I really don't think they're easier to use than script calls, and they're certainly more limiting. For that reason, I'm just going to give you the script calls.

So here are the script calls you'd need to get this working.

tks.distance = x //Where x is the distance you want the object to be able to move from it's origin
tks.active = true //This allows telekinesis to happen. If this is set to false, telekinesis can't happen.

Also, for an object to be moveable by telekinesis, it needs to have
<sp_tk> in it's notebox.


Like I said, I don't know all the specifics of what you'd need, but I went ahead and made it so you can only move an event based off of it's original x and y when the map was loaded. This is to prevent someone from picking up an object, moving it as far as the limit allows, then dropping it and picking it up again, only to move it outside of it's original bounds.
 

Attachments

Last edited:

NinjaKittyProductions

Professional Murder Hobos
Veteran
Joined
Jul 9, 2013
Messages
403
Reaction score
352
First Language
English
Primarily Uses
RMMV
I tried the plugin and it seems to work flawlessly.
There were only a couple of things that stood out. 1)My characters moved while I tried to move the object. No biggie as I came up with a couple of Common Events that put a stop to that ^_^. 2) The distance X didn't seem to work but I really only need to move it only 2 squares at a time anyway so all is good.

Anyway, this was an awesome little plugin and I really appreciate you taking the time to make it ^_^. I hope others find this plugin useful as there are all sorts of ways to use it... from freeing up clutter, unblocking a passage/etc., puzzle-solving... really anything you can do with an event that needs to move ^_^

 

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

Latest Threads

Latest Posts

Latest Profile Posts

Trading has been halted on the TSX (Canadian stock market) because of "technical issues". Suspicious... I'm bracing myself for a sea of red tomorrow lol
The Loco-Motion song pre-dates the dance. Meaning the lyrics are kinda misleading. "Everybody's doing a brand new dance now"... No they weren't, you just used peer pressure to trick everyone into going along with it.
Love it when someone confuses "RPG Maker (or script/plugin) has a bug" with "I didn't set it up right and it's not working as I want (or gives an error)"
Is animation really as hard as I think it is?
Out of sudden, snow. Everywhere.

Forum statistics

Threads
94,579
Messages
922,046
Members
124,446
Latest member
chungagunga
Top