Help figuring out this Variable Problem in VX please. [Solved]

0 Members and 1 Guest are viewing this topic. nemrog    Rep:
Level 63
RMRK Junior #1 • Jan 11, 2012
• • 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]

CIV == PVC

CIV / CC

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]

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 » modern algebra    #2 • Jan 11, 2012
• • 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  # Operand    when 0  # Constant      value = @params    when 1  # Variable      value = \$game_variables[@params]    when 2  # Random      value = @params + rand(@params - @params + 1)    when 3  # Item      value = \$game_party.item_number(\$data_items[@params])      actor = \$game_actors[@parameters]      actor = \$game_actors[@params]      if actor != nil        case @params        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]      if enemy != nil        case @params        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)      if character != nil        case @params        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      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 .. @params   # Batch control      case @params  # 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  # Operand    when 0  # Constant      value = @params    when 1  # Variable      value = \$game_variables[@params]    when 2  # Random      value = @params + rand(@params - @params + 1)    when 3  # Item      value = \$game_party.item_number(\$data_items[@params])    when 4      actor = \$game_actors[@params]      if actor != nil        case @params        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]      if enemy != nil        case @params        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)      if character != nil        case @params        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      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 .. @params   # Batch control      case @params  # 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`  nemrog    Rep:
Level 63
RMRK Junior #3 • Jan 11, 2012
• • 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. modern algebra    #4 • Jan 11, 2012
• • 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  nemrog    Rep:
Level 63
RMRK Junior #5 • Jan 11, 2012
• • 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.

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. modern algebra    #6 • Jan 11, 2012
• • 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.  nemrog    Rep:
Level 63
RMRK Junior #7 • Jan 11, 2012
• • Thank you very much it works perfectly now. .