#-------------------------------------------------------------------# Cannibal hit list#-------------------------------------------------------------------# by Dark Griffin# version 0.1#-------------------------------------------------------------------# Add on to the cannibalism script by Kread-EX, won't work without it.## version 0.1# Provides a menu to check what enemies a party member has eaten.# The menu simply checks if they have any cannibal count for now,# I haven't worked out how to get the enemy eating_limit outside# of combat yet(the flags don't exist on the enemy objects till the # troop is loaded into# combat memory in the default cannibalism script, so I'll need to# write my own parser to emulate that part of the engine).# Not quite up to writing a notespace parcer yet.# This should be fine for my game, as each enemy only gives stats# once anyway.#-------------------------------------------------------------------if !$imported["YEA-AceMenuEngine"]#-------------------------------------------------------------------# Non Yanfly menu addon code# NOTE: This is currently untested and probably broken, but won't run unless# in vanilla RPG Maker.#-------------------------------------------------------------------class Scene_Menu < Scene_MenuBase def create_command_window @command_window.set_handler(:hitlist, method(:Scene_CHitList)) end def Scene_CHitList SceneManager.call(Scene_Cannibal_Hitlist) endend#-------------------------------------------------------------------end# End of non yanfly menu add on code.#-------------------------------------------------------------------#-------------------------------------------------------------------# Window_Cannibal_Hitlist#-------------------------------------------------------------------class Window_Cannibal_Hitlist < Window_Selectable #------------------------------------------------------------------- # Public instance variables #------------------------------------------------------------------- attr_accessor :hitlist attr_accessor :monsterlistnames attr_accessor :partymemberID #------------------------------------------------------------------- # initialize #------------------------------------------------------------------- def initialize(x, y, width, height) super @index = 0 # just a quick overwrite to allow selections. @column_max = 1 #single column display, we just want a list. @cursor_fix = false #no idea what this does, but most menus have it off. @cursor_all = false #no idea what this does, but most menus have it off. @hitlist = [] #set hitlist to array type, and empty. @partymemberID = $game_party.menu_actor.id #get the selected party member calculate_hitlist # calculate the hitlist arrays, so we have data # to work with refresh # refresh the window to make it show up enable_indexing_if_content #check if there is any content to display end #------------------------------------------------------------------- # Test to see if process_cursor_move happens # Yes, it runs every frame the menu is open when this is enabled. #------------------------------------------------------------------- #def process_cursor_move #super #p("process_cursor_move has run") #end #------------------------------------------------------------------- # enable_indexing_if_content - turns index to 0 and populates list # when there is content in the @monsterlistnames array. #------------------------------------------------------------------- def enable_indexing_if_content if @monsterlistnames != [] #set index to enable cursor @index = 0 #set item_max to length of hitlist @item_max = @monsterlistnames.length end end #------------------------------------------------------------------- # calculate_hitlist - build the @monsterlistnames array # also builds the @hitlist array from the party member's data #------------------------------------------------------------------- def calculate_hitlist #if there are eaten enemies in the list, start parsing if !$game_actors[@partymemberID].devoured.nil? #clear ids and names arrays monster_ids = [] @monsterlistnames = [] #for every entry in the monster db, check it. $data_enemies.each_index do |i| if $data_enemies[i] != nil # if not nil if $data_enemies[i].name != nil # if it has a name. monster_ids.push $data_enemies[i].id # push the id to array end end end #for every id found, do this. monster_ids.each_index do |i| if $data_enemies[i] != nil #if not nil @monsterlistnames.push $data_enemies[i].name #add the name to array end end #get actor hit list actor_hit_list = $game_actors[@partymemberID].devoured # run over all of actor hit list, and push monster name # entries to @hitlist if # they have eaten the enemy. actor_hit_list.each_index do |i| #check against database if actor_hit_list[i] != nil #if the monster has been eaten, push name to hitlist. @hitlist.push $data_enemies[i].name end end else #if there are no enemies eaten, just set to nothing. @hitlist = [] end end #------------------------------------------------------------------- # refresh data - clears contents , then calls can_draw_all_monster_names #------------------------------------------------------------------- def refresh #p("clearing contents") contents.clear #p("drawing all items in menu") can_draw_all_monster_names end #------------------------------------------------------------------- # can draw all monster names - loop through monster name list and # call can_draw_monster_name for each index. #------------------------------------------------------------------- def can_draw_all_monster_names #declare offset value @monster_offset = 0 @monsterlistnames.each_index do |i| #only draw if not nil and has name. if i != nil && @monsterlistnames[i] != "" can_draw_monster_name(i) # draw monster in list end # if the name was "" then back up one menu item for any remaining # monsters in the list. This avoids gaps used in the editor to # sort monsters into groups when the editor data has them. if @monsterlistnames[i] == "" @monster_offset = @monster_offset - 1 end end end #------------------------------------------------------------------- # can draw monster name - checks if item index is in hitlist, # modifies it depending on result, and draws the item to contents #------------------------------------------------------------------- def can_draw_monster_name(index) item = @monsterlistnames[index] # check if item even has name if item != "" #----------------- # check if item is in both arrays if @hitlist.include?(item) # if it is, add a "* " to the string item = "* " + item else # if not, add a "- " instead item = "- " + item end #----------------- #draw the line of text for the enemy item entry. ypos = line_height * (index + @monster_offset) contents.draw_text(x + 24, ypos, width, line_height, item) end end #-------------------------------------------------------------------end##################################################################################################### Scene_Cannibal_Hitlist#############################class Scene_Cannibal_Hitlist < Scene_MenuBase #------------------------------------------------------------------- # attribute accessors for the scene object #------------------------------------------------------------------- attr_accessor :WindowC #------------------------------------------------------------------- # Start #------------------------------------------------------------------- def start super @WindowC = Window_Cannibal_Hitlist.new(0,0,Graphics.width,Graphics.height) set_handlers_on_window @WindowC.activate p("is window active?") p(@WindowC.active) end #------------------------------------------------------------------- # set handlers on window - sets the cancel button for now #------------------------------------------------------------------- def set_handlers_on_window @WindowC.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # Dispose Window #-------------------------------------------------------------------------- def terminate @WindowC.dispose end end######################################################################-------------------------------------------------------------------# Start of Yanfly addon code#-------------------------------------------------------------------if $imported["YEA-AceMenuEngine"]############################################################################ NOTE: To add to the menu, use this tag in custom commands# :chitlist => ["Prey List", 0, 0, :Scene_CHitList],#-------------------------------------------------------------------# You will also need to add this to the commands menu list for it to appear# :chitlist, # Opens the cannibalism hit list menu.########################################################################### #------------------------------------------------------------------- # Add to Yanfly menu #------------------------------------------------------------------- class Scene_Menu < Scene_MenuBase #------------------------------------------------------------------- # Scene_CHitList definition - selects a member, then launches the window #------------------------------------------------------------------- def Scene_CHitList #pick a party member @status_window.select_last @status_window.activate @status_window.set_handler(:ok, method(:openCannibalHitlist)) @status_window.set_handler(:cancel, method(:on_personal_cancel)) end #------------------------------------------------------------------- # open cannibal hit list - calls a change to the cannibal hitlist scene #------------------------------------------------------------------- def openCannibalHitlist #p("status window passed an ok command") @status_window.deactivate SceneManager.call(Scene_Cannibal_Hitlist) end end#########################################################end #end Yanfly menu add on