Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Resolved and thank you:D]Scripting:Game_Battler3 -> if monster/ if hero, making calculations based on whether attacker/user is actor or monster
syperius
post Jan 17 2010, 06:24 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 6
Type: None
RM Skill: Undisclosed




I'm still rather new to RGSS ruby so there's many syntax/properties I'm unaware of.

I'm tryin to accomplish the following during damage calculations for both normal and skill attacks:

I want certain calculations to be done based on whether or not the attacker is a hero or monster. For exmaple I want the heroes level to scale variance, etc etc etc. Obviously monsters don't have a level attribute so this would cause the game to crash if it went to check this during a monster attack.
it would be EVEN better if i could make it based on specific heroes or classes / monsters/troops.

Any method used to accomplish this would be fine by me and the help would be a million times appreciated.

anywho if you have any questions about what i'm trying to accomplish just ask away, and once again, thankyou kindly:)

final edit, i think: I've done some research elsewhere i found a way to do this
if attacker.name == $data_actors[1].name ......... doing a check through each actor id and then from i can do what i need.

This post has been edited by syperius: Jan 21 2010, 02:05 PM
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 17 2010, 08:38 PM
Post #2


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




For the defensive bonus, couldnt you script in on the action of defense to add a state that adds 5% defense and remove them when attacking?

As for the damage calculation I'm pretty sure you can accomplish what you want in Game_Battler_3 script. Line 42 starts the defining of Normal attack damage.

CODE
def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end


I haven't programmed with RMXP much but the basics would be to put something like this in after if hit_result == true

if attacker.class(#) == true
Damage Calculation
elsif attack.class(#) == true
Damage Calculation


I believe monsters are given class 0 but I dont know 100%.
Once again I havent scripted in this language much at all so I'm only guessing they will help you out.


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
syperius
post Jan 17 2010, 08:49 PM
Post #3


Level 1
Group Icon

Group: Member
Posts: 6
Type: None
RM Skill: Undisclosed




Ok I'm going to try this out and see how it goes. Thank you so very much!!

edit: Ok i've tried using the class property as you mentioned and that didn't work out so i tried a bunch of stuff like $game_class/actor/enemy[#] and what not with no luck either. sad.gif I'm really hoping someone out there knows a property or syntax i can use to determine who the current attacker is!

This post has been edited by syperius: Jan 17 2010, 09:15 PM
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 17 2010, 10:57 PM
Post #4


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




Ah, sorry my answer wasnt the right one, but looks like I got you enough information to find the right one. smile.gif


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 10:52 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker