Events only allow the modification of six parameters:
- max hp
- max sp
- str
- dex
- agi
- int
But many more variables/parameters exist worth changing, for example, control variables lists the following:
I've placed the normally* inaccessible values in green.
- Level (*can be directly changed with events)
- Exp (*can be directly changed with events)
- Hp (*can be temporarily changed with events)
- Sp (*can be temporarily changed with events)
- Max hp
- max sp
- str
- dex
- agi
- int
- atk
- PDEF
- MDEF
- EVA
btw. I do not know how to adress specific characters, but I tried something like
$data_actors[11].pdef == 100which naturally crashed.
If I had my computer here, I could probably be of more assistance. Provided I've got the RGSS Syntax right, your on the right track, but switch 'data' with 'game'.
Long time since I last used XP, you see...
You can definitely change those with events. Not sure what your problem is.
Quote from: grafikal on May 06, 2010, 05:32:56 AM
You can definitely change those with events. Not sure what your problem is.
can you demonstrate how to do so? If I knew how I would have by now,
but not seeing a way of doing so, I assumed an event with script would be alternative. As far as I know, without making hundreds of "states" to address the various MDEF/PDEF possibilities, it's not possible with eventing.
yeah, ill show you soon. im on the phone with my cellphone company lol. i have my info for them on my mac but when im done ill swap over to windows and take a few screenshots.
PS. I dont remember if you can alter Mdef but Pdef is just DEF
double post:
ok, you can change all but PDEF and MDEF. the DEF stat is editable only via Armor and you cant change armor stats in events unless you're tricky and create copies of armor with different stats. Dont do that.
attached is a copy of the 3rd page in the events tab.
clearly you can change everything you asked except for EVA MDEF and PDEF
i have no idea how you missed all of those when they're right next to what you were using
That's all true for certain. However, I want to change PDEF, EVA, and MDEF. I presume that can be done through script, but I could be wrong. Is it impossible?
script
Insert bellow main:
[spoiler]#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :name # name
attr_reader :character_name # character file name
attr_reader :character_hue # character hue
attr_reader :class_id # class ID
attr_reader :weapon_id # weapon ID
attr_reader :armor1_id # shield ID
attr_reader :armor2_id # helmet ID
attr_reader :armor3_id # body armor ID
attr_reader :armor4_id # accessory ID
attr_reader :level # level
attr_reader :exp # EXP
attr_reader :skills # skills
#--------------------------------------------------------------------------
# * Object Initialization
# actor_id : actor ID
#--------------------------------------------------------------------------
def initialize(actor_id)
super()
setup(actor_id)
end
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
mdef1 = weapon != nil ? weapon.mdef : 0
mdef2 = armor1 != nil ? armor1.mdef : 0
mdef3 = armor2 != nil ? armor2.mdef : 0
mdef4 = armor3 != nil ? armor3.mdef : 0
mdef5 = armor4 != nil ? armor4.mdef : 0
@var_mdef = mdef1 + mdef2 + mdef3 + mdef4 + mdef5
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
pdef1 = weapon != nil ? weapon.pdef : 0
pdef2 = armor1 != nil ? armor1.pdef : 0
pdef3 = armor2 != nil ? armor2.pdef : 0
pdef4 = armor3 != nil ? armor3.pdef : 0
pdef5 = armor4 != nil ? armor4.pdef : 0
@var_pdef = pdef1 + pdef2 + pdef3 + pdef4 + pdef5
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_name = actor.character_name
@character_hue = actor.character_hue
@battler_name = actor.battler_name
@battler_hue = actor.battler_hue
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
@hp = maxhp
@sp = maxsp
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
# Learn skill
for i in 1..@level
for j in $data_classes[@class_id].learnings
if j.level == i
learn_skill(j.skill_id)
end
end
end
# Update auto state
update_auto_state(nil, $data_armors[@armor1_id])
update_auto_state(nil, $data_armors[@armor2_id])
update_auto_state(nil, $data_armors[@armor3_id])
update_auto_state(nil, $data_armors[@armor4_id])
end
#--------------------------------------------------------------------------
# * Get Actor ID
#--------------------------------------------------------------------------
def id
return @actor_id
end
#--------------------------------------------------------------------------
# * Get Index
#--------------------------------------------------------------------------
def index
return $game_party.actors.index(self)
end
#--------------------------------------------------------------------------
# * Calculate EXP
#--------------------------------------------------------------------------
def make_exp_list
actor = $data_actors[@actor_id]
@exp_list[1] = 0
pow_i = 2.4 + actor.exp_inflation / 100.0
for i in 2..100
if i > actor.final_level
@exp_list = 0
else
n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
@exp_list = @exp_list[i-1] + Integer(n)
end
end
end
#--------------------------------------------------------------------------
# * Get Element Revision Value
# element_id : element ID
#--------------------------------------------------------------------------
def element_rate(element_id)
# Get values corresponding to element effectiveness
table = [0,200,150,100,50,0,-100]
result = table[$data_classes[@class_id].element_ranks[element_id]]
# If this element is protected by armor, then it's reduced by half
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
armor = $data_armors
if armor != nil and armor.guard_element_set.include?(element_id)
result /= 2
end
end
# If this element is protected by states, then it's reduced by half
for i in @states
if $data_states.guard_element_set.include?(element_id)
result /= 2
end
end
# End Method
return result
end
#--------------------------------------------------------------------------
# * Get State Effectiveness
#--------------------------------------------------------------------------
def state_ranks
return $data_classes[@class_id].state_ranks
end
#--------------------------------------------------------------------------
# * Determine State Guard
# state_id : state ID
#--------------------------------------------------------------------------
def state_guard?(state_id)
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
armor = $data_armors
if armor != nil
if armor.guard_state_set.include?(state_id)
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# * Get Normal Attack Element
#--------------------------------------------------------------------------
def element_set
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.element_set : []
end
#--------------------------------------------------------------------------
# * Get Normal Attack State Change (+)
#--------------------------------------------------------------------------
def plus_state_set
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.plus_state_set : []
end
#--------------------------------------------------------------------------
# * Get Normal Attack State Change (-)
#--------------------------------------------------------------------------
def minus_state_set
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.minus_state_set : []
end
#--------------------------------------------------------------------------
# * Get Maximum HP
#--------------------------------------------------------------------------
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min
for i in @states
n *= $data_states.maxhp_rate / 100.0
end
n = [[Integer(n), 1].max, 9999].min
return n
end
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
def base_maxhp
return $data_actors[@actor_id].parameters[0, @level]
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
def base_maxsp
return $data_actors[@actor_id].parameters[1, @level]
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
def base_str
n = $data_actors[@actor_id].parameters[2, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.str_plus : 0
n += armor1 != nil ? armor1.str_plus : 0
n += armor2 != nil ? armor2.str_plus : 0
n += armor3 != nil ? armor3.str_plus : 0
n += armor4 != nil ? armor4.str_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
def base_dex
n = $data_actors[@actor_id].parameters[3, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.dex_plus : 0
n += armor1 != nil ? armor1.dex_plus : 0
n += armor2 != nil ? armor2.dex_plus : 0
n += armor3 != nil ? armor3.dex_plus : 0
n += armor4 != nil ? armor4.dex_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
n = $data_actors[@actor_id].parameters[4, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.agi_plus : 0
n += armor1 != nil ? armor1.agi_plus : 0
n += armor2 != nil ? armor2.agi_plus : 0
n += armor3 != nil ? armor3.agi_plus : 0
n += armor4 != nil ? armor4.agi_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
def base_int
n = $data_actors[@actor_id].parameters[5, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += weapon != nil ? weapon.int_plus : 0
n += armor1 != nil ? armor1.int_plus : 0
n += armor2 != nil ? armor2.int_plus : 0
n += armor3 != nil ? armor3.int_plus : 0
n += armor4 != nil ? armor4.int_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# * Get Basic Attack Power
#--------------------------------------------------------------------------
def base_atk
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.atk : 0
end
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
def base_pdef
@var_pdef
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
def base_mdef
@var_mdef
end
#--------------------------------------------------------------------------
# * Get Basic Evasion Correction
#--------------------------------------------------------------------------
def base_eva
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
eva1 = armor1 != nil ? armor1.eva : 0
eva2 = armor2 != nil ? armor2.eva : 0
eva3 = armor3 != nil ? armor3.eva : 0
eva4 = armor4 != nil ? armor4.eva : 0
return eva1 + eva2 + eva3 + eva4
end
#--------------------------------------------------------------------------
# * Get Offensive Animation ID for Normal Attacks
#--------------------------------------------------------------------------
def animation1_id
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.animation1_id : 0
end
#--------------------------------------------------------------------------
# * Get Target Animation ID for Normal Attacks
#--------------------------------------------------------------------------
def animation2_id
weapon = $data_weapons[@weapon_id]
return weapon != nil ? weapon.animation2_id : 0
end
#--------------------------------------------------------------------------
# * Get Class Name
#--------------------------------------------------------------------------
def class_name
return $data_classes[@class_id].name
end
#--------------------------------------------------------------------------
# * Get EXP String
#--------------------------------------------------------------------------
def exp_s
return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"
end
#--------------------------------------------------------------------------
# * Get Next Level EXP String
#--------------------------------------------------------------------------
def next_exp_s
return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"
end
#--------------------------------------------------------------------------
# * Get Until Next Level EXP String
#--------------------------------------------------------------------------
def next_rest_exp_s
return @exp_list[@level+1] > 0 ?
(@exp_list[@level+1] - @exp).to_s : "-------"
end
#--------------------------------------------------------------------------
# * Update Auto State
# old_armor : unequipped armor
# new_armor : equipped armor
#--------------------------------------------------------------------------
def update_auto_state(old_armor, new_armor)
# Forcefully remove unequipped armor's auto state
if old_armor != nil and old_armor.auto_state_id != 0
remove_state(old_armor.auto_state_id, true)
end
# Forcefully add unequipped armor's auto state
if new_armor != nil and new_armor.auto_state_id != 0
add_state(new_armor.auto_state_id, true)
end
end
#--------------------------------------------------------------------------
# * Determine Fixed Equipment
# equip_type : type of equipment
#--------------------------------------------------------------------------
def equip_fix?(equip_type)
case equip_type
when 0 # Weapon
return $data_actors[@actor_id].weapon_fix
when 1 # Shield
return $data_actors[@actor_id].armor1_fix
when 2 # Head
return $data_actors[@actor_id].armor2_fix
when 3 # Body
return $data_actors[@actor_id].armor3_fix
when 4 # Accessory
return $data_actors[@actor_id].armor4_fix
end
return false
end
#--------------------------------------------------------------------------
# * Change Equipment
# equip_type : type of equipment
# id : weapon or armor ID (If 0, remove equipment)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # Weapon
if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
$game_party.lose_weapon(id, 1)
end
when 1 # Shield
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
$game_party.gain_armor(@armor1_id, 1)
@armor1_id = id
$game_party.lose_armor(id, 1)
end
when 2 # Head
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
$game_party.gain_armor(@armor2_id, 1)
@armor2_id = id
$game_party.lose_armor(id, 1)
end
when 3 # Body
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
$game_party.gain_armor(@armor3_id, 1)
@armor3_id = id
$game_party.lose_armor(id, 1)
end
when 4 # Accessory
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
$game_party.gain_armor(@armor4_id, 1)
@armor4_id = id
$game_party.lose_armor(id, 1)
end
end
end
#--------------------------------------------------------------------------
# * Determine if Equippable
# item : item
#--------------------------------------------------------------------------
def equippable?(item)
# If weapon
if item.is_a?(RPG::Weapon)
# If included among equippable weapons in current class
if $data_classes[@class_id].weapon_set.include?(item.id)
return true
end
end
# If armor
if item.is_a?(RPG::Armor)
# If included among equippable armor in current class
if $data_classes[@class_id].armor_set.include?(item.id)
return true
end
end
return false
end
#--------------------------------------------------------------------------
# * Change EXP
# exp : new EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
# Learn skill
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
# Level down
while @exp < @exp_list[@level]
@level -= 1
end
# Correction if exceeding current max HP and max SP
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# * Change Level
# level : new level
#--------------------------------------------------------------------------
def level=(level)
# Check up and down limits
level = [[level, $data_actors[@actor_id].final_level].min, 1].max
# Change EXP
self.exp = @exp_list[level]
end
#--------------------------------------------------------------------------
# * Learn Skill
# skill_id : skill ID
#--------------------------------------------------------------------------
def learn_skill(skill_id)
if skill_id > 0 and not skill_learn?(skill_id)
@skills.push(skill_id)
@skills.sort!
end
end
#--------------------------------------------------------------------------
# * Forget Skill
# skill_id : skill ID
#--------------------------------------------------------------------------
def forget_skill(skill_id)
@skills.delete(skill_id)
end
#--------------------------------------------------------------------------
# * Determine if Finished Learning Skill
# skill_id : skill ID
#--------------------------------------------------------------------------
def skill_learn?(skill_id)
return @skills.include?(skill_id)
end
#--------------------------------------------------------------------------
# * Determine if Skill can be Used
# skill_id : skill ID
#--------------------------------------------------------------------------
def skill_can_use?(skill_id)
if not skill_learn?(skill_id)
return false
end
return super
end
#--------------------------------------------------------------------------
# * Change Name
# name : new name
#--------------------------------------------------------------------------
def name=(name)
@name = name
end
#--------------------------------------------------------------------------
# * Change Class ID
# class_id : new class ID
#--------------------------------------------------------------------------
def class_id=(class_id)
if $data_classes[class_id] != nil
@class_id = class_id
# Remove items that are no longer equippable
unless equippable?($data_weapons[@weapon_id])
equip(0, 0)
end
unless equippable?($data_armors[@armor1_id])
equip(1, 0)
end
unless equippable?($data_armors[@armor2_id])
equip(2, 0)
end
unless equippable?($data_armors[@armor3_id])
equip(3, 0)
end
unless equippable?($data_armors[@armor4_id])
equip(4, 0)
end
end
end
#--------------------------------------------------------------------------
# * Change Graphics
# character_name : new character file name
# character_hue : new character hue
# battler_name : new battler file name
# battler_hue : new battler hue
#--------------------------------------------------------------------------
def set_graphic(character_name, character_hue, battler_name, battler_hue)
@character_name = character_name
@character_hue = character_hue
@battler_name = battler_name
@battler_hue = battler_hue
end
#--------------------------------------------------------------------------
# * Get Battle Screen X-Coordinate
#--------------------------------------------------------------------------
def screen_x
# Return after calculating x-coordinate by order of members in party
if self.index != nil
return self.index * 160 + 80
else
return 0
end
end
#--------------------------------------------------------------------------
# * Get Battle Screen Y-Coordinate
#--------------------------------------------------------------------------
def screen_y
return 464
end
#--------------------------------------------------------------------------
# * Get Battle Screen Z-Coordinate
#--------------------------------------------------------------------------
def screen_z
# Return after calculating z-coordinate by order of members in party
if self.index != nil
return 4 - self.index
else
return 0
end
end
end
[/spoiler]
To change mdef or pdef, put the following in a "script..." command:
$game_party.actors[Id of actor].var_pdef += how much you want to add
or
$game_party.actors[Id of actor].var_mdef += how much you want to add
I wasn't certain if it was my own script screwing things up so I opened a new project to do a dry run, and it spat out
"undefined method 'var_def' for #<Game_Actor:0x3681380>
the gibberish in red changes each time I load it, even if I don't change anything, so they must not mean anything.
you wrote "var_def"
you should write "var_pdef" or "var_mdef"
Quote from: valdred on May 06, 2010, 08:02:49 PM
you wrote "var_def"
you should write "var_pdef" or "var_mdef"
sorry about the typo, the error actually reads:
"undefined method 'var_pdef' for #<Game_Actor:0x3681380>"
if you were wondering if I typed it incorrectly in the project, the answer is no, I copy pasted.
Actors don't have a MDEF or PDEF. Only armor has that. You're trying to alter actor stats that don't exist.
I made the instance variable in Game_Actor and rewrote the methods for pdef and mdef. I don't know why it's not working.
good point. lol
I've been able to create and call out variables in script, but haven't been able to change them one whit.
for example, the basic script:
p $game_actors[10].base_sta
p $game_actors[10].base_str
p $game_actors[10].base_int
p $game_actors[10].base_pdef
p $game_actors[10].base_mdef
will print the integers of my character's stats (actor #10) and even print the variable of a new stat I created called Stamina. but if I wrote something like
$game_actors[10].base_int += 10
or
$game_actors[10].base_int = 100
it would crash.
I was even able to get this working:
p $game_actors[10].base_str + 10
which prints the total. But I don't know how to change any of these values.
Closest I could get to changing the values without doing anything major. Basically, each value is stored in a variable + the armour. So if the Physical Defense you get from your armour is 1, and the defense you store in your variable is 2, then the total defense would be 3.
Can't say for sure this will work exactly as you want it to, if it doesn't, please specify what else you want done.
# Change PDEF_VAR to the variable you want your pdef to be stored in.
# Change MDEF_VAR to the variable you want your mdef to be stored in.
# Change EVA_VAR to the variable you want your eva to be stored in.
module COZZIEKUNS
PDEF_VAR = 1
MDEF_VAR = 2
EVA_VAR = 3
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
def base_pdef
@pdef = COZZIEKUNS::PDEF_VAR
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
pdef1 = weapon != nil ? weapon.pdef : 0
pdef2 = armor1 != nil ? armor1.pdef : 0
pdef3 = armor2 != nil ? armor2.pdef : 0
pdef4 = armor3 != nil ? armor3.pdef : 0
pdef5 = armor4 != nil ? armor4.pdef : 0
pdef6 = $game_variables[@pdef]
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + pdef6
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
def base_mdef
@mdef = COZZIEKUNS::MDEF_VAR
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
mdef1 = weapon != nil ? weapon.mdef : 0
mdef2 = armor1 != nil ? armor1.mdef : 0
mdef3 = armor2 != nil ? armor2.mdef : 0
mdef4 = armor3 != nil ? armor3.mdef : 0
mdef5 = armor4 != nil ? armor4.mdef : 0
mdef6 = $game_variables[@mdef]
return mdef1 + mdef2 + mdef3 + mdef4 + mdef5 + mdef6
end
#--------------------------------------------------------------------------
# * Get Basic Evasion Correction
#--------------------------------------------------------------------------
def base_eva
@eva = COZZIEKUNS::EVA_VAR
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
eva1 = armor1 != nil ? armor1.eva : 0
eva2 = armor2 != nil ? armor2.eva : 0
eva3 = armor3 != nil ? armor3.eva : 0
eva4 = armor4 != nil ? armor4.eva : 0
eva5 = $game_variables[@eva]
return eva1 + eva2 + eva3 + eva4 + eva5
end
end
Quote from: cozziekuns on May 06, 2010, 11:34:48 PM
Closest I could get to changing the values without doing anything major. Basically, each value is stored in a variable + the armour. So if the Physical Defense you get from your armour is 1, and the defense you store in your variable is 2, then the total defense would be 3.
Can't say for sure this will work exactly as you want it to, if it doesn't, please specify what else you want done.
# Change PDEF_VAR to the variable you want your pdef to be stored in.
# Change MDEF_VAR to the variable you want your mdef to be stored in.
# Change EVA_VAR to the variable you want your eva to be stored in.
module COZZIEKUNS
PDEF_VAR = 1
MDEF_VAR = 2
EVA_VAR = 3
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
def base_pdef
@pdef = COZZIEKUNS::PDEF_VAR
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
pdef1 = weapon != nil ? weapon.pdef : 0
pdef2 = armor1 != nil ? armor1.pdef : 0
pdef3 = armor2 != nil ? armor2.pdef : 0
pdef4 = armor3 != nil ? armor3.pdef : 0
pdef5 = armor4 != nil ? armor4.pdef : 0
pdef6 = $game_variables[1]
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + pdef6
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
def base_mdef
@mdef = COZZIEKUNS::MDEF_VAR
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
mdef1 = weapon != nil ? weapon.mdef : 0
mdef2 = armor1 != nil ? armor1.mdef : 0
mdef3 = armor2 != nil ? armor2.mdef : 0
mdef4 = armor3 != nil ? armor3.mdef : 0
mdef5 = armor4 != nil ? armor4.mdef : 0
mdef6 = $game_variables[2]
return mdef1 + mdef2 + mdef3 + mdef4 + mdef5 + mdef6
end
#--------------------------------------------------------------------------
# * Get Basic Evasion Correction
#--------------------------------------------------------------------------
def base_eva
@eva = COZZIEKUNS::EVA_VAR
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
eva1 = armor1 != nil ? armor1.eva : 0
eva2 = armor2 != nil ? armor2.eva : 0
eva3 = armor3 != nil ? armor3.eva : 0
eva4 = armor4 != nil ? armor4.eva : 0
eva5 = $game_variables[3]
return eva1 + eva2 + eva3 + eva4 + eva5
end
end
Does the value stay constant say if you swap your armor to something new with the same PD and MD? So if the PD from the armor is 1 and the variable is 2 it = 3, but if you swap the armor you're wearing (that was equal to 1) to something different but the same value, does it stay 3 (including the variable)? Similarly, does this work if the armor changes to a new value like 3 and the variable is still 2, does it now equal 5 or is it still 3? So I guess I'm asking if it updates the info when you swap armor and stuff.
Also what if the player is not wearing armor?
Maybe I ought to explain it better. A lot better. Sorry for my crappy explanation.
The first thing that I think I better explain is that the PDEF is NOT stored in the variable. The variable is just an addition the the actors regular defence (e.g If his regular defence with armour is 10, and the variable is 1, then his true defence would be 11.)
Secondly, yes, the actors true defence it updates when you switch armour. However, the variable does not, it stays constant.
Finally, if the player isn't wearing any armour, then the PDEF is just the variable that you set his PDEF as.
Very cool. It should work just fine for him then. :)
so lets say I wanted to increase Aluxes PDEF by 100.
I copy paste your code into the bottom of the "MAIN" section of script, and save.
Then I made a single event (action button activated) who says "Hi" and then runs the script through her event:
$game_party.actors[1].PDEF_VAR =100
what needs fixing in this code (which does not work)
Quote from: shintashi on May 07, 2010, 12:09:04 AM
so lets say I wanted to increase Aluxes PDEF by 100.
I copy paste your code into the bottom of the "MAIN" section of script, and save.
Then I made a single event (action button activated) who says "Hi" and then runs the script through her event:
$game_party.actors[1].PDEF_VAR =100
what needs fixing in this code (which does not work)
Umm... I'm not quite sure you understood my explanation.
Lets say we want to
raise Alexus' PDEF by 100. Then we would go:
Control Variable[Whatever you set PDEF_VAR as]: = 100
If you want Alexus' PDEF to equal exactly 100, I could just quickly modify this script for you.
Or you could just strip Alexus / Modify his equips so that they give 0 PDEF, and Control Variable[Whatever you set PDEF_VAR as]: = 100
module COZZIEKUNS
PDEF_VAR = 1
MDEF_VAR = 2
EVA_VAR = 3
end
See those lines?
That means that variable[001] currently controls the value for Physical Defense, variable[002] currently controls the value for Magic Defence and variable[003] currently controls the value for Evasion. So if you do nothing but copy/paste the script into the game, all you need to do is use the event command "Control Variables..." and alter any of those 3 variables to add or subtract the value.
You can change those lines of code to make them equal a different number in case you're currently already using those variables for something completely different.
You DO NOT need to use any script commands in an event. ONLY "CONTROL VARIABLES..."
lol.
Thanks for explaining it better Mr. Grafikal, I know I'm not the best at explaining things :(
Wow. Now I'm even more confused.
I tried creating a basic event encounter:
Text:hi
Control Variables:[001:PDEF] = 1000
And nothing happened. I think you guys are assuming I know something I clearly don't. Right now I'm praying for captain obvious because I'm on the slow train.
try doing +100
technically the program stops at 999 without a script, so that wouldn't do anything.
Quote from: grafikal on May 07, 2010, 12:43:27 AM
try doing +100
technically the program stops at 999 without a script, so that wouldn't do anything.
tried setting it to 100, but how is setting a variable going to target specific characters?
basically, I want to turn this effect backwards:
Control Variables: [001: PDEF] += [Aluxis]'s PDEFinto something like
Control Variables: [001: PDEF] = 100
Control Variables: [Aluxis]'s PDEF + = [001: PDEF]
so when i want to increase Aluxis's PDEF, and then check their values in Status Menu, the numbers displayed reflect these changes.
Aluxis has a default PDEF of 153.
What do I have to do to make it say 253?
Oh frick, I forgot you wanted specific actors.
That's gonna take a lot more work. Sorry about this.
EDIT: Try using $game_party.actors[Id of actor].base_pdef += how much you want to add.
Quote from: cozziekuns on May 07, 2010, 02:28:28 AM
Oh frick, I forgot you wanted specific actors.
That's gonna take a lot more work. Sorry about this.
EDIT: Try using $game_party.actors[Id of actor].base_pdef += how much you want to add.
used:
$game_party.actors[10].base_pdef += 10output:
undefined method 'base_pdef' for nil:NilClassI see this 'nil:NilClass' a lot.
come to think of it, I haven't been able to modify any values using script. I found you can see all sorts of values by typing
p game_actors[actor number]
and
p data_actors[actor number]
but I haven't figured out how to modify any of these values in a string.
Well it's finally obvious what the problem is. I downloaded RPG Maker XP (something I should have done a long time ago before I replied to this thread), and it seems that the methods pdef, and pdef= are different (something I should have realised a long time ago, I'm facepalming myself already).
Sorry, but I can't work on it just now. Hopefully you can get this resolved quickly.
Quote from: cozziekuns on May 08, 2010, 04:35:21 AM
Well it's finally obvious what the problem is. I downloaded RPG Maker XP (something I should have done a long time ago before I replied to this thread), and it seems that the methods pdef, and pdef= are different (something I should have realised a long time ago, I'm facepalming myself already).
Sorry, but I can't work on it just now. Hopefully you can get this resolved quickly.
i can wait a really long time actually. I'm writing a K-12 learning game and just got to long division. I'm just hoping you or someone else can figure this out before I finish the section on pre-algebra.
So far I've got
$game_actors[1].base_pdef + 100
$game_actors[2].pdef + 100
$game_actors[1].eva + 95
$game_actors[2].eva + 95
I've been asking around. Someone came up with this. It doesn't work (stats don't actually change), but it doesn't crash either. Event Script is clearly different from Script editor.
No, it's about the same. I couldn't imagine why it wouldn't be working, especially after several people (i think) suggested this. Try throwing Modern Algebra a PM about this topic and see what he has to say about it. He's our resident scripting God and he's nice too :]
Someone said stats editing like
$game_actors[1].agi += 200
or
$game_actors[2].str += 35
could work (and it does), but things like PDEF only exist for equipment so the script editor needs some kind of prompt to create PDEF independent of equipment. Now I know if I modify this line in Game Actor:
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5
to anything like
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + my_new_stat
whatever I set as my_new_stat to be, it changes accordingly, but how do I access "my_new_stat" from the event script editor?
When I created my own stamina stat, I had to define it all over the place, in the Window Base, in the Game Actor, in the window Status, and so on. But realizing I didn't have a way to access it from the game, it ended up being a mesh of two stats, Strength and Level, plus a constant. So if anyone wants to know how to make a hybrid Stat, I can totally do that, but without knowing how to make an event script to address it, it won't feel like a real attribute.
This just means I've figured out half the puzzle.
a string like this
$game_actors[10].sta += 200
still doesn't work.
Well, I kind of already knew that the base_pdef class needed changing with a new stat, thus the reason why I assigned a variable to add to the base defense. However, the placement of Game_Actor, as well as the fact that each actor needs a specific variable makes it more complicated. Your hybrid method works because the parameter str is stored in a RPGXP file, so it's different for every actor. However, I have yet to mimic this through scripting.
I'm still new to scripting, so Modern's your best bet.
Well, I think valdred was on the right track, though he didn't need to do quite as much as he did. I didn't look through his code, but it probably worked - but he didn't put it in a code box so it got corrupted halfway through. Anyway, this is what I whipped up:
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new accessor methods - @mod_pdef; @mod_mdef
# aliased methods - initialize; base_pdef; base_mdef
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :mod_pdef
attr_accessor :mod_mdef
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malgstsh_intz_6hn3 initialize
def initialize (*args)
@mod_pdef = 0
@mod_mdef = 0
malgstsh_intz_6hn3 (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Base PDEF
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mashin_pmdefmod_basep_8ik2 base_pdef
def base_pdef (*args)
return mashin_pmdefmod_basep_8ik2 (*args) + @mod_pdef # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Base MDEF
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias algtash_mpdmod_mdfbse_5yh3 base_mdef
def base_mdef (*args)
return algtash_mpdmod_mdfbse_5yh3 (*args) + @mod_mdef # Run Original Method
end
end
Try throwing that in the script editor, somewhere above Main but below the other default scripts.
To change the pdef or mdef of a character, use the following code in a script call:
$game_actors[actor_id].mod_pdef += x
$game_actors[actor_id].mod_mdef += y
So, something like this:
$game_actors[1].mod_pdef += 15
would add 15 to Aluxes' PDEF. Other operations will work, such as:
-=
%=
/=
*=
=
(subtract; mod; divide; multiply; set equal to)
Anyway, tell me if you have any problems.
I should've known you could change what the value returned instead of trying to change it from the inside.
And I have a question unrelated to the topic. Why do you always put (*args) next to your definitions? I've never seen another scripter do that before, and the help topic doesn't really explain it too well.
It's just a safety measure in terms of compatibility. Basically, it allows you to alter a method without knowing what arguments the method expects. Now, generally, this is not going to be a problem - you'll always know what a method expects by default. But, if another scripter alters the method and adds a new argument to it, then you will get an argument error since that scripter is passing an argument to the method that your method isn't passing. However, by putting in *args, I'm bypassing that problem since the argument will get passed even though I don't know what it is.
For the most part, this won't make much of a difference. But it's just a precaution.
holy crap it works!
I got so used to it crashing I'm actually quite shocked! :o
thank you very very much everyone!
I learned lots of script this week :D