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.

small scripting question

I was wondering if it was possible to call a script from within an event to change the monster id's in a certain "troop" id

it is so i could have a dummy troop that i could change what monsters are in it based on what is happening in the game.

i don't know ruby very well at all but something like

troop(2).enemyid(1) = 3

so in my very crappy qbasic like programming there it would change the 1st monster in the 2nd troop to monster id 3

hope these makes sense i feel like i have seen something like this as part of a much bigger combat system but couldn't find anything by itself.
 

Atoa

Member

Code:
  def initialize(troop_id, member_index)

    super()

    @troop_id = troop_id

    @member_index = member_index

    troop = $data_troops[@troop_id]

    @enemy_id = troop.members[@member_index].enemy_id

    enemy = $data_enemies[@enemy_id]

 
This is the start of initialize of game enemy


on my battle system i've made the following change:
Code:
  def initialize(troop_id, member_index, id = nil)

    super()

    @troop_id = troop_id

    @member_index = member_index

    troop = $data_troops[@troop_id]

    @enemy_id = id.nil? ? troop.members[@member_index].enemy_id : id

    enemy = $data_enemies[@enemy_id]
That way i can call enemy Game_Enemy.new(X, Y, enemy_id)

on your example you could add an 'attr_accessor :enemies' on $game_troop an call $game_trop.enemies[index] = Game_Enemy.new(troop_id, index, enemy_id)
 
I had a little time to try what you where talking about but was getting some errors.
i added the

attr_accessor :enemies

to the game_troop

then tried to call the $game_troop.enemies[index] = Game_Enemy.new(troop_id, index, enemy_id)...and i first got a "wrong number of arguments 3 for 2" error so i tried only using 2 which then gave me a different error.

anyway sorry i will look at it more tomorrow but i was just wondering if you could explain which index goes where..in the
$game_troop.enemies[index] = Game_Enemy.new(troop_id, index, enemy_id)

i should mention i am using the old enu's sideview system with some of your add-on's that might be interfering.
 
Ok i started a new project to test this out on and changed the monsters in troop 1 to the preset hellhounds. Then called the
$game_troop.enemies[1] = Game_Enemy.new(1,1,1) from an event (all 1's sense i was not sure on the first "index" variable) this way i figured it would change the 1st monster in the 1st troop with the 1st monster on the monster list......but nothing happened....no error but no change to the fight ether.

Thank you for taking time to help me out with this Atoa. I appreciate it.
 
well I found a way to do what i needed by looking at the "transform command" in "interpreter 7" and coping that process then pasting it in script calls on the troop event page and changing the @parameters[0] and @parameters[1] to game_variables.

i was trying to set up the fight before it was called but i guess it really doesn't matter if it happens on turn 0 you can't tell.

thanks for the help Atoa you got me looking in the right places
 

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