Heya! I've been thinking a lot lately about my game The Missing Part and i thought: "I realy realy realy hate random encounters, they are so freaking ANNOYING!"
But then i thought: "If i make it so that enemies walks the map instead and when you touch them you get to battle them?"
This will be a big step in my game and the script that i need will make it like this:
When you move within a specified number of frames of an event(let's say, an events 6x and 6y) the event will, from the movement course i set up, change to speed to Faster(5) and the frequency to Fastest(6) and the course will be set to follow so that when it touches the player, the event commands i put will take place. If the player manages to move out of the 5 frame range of the event the movement options will be changed back to as it first was.
The only thing that strikes my mind is, how do i make an event into this perticular kind of event? Maybe put a command in the start of the event? Maybe i can even add my own preferences in the event itself by adding comments like:
Speed 5
Frequency 6
Frames 6 (The number of frames to move within for the enemy to start chasing you)
Maybe even put a parallel animation on it if it's possible(was thinking a "!" sign that signifies that it has noticed the player)? So the command would look something like this:
Speed 5
Frequency 6
Frames 6 (The number of frames to move within for the enemy to start chasing you)
Animation [ID] or Animation [false] (for no animation)
I am not sure how this will be possible as i am no scripter and i don't know if this requires a big script. This is how i imagined it to work, it doesn't necessarily have to be exactly like this one.
I am not expecting this to be made in just a week, but if you could find it in your heart to tell me if this is even possible to begin with so i don't have to wait in vain :shy:
This could be evented.
Sec...
Wouln't that require TONS of parallel events on every single map i have enemies in? 8-O
Not to mention the number of switches i will have to use and to keep track of it all together.
http://dl.dropbox.com/u/23928630/EnemyChasing.zip
Um... No?
Enemies check only themselves against the player.
I didn't make hoards follow the player if one person spotted him, but I can add that.
Edit:
Didn't have time to add some more notes when I first made the post.
You only need to have that one line of setup that is in the event on map001.
And then for the enemies, you can copy and paste them.
Just have to change the graphics, movement controls (if needed), and the battle settings and stuff.
I hate no idea what those scripts in the Event Commands do :xD:
However, this seem to work perfect and it's EXACTLY what i wanted! :)
There's is just one thing. Is it possible to make the enemies stop when they reach the player and not run around him/her like they do?
Pretty sure i fixed this part by splitting the "player touch" part(aheam..) into a separate event page and made it "Autorun" instead of a Parallel process. Naturaly i altso had to turn off the self swich at the end of the event.
EDIT: Altso, the enemies should reapear when i exit/enter the map. I messed around a bit but i'm not sure how to find a solution.
Nevermind, i fixed that too :xD: I just made an "erase event" instead of swiching to a new self switch.
It now works EXACTLY like i want it to! Thank you so much Aqua for taking time to help me! :cclove:
Oh right... forgot about erasing events... lol
Want me to add anything else or explain the code stuff?
nope, everything works as it should and it's still going to take some time before i understand coding at all :roll: (I'm working on it).
Thank you once again :clap:
Uhm, after a long time I actually found a bug with this. The line: $monster_dist_thresh = 6 resets whenever I exit the engine and re-open it to load a saved game. So I actually have to create a new event which activates the call script command again everytime I load a saved game after closing the engine.
Know any way around this? :uhm:
Add this:
class Game_System
attr_accessor :monster_dist_thresh
end
Now replace all instances of $monster_dist_thresh with $game_system.monster_dist_thresh
So i will make a new script with this?
class Game_System
attr_accessor :monster_dist_thresh
end
Man, i've already placed so many enemies around the maps. Replacing this line on every single event will be so much work :xD:
oh well, i'll report the resoults when i have a chance to test it, thanks :)
I can make a script that iterates through all your maps and changes the event's script calls for you, it would only take a second
EDIT:
Here it be. Hopefully you didn't already go and change everything manually...
# Define the input and output strings.
INPUT = "$monster_dist_thresh"
OUTPUT = "$game_system.monster_dist_thresh"
#===============================================================================
count = 0
Dir.entries('Data').each {|filename|
if filename =~ /Map[\d]+\.rxdata/
changed = false
map = load_data("Data/#{filename}")
map.events.each_key {|key|
event = map.events[key]
event.pages.each_index {|i|
page = event.pages[i]
page.list.each_index {|j|
cmd = page.list[j]
next unless [355, 655].include?(cmd.code)
if event.pages[i].list[j].parameters[0].include?(INPUT)
count += 1
event.pages[i].list[j].parameters[0].gsub!(INPUT) { OUTPUT }
map.events[key] = event
changed = true
end
}
}
if changed
File.open("Data/#{filename}", 'wb') {|file| Marshal.dump(map, file) }
end
}
end
}
if count == 0
print "No event script calls found with matching string."
else
print "Found and replaced #{count} occurences of input string.\n" +
"Make sure to close and reload your project in order for the effects " +
"take place. DO NOT SAVE THE GAME when closing or nothing will change."
end
exit
This does not work. $game_system.monster_dist_thresh does not make the script call in the events recognise the code. It gives me the error: Comparison of float with nil failed. This is the error i get if i walk to a map with a patrolling enemy without using the code $monster_dist_thresh.
$game_system.monster_dist_thresh Does not give that effect and i get that error I just told about.
Edit: Oh, and that new script you made worked.
Sorry, I made the assumption that there was actually a script that set the initial value of $monster_dist_thresh.
This will fix it:
class Game_System
attr_accessor :monster_dist_thresh
alias monster_dist_init initialize
def initialize
@monster_dist_thresh = 6
monster_dist_init
end
end
Nope, I still get the float error. $game_system.monster_dist_thresh still isn't taking effect.
Are you running this from a save game, or a new game?
If its a new game, then it makes no sense unless a script below it is overwriting all of the Game_System initialize method.
I tried both New game and a Saved game and the script is furthest down in the list (above Main of course).
That doesn't make sense. Short of not using Game_System, the only possible way that could happen is if you are setting $game_system.monster_dist_thresh to nil somewhere after being initialized. There is no other possibility.
Honestly, I don't know. Maybe a possible solution would be to add the Spotted-Range with a Variable? But I guess I'll have to change the call scripts used in the Patrolling Enemies then, if it's a possible solution i will do it.
i tested what foreverzer0 added with the original demo that aqua posted and it worked fine, theres definatly something breaking it in your project
Strange! :O.o:
Let me test out a few things...
EDIT: Nope, I tested it out on a new project and $game_system.monster_dist_thresh still isn't doing what $monster_dist_thresh does.
And if I use $monster_dist_thresh instead it won't be saved when I restart the engine, like I explained before.
Are you sure I don't have to change anything in the call scripts of the patrolling events?
everything that was $monster_dist_thresh should now be $game_system.monster_dist_thresh, in the demo it was only the conditional branches that checked this, have you changed the structure much? post a screenshot of what your events look like at the moment, you also dont need to set $game_system.monster_dist_thresh to 6 at the start of the game as the initialize method does that for you
The problem has been found. The scipt you made, Zer0, does not change the strings (or call scripts) in the conditional branches, they are still the same as before. I will have to replace all of the event with new ones that uses the new Branch call scripts. I will do this later when I feel like it :P
The problem is as good as solved! Thank you guys for helping me out :)
Ah, yes I made it to change call script commands. I can make an edit.
If it's not too much trouble :)
I will get it later today.
There was a storm last night, and my power was out from 7:30 PM until some time in the middle of the night, so I didn't get to do it.
EDIT:
Give this a try, it should change conditional branches as well.
# Define the input and output strings.
INPUT = "$monster_dist_thresh"
OUTPUT = "$game_system.monster_dist_thresh"
#===============================================================================
count = 0
Dir.entries('Data').each {|filename|
if filename =~ /Map[\d]+\.rxdata/
changed = false
map = load_data("Data/#{filename}")
map.events.each_key {|key|
event = map.events[key]
event.pages.each_index {|i|
page = event.pages[i]
page.list.each_index {|j|
cmd = page.list[j]
if cmd.code == 111 && cmd.parameters[0] == 12 &&
cmd.parameters[1].include?(INPUT)
count += 1
event.pages[i].list[j].parameters[1].gsub!(INPUT) { OUTPUT }
map.events[key] = event
changed = true
next
end
next unless [355, 655].include?(cmd.code)
if event.pages[i].list[j].parameters[0].include?(INPUT)
count += 1
event.pages[i].list[j].parameters[0].gsub!(INPUT) { OUTPUT }
map.events[key] = event
changed = true
end
}
}
if changed
File.open("Data/#{filename}", 'wb') {|file| Marshal.dump(map, file) }
end
}
end
}
if count == 0
print "No event script calls found with matching string."
else
print "Found and replaced #{count} occurences of input string.\n" +
"Make sure to close and reload your project in order for the effects " +
"take place. DO NOT SAVE THE GAME when closing or nothing will change."
end
exit
Worked like a charm! Thank you once again for helping me. Everything is now working as intended and The Missing Part is bugfree :D