Coding in RMXP.
Okay, so I'm trying increase my knowledge of scripting in Ruby. Overall, I'm pretty good at taking already created scripts and editing them, but I still struggle a LOT scripting on my own with definitions and syntax, so I'm trying to learn.
I know there's some Passive Skill scripts out there, but I want to make some passive skills do things that aren't in these scripts such as:
1. Increase Critical % in battle
2. Increase damage/number of attacks with a certain weapon type
3. Increase XP/Gold gain after combat (Gando's script, for some reason, is incompatible with my skill learning system)
etc.
For the most part, I know where to find most of these things in the basic script, it's just a matter of adding them. I'm having a lot more trouble with skills, where it is a situation of "if this character knows skill 1, then increase (insert whatever)."
1. How do I code this?: "If character i knows skill 1, then increase critical by 3%"
I think I have equipment down. So, weapon 21 is +3% critical and weapon 5 is +5% critical. Does this look okay?:
2. Again, I'm not sure how to code skills into this.
If I wanted to create equipment with similar effects...say I have an accessory called "Gauntlet" at Armor ID: 100, and I want it to increase damage by 50% for all swords (Weapon ID: 1-20), could I just add code like this in at the end of the damage script?
3. This one is more tricky. Gando's script increased the party XP by a certain amount, but I want to increase just one character's XP gain, not everyone. How would I go about editing the script here to include skill and/or equipment bonuses?
XP:
Gold:
Again, thank you for any help you can provide. I'm really wanting to learn how to define skills and equipment in the code so I can do this stuff on my own.
Okay, so I'm trying increase my knowledge of scripting in Ruby. Overall, I'm pretty good at taking already created scripts and editing them, but I still struggle a LOT scripting on my own with definitions and syntax, so I'm trying to learn.
I know there's some Passive Skill scripts out there, but I want to make some passive skills do things that aren't in these scripts such as:
1. Increase Critical % in battle
2. Increase damage/number of attacks with a certain weapon type
3. Increase XP/Gold gain after combat (Gando's script, for some reason, is incompatible with my skill learning system)
etc.
For the most part, I know where to find most of these things in the basic script, it's just a matter of adding them. I'm having a lot more trouble with skills, where it is a situation of "if this character knows skill 1, then increase (insert whatever)."
1. How do I code this?: "If character i knows skill 1, then increase critical by 3%"
I think I have equipment down. So, weapon 21 is +3% critical and weapon 5 is +5% critical. Does this look okay?:
Code:
if self.damage > 0
if attacker.weapon_id = 21
crit = 3
eslif attacker.weapon_id = 22
crit = 5
end
# Critical correction
if rand(100) < (4 * attacker.dex / self.agi) + crit
self.damage *= 2
self.critical = true
end
2. Again, I'm not sure how to code skills into this.
If I wanted to create equipment with similar effects...say I have an accessory called "Gauntlet" at Armor ID: 100, and I want it to increase damage by 50% for all swords (Weapon ID: 1-20), could I just add code like this in at the end of the damage script?
Code:
if attacker.armor4_id = 100 and attacker.weapon_id <= 20
self.damage *= 1.5
end
3. This one is more tricky. Gando's script increased the party XP by a certain amount, but I want to increase just one character's XP gain, not everyone. How would I go about editing the script here to include skill and/or equipment bonuses?
XP:
Code:
# Obtaining EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
Code:
gold += enemy.gold
Again, thank you for any help you can provide. I'm really wanting to learn how to define skills and equipment in the code so I can do this stuff on my own.