[RESOLVED] [XP] Events/Enemies Chase Script

Started by MarkHest, February 24, 2012, 04:32:42 pm

Previous topic - Next topic

diagostimo

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

MarkHest

August 08, 2012, 08:48:15 pm #21 Last Edit: August 08, 2012, 08:50:42 pm by MarkHest
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 :)
   

ForeverZer0

Ah, yes I made it to change call script commands. I can make an edit.
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.

MarkHest

   

ForeverZer0

August 09, 2012, 10:16:17 am #24 Last Edit: August 09, 2012, 05:17:37 pm by ForeverZer0
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
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.

MarkHest

August 09, 2012, 07:41:02 pm #25 Last Edit: August 09, 2012, 07:42:03 pm by MarkHest
Worked like a charm! Thank you once again for helping me. Everything is now working as intended and The Missing Part is bugfree :D