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
> .note, Need general help with setting up a one for States, Like PoisonDMG =
Titanhex
post Feb 6 2012, 02:27 PM
Post #1


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Alright I want to use the .note of a State so that I can read some values from it.

Particularly, I want it so if the string Slip DMG = is in the note it uses the value after Slip DMG =. This isn't mentioned in dah0rst's tutorial, so I came here to ask how I'd do it. How would I go about something like this?

I want it to be used in Game_Battler class, since that contains this:

CODE
  def slip_damage_effect
    if slip_damage? and @hp > 0
      @hp_damage = apply_variance(maxhp / 10, 10)
      @hp_damage = @hp - 1 if @hp_damage >= @hp
      self.hp -= @hp_damage
    end
  end


I constructed this snippet from reference and for the most part understand it:


CODE
      $data_states[].note.each_line { |line|
      slip_amount = line.gsub('Slip DMG = ', '').chomp.to_i if line.include?('Slip DMG = ')
      }


Unfortunately I don't know how to get the number of the state causing the slip damage.


__________________________
Go to the top of the page
 
+Quote Post
   
ForeverZer0
post Feb 6 2012, 02:45 PM
Post #2


Level 2
Group Icon

Group: Member
Posts: 26
Type: Scripter
RM Skill: Masterful




Use a simple Regular Expression.

CODE
input_string = 'Slip DMG = 45'

if input_string =~ /#{input_string}([0-9]+)/
  value = $1.to_i
end


This post has been edited by ForeverZer0: Feb 6 2012, 02:45 PM
Go to the top of the page
 
+Quote Post
   
Titanhex
post Feb 6 2012, 03:11 PM
Post #3


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Ah okay. That answers one part of the question. Though I found another way to do it by checking out other codes.

I'll keep regexp in mind though. If nothing else I should research it more.


__________________________
Go to the top of the page
 
+Quote Post
   
Titanhex
post Feb 8 2012, 10:28 AM
Post #4


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Bump for help :3


__________________________
Go to the top of the page
 
+Quote Post
   
Titanhex
post Feb 11 2012, 11:53 PM
Post #5


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Once again, ba-bump.


__________________________
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Feb 12 2012, 03:28 AM
Post #6


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




QUOTE (Titanhex @ Feb 12 2012, 08:53 AM) *
Once again, ba-bump.


Try this (it was for RGSS, but I bet methods are quite the same)

CODE
def slip_damage_effect
if slip_damage? and @hp > 0
amount = 0
for state_id in self.states
if $data_states[state_id].slip_damage
#insert your snippet here...
#just one thing: damage should be stored into a variable named [i]slip_amount[/i]
#for example, I pasted your code just below this line, but if you've changed it just replace these lines...
  $data_states[state_id].note.each_line { |line|
      slip_amount = line.gsub('Slip DMG = ', '').chomp.to_i if line.include?('Slip DMG = ')
      }

#sum amounts
amount += slip_amount
end
end

#do damage
self.hp -= amount
end
end


This is a loop checking every status your hero / enemy has and check the notes only for slip_damage status.
Try and let me know...

Jens

This post has been edited by Jens of Zanicuud: Feb 12 2012, 03:38 AM


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   
Titanhex
post Feb 13 2012, 05:21 PM
Post #7


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




It gives an error with Cannot convert RPG::State into integer. In reference to states. makes sense to me. The only other solution is a very inneffective run through all the states to check which states are applied.


__________________________
Go to the top of the page
 
+Quote Post
   
Pacman
post Feb 14 2012, 03:53 AM
Post #8


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




Fetching code from notes is easiest done using REGEXP.
CODE
class RPG::State
  def slp_dmg
    return @slp_dmg if !@slp_dmg.nil?
    @slp_dmg = self.note[/SLIP[_ ]?DA?MA?GE? = (\d+)/i].nil? ? 0 : $1.to_i
    return @slp_dmg
  end
end

That will respond to slip dmg = x, slipdamage = x, SlIP_DaMagE = x, case insensitive. It will return the integer(s) places after the '=' sign.
I think.


__________________________
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Feb 14 2012, 04:10 AM
Post #9


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




@Titanhex

What line does the error occurr?

Jens

This post has been edited by Jens of Zanicuud: Feb 14 2012, 04:21 AM


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Feb 14 2012, 04:20 AM
Post #10


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




I tried this code onto RMXP and it works (though I set "name" instead of "note")
Try this modified version, this should work on RMVX.

CODE
#Pacman's slip damage module

class RPG::State
  def slp_dmg
    return @slp_dmg if !@slp_dmg.nil?
    @slp_dmg = self.note[/SLIP[_ ]?DA?MA?GE? = (\d+)/i].nil? ? 0 : $1.to_i
    return @slp_dmg
  end
end

#slip_damage_procedure
class Game_Battler

def slip_damage_effect
if slip_damage? and @hp > 0
amount = 0
for state in self.states
#for cicle
if state.slip_damage
#Pacman snippet (credits to him)
slip_amount = state.slp_dmg
#sum amounts
amount += slip_amount
end
end

#do damage
@hp_damage = amount
self.hp -= amount
end
end
end


Maybe this version will work.
Thx Pacman for the note reader smile.gif

Jens

This post has been edited by Jens of Zanicuud: Feb 14 2012, 04:21 AM


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   
Titanhex
post Feb 14 2012, 06:34 AM
Post #11


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Awesome! Works perfectly now. I modified it a little better so it could still remain dynamic:


CODE
class RPG::State
  def slp_dmg
    return @slp_dmg if !@slp_dmg.nil?
    @slp_dmg = self.note[/SLIP[_ ]?DA?MA?GE? = (\d+)/i].nil? ? 0 : $1.to_i
    return @slp_dmg
  end
end

class Game_battler
  def slip_damage_effect
    if slip_damage? and @hp > 0
      amount = 0
      for state in self.states
      #for cycle
        if state.slip_damage
          amount += state.slp_dmg
          if amount == 0
            amount = apply_variance(maxhp / 10, 10)
            amount = @hp - 1 if amount >= @hp
          end
        end
      end

      #do damage
      @hp_damage = amount
      self.hp -= @hp_damage
    end
  end
end


Works like I want it to and it's pretty nice. Thanks!


__________________________
Go to the top of the page
 
+Quote Post
   
Pacman
post Feb 14 2012, 11:17 PM
Post #12


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




No problem. If anyone needs any help in REGEXP (it's a very handy technique to have), I'd be glad to offer my teachings.


__________________________
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: 20th May 2013 - 10:54 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker