# Velvet Isis' Direction Based Interaction Script #------------------------------------------------------------------------------- # This is not entirely my own work. It is mostly based on: # The Infamous Bon Bon's Direction Based Line of Sight Events # This script takes the information they gave and adds a little bit to turn it # into a simple but functional Direction Based Interaction script. #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Directions: To make an event's interaction be direction based use the event # command 'Script...' under tab 3 of the Event Commands and type in # # director # # That's it, no ' no " just the word director, all lower case. Also they MUST # MUST MUST MUST MUST be set to parallel process. # # Then for what they do when interacted with by the Player, have a new page # with the Condition: self-switch B is on for when interacted from the side # and Condition: self-switch C is on for when interacted from behind. # The defaults are B and C, but you can change them below. #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Things you can edit #------------------------------------------------------------------------------- module VIS SIDE_SELFSWITCH = "B" #This is which self switch becomes true when the Event is interacted with #from the side. #Be sure to keep the " " around the letter. BACK_SELFSWITCH = "C" #This is which self switch becomes true when the Event is interacted with #from the side. #Be sure to keep the " " around the letter. end #------------------------------------------------------------------------------- # You probably shouldn't edit things below here, but I'm not gonna judge. # I mean, that's how I learned to do things, was by putzin' around with # other people's scripts. I mean if you change stuff the script might not # work, but you live and you learn, and that's how you get better #------------------------------------------------------------------------------- class Game_Character #------------------------------------------------------------------------------- # Player's position relation to Enemy #------------------------------------------------------------------------------- #---------------------------------# # Enemy behind Player? # #---------------------------------# def E_behind_P? ex = self.x ey = self.y px = $game_player.x py = $game_player.y pd = $game_player.direction if @direction == 2 && pd == 2 && py > ey || @direction == 8 && pd == 8 && py < ey || @direction == 4 && pd == 4 && px < ex || @direction == 6 && pd == 6 && px > ex return true end end #---------------------------------# # Player behind Enemy? # #---------------------------------# def P_behind_E? ex = self.x ey = self.y px = $game_player.x py = $game_player.y pd = $game_player.direction if @direction == 2 && pd == 2 && py < ey || @direction == 8 && pd == 8 && py > ey || @direction == 4 && pd == 4 && px > ex || @direction == 6 && pd == 6 && px < ex return true end end #---------------------------------# # Player Facing Enemy # #---------------------------------# def P_face? ex = self.x ey = self.y px = $game_player.x py = $game_player.y pd = $game_player.direction if pd == 2 && py < ey || pd == 8 && py > ey || pd == 4 && px > ex || pd == 6 && px < ex return true end end #---------------------------------# # Enemy Facing Player # #---------------------------------# def E_face? ex = self.x ey = self.y ed = self.direction px = $game_player.x py = $game_player.y if ed == 2 && ey < py || ed == 8 && ey > py || ed == 4 && ex > px || ed == 6 && ex < px return true end end #---------------------------------# # Facing Each Other # #---------------------------------# def facing? ex = self.x ey = self.y px = $game_player.x py = $game_player.y pd = $game_player.direction if @direction == 8 && pd == 2 && py < ey || @direction == 2 && pd == 8 && py > ey || @direction == 6 && pd == 4 && px > ex || @direction == 4 && pd == 6 && px < ex return true end end #---------------------------------# # Touching # #---------------------------------# def touching? ex = self.x ey = self.y px = $game_player.x py = $game_player.y if (ex - px).abs + (ey - py).abs <= 1 return true end end #------------------------------------------------------------------------------- # Hitting #------------------------------------------------------------------------------- #---------------------------------# # Hit from Front # #---------------------------------# def hitting if touching? if P_face? if P_behind_E? #Hitting from behind if Input.press?(:C) set_self_switch("C", true) end elsif facing? #Hitting from in front if Input.press?(:C) set_self_switch("D", true) end else #Hitting from side if Input.press?(:C) set_self_switch("B", true) end end end end end #------------------------------------------------------------------------------- # Basic Enemy Behavior #------------------------------------------------------------------------------- #---------------------------------# # Director # #---------------------------------# def director hitting end #------------------------------------------------------------------------------- # Self Switches #------------------------------------------------------------------------------- #-----------------------------# # Get Self Switch # #-----------------------------# def get_self_switch(switch) key = [@map_id, @id, switch] return $game_self_switches[key] end #-----------------------------# # Set Self Switch # #-----------------------------# def set_self_switch(switch,true_false) key = [@map_id, @id, switch] $game_self_switches[key] = true_false $game_map.need_refresh = true end end class Game_Interpreter def director get_character(0).director end end