Jump to content

Recommended Posts


What is Simple Detect System?

Let's explain it. When player get closer to a specific event, player will be detected.

How Works It

Read Introductions in Script.

Note : Make Parallel Process in detector event.

Example :

195jwl.png

Script :

# -------------------------------------------------
# Script Name : Detector
# Scripter : efeberk
# Date : 08.08.2012
# Version : RPG Maker VX Ace(RGSS3)
# Special Thanks to Bird Eater
# ------------------------------------------------
#
# Features :
#
# This script allows an event detects player when player near to event.
#
# Introductions :
#
# Make a "Conditional Branch" event command and select Script.
# ------------------------------------------------------------------------
# Script : detected?(e, d, true)
#
# e : event id
#
# 0 => Current Event
# 1+ => Event ID
#
# d => distance range from player.
#
# Example : Conditional Branch : detected?(3, 4, true)
#
# This means : returns true if distance 4 from 3. event to player and
# 3.event saw player.

#~ -----------------------------------------------------------------------
#~ Script : region_reached?(a)
#~
#~ This method allows to return true if player reached a
#~ specific region ID.
#~
#~ a => region ID
#~
#~ Example : region_reached?(6)

#~ This means : True if player is on region 6.
#~
#~ -------------------------------------------------------------------------
#~ Script : saw_player?(e)
#~
#~ This method allows to return true if an event saw the player.
#~
#~ e => event ID
#~
#~ 0 = event that used script.
#~ 1+ = event ID
#~
#~ Example : saw_player?(3)
#~
#~ Returns true if 3.event saw player.


class Game_Event < Game_Character

def move_type_toward_player
if near_the_player?
move_toward_player

else
move_random
end
end
end


class Game_Interpreter

def get_event(i)
if i == 0
return $game_map.events[@event_id]
end
if i > 0
return $game_map.events[i]
end

end


def detected?(a, d, k = false)
if k == true
return distance(a, d) && saw_player?(a)
else
return distance(a, d)
end
end

def distance(a,d)
ax = (get_event(a).x - $game_player.x).abs
ay = (get_event(a).y - $game_player.y).abs
if((ax + ay) <= d)
return true
else
return false
end
end


def region_reached?(a)
if $game_player.region_id == a
return true
else
return false
end

end

def saw_player?(e)
sx = distance_x_from(e, $game_player.x)
sy = distance_y_from(e, $game_player.y)
if sx.abs > sy.abs
direction = sx > 0 ? 4 : 6
else
direction = sy > 0 ? 8 : 2
end
if (direction == get_event(e).direction)
return true
else
return false
end

end

def distance_x_from(e, x)
result = get_event(e).x - x
if $game_map.loop_horizontal? && result.abs > $game_map.width / 2
if result < 0
result += $game_map.width
else
result -= $game_map.width
end
end
result
end

def distance_y_from(e, y)
result = get_event(e).y - y
if $game_map.loop_vertical? && result.abs > $game_map.height / 2
if result < 0
result += $game_map.height
else
result -= $game_map.height
end
end
result
end

end
Edited by efeberk

Share this post


Link to post
Share on other sites

Is there a way to extend above this and make it to where when you reach a certain area of the gaurd he runs after you and if he caughts you then you get sent back to some point? I am sure this can all be evented.

Share this post


Link to post
Share on other sites
name='Letsgo12' timestamp='1344396329' post='50328']

Is there a way to extend above this and make it to where when you reach a certain area of the gaurd he runs after you and if he caughts you then you get sent back to some point? I am sure this can all be evented.

[/b]

 

I added a new method named "region_reached?". It may help you. Look new script.

 

name='Death10' timestamp='1344419061' post='50395']

Can "the detecter" see through wall?

Here is my script (too lazy to update the new version): http://www.rpgmakerv...4-guard-events/

It like this one, but more complex :)

[/b]

 

I didn't make it but i added a new method named "saw_player?". So event detects when event just saw player.

Share this post


Link to post
Share on other sites

Sorry for necro-posting (is this necro-posting?)

 

Is it possible to make this script capable of detecting other events other than the player?  Say if we have an Enemy Event and there is a Friendly Event within the Enemy Event detection radius, then it will go after the Friendly Event?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×