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.
Hi , i was wondering of someone could make this script, i dont think its really hard, and maybe some1 alredy done it.
I need a script that make the state Confused to atack random targets, the common option is to atack only allies or only enemies, but not both...
So if any1 could help me making a script that change this to make the character that have this "state" to atack randomly an enemie or an ally.
You could do it with events, if no one is going to script this.
Make two identical status effects. Name them the same thing (or, just set their rating to 0 to keep them hidden).
Make one so they "always attack allies" and the other to "randomly attack enemies".
Then, have both of them call the same Common Event and use a variable to pick one of them at random.
@Conditional Branch: Player is Confused:
@Control Variable: Variable [0001] (for example) = Random (1...2)
@Conditional Branch: Variable [0001] = 1
...<>Change State: +(the one that attacks allies)
Else:
@Conditional Branch: Variable [0001] = 2
...<>Change State: +(the one that attacks enemies)
Make a duplicate for this for if the player is inflicted with your other "Confused" state.
Set both states to release at end of battle, etc. and make sure that each state removes the other state when it is inflicted.
You can also set it up to choose a random number 1 ~ 3 and, if Variable 0001] = 3, remove both states (person recovers). Set a larger range to reduce % chance of recovery.
That would be 'random' if it worked. 50% of the time you attack an ally, 50% of the time you attack an enemy.
The problem is... there is no "call common event" on a state.
You could use Rhaz' common event, add a line to remove the other state, and call the common event
every turn in the battle events page for each troop.
In 'Scene_Battle 4' , look for the method 'def make_basic_action_result'
Add the section surrounded by '###############'
Code:
#--------------------------------------------------------------------------
# * Make Basic Action Results
#--------------------------------------------------------------------------
def make_basic_action_result
# If attack
if @active_battler.current_action.basic == 0
# Set anaimation ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# If action battler is enemy
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
# If action battler is actor
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
##################################################################
# If current state is 'confuse', target random ally or enemy
if @active_battler.state?(6)
side = rand(100)
if (side < 50) #set to % odds of hitting an enemy
target = $game_troop.random_target_enemy
else
target = $game_party.random_target_actor
end
end
##################################################################
# Set array of targeted battlers
@target_battlers = [target]
# Apply normal attack results
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
# If guard
if @active_battler.current_action.basic == 1
# Display "Guard" in help window
@help_window.set_text($data_system.words.guard, 1)
return
end
# If escape
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
# Display "Escape" in help window
@help_window.set_text("Escape", 1)
# Escape
@active_battler.escape
return
end
# If doing nothing
if @active_battler.current_action.basic == 3
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
Change the '50' to the % odds that an enemy gets hit.
Change the '6' if your confuse state is not #6
Caveat: an actor can attack himself
It might be cool to use the 'restriction' to set a preference...
i.e. if it's 'attack enemy', use 75% chance of hitting enemy,
if 'attack ally', use 25% chace of hitting enemy.. ??