Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Making a monster chase you when you enter its defined range
lilcooldude69
post Apr 23 2013, 10:38 PM
Post #1


The pro-est eventer u know ;D
Group Icon

Group: Revolutionary
Posts: 297
Type: Event Designer
RM Skill: Masterful




Okay so first let me say that this involves a bit of script calls so this might be a little advanced for some of you, with that being said if you decide to continue and can't seem to understand it then don't get angry with me D:


some of the features of this type of event would be, walking onto a dungeon map and a monster sees you in range and begins to chase you, and as soon as it catches up to you, the monster will start a battle.

the end result of this will create a 4x4 invisible box around the event and if you enter this box it will chase you

anyways right to it shall we


first thing we will want to do is define some variables with control variables, make sure you place these in the monster out on the map

Variables

@>Control Variables: [001:Event's X] = This Event's Map X
@>Control Variables: [002:Event's Y] = This Event's Map X
@>Control Variables: [003:Player's X] = Player's Map X
@>Control Variables: [004: Player's Y] = Player's Map Y


these can be any variable id of course, just make sure the id's are set to the correct game data

next part gets a bit tricky, this is where some of the script calls come in, but no need to worry i shall explain smile.gif

Super crazy hard Conditional Branch D:

@>Conditional Branch: Script: $game_variables[3].between?($game_variables[1]-4,$game_variables[1]+4) and $game_variables[4].between?($game_variables[2]-4,$game_variables[2]+4)


haha don't worry i know it looks overwhelming but i shall break it down piece by piece for you smile.gif

Super simple Breakdown
$game_variables[3].between?($game_variables[1]-4,$game_variables[1]+4)
okay so this $game_variables[3] actually is a call for the variable id of 3, remember the variables we made earlier, well if you look back one of them has an ID of 3 correct? well thats what this variables is, the .between? after it, is a bult-in method that checks between 2 numbers its base form is actually setup like this .between?(n1,n2) where n1 is the first number and n2 is the second number it will check.

so if you notice after the $game_variables[3].between? i have a ($game_variables[1]-4,$game_variables[1]+4), you should recognize the $game_variables[1] call, thats Variable ID 1 that we defined earlier in this tutorial its the Event's X coordinate - 4, the number 4 is the actual range of squares the monster is checking to see if anyone is inside of it, you can change this to whatever number you want, so basically so far what we have is

if our player's X coordinate is between our events X coordinate minus 4 and our events x coordinate plus 4, this is what the first part of this conditional branch says in english.

now for the second part of it



and $game_variables[4].between?($game_variables[2]-4,$game_variables[2]+4)

okay so, "and" is actually telling the rest of this conditional that this part of it must be true as well other wise, i won't run the next section of the event, i'll mark the whole conditional branch as false if this isnt true as well.

$game_variables[4].between?, like before this is calling upon our variable of id 4 which is our player's Y coordinate and it wants to check if our Y coordinate is .between?($game_variables[2]-4,$game_variables[2]+4) which is checking for the events Y coordinate +4 and -4, remember this -4 and +4 will be 4 squares above and below our event.

okay so the whole conditional branch in english reads like this,

if the player's X coordinate is between(the event's x coordinate minus 4 and our events x coordinate +4) and if the player's Y coordinate is between(the events Y coordinate-4 and the event's Y coordinate+4)


now onto the events that will be ran when this is true,

Code so far

@>Control Variables: [001:Event's X] = This Event's Map X
@>Control Variables: [002:Event's Y] = This Event's Map X
@>Control Variables: [003:Player's X] = Player's Map X
@>Control Variables: [004: Player's Y] = Player's Map Y
@>Conditional Branch: Script: $game_variables[3].between?($game_variables[1]-4,$game_variables[1]+4) and $game_variables[4].between?($game_variables[2]-4,$game_variables[2]+4)



Code inside of the conditional branch

@>Control Variables: [001:Event's X] = This Event's Map X
@>Control Variables: [002:Event's Y] = This Event's Map X
@>Control Variables: [003:Player's X] = Player's Map X
@>Control Variables: [004: Player's Y] = Player's Map Y
@>Set Move Route: This Event (Skip, Wait)
$>Move Toward player


the reason were putting the variables again is so we can update it on the fly because once a variable is stored to game data, it will not change until its ran again, if we didn't put this in here, every time we walked near the monster, the variables would stay the same and he would chase you all over the map, we'd still want you to have a chance to escape right?

finally the part where the event will chase your player, the reason we only put it once is because this event will be a paralell process, so it will run this code over and over until something shuts it off..


@>Conditional Branch: Script: $game_variables[1].between?($game_variables[3]-1,$game_variables[3]+1) and $game_variables[2].between?($game_variables[4]-1,$game_variables[4]+1)


okay so this is basically the same thing as the last one, but instead were switching them around, this time we'll be checking if the event's x and y coordinates are the same as the players + and - 1, because, an event that doesn't have through on will never be on top of you.

so...so far we have it setup that the event will chase you once you enter its range and now once it reaches you we will make it do something, like perhaps, initiate battle biggrin.gif?

the rest should be self explainitory i'll upload a screenshot for reference tongue.gif


Attached File  tut.png ( 104.59K ) Number of downloads: 10


This post has been edited by lilcooldude69: Apr 23 2013, 10:52 PM


__________________________

My Userbars


Rated pg-13 part of signiture
Scientist A: "A single sperm has 37.5MB of DNA information in it. That means a normal ejaculation represents a data transfer of 1,587.5TB."
Scientist B: Too bad ejaculate has terrible packet loss
Scientist C:but the transfer does have a lot of redundancy

Go to the top of the page
 
+Quote Post
   
atlus
post Apr 24 2013, 01:03 PM
Post #2


Etrian Odyssey 3 Character
Group Icon

Group: Revolutionary
Posts: 200
Type: None
RM Skill: Intermediate




This is exactly what I needed...until I the script spoiled it. Is it bychance a way to convert this into rpgmaker 2003? I have been needing somthing like this forever.

This post has been edited by namco: Apr 24 2013, 01:04 PM


__________________________
Go to the top of the page
 
+Quote Post
   
lilcooldude69
post Apr 24 2013, 04:00 PM
Post #3


The pro-est eventer u know ;D
Group Icon

Group: Revolutionary
Posts: 297
Type: Event Designer
RM Skill: Masterful




actually XD ive never used rm2k3, if it has a script option it may be possible, actually it would be possible but ud have to specify loads of control variables :X and if then statements to check the tile and such


__________________________

My Userbars


Rated pg-13 part of signiture
Scientist A: "A single sperm has 37.5MB of DNA information in it. That means a normal ejaculation represents a data transfer of 1,587.5TB."
Scientist B: Too bad ejaculate has terrible packet loss
Scientist C:but the transfer does have a lot of redundancy

Go to the top of the page
 
+Quote Post
   
atlus
post Apr 24 2013, 07:58 PM
Post #4


Etrian Odyssey 3 Character
Group Icon

Group: Revolutionary
Posts: 200
Type: None
RM Skill: Intermediate




Oh well there was this plugin that allows scripting but alas ohwel. I have a turorial i found I think that shows how to do pathfinding.......

OH! I just remebered I have a pathfinding plugin but alas I dont know how to do the coding.


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 04:21 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker