Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Returning the target of a skill

I just need a simple little script that returns the Monster ID of a skill's target; I tried using $game_troop.smooth_target_enemy, but I couldn't get it to work. Thanks!
 
Well, since this isn't in the script requests board..

Scene_Battle, add this:
Code:
attr_accessor :target_battlers
Then use $scene.target_battlers[0].id

I think that's the way it works. Or you can just set a variable whenever skill effect in Game_Battler3 is used to "= self.id"
 
Okay, now I'm just having stupidity issues.

I defined @target in Game_Battler#Initialize as @target = 0, and in Skill_Effect I inserted the line
Code:
@target = self.id

But when I try to call it with
Code:
$game_battler.target == 34

I get an undefined method error for Target. What gives?
 
You need to be able to access target outside of it. That's what the accessor part is for, but Game_Battler isn't actually used as that inside of RMXP

Try this instead :)

Code:
begin
  SDK.log('Skill Target', 'sandgolem', 1, '15.07.06')
  rescue
end

class Game_Battler
  alias sandgolem_itemtarget_battler_skeff skill_effect
  def skill_effect(user,skill)
    sandgolem_itemtarget_battler_skeff(user,skill)
    $sg_skilltarget = self
  end
end
Then use $sg_skilltarget.id instead of $game_battler.target.

Or you can change $sg_skilltarget = self to
Code:
$game_variables[#] = self.id
To use it easier as a regular variable if that's all you want the target for. Change the # to a number.

A scan skill as an event? Odd. But definetely a good reason to have that base events script :)
 
Heh, as it turns out, I could just use a Common Event to store all the Scan messages and process that stuff. Thanks again! I'm not sure why I didn't think of just setting it to a game variable, but RGSS is still quite new to me.

One last question, if you're still reading: how can I make an array to store a set of IDs? With such an array, I could reference which enemy types have already been scanned.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top