Ruby/RGSSx questions that don't deserve their own thread

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,907
Reaction score
9,440
First Language
Indonesian
Primarily Uses
N/A
Or be dumb like
Ruby:
class Game_System
  #--------------------------------------------------------------------------
  # * New Method:
  #--------------------------------------------------------------------------
  def unlock_achievement_slot
    $game_switches
  end
end
Ruby:
$game_system.unlock_achievement_slot[value] = string
 
Last edited:

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Or be dumb like
Ruby:
class Game_System
  #--------------------------------------------------------------------------
  # * New Method:
  #--------------------------------------------------------------------------
  def unlock_achievement_slot(value)=(string)
    $game_switches
  end
end
Ruby:
$game_system.unlock_achievement_slot[value] = string
Well, as long as the solution works... is it really dumb? I will give this one a go as well. Thanks for the different approach.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,907
Reaction score
9,440
First Language
Indonesian
Primarily Uses
N/A
Oh I forgot to remove the parameters, edited
 

mashedcookie

Warper
Member
Joined
Mar 24, 2022
Messages
2
Reaction score
0
First Language
Indonesia
Primarily Uses
RMVXA
I have a question regarding game_battlerbase. This is long but actually just need short answer.
Please bear with me.
Im not a scripter, only can read basic stuff.
Suppose I want to create custom hit rate, I copy item_hit from game_battler and create new snippet.
I use sixth custom param to create custom parameter and Yanfly enemy level so enemy can have its own level (albeit no parameter growth)
Ruby:
def item_hit(user, item)
    rate = item.success_rate * 0.01     # Get success rate
    rate *= ((user.hit*1.0) / self.eva) + (((user.level+user.hit)*1.0) / (self.level + self.eva)) / 2 
    return rate                         # Return calculated hit rate
  end
Thing is, this is work.
But on my mind, this shouldnt. The code is filled with user. and self.
And self.(?) is actually refering to enemy? shouldnt it be the attacker ?

And then my formula damage snip
Ruby:
def basicatk(base)
   ((self.level+(self.atk*base/100.0) - (target.def/2))*(100.0/(100+(target.def/2.0))))*self.tdm
end
I can use target.def, my brain can accept it.
But why item_hit cant use target. ?
Ruby:
def apply_critical(damage)
    damage * target.cdmg / 100.0
  end
and this critical damage multiplier only work when using target.critical stats instead self.critical stats
Can someone explain to me why this is happen ?
As people who isnt scripter like me, these arent make sense because they are classmates (in 1 class).
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,907
Reaction score
9,440
First Language
Indonesian
Primarily Uses
N/A
The code is filled with user. and self.
And self.(?) is actually refering to enemy? shouldnt it be the attacker ?
"Self" refers to the target (actor/enemy).
"User" refers to the attacker (or the user of skill/item)
Because the function is evaluated within the target object, not the attacker.

"Self" is a Ruby keyword that refers to the class instance (for example, the enemy object).

I can use target.def, my brain can accept it.
But why item_hit cant use target. ?
Because there is no reference to "target". What does it mean? what does it refer to?
If it is used in the damage formula, you can do it like

Ruby:
def basicatk(base, target, user)
   ((user.level+(user.atk*base/100.0) - (target.def/2))*(100.0/(100+(target.def/2.0))))*user.tdm
end
Then in the damage formula
Ruby:
basicatk(100, b, a)
You are passing it as an argument to the function

EDIT:
I misread your post, but my answer is still the same.
There is no reference to "target" in the item_hit.

and this critical damage multiplier only work when using target.critical stats instead self.critical stats
Are you sure it isn't the otherwise?
 

Latest Threads

Latest Posts

Latest Profile Posts

I've never felt prouder of my little game!! *o*
DamageEvil_2.png added!
index.php

Forum statistics

Threads
125,672
Messages
1,172,712
Members
164,799
Latest member
PurpleClouds
Top