RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Skill's user & target

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 68
RMRK Junior
I want to get a user and target of skill when it is used with some script lines to use in event commands

**
Rep: +0/-0Level 68
RMRK Junior
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

Code: [Select]
#==============================================================================
# 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
« Last Edit: July 30, 2011, 02:28:04 PM by gerkrt »

**
Rep: +0/-0Level 68
RMRK Junior
Thank you, I'll test it ,I think it's good