I want to get a user and target of skill when it is used with some script lines to use in event commands
Test and check this script and tell if its waht you want
#==============================================================================
# Get attacker, target ids, in battle? and battle turn in combat for
# comand events
# By gerkrt/gerrtunk
# Version: 1.5
# License: MIT, credits
# Date: 22/07/2011
#==============================================================================
=begin
--------INTRODUCTION--------
This add two functions to use in battle that save the attacker and
targets ids for use in events engines.
------USAGE(call scripts)------
Get battle turn:
v = $game_temp.battle_turn
$game_variables[X] = v
Get if its in a battle or not:
v = $game_temp.in_battle
$game_switches[X] = v
Attacker id(skill or whatever):
v = attacker_id
$game_variables[X] = v
Target id(skill or whatever):
v = target_id
$game_variables[X] = v
Where X is the game variable you want to store the result
Returns the database id for enemy or actor, it autochecks that.
These two commands get the active battler id. That battler is the one is
executing the action so you have to get it when it does that.
=end
class Game_Actor < Game_Battler
attr_reader :actor_id
end
class Scene_Battle
def attacker_id
if @active_battler.is_a? Game_Actor
return @active_battler.actor_id
else
return @active_battler.enemy_id
end
end
def target_id
if @active_battler.is_a? Game_Actor
return @active_battler.current_action.target_index
else
return $game_party.actors[@active_battler.current_action.target_index].actor_id
end
end
end