RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Help figuring out this Variable Problem in VX please. [Solved]

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 63
RMRK Junior
Ks. I figured out how to do a simple Income Event like in Fable for Criminal Empires. Wich is rather Simple. But the Counter Part is giving me Problems and I've been stuck since 1 PM EST.

[Simple Crime]

Crime Income Value [CIV]

Crime Counter [Workers, how many Jobs you can do, Maintenance, etc.] [CC]

Product Counter Value [How much money your Services Bring in] [PCV]

CIV == PVC

CIV / CC

This bring in your Income.


But Legal Businesses [Where I'm Stuck].

I have:

Base Price [How much the building Costs without any extras.]  [BP]

Building Bonus [Base Bonus to the Building as a Global Building Value] [BB]

Security Bonus [ How much Extra you gain for having Better Security and Safety] [SB]

Addon Bonus [Additions added to Building. Boosting Price]. [AB]

Resident Bonus [Same as Crime counter. Simulates Business out come do to owning property.] [RB]

What I want is this.

(BB (SB+AB) / RB) BP = Sales Price [how much it sales for]

and SP / 100 = Building Income [how much you make].


Then I simply have a Chest. + [Variable [CIV]] Gold, or if I get it to work + [Variable [BI]] Gold.

After gold is gotten Self Switch A.

Wait Several Mins. [5 Minutes]. And then go Allow to draw more gold.

But I'm stuck on getting that above Math equation to work. Heck even just showing Sales Price the closest I got. Repeatedly took more Gold till there was nothing left on the Sales Price. So any help will be appreciated.


« Last Edit: January 11, 2012, 10:46:43 PM by nemrog »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Do you have the variable fix for Game_Interpreter?

Otherwise multiplication doesn't work.

If you don't have the fix, then you need to go to about line 736 in Game_Interpreter. You should see this:

Code: [Select]

  #--------------------------------------------------------------------------
  # * Control Variables
  #--------------------------------------------------------------------------
  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]])
      actor = $game_actors[@parameters[1]]
      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[i] = value
      when 1  # Add
        $game_variables[i] += value
      when 2  # Sub
        $game_variables[i] -= value
      when 3  # Mul
        $game_variables[i] = value
      when 4  # Div
        $game_variables[i] /= value if value != 0
      when 5  # Mod
        $game_variables[i] %= value if value != 0
      end
      if $game_variables[i] > 99999999    # Maximum limit check
        $game_variables[i] = 99999999
      end
      if $game_variables[i] < -99999999   # Minimum limit check
        $game_variables[i] = -99999999
      end
    end
    $game_map.need_refresh = true
    return true
  end

Replace it with this:

Code: [Select]

  #--------------------------------------------------------------------------
  # * Control Variables
  #--------------------------------------------------------------------------
  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 = $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[i] = value
      when 1  # Add
        $game_variables[i] += value
      when 2  # Sub
        $game_variables[i] -= value
      when 3  # Mul
        $game_variables[i] *= value
      when 4  # Div
        $game_variables[i] /= value if value != 0
      when 5  # Mod
        $game_variables[i] %= value if value != 0
      end
      if $game_variables[i] > 99999999    # Maximum limit check
        $game_variables[i] = 99999999
      end
      if $game_variables[i] < -99999999   # Minimum limit check
        $game_variables[i] = -99999999
      end
    end
    $game_map.need_refresh = true
    return true
  end

**
Rep:
Level 63
RMRK Junior
I added that [thanks for the fix btw.]. and I'm still getting disappearing Funds.

Mostly because I don't know what Variables of where. At the moment I have it as:

*Points to Above Abbreviations*:

BP * BB

BP * SB

BP + AB

BP / RB

----------------

BP = 1000

BP = 1

SP = 1

AB = 0

RB = 10
----------------

First it shows up as 10. Then when I check on it a second time I get 0.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, I don't really understand what you're saying there? Are the values below the initial values, or are they what you are getting after the calculations?

Most importantly, you should not be directly multiplying to BP, as that obviously modifies your variable. In other words, if 1000 is the initial value for BP and you then go through that calculation, the new value for BP will be whatever you get as a result, so when you run the calculation again, BP will not be 1000. That is probably why it reduces to 0 after one iteration.

In any case, you stated your desired formula as:

(BB (SB+AB) / RB) BP

The order of calculations listed above does not correspond to that. Remember BEDMAS?

What you would want to do is create a new variable (I will call if DV, or Dummy Variable) and this is what the calculation should look like to match the equation above:

DV = SB
DV + AB
DV / RB
DV * BB
DV * BP

That would give you the sales price. To then get the income, you would:

DV / 100


**
Rep:
Level 63
RMRK Junior
I Remember my PEMDAS.

And yep the Initials were standins for the Numbers I was using and the Numbers beneath were my out come.

I tried the above equation. It shows up 0 as well.

Basically here are the Numbers of Each Abbreviation.

Before The above equation and After [don't worry I get 0 alot on this thing for some reason.]


BP = 1000
BB = 1
SB = 1
AB = 0
RB = 10

What should have happened is First.

Security and Add on Bonuses are Added.

That is Multiplied to Building Bonus.

Building Bonus is Multiplied to Base Price. Where the End Result is Divided by 10.

So I should be getting 100 as my Sale Price.

But instead I somehow got 10.

Then the second Check got me an Outcome of 0.

----------------------------------------

The Last Equation

BI=0 & BI =1

Then Did all the above things and kept getting 0.

-------------------------------------------

But yeah this Equation shouldn't be as hard as it's turning out to be.

1+0 = 1 [SB+AB]

1*1 = 1 [SB * BB]

1*1000 = [BP * BB]

1000 / 10 = 100 [BP / RB]

--------------------

So I have no idea how I'm getting 10 then 0.  Or You're Equation which should've worked too.

1*1 = 1 [BI * SB]

1+0 = 1 [SB + 0]

BB * SB =  [ 1*1]

I moved the RB to the Bottom but both brought up 0.

BB * BP = 1*1000 = 1000

BP / RB = 1000 /10 = 100.

So I don't get why I'm getting 0. But of course I'm not used to RPG Makers Variable Placement.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I have no idea what you mean by RPG Maker's variable placement. As long as you are using a dummy variable and not unknowingly modifying the variables elsewhere, the one you have should work. The fact that you are getting different results each time is suggesting to me that you are not using dummy variables though, or that you are altering the variables elsewhere.

Anyway, so this is the formula you want?

(BP*(BB*(SB+AB))) / RB

I attached a picture of what I did, and it works perfectly well. I set the initial values of the variable in the event itself, but you could just as easily set them out elsewhere. Calculator is a dummy variable so that you do not alter the initial values of any of your data. You could use whatever variable you want to hold the final result of your calculation (in this case, Building Income), but I separated them to illustrate the concept.

**
Rep:
Level 63
RMRK Junior
Thank you very much it works perfectly now.  ^_^.