Envision, Create, Share

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.

Using scripts to change parameters

Hey everyone,

I tried to do this on my own without scripting by using only events, but it doesn't seem possible. Anyhow, here is what i'm trying to do;

In my game all of the characters have 0 MAXsp, and the only way to get SP is through certain items. For instance, by equipping a particular weapon you're MAXsp is raised to 10 but as soon as you unequip the weapon, your MAXsp drops back to 0. Different weapons/items give different values.

I was hoping that maybe someone could help write a script that can do what i described above; something versatile, where i can add more weapons/items and their respective parameters quickly and easily.

I thought i could use conditional branches to do this, but i couldn't set the MAXsp parameter, could only increase it (So instead of setting my char's MAXsp to 10, it would INCREASE it by 10 every second!). Besides, even if i did get it to work, i would need to make like 50 conditional branches for each piece of weapon/item armor.

Thanks is advance :)

EDIT: Sorry XP
 
XP or VX?

[edit] Then I shall have this done shortly.

[edit2]
Code:
class Game_Actor

  WEAPONS_SP = []

  WEAPONS_SP[4] = 100

  ARMORS_SP = [0, 5, 10, 2, 6]

  #--------------------------------------------------------------------------

  # * Get Basic Maximum SP

  #--------------------------------------------------------------------------

  def base_maxsp

    n = $data_actors[@actor_id].parameters[1, @level]

    weapon = WEAPONS_SP[@weapon_id]

    armor1 = ARMORS_SP[@armor1_id]

    armor2 = ARMORS_SP[@armor2_id]

    armor3 = ARMORS_SP[@armor3_id]

    armor4 = ARMORS_SP[@armor4_id]

    n += weapon != nil ? weapon : 0

    n += armor1 != nil ? armor1 : 0

    n += armor2 != nil ? armor2 : 0

    n += armor3 != nil ? armor3 : 0

    n += armor4 != nil ? armor4 : 0

    n = [[Integer(n), 0].max, 9999].min

    return n

  end

end
You define how much SP it increase at the top, either how WEAPONS_SP does it with 1 id per line, or like ARMORS_SP, where it's all in one line. In the armor example, the first 0 is for id 0, which doesn't exist. So armor 1 would have the 5 SP bonus.
 
Thank you very much!

But I'm a bit new to the scripting aspect, so where exactly would i put your code?

Also i'm a little bit confused as to how i should assign SP bonus to my weapons...sorry

Thanks for your help
 
Just above main is generally a good spot for inserted scripts. Right-click main, and click insert.

Basically I was trying to demonstrate the two ways you can assign the sp.
You can either go
WEAPONS_SP = []
WEAPONS_SP[weapon_id] = sp_bonus
WEAPONS_SP[different_weapon_id] = sp_bonus
etc etc

or

WEAPONS_SP = [0, weapon1_sp_bonus, weapon2_sp_bonus, weapon3_sp_bonus, etc etc etc]

For the first method, if you don't give a specific weapon a bonus, it will default to 0.

Oh enterbrain, how I wish you let us edit the database editor to make our life easier
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top