Author Topic: [XP] Event Range Conditions  (Read 12425 times)

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
[XP] Event Range Conditions
« on: May 02, 2011, 06:37:27 AM »
Event Range Conditions
Authors: ForeverZer0
Version: 1.1
Type: Event Add-On
Key Term: Game Utility

Introduction

Allows you to set up conditional branches in events that will be based off the event's coordinates in relation to the player's coordinates without having to create any variables for the X and Y of each.

Features

  • Conditions based on distance radius
  • Conditions based on if they are ON/OFF screen
  • Conditions based on linear distance on each axis
  • Conditions based on whether they are above, below, left, or right in relation to player or other event
  • Simple to use

Screenshots

None.

Demo

None.

Script

Click here for the script.
(click to show/hide)

Instructions

Place script anywhere below the Interpreter scripts, and above "Main"
The different script calls are listed within the script.

Compatibility

Possible compatibility issues with pixel-movement scripts.

Credits and Thanks

  • ForeverZer0, for the script

Author's Notes

Please report any bugs/issues you find.
Hope you enjoy!
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Shalaren

  • Ethereal Devastator
  • ****
  • Posts: 442
  • LV: 46
  • Gender: Male
  • Also known as DexKyle
    • View Profile
Re: [XP] Event Range Conditions
« Reply #1 on: May 03, 2011, 04:18:33 AM »
"#   Remember that if you use a range condition with a parallel trigger, it will
#   continue to execute as long as the condition is met and if the player cannot
#   move during the event's code, the game will effectively be stuck."
I dont get that part S:, the game is stuck for me when I put a range condition, I cant move the player, I dont really get what is cousing it, S:.
can you explain that part just alittle bit better? like an example of what can cause that.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #2 on: May 03, 2011, 04:27:17 AM »
ex.

You have an event with a parallel trigger. There is "range?(4)" condition that will show a text box, which the player cannot move while it is displayed. If you do not set a switch use a self switch or something to stop this checking this condition, the second the player exits the message, the event condition is re-checked, and since the player is still in the same location since control was lost, the condition is still true and the message pops up again. It will continue to do this.

It can easily be stopped by a self-switch or something to switch to stop checking after it is first executed, you just need to be conscious  of these possible scenarios when building your events.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Sacred Nym

  • Awakened Visionist
  • **
  • Posts: 70
  • LV: 0
  • Gender: Male
    • View Profile
Re: [XP] Event Range Conditions
« Reply #3 on: May 03, 2011, 09:05:58 AM »
I love you. No homo.

That is all.
Quote
昨日の自分に「さようなら」
Say "Goodbye" to who you were yesterday.

Offline yuhikaru

  • Trained Member
  • *
  • Posts: 21
  • LV: 3
  • Gender: Female
    • View Profile
Re: [XP] Event Range Conditions
« Reply #4 on: May 19, 2011, 02:14:03 PM »
Whoa, that's a real time saver, thank you! 
If it interests anyone, aparently works fine with cogwheel's pixel movement :)

Offline Susanm

  • Trained Member
  • *
  • Posts: 20
  • LV: 2
    • View Profile
Re: [XP] Event Range Conditions
« Reply #5 on: August 10, 2011, 11:15:21 AM »
range?(RANGE, EVENT_ID) 

I know that this line only checks for if EVENT_ID is in defined range distance away from PLAYER then it returns true.... Is there a way to use this line or perhaps another line in the script so it can be use for EVENT_ID checks another EVENT_ID if within range and not the player? Im trying to make an event check the distance range with another event and if within specified range between both events then condition is true and will say "Hi!" between both events...

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #6 on: August 11, 2011, 01:26:04 AM »
Add this method to the script.  Its pretty self-explanatory, just use this call:

event_range?(EVENT1_ID, EVENT2_ID, RANGE)

Code: [Select]
  def event_range?(event1_id, event2_id, range)
    e1, e2 = $game_map.events[event1_id], $game_map.events[event2_id]
    radius = (Math.hypot((e1.x - e2.x), (e1.y - e2.y))).abs
    return (radius <= range)
  end
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Susanm

  • Trained Member
  • *
  • Posts: 20
  • LV: 2
    • View Profile
Re: [XP] Event Range Conditions
« Reply #7 on: August 11, 2011, 02:22:45 AM »
Thanks a bunch! It worked -)  kudos!  :shy:  now u have a new version LoL :haha:

xTsukihime

  • Guest
Re: [XP] Event Range Conditions
« Reply #8 on: September 28, 2011, 09:53:54 PM »
When the player approaches an event, a self-switch will be set.
When the player moves away from the event, the self-switch should be turned off.

Currently the first page uses range condition to activate the self-switch, but then I do all sorts of things just to get the self to turn off when I move away.

Is there an easy way to deal with this?

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #9 on: September 28, 2011, 10:31:23 PM »
Just use the inverse condition on the page that is activated by the first page.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

xTsukihime

  • Guest
Re: [XP] Event Range Conditions
« Reply #10 on: September 28, 2011, 11:44:21 PM »
Got it. Didn't know "not" would do the trick.  :)

horus02

  • Guest
Re: [XP] Event Range Conditions
« Reply #11 on: November 02, 2011, 11:11:34 AM »
Hello, I'm kinda new and a total scripting Noob...
I wanted to use your Range Conditions with your Custom Event Triggers (http://forum.chaos-project.com/index.php/topic,6893.0.html) but it never works. I'm too dumb to get it to run I think. Could you please tell me how I should set it up? I tried something like this:

Comment: Custom Trigger
            : player_above?(14)

But it always gives me an error like this: "undefined method `player_above?´ for ..."

edit
I got it to work for me.
/edit
« Last Edit: November 05, 2011, 05:05:56 PM by horus02 »

Offline Vexus

  • Ethereal Devastator
  • ****
  • Posts: 365
  • LV: 9
    • View Profile
Re: [XP] Event Range Conditions
« Reply #12 on: December 14, 2011, 02:31:46 AM »
I'm using this great script in my project and it's doing wonders! Can make events conflict with other events  :evil:

Anyway would it be possible to make an event follow/chase another event?

It would be very great if it would be possible.

Thanks for the help.
Current Project/s:

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #13 on: December 14, 2011, 02:58:41 AM »
I suppose you could use this for chasing, though it would require a bit of an expansive event. The easiest way would be to have an event set a variable determining the direction it is from the second event, then branch to determine what direction to make the chasing event turn, then use "One Step Forward".

Or you can just use a pathfinding script like this or this variation of it that allows for using event names.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Vexus

  • Ethereal Devastator
  • ****
  • Posts: 365
  • LV: 9
    • View Profile
Re: [XP] Event Range Conditions
« Reply #14 on: December 14, 2011, 05:03:09 AM »
Ok thanks for the help will try one of them tomorrow.

(Trying to make the wildlife fight each other if x beast gets near y beast territories, etc)

Ok tried the variation one using the example in the thread and getting an error like the last guy posted on the thread without getting a response :S
« Last Edit: December 14, 2011, 05:14:06 AM by Vexus »
Current Project/s:

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #15 on: December 14, 2011, 06:49:27 AM »
The first is my original script. The second link is my script which someone else modified, and the error appears to be with his edits. You can always use the original, just won't be able to call using the event's name.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Vexus

  • Ethereal Devastator
  • ****
  • Posts: 365
  • LV: 9
    • View Profile
Re: [XP] Event Range Conditions
« Reply #16 on: December 14, 2011, 02:07:29 PM »
I could but I didn't understand how to do it on your version (Even on the other one if it wasn't for the example he gave) as the description doesn't clearly say how to make x event follow y event but only go on z location or maybe I got it wrong don't know.
Current Project/s:

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #17 on: December 14, 2011, 07:32:01 PM »
Create an event that tracks the coordinates of the first event and have the second pathfind to it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Vexus

  • Ethereal Devastator
  • ****
  • Posts: 365
  • LV: 9
    • View Profile
Re: [XP] Event Range Conditions
« Reply #18 on: December 15, 2011, 03:37:43 AM »
But the type I wanted to do was not on an event that stood still waiting for the other event to reach it that's the problem.

Say for example there's a cat on the fields and a mouse gets too close the cat starts chasing it but the mouse won't stand still and that script (Checked the demo) only makes x event/player move to y coordinates.

Anyways if it's too trouble no need to do it and thanks for the help nonetheless :).
Current Project/s:

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3248
  • LV: 294
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Event Range Conditions
« Reply #19 on: December 15, 2011, 06:01:17 AM »
Its a single parallel process event and two variables. I didn't think it was too difficult unless you are just misunderstanding what I suggested.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.