Problem with a script

class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # Attack Forumla configuration ( Attack Bonus, Armor class, WeaponStats) #-------------------------------------------------------------------------- def custom_damage_formula (user, target) attackBonus = user.atk + user.agi rolledNumber = 1 + rand(20) + attackBonus @wpn_dmg = 1 + rand(3) # Enumerate user's weapons @wpn_dmg = 1 + rand(6) if user.weapons[1].wtype_id == 1 @wpn_dmg = 1 + rand(8) if user.weapons[1].wtype_id == 2 @wpn_dmg = 1 + rand(10) if user.weapons[1].wtype_id == 3 @wpn_dmg = 1 + rand(12) if user.weapons[1].wtype_id == 4 if user.weapons[1].wtype_id == 5 # Category with specials user.weapons.each { |wpn| case wpn.id when 1 # Hand Axe @wpn_dmg = (1 + rand(4)) when 2 # Battle Axe @wpn_dmg = (1 + rand(6)) when 3 # Bardiche @wpn_dmg = (1 + rand(8))# when X # Etc ...# @wpn_dmg = (1 + rand(X)) else # If weapon is none of the above @wpn_dmg = (1 + rand(5)) end } end #returns value if rolledNumber > target.def @custom_Formula_Result = @wpn_dmg else @custom_Formula_Result = 0 end return @custom_Formula_Result endendSo I have made this script and in a damage formula of attack I Use:

a.custom_damage_formula(a, However, in battle, No side can deal damage ( I am sure they can't since I have set their defence on 1  and atk on 110 while the characters def = 1 for testing. and atk = 110... ) 

Then when I comment out the section # Enumerate user's weapons. 

I also have a problem .That only the monster's deal damage....

Can anyone point out where I might have made a mistake ????

EDIT: 

For some reason it doesn't enter the Enumerate user's Weapons section and stops right there. Doesn't get to reach the return line... 

Maybe something is wrong with this Syntax

@wpn_dmg = 1 + rand(6) if user.weapons[1].wtype_id == 1Since it ignores the lines afterwards....

As for when I commend out the Enumeration section , only when monsters attack it calls the method... 

When the player attacks , it doesn't call it at all. 

 Actually either it is commended out or not, the playable character doesn;t call this method when he attacks...
Add in some print statements and play with the console on so you can see what is happening at each stage.
When I have the Console visible it is just a black - empty window . Don't know how to make it useful....

... 
I updated the post with more info I found out with the problem....
You can print every object or value to the console by using:

Code:
p <anything>puts <anything>
Both do the same, but puts is easier to remove afterwards.
I have been using msgbox_p() for seeing the values in different spots on the script and I found out the script what I said in the edit..
Is this script only applicable to the 2nd weapon? Or are both 2 weapons applicable?
I want it only on the first
Change weapons[1] to weapons[0] in all parts if that's the case.

Although only actors can hold the weapons unless you have some scripts that will make the enemies also have weapons.
Change weapons[1] to weapons[0] in all parts if that's the case.

Although only actors can hold the weapons unless you have some scripts that will make the enemies also have weapons.
That was not the case. I even changed the script to

def custom_damage_formula(a, attackBonus = a.atk + a.agi rolledNumber = 1 + rand(20) + attackBonus msgbox_p("Rolled Number ", rolledNumber) msgbox_p("Enemy's armor class: ", b.def) # Enumerate user's weapons if a.weapons.include?($data_weapons[1]) @wpn_dmg = (1 + rand(4)) elsif a.weapons.include?($data_weapons[2]) @wpn_dmg = (1 + rand(6)) elsif a.weapons.include?($data_weapons[3]) @wpn_dmg = (1 + rand(8)) else @wpn_dmg = 1 + rand(3) end msgbox_p("Weapon Damage C' ", @wpn_dmg) #returns value if rolledNumber > b.def @custom_Formula_Result = @wpn_dmg else @custom_Formula_Result = 0 end msgbox_p("Final Damage: ", @custom_Formula_Result) return @custom_Formula_Result.to_i endbut still the same result. For some Reason the method stops running when entering the enumerate user's weapon section (Line 17)....

Also the player doesn't even call the method when attacking....
Hmm...

I tried using the script and it seems it only doesn't work on enemy attacks. It works perfectly when actors used it.
Still, why aren't both using it? And for me why does it run halfways for enemies...
I almost totally forgot what I said yesterday about weapons:

Although only actors can hold the weapons unless you have some scripts that will make the enemies also have weapons.
Try to change the conditions to be like this in the enumerate weapon section since like I said yesterday, the weapons are not available on enemies.

if a.actor? && a.weapons.include?($data_weapons[1])In short, just add "a.actor? &&" (without quotes) in the conditions.
I found out why my actors did not hit the enemies. Default classes actually had extra parameter +95% hit, which I didn't add to my classes. So now my actors are doing perfect with the formulae. The problem now is that the enemies do it halfway. They even though I changed the script to 

def custom_damage_formula(a, attackBonus = a.atk + a.agi rolledNumber = 1 + rand(20) + attackBonus msgbox_p("Rolled Number ", rolledNumber) msgbox_p("Enemy's armor class: ", b.def) # Enumerate user's weapons if a.weapons.include?($data_weapons[1]) && a.actor? @wpn_dmg = (1 + rand(4)) elsif a.weapons.include?($data_weapons[2])&& a.actor? @wpn_dmg = (1 + rand(6)) elsif a.weapons.include?($data_weapons[3])&& a.actor? @wpn_dmg = (1 + rand(8)) elsif a.actor? @wpn_dmg = 1 + rand(3) else @wpn_dmg = 1 + rand(6) end msgbox_p("Weapon Damage C' ", @wpn_dmg) #returns value if rolledNumber > b.def @custom_Formula_Result = @wpn_dmg else @custom_Formula_Result = 0 end msgbox_p("Final Damage: ", @custom_Formula_Result) return @custom_Formula_Result.to_i end As you can see in line 26 I have an else keyword in case it is a monster. However for some reason, the enemies even though they call the method. they stop midways. Before the if sentence...
Seems like I found a solution. 
 

# Enumerate user's weapons if a.actor? if a.weapons.include?($data_weapons[1]) @wpn_dmg = (1 + rand(6)) elsif a.weapons.include?($data_weapons[2]) @wpn_dmg = (1 + rand(6)) elsif a.weapons.include?($data_weapons[3]) @wpn_dmg = (1 + rand(8)) else @wpn_dmg = 1 + rand(3) end else @wpn_dmg = 1 +rand(6) endAt least it works for now. 
Thanks for helping me. Everyone!!!

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-a-script.40773/