New account registration is temporarily disabled.

SNIPPETS FOR ADDING AND REMOVING FEATURES FROM ACTORS?

Posts

Pages: 1
how's it going guys? i need some help figuring out how to add and remove "features" from the actors via the script editor.

what i'm hoping to accomplish:
i'm working on a custom menu system to be used in my game only. i'm still fairly new at scripting so i get sideswiped often. i'm making strides though in my opinion, but i need some help this time. i included a "Tactics" option in my main menu. the purpose of this option is to toggle between manual and auto battling modes from the main menu. upon selecting the "Tactics" command via the main menu, i made it so the command becomes personal as though you're selecting an actor to view his status or equipment, etc. by pressing the "ok" button on each of your actors, you toggle their tactic mode.

the only thing i need help with is discovering the proper syntax to apply or remove the auto_battle? feature from actors. thanks in advance guys.
Marrend
Guardian of the Description Thread
21806
I'm not exactly sure myself, but looking into Game_BattlerBase, the function that is of interest to this scenario is "special_flag". If one could decipher how the heck that function determines the existence of the auto_battle property, you could use something like:


if $game_actors[x].tactic == "auto"
if $game_actors[x].auto_battle? == false
# Insert code to enable auto-battle here.
elsif $game_battler[x].tactic == "manual"
if $game_actors[x].auto_battle? == true
# Insert code to disable auto-battle here.
end
end

Or, maybe not. I'm not terribly certain of this.
i have been working on this for a couple of hours (a little disappointed that i've been unsuccessful) and i have the groundwork in place. this is an extremely simple task to achieve if i could discover the syntax to add the auto battle feature. i'm utilizing the "on_personal_ok" case method from the menu script to toggle between the feature's state. looks something like this.

def on_personal_ok
case @party_command_symbol.current_symbol
when :skill
SceneManager.call(Scene_Skill)
when :equip
SceneManager.call(Scene_Equip)
when :status
SceneManager.call(Scene_Status)
when :tactics
swap_tactics
when :transgress
SceneManager.call(Scene_Transgress)
when :trophies
SceneManager.call(Scene_Trophies)
end
end

all i need to do is set up my new method "swap_tactics" to do nothing more than toggle the selected actor's auto battle feature state. sounds so simple, but i can't discover the syntax for the life of me. my method looks like this.

def swap_tactics
actor = $game_party.members[@status_window.index]
if actor.auto_battle?
insert code here to remove auto battle
elsif !actor.auto_battle?
insert code here to add auto battle
end
@status_window.refresh
@status_window.activate
end

i refresh the status window after the fact because i have icons that indicate the current status of the auto battle feature. does anyone know how the hell to toggle the state of a feature!? LOL.
Marrend
Guardian of the Description Thread
21806
This is a huge guess on my part, but I'm thinking that to turn it on, the line would be...


$game_actors[x].special_flag(0) == true

...Since the "FLAG_ID_AUTO_BATTLE" constant in the Game_Battler class is 0. To turn it off, assuming that works (Let's face it, that's a huge assumption!), it would be...


$game_actors[x].special_flag(0) == false

How it would work off of $game_party, or the reference to "@status_window.index"? I have no idea. The $game_party array might reference $game_actors in it's code, but the IDs of the arrays could, and probably would, be different.

*Edit: Is it possible to get the $game_actors ID array from $game_party.actors.id? If so, that could be a solution!
hey Marren, thanks so much for working on this with me and trying to resolve this dilemma. i decided to take another route though after numerous syntax errors. instead of trying to apply features directly i found that it works just as well to apply a new state to the actors, which includes the auto battle feature as its primary effect.

$game_party is a variable that stores information about your party, including each actor that makes up your battle team. i allow the player to toggle the auto battle feature from the main menu as though he is selecting an actor to view his stats or his skills, etc...so specifically, you toggle auto battle from the menu status window. ultimately, by passing the status window's index through $game_party i tell the game to evaluate the toggle method only for the actor who is being currently selected on the status window and no one else. that is why i pass the status window through $game_party as an argument.

if you're interested in taking a closer look, here is a demo i made. you can gander at all code mods in there. again, thanks for helping out!

dbchest's Auto Battle and Simple Status
Marrend
Guardian of the Description Thread
21806
If it's done through a state, doesn't the state get cleared off after becoming comatose, or resting? Then again, there is (now) a demo project that demonstrates how this works, so...

*Edit: I gave this a test-run. The tactics setting does, in fact, reset itself to "manual" after resting and/or becoming comatose. Otherwise, it does seem to function as intended.
Pages: 1