Variables Problem : RMVX doesn't recognize actor parameters ?

Status
Not open for further replies.

Dissentrix

Veteran
Veteran
Joined
Oct 21, 2014
Messages
44
Reaction score
0
First Language
English
Primarily Uses
Hello again ! I'm sorry if I'm hogging the forums, but this is a beloved project of mine and I'm something of a beginner in RPG Maker.

As you can see in the file attached, I've got a parallel process common event that's supposed to mimic the effects of withdrawal. I know I've done the switches and the conditions properly, because the "You begin to feel pain more acutely..." message pops up as expected. What happens is that it pops up, and then... nothing. Whereas the other effects work all right, this particular one doesn't. It's supposed to lower the defense parameter when the second threshold has been passed, but for some reason it doesn't, either because it doesn't store the actor parameter variables, or because I did something wrong with my variables.

Now I've downloaded Lunarea's Game Interpreter fix (which, btw, I don't know what it does exactly), I've tried messing around to see if only DEF was affected, What you see is only the very last attempt to affect that damned DEF. I've tried subtracting the variable from itself, dividing it by itself, dividing it by ten, and subtracting ten from it. Nothing works.

tl;dr

Basically, the value stored in the variable, which is the actor's defense, doesn't change at all, despite my best efforts.

What am I doing wrong ? Any input is, as usual, appreciated.

EDIT : The second screenshot is the end of the event, if that helps at all. It's supposed to stop the parallel process from endlessly repeating.

Untitled.png

Untitled 2.png
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,052
Reaction score
6,695
First Language
German
Primarily Uses
RMMV
Your first problem is that you haven't used a single command to change any parameter anywhere in that event.


You have changed variables, but changing variables does not change parameters, because they are not the same.


The control variable command reads the value of a parameter into the variable, but that variable CANNOT send the value back to the parameter...


The solution is to create states that change the parameters, and then apply those states to the actors when you want the parameters to change. However, that requires a different form of math because the states have fixed values and can't be stacked...
 

Tai_MT

Veteran
Veteran
Joined
May 1, 2013
Messages
5,243
Reaction score
4,455
First Language
English
Primarily Uses
RMMV
What it looks like to me is this:

You're trying to change the variable to go lower... and you're hoping that by changing the variable to be lower, it'll lower the actual parameter.  That's not really how variables work.  I'm assuming your variable is set up as "value of variable is equal to defense of X character", right?  If that's the case, even changing the number of that variable won't really do anything to your defense, or the variable itself.  The variable (from the way I understand it) will simply reset itself back to be the value of the defense attribute because of your parallel process common event.

The few ways I know of to actually lower the defense parameter involve either states or outright telling the game to just lower the parameter.

You could, through your common events, mimic withdrawal in the way you want by having it store the "maximum" defense somewhere and then after having X amount of time gone by, tell the game to just change the defense stat downwards.  You could then have the game check the "maximum defense" variable and have it bring the defense back up to that when withdrawal no longer happens.

Though, admittedly...  This might be a lot easier and more flexible with a script to execute.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,314
Reaction score
315
First Language
German
Primarily Uses
RMMV
Yes thats a known Bug that in VX that this BUG failure happens, there is a Bug Fix Script to Fix that OP, but i dont have link at the moment sorry.

Hero Variables Fix:

lass Game_Interpreter
  def command_122
    value = 0
    case @params[3]  # Operand
    when 0  # Constant
      value = @params[4]
    when 1  # Variable
      value = $game_variables[@params[4]]
    when 2  # Random
      value = @params[4] + rand(@params[5] - @params[4] + 1)
    when 3  # Item
      value = $game_party.item_number($data_items[@params[4]])
    when 4  # Actor
      actor = $game_actors[@params[4]]
      if actor != nil
        case @params[5]
        when 0  # Level
          value = actor.level
        when 1  # Experience
          value = actor.exp
        when 2  # HP
          value = actor.hp
        when 3  # MP
          value = actor.mp
        when 4  # Maximum HP
          value = actor.maxhp
        when 5  # Maximum MP
          value = actor.maxmp
        when 6  # Attack
          value = actor.atk
        when 7  # Defense
          value = actor.def
        when 8  # Spirit
          value = actor.spi
        when 9  # Agility
          value = actor.agi
        end
      end
    when 5  # Enemy
      enemy = $game_troop.members[@params[4]]
      if enemy != nil
        case @params[5]
        when 0  # HP
          value = enemy.hp
        when 1  # MP
          value = enemy.mp
        when 2  # Maximum HP
          value = enemy.maxhp
        when 3  # Maximum MP
          value = enemy.maxmp
        when 4  # Attack
          value = enemy.atk
        when 5  # Defense
          value = enemy.def
        when 6  # Spirit
          value = enemy.spi
        when 7  # Agility
          value = enemy.agi
        end
      end
    when 6  # Character
      character = get_character(@params[4])
      if character != nil
        case @params[5]
        when 0  # x-coordinate
          value = character.x
        when 1  # y-coordinate
          value = character.y
        when 2  # direction
          value = character.direction
        when 3  # screen x-coordinate
          value = character.screen_x
        when 4  # screen y-coordinate
          value = character.screen_y
        end
      end
    when 7  # Other
      case @params[4]
      when 0  # map ID
        value = $game_map.map_id
      when 1  # number of party members
        value = $game_party.members.size
      when 2  # gold
        value = $game_party.gold
      when 3  # steps
        value = $game_party.steps
      when 4  # play time
        value = Graphics.frame_count / Graphics.frame_rate
      when 5  # timer
        value = $game_system.timer / Graphics.frame_rate
      when 6  # save count
        value = $game_system.save_count
      end
    end
    for i in @params[0] .. @params[1]   # Batch control
      case @params[2]  # Operation
      when 0  # Set
        $game_variables = value
      when 1  # Add
        $game_variables += value
      when 2  # Sub
        $game_variables -= value
      when 3  # Mul
        $game_variables *= value
      when 4  # Div
        $game_variables /= value if value != 0
      when 5  # Mod
        $game_variables %= value if value != 0
      end
      if $game_variables > 99999999    # Maximum limit check
        $game_variables = 99999999
      end
      if $game_variables < -99999999   # Minimum limit check
        $game_variables = -99999999
      end
    end
    $game_map.need_refresh = true
    return true
  end
end

 

 

 

-------And here a Seccond Script:

 

#=========================================================================
# ? ? [VX] Animation Bug Fixed ? ? by Woratana (21/05/2008)
# * Fixed bug that animation will follow screen, not stay on character~ *
# * You can place this script in any slot below the slot 'Sprite_Base'
#-------------------------------------------------------------------------
class Sprite_Base < Sprite
  alias wora_bugfix_sprbas_upd update
  def update
   if !@animation.nil?
     if @animation.position == 3
      if viewport == nil
        @animation_ox = Graphics.width / 2
        @animation_oy = Graphics.height / 2
      else
        @animation_ox = viewport.rect.width / 2
        @animation_oy = viewport.rect.height / 2
      end
     else
      @animation_ox = x - ox + width / 2
      @animation_oy = y - oy + height / 2
      if @animation.position == 0
        @animation_oy -= height / 2
      elsif @animation.position == 2
        @animation_oy += height / 2
      end
     end
   end
   wora_bugfix_sprbas_upd
  end
end
 
Last edited by a moderator:

Dissentrix

Veteran
Veteran
Joined
Oct 21, 2014
Messages
44
Reaction score
0
First Language
English
Primarily Uses
Your first problem is that you haven't used a single command to change any parameter anywhere in that event.

You have changed variables, but changing variables does not change parameters, because they are not the same.

The control variable command reads the value of a parameter into the variable, but that variable CANNOT send the value back to the parameter...

The solution is to create states that change the parameters, and then apply those states to the actors when you want the parameters to change. However, that requires a different form of math because the states have fixed values and can't be stacked...
What it looks like to me is this:

You're trying to change the variable to go lower... and you're hoping that by changing the variable to be lower, it'll lower the actual parameter.  That's not really how variables work.  I'm assuming your variable is set up as "value of variable is equal to defense of X character", right?  If that's the case, even changing the number of that variable won't really do anything to your defense, or the variable itself.  The variable (from the way I understand it) will simply reset itself back to be the value of the defense attribute because of your parallel process common event.

The few ways I know of to actually lower the defense parameter involve either states or outright telling the game to just lower the parameter.

You could, through your common events, mimic withdrawal in the way you want by having it store the "maximum" defense somewhere and then after having X amount of time gShow meone by, tell the game to just change the defense stat downwards.  You could then have the game check the "maximum defense" variable and have it bring the defense back up to that when withdrawal no longer happens.

Though, admittedly...  This might be a lot easier and more flexible with a script to execute.
Wow, thanks for the speedy replies, you guys !

I've tried it with states, as you suggested, For anyone wondering, I've set the DEF to 1%, and put it back to normal when they take heroin. So all's good and well.

Thank you for clearing up what variables were all about.

As for your solution, Bex, I'll try it out, but since states work out, I'm not sure it's needed. Anyway, this topic can be closed.

Thanks again !
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,052
Reaction score
6,695
First Language
German
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

I survived Baudelaire and Bukowski, but I can't face C. Lispector. :kaoswt:
I'm a bit late, but Happy New Year to everyone! And to all of those who have an Asian heritage that celebrates the New Year, I wish you all get many fat red envelopes hehehe~
Pretend you were telling, reading, or listening to a very serious, slightly scary story about witches. Would a witch doing the stereotypical flying on a broomstick thing ruin the mood?
Yeseylon wrote on CrowStorm's profile.
All Hail Storm Crow, the Blue Eyes White Dragon of MtG!

Forum statistics

Threads
93,649
Messages
914,275
Members
123,236
Latest member
eriedev
Top