Problem with a script

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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...
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Add in some print statements and play with the console on so you can see what is happening at each stage.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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....
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
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.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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..
 
Last edited by a moderator:

Jeneeus Guruman

The Returnee
Veteran
Joined
Mar 28, 2012
Messages
1,078
Reaction score
197
First Language
Filipino
Is this script only applicable to the 2nd weapon? Or are both 2 weapons applicable?
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
I want it only on the first
 

Jeneeus Guruman

The Returnee
Veteran
Joined
Mar 28, 2012
Messages
1,078
Reaction score
197
First Language
Filipino
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.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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....
 
Last edited by a moderator:

Jeneeus Guruman

The Returnee
Veteran
Joined
Mar 28, 2012
Messages
1,078
Reaction score
197
First Language
Filipino
Hmm...

I tried using the script and it seems it only doesn't work on enemy attacks. It works perfectly when actors used it.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
Still, why aren't both using it? And for me why does it run halfways for enemies...
 

Jeneeus Guruman

The Returnee
Veteran
Joined
Mar 28, 2012
Messages
1,078
Reaction score
197
First Language
Filipino
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.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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...
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
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!!!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top