Hi, I'm looking for a way to make new stats, and have them show up in various places like the Status Menu, Item/Weapon and Monster Generators, and so on.
I decided I would start with the most simple Stat I could, so I chose Stamina. My long term goal is to have it do lots of things and be a primary stat for resisting things like poison & plague, but for now I just want it to add bonus hp.
I stuck a wide variety of codes in my script editor:
for example in Game_Battler 1
#--------------------------------------------------------------------------
# NEW Attribute - Added by J
# * Set Stamina (STA)
# sta : new Stamina (STA)
#--------------------------------------------------------------------------
def sta
n = [[base_sta + @sta_plus, 1].max, 999].min
for i in @states
n *= $data_states[i].sta_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
def sta=(sta)
@sta_plus += sta - self.sta
@sta_plus = [[@sta_plus, -999].max, 999].min
end
and in various places where lists of all stats exist, I added a Stamina line:
Such as in Game_Battler 3
# Branch by parameter
case item.parameter_type
when 1 # Max HP
@maxhp_plus += item.parameter_points
when 2 # Max SP
@maxsp_plus += item.parameter_points
when 3 # Strength
@str_plus += item.parameter_points
when 4 # Dexterity
@dex_plus += item.parameter_points
when 5 # Agility
@agi_plus += item.parameter_points
when 6 # Intelligence
@int_plus += item.parameter_points
when 7 # Stamina
@sta_plus += item.parameter_points
end
# Set to effective flag
effective = true
in all, I've made additions in 9 different places, in Game Actor, Game Enemy, Interpreters 4 and 6, and the ones above, Battler 1 and 3. I feel like there's something major I'm missing, and am lucky the script approach so far hasn't crashed (I haven't had stamina do anything yet, and don't plan to until it shows up in the menus).
This of course is only one Stat, there are others that come to mind, like Charisma, Tech, Spirit, Sanity, and so forth. I'm really new to this kind of programming.
Yoroshiku Onegaishimasu.
Ok, so I got a rudimentary version working for Stamina. By rudimentary, I mean the Menu Status screen for my character displays an "STA 100" for Stamina next to the "STR 99" for Strength. And it doesn't crash (yet) :lol:
The variations I tried before crashed several times, so I did some minor editing. Right now, Stamina is a fixed value, at 100, until I can figure out how to interface the attribute directly with the Game, probably through Events.
The code I used is as follows:
[spoiler]
lines 39, 88-98, and 158-166 of Game Battler 1: not sure this does anything yet
@sta_plus = 0
>>
#--------------------------------------------------------------------------
# NEW Attribute added by J
# * Get Stamina (STA)
#--------------------------------------------------------------------------
def sta
n = [[base_sta + @sta_plus, 1].max, 999].min
for i in @states
n *= $data_states.sta_rate / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
>>
#--------------------------------------------------------------------------
# NEW Attribute - Added by J
# * Set Stamina (STA)
# sta : new Stamina (STA)
#--------------------------------------------------------------------------
def sta=(sta)
@sta_plus += sta - self.sta
@sta_plus = [[@sta_plus, -999].max, 999].min
end
##--------------------------------------
lines 291-292 of Game Battler 3
when 7 # Stamina
@sta_plus += item.parameter_points
##--------------------------------------
lines 214-219 of Game Actor: this needs to be changed to variable
#--------------------------------------------------------------------------
# * Get Basic Stamina - Added by J
#--------------------------------------------------------------------------
def base_sta
n = 100
end
##--------------------------------------
lines 64-70 of Game Enemy
#--------------------------------------------------------------------------
# New Stat Added here By J.
# * Get Basic Stamina
#--------------------------------------------------------------------------
def base_sta
return $data_enemies[@enemy_id].sta
end
##--------------------------------------
line 37 of Window Status:
draw_actor_parameter(@actor, 320, 304, 7)
##--------------------------------------
lines 300-302 of Window Base - "draw actor parameter":
when 7
parameter_name = "STA"
parameter_value = actor.sta
##--------------------------------------
lines 71-72 and 104-105 of Interpreter 4:
when 14 # stamina
value = actor.sta
>>
lines 104-105 of Interpreter 4:
when 12 # stamina
value = enemy.sta
##--------------------------------------
lines 232-233 of Interpreter 6:
when 6 # stamina
actor.sta += value[/spoiler]
Although I must note much of this is unlikely to do anything, I think it's a good start.
Ok, so my Stamina progress is much more kick ass. I tried hacking the System file using a hex de-compiler thingamajig but that caused it to crash - thankfully i had a backup. So instead I went back to messing with the script, moved the STA
stat above STR and moved the other stats and armor stuff in the menu around so it looked nice.
Then edited the Game actor file so this:
#--------------------------------------------------------------------------
# * Get Basic Stamina
#--------------------------------------------------------------------------
def base_sta
n = 49 + level + Integer(base_str/2)
end
Became the new Stamina generator. This is obviously a jury rigged way of allowing you to modify Stamina based on Strength and Level, at least until some other script or effect can function with it.
By modifying these two lines:
@hp = maxhp
@maxhp_plus = 0
to read:
@hp = maxhp + base_sta
@maxhp_plus = base_sta
You can increase your hp accordingly. Alternatively, what I did was modified this line:
def maxhp
n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min
to read:
def maxhp
n = [[base_maxhp + @maxhp_plus + sta, 1].max, 9999].min
I also modified physical defense accordingly:
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5
to read:
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + sta
>>So Stamina is kind of sort of in my game. I had to convert that n* thing to read "100/100" for Status effects (since the computer doesn't really believe Stamina exists) and generally avoided adding it to areas I don't have much access to.
I hope someone can benefit from my research, or conversely, I can benefit from someone else's insight.
Functional Import Instructions:
[spoiler] Game Battler 1
80s
#--------------------------------------------------------------------------
# NEW Attribute added by J States sections need to be modified later
# * Get Stamina (STA)
#--------------------------------------------------------------------------
def sta
n = [[base_sta + @sta_plus, 1].max, 999].min
for i in @states
n *= 100 / 100.0
end
n = [[Integer(n), 1].max, 999].min
return n
end
150-160s
#--------------------------------------------------------------------------
# NEW Attribute - Added by J
# * Set Stamina (STA)
# sta : new Stamina (STA)
#--------------------------------------------------------------------------
def sta=(sta)
@sta_plus += sta - self.sta
@sta_plus = [[@sta_plus, -999].max, 999].min
end
Game Battler 3
290
when 7 # Stamina
@sta_plus += item.parameter_points
Game Actor
39
@sta_plus = 0 # Stamina added – may not work
178
n = [[base_maxhp + @maxhp_plus + sta, 1].max, 9999].min
214
#--------------------------------------------------------------------------
# * Get Basic Stamina - Added by J
#--------------------------------------------------------------------------
def base_sta
n = 49 + level + Integer(base_str/2)
end
292
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + sta
Window Base
300
when 7
parameter_name = "STA"
parameter_value = actor.sta
Window Status
#--------------------------------------------------------------------------
# * Refresh: Edited to Contain Stamina on lines 37-50 - J
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_graphic(@actor, 40, 112)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 96, 32)
draw_actor_state(@actor, 96, 64)
draw_actor_hp(@actor, 96, 112, 172)
draw_actor_sp(@actor, 96, 144, 172)
draw_actor_parameter(@actor, 96, 192, 0)
draw_actor_parameter(@actor, 96, 224, 1)
draw_actor_parameter(@actor, 96, 256, 2)
draw_actor_parameter(@actor, 96, 320, 3)
draw_actor_parameter(@actor, 96, 352, 4)
draw_actor_parameter(@actor, 96, 384, 5)
draw_actor_parameter(@actor, 96, 416, 6)
draw_actor_parameter(@actor, 96, 288, 7)
self.contents.font.color = system_color
self.contents.draw_text(320, 48, 80, 32, "EXP")
self.contents.draw_text(320, 80, 80, 32, "NEXT")
self.contents.font.color = normal_color
self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(320, 160, 96, 32, "equipment")
draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 320)
draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 368)
draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 416)
end
Interpreter 4
71
when 14 # stamina
value = actor.sta
103
when 12 # stamina
value = enemy.sta
Interpreter 6
232
when 6 # stamina
actor.sta += value
Monk Unarmed Damage (someone else's idea, here for completion):
Game Battler 3
51-55
#--------------------------------------------------------------------------
# * Adding Monk Damage with atk --> (atk + 1) -by J
# will need to add monk level to attacker.str when located
#--------------------------------------------------------------------------
self.damage = (atk + 1) * (20 + attacker.str) / 20
[/spoiler]
Basically you add the stuff above with the estimated location of line numbers (use common sense before copy pasting, some will be written over like the extensive window section). I tested this in a new game file and it works fine.