Optional DMG increase depending on Weapon Type

cavemanK

Villager
Member
Joined
May 17, 2016
Messages
28
Reaction score
9
First Language
English
Primarily Uses
Hello everyone!

I am trying to add a skill proficiency to my game and wanted to do something I figured was hidden somewhere in the database. Does anyone know if there is a way to give bonuses to an actor's attack based on certain weapon types? 

Ex. Frank trains his "Firearm" skill and now has an additional 2 ATK whenever using a weapon of "gun" type.

I feel like there is a very easy and obvious way to accomplish this that I'm overlooking. If I end up having to script it, where might the easiest entry point (i.e. somewhere where I can use an if statement to add to combat damage based on what type current weapon is) be?

Thanks!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,992
First Language
Tagalog
Primarily Uses
Well, if you only need him to deal more damage based on the "skill" and the weapon type, you can just utilize the damage formula of your skills.. something like


your_damage_formula + 2 if a.weapons[0].wtype_id == ID_OF_YOUR_GUN_WEAPON_TYPE


I'm not sure if it's wtype_id or wtypeid or whatever and you might still need to check for the "firearm" skill, is it an actual skill or something else?


But if you want all skills to do this check, you might just want to make it as a method in a script for shorter call,


or just script it in such a way that all skills do the check automatically
 

Rhaeami

The Sleepy-Eyed One
Veteran
Joined
Jun 2, 2014
Messages
250
Reaction score
177
First Language
English
Primarily Uses
RMVXA
Another way, also using the damage formula, is to track your skill proficiency using variables and then multiply those variables in your damage formulas.


{Damage Formula} + (Actor01_Gun_Skill * {Bonus Damage per Level})


The downside to this method would be having to have a separate variable for each combination of actor and skill type, and that you'd need a different copy of the ability for each actor so that you could set the appropriate variable call in their damage formula.


EDIT:  Sorry, I misread your question, missed that it was to be based on equipped weapons.  My mistake. :headshake:
 
Last edited by a moderator:

cavemanK

Villager
Member
Joined
May 17, 2016
Messages
28
Reaction score
9
First Language
English
Primarily Uses
Well, if you only need him to deal more damage based on the "skill" and the weapon type, you can just utilize the damage formula of your skills.. something like


your_damage_formula + 2 if a.weapons[0].wtype_id == ID_OF_YOUR_GUN_WEAPON_TYPE


I'm not sure if it's wtype_id or wtypeid or whatever and you might still need to check for the "firearm" skill, is it an actual skill or something else?


But if you want all skills to do this check, you might just want to make it as a method in a script for shorter call,


or just script it in such a way that all skills do the check automatically


Thanks!

My bad, "skill" was a horrible choice of words. Firearm would just be an integer that I could in a control variable or script it backend.  You basically got the idea, but you can't calculate damage on weapons the same way you can with skills. I'd like this to apply to a weapon.  But yeah I think appending it to the damage formula somewhere is the easiest route to go! Thanks!

EDIT:

 

Another way, also using the damage formula, is to track your skill proficiency using variables and then multiply those variables in your damage formulas.


{Damage Formula} + (Actor01_Gun_Skill * {Bonus Damage per Level})


The downside to this method would be having to have a separate variable for each combination of actor and skill type, and that you'd need a different copy of the ability for each actor so that you could set the appropriate variable call in their damage formula.


EDIT:  Sorry, I misread your question, missed that it was to be based on equipped weapons.  My mistake. :headshake:

No worries! I just noticed that weapons did not have access to damage formulas myself.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,992
First Language
Tagalog
Primarily Uses
yeah, weapons don't have access to the damage formula because it's the skills that you use which deals damage so either you do this via skill damage formula, or have a plugin that give you the capability to modify the damage of skills with weapons, more than how you currently can do it via editing the parameters of the weapons. Though seeing your needs, I don't think you need to involve the weapons themselves. All you'd need is to check the weapon type and the corresponding "skill" that improves the damage when using that weapon type.
 
Last edited by a moderator:

cavemanK

Villager
Member
Joined
May 17, 2016
Messages
28
Reaction score
9
First Language
English
Primarily Uses
yeah, weapons don't have access to the damage formula because it's the skills that you use which deals damage so either you do this via skill damage formula, or have a plugin that give you the capability to modify the damage of skills with weapons, more than how you currently can do it via editing the parameters of the weapons. Though seeing your needs, I don't think you need to involve the weapons themselves. All you'd need is to check the weapon type and the corresponding "skill" that improves the damage when using that weapon type.

This was a relationship in the engine I was looking for a little more clarification on--it helped tremendously, thank you! I just got working with a little of scripting through the Game_Actor class. At first, I tried using a script directly through the damage formula, but I couldn't get it to work. 

This is what I had:

 

class Game_Battler < Game_BattlerBase
def profDam(a, b, v)
dam = 0
if !$game_actors[1].equips[0].nil
if $game_actors[1].equips[0].wtype_id == 10&&$game_switches[17] #<-the "gun license" switch
dam += 2
end
end
3 + dam + a.atk * 0.4 - b.def * 0.2
end
end


Then I called it from the damage formula box with : 


profDam(a, b, v)


The game launched without any errors but my main attack skill did 0 damage, and using some debug printing I could tell that the script wasn't executing.

Moving on, I thought to just use the v[n] capability of the damage formula and change its value based on the gun license with a script elsewhere. Thinking of an entry point, I landed on  the weapon or armor is equip method in Game_Actor called "change_equip_by_id". I aliased the method then appended it with the same code I tried in profDam earlier. I switch control variable[21] to 2 if the weapon equipped is a gun, and make sure to switch it back to 0 if the weapon is not a gun.

Here is the alias method:

 

class Game_Actor < Game_Battler
alias changeSlot change_equip_by_id
def change_equip_by_id(slot_id, item_id)
changeSlot(slot_id, item_id)
if $game_actors[1].equips[0] != nil
if $game_actors[1].equips[0].wtype_id == 10&&$game_switches[17]
$game_variables[21] = 2 #damage bonus
else
$game_variables[21] = 0
end
#p $game_variables[21]
end
end
end


 And then the damage formula looks like:
 


3 + v[21] + a.atk * 0.4 - b.def * 0.2


This is a really useful entry point for me, because I can very easily make the damage variable grow as the player upgrades their gun skill. I was also looking for a place to make sure that the corresponding ammo type is set to the reload slot every time the player switches weapons, and this is the perfect place for that as well.

All in all, problem solved! Thanks again for both of your help.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,992
First Language
Tagalog
Primarily Uses
If it returns 0 it means it encounters an error, the damage formula was made in a way that errors are captured and returns 0 instead of showing u the error. Looking at the code, I think your problem is this line:  


if !$game_actors[1].equips[0].nil


AFAIK, the shortcut for the check for obejct == nil is object.nill? , you forgot the question mark. 
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Me: "Finally finished most of my game backlog. Probably time to do some gamedev" | Steam: *offer sales*
If I recorded while I created (what I think is) a small plugin, would you be interested enough in the process to watch it?
I keep trying to explain to clients that the huddle masses behind the old K-Mart are a Fallout Reenactment group. Somehow I don't think they believe me. :LZSskeptic:
Hey people! What do you think about a core plugin? This will save some lines of code that I repeatedly use in all my plugins...
Wondering if I should make my enemies scale in my non-linear rpg. I'm leaning towards yes, but I don't want to use Yanfly's plugin...

Forum statistics

Threads
94,594
Messages
922,169
Members
124,465
Latest member
Spielmister
Top