SCRIPT CALLS AND BASE STATS IN VX/ YEM

Posts

Pages: 1
Versalia
must be all that rtp in your diet
1405
I'm trying to use script calls to modify the player's stats, like a reward during a cutscene. I figured I'd look at how items that add permanent stats do it, and use that as an example, but they just seem to add to the @stat_plus. I am thinking that another method actually recalculates and adds to the stats using these variables, but I can't track it down, if that is the case.

This is the example I'm looking at:

under default GAME_BATTLER (nothing I am using overwrites item_growth_effect)

#--------------------------------------------------------------------------
# * Item Growth Effect Application
# user : Item user
# item : item
#--------------------------------------------------------------------------

def item_growth_effect(user, item)
if item.parameter_type > 0 and item.parameter_points != 0
case item.parameter_type
when 1 # Maximum HP
@maxhp_plus += item.parameter_points
when 2 # Maximum MP
@maxmp_plus += item.parameter_points
when 3 # Attack
@atk_plus += item.parameter_points
when 4 # Defense
@def_plus += item.parameter_points
when 5 # Spirit
@spi_plus += item.parameter_points
when 6 # Agility
@agi_plus += item.parameter_points
end
end
end


I'm not really sure how to translate this into a sensible script call. D: Obviously I want to modify @STAT_plus variables, but I'm not sure how to determine which actor it is affecting without calling the item_growth_effect method itself and tying it to database items (clumsy workaround ew). Based on some existing scripts' examples, I also feel like the script call window in the eventing commands might have slightly different syntax than the normal script editor? I might just be imagining it, though.
You may want to check the event command "change parameters" (command_317, i think) on the interpreter class, normally it helps.
Anyway, in XP, you can just use $game_actors[id].stat += x, but it might be slightly different for VX.
I'm not a scripter, but I don't see why the syntax would be different on the script call.

edit: lol, I can't write the brackets right. I hope it shows.
Versalia
must be all that rtp in your diet
1405
author=yuhikaru
You may want to check the event command "change parameters" (command_317, i think) on the interpreter class, normally it helps.

I completely forgot those commands all exist within Interpreter. derp. derpreter


#--------------------------------------------------------------------------
# * Change Parameters
#--------------------------------------------------------------------------

def command_317
value = operate_value(@params, @params, @params)
actor = $game_actors[@params]
if actor != nil
case @params
when 0 # Maximum HP
actor.maxhp += value
when 1 # Maximum MP
actor.maxmp += value
when 2 # Attack
actor.atk += value
when 3 # Defense
actor.def += value
when 4 # Spirit
actor.spi += value
when 5 # Agility
actor.agi += value
end
end
return true
end


The problem is that I don't see any examples of "actor.dex += value" being used in any of the YEM scripts, which means this particular snippet of code won't work with the made-up stats I implemented. Hmmmm.
Try "$game_actors(X).dex += Y", but with square brackets instead of brackets. It increased actor X's dexterity with Y when I tested it.
Versalia
must be all that rtp in your diet
1405
That works, and I feel retarded. Hooray. This is how I'm using it:

You receive a stat bonus equal to 5*(# of battles you survived out of ten/10) based on your primary class. (I push the class id into "actor.classes") These are the bits of script I have thought up for myself to use, but I'm not sure what class to put them in (Game_Actor, maybe?):


def victorybonus(actor_id)
@actor_id = actor_id
bonus = 0
bonus = $game_variables{@actor_id}
bonus = (value/10)*5
return bonus
end


(the game variable matching the actor's ID is what is holding how many battles they've survived so far; I tried keeping track within the script itself, but it didn't work. I AM SUCH A N00B HELP PLOX.)


def firstclass(actor_id)
@actor_id = actor_id
@firstclass = actor.classes{0} # first in an array is number zero
bonus = eval(victorybonus)
$game_actors{@actor_id}.dex += bonus if firstclass == 1 # Stylist (class ID 1)
$game_actors{@actor_id}.pwr += bonus if firstclass == 2 # Postman (class ID 2)
etc
end

(applies the stat boost to the appropriate stat based on what 'victorybonus' returns)
Here is an idea. It's for XP, but it probably works for VX if you change the syntax where needed. I'm not familiar with YEM, I'm thinking on base scripts only. And I didn't understand what the firstclass is, so I kept it simple.
(Just a warning: I'm really a noob in scripting, but I try)

You can create in Game_battler a new object called 'victorycount' or whatever, so you don't need to use the global variable, and a method to modify it's value. Then, in Game_actor, you can create the 'victorybonus' method you want. It would be something like this:

In Game_battler:

class Game_Battler

attr_reader :victorycount # counts victory for each actor
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@victorycount = 0 # Initialize the object, because it doesn't exist in the database
#etc...
end

#etc...

def victorycount=(value) # This method modifies the value of victorycount: $game_actors{id}.victorycount += x
@victorycount = value
end



Then, in Game_actor, you can place the method you created. In my example, I merged the two, because the first looks very simple:

def victorybonus # This method adds the victory bonus to a diferent stat depending on the class: $game_actors{id}.victorybonus
actor = $game_actors{@actor_id}
bonus = (actor.victorycount/10)*5
actor.dex += bonus if @class_id == 1
actor.str += bonus if @class_id == 2
#etc...
end


Then, in Scene_battle, whichever you are using, you add a $game_actors{i}.victorycount += 1 for all the actors in party, when it decides the battle results.

I think that's it, I hope it works out.
Versalia
must be all that rtp in your diet
1405
Yuki: Thanks! That was super helpful. I modified it a little bit for my needs and I think it will work <3
Versalia
must be all that rtp in your diet
1405
Okay, as I've implemented it, I'm not sure how to get victorycount to be called from process_victory. Even after adding:

def victorycount=(value) # This method modifies the value of victorycount: $game_actors{id}.victorycount += x
@victorycount = value
end

^^^ into scene_battle (where process_victory exists), this code (inserted INTO process_victory) gave me the Nomethod error for victorycount:

for actor in $game_party.members
 actor.victorycount += 1 unless $scene.is_a?(Scene_Gameover)

I can use $game_actors{id}.victorycount += x in a script call from an event to make it work, so I know it's properly working in Game_Actor / Game_Battler. How can I make process_victory automatically increase everybody's individual victory count by 1 instead of using a script call inside the event after every battle?
Is victorycount= part of Game_Actor? Can you read victorycount? You have to be able to read a value to assign +1 to it. If you're adding a new attribute to the class and don't care how it's read or written to just mark it 'attr_accessor :victorycount'. You can find examples in most of the Game_whatever classes.
Pages: 1