Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=============================================================================
- # Borders
- #=============================================================================
- #Borders prevent the player from crossing past a point in a certain direction
- #Set the event to parallel process, with conditional script Border(point,"direction")
- def Border(point,direction)
- event=$game_map.events[@event_id]
- px=$game_player.x
- py=$game_player.y
- if event
- case direction
- when "up"
- if py<point
- return true
- end
- when "right"
- if px>point
- return true
- end
- when "down"
- if py>point
- return true
- end
- when "left"
- if px<point
- return true
- end
- end
- end
- end
- #=============================================================================
- # Boundaries
- #=============================================================================
- #Boundaries require the player to stay within the limits given.
- #Set the event to parallel process, with conditional script Boundary(X1,X2,Y1,Y2)
- # Y1
- # X1 (||) X2
- # Y2
- #Set both Xs to 0 for only Y boundaries, and vice versa
- def Boundary(x1,x2,y1,y2)
- event=$game_map.events[@event_id]
- px=$game_player.x
- py=$game_player.y
- if event
- if y1==y2
- if px<x1 || px>x2
- return true
- else
- return false
- end
- elsif x1==x2
- if py<y1 || py>y2
- return true
- else
- return false
- end
- else
- if px<x1 || px>x2 ||
- py<y1 || py>y2
- return true
- else
- return false
- end
- end
- end
- end
- #=============================================================================
- # Anchors
- #=============================================================================
- #Anchors require the player to be within a certain range of their event.
- #Set the event to parallel process, with a conditional script Anchor(#), with
- #"#" being the number of tiles away the player can be before triggering the event.
- #xonly will only restrict the player horizontally
- #yonly will only restrict the player vertically
- def Anchor(limit,xonly=false,yonly=false)
- event=$game_map.events[@event_id]
- if event
- x=event.x
- y=event.y
- px=$game_player.x
- py=$game_player.y
- if xonly==true
- if px<=(x-limit) || px>=(x+limit)
- return true
- end
- elsif yonly==true
- if py<=(y-limit) || px>=(y+limit)
- return true
- end
- end
- if px<=(x-limit) || px>=(x+limit) ||
- py<=(y-limit) || py>=(y+limit)
- return true
- else
- return false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement