Help - Search - Members - Calendar
Full Version: Mining Event Error
RPG RPG Revolution Forums > Game Engines > RPG Maker VX Ace Discussion
TheDreamWriter
Hey, R3,

If you are reading this, thanks in advance smile.gif you are the people that keep the R3 community alive smile.gif

Okay, here is my problem. I have made a mining system... Well, I'm trying to. I have hit a slight snag. I will show you the event first before I explain what it is meant to do.

Page 1

CODE
Graphic: Anthracite Ore
Conditions: None
Priority: Same as Characters
Trigger: Action Button

@>Conditional Branch: [Pickaxe] in Inventory                                      
     @>Conditional Branch: Switch [0001:First Time Use PA] == OFF
          @>Control Variables: [0020:Pickaxe Health] = Random No. (15...20)
          @>Control Switches: [0001:First Time Use PA] = ON
          @>
      :   Branch End
      @>Text: -, -, Normal, Bottom
      :           : My pickaxe health is currently \V[20].
      @>Set Move Route: Player (Wait)
      :                              : $>Turn 90 Right
      :                              : $>Wait: 10 Frame(s)
      :                              : $>Turn 90 Right
      :                              : $>Wait: 10 Frame(s)
      :                              : $>Turn 90 Right
      :                              : $>Wait: 10 Frame(s)
      :                              : $>Turn 90 Right
      :                              : $>Wait: 10 Frame(s)
     @>Control Variables: [0003:Mining Ore] = Random No. (0...20)
     @>Control Self Switch: A =ON
     @>
:    Else
     @>Text: -, -, Normal, Bottom
     :           : I need a pickaxe to mine this ore!
:    Branch End
@>



Page 2

CODE
Graphic: Anthracite Ore
Conditions: Self Switch A is ON
Priority: Same as Characters
Trigger: Parallel Process

@>Conditional Branch: Variable [0003:Mining Ore] >= 16
     @>Control Variables: [0004:Ore Obtained] = Random No. (18...20)
     @>Text: -, -, Normal, Bottom
      :          : Yay! I got \V[4] units of anthracite!
:    Else
     @>Conditional Branch: Variable [0003:Mining Ore] >= 12
          @>Control Variables: [0004:Ore Obtained] = Random No. (14...17)
          @>Text: -, -, Normal, Bottom
           :          : Yay! I got \V[4] units of anthracite!
     :     Else
           @>Conditional Branch: Variable [0003:Mining Ore] >= 8
                @>Control Variables: [0004:Ore Obtained] = Random No. (9...13)
                @>Text: -, -, Normal, Bottom
                 :          : Yay! I got \V[4] units of anthracite!
            :    Else
                 @>Conditional Branch: Variable [0003:Mining Ore] >= 4
                      @>Control Variables: [0004:Ore Obtained] = Random No. (4..8)
                      @>Text: -, -, Normal, Bottom
                       :          : Yay! I got \V[4] units of anthracite!
                  :    Else
                       @>Conditional Branch: Variable [0003:Mining Ore] >= 2
                            @>Text: -, -, Normal, Bottom
                             :          : Ooooh... :(
                             :          : The ore disintegrated :(
                        :    Else
                             @>Conditional Branch: Variable [0003:Mining Ore] >= 0
                                  @>Text: -, -, Normal, Bottom
                                   :          : I broke my pickaxe! :(
                                  @>Change Weapons: [Pickaxe] - 1
                                  @>Jump to Label: End
                                  @>
                             :    Branch End
                            @>
                       :    Branch End
                      @>
                 :    Branch End
                 @>
            :    Branch End
            @>
       :    Branch End
      @>
:    Branch End
@>Control Variables: [0019:Damage] = Random No. (0...10)
@>Control Variables: [0020:Pickaxe Health] -= Variable [0019:Damage]
@>Conditional Branch: Variable [0020:Pickaxe Health] <= 0
     @>Text: -, -, Normal, Bottom
      :          : That caused \V[19] damage to my pickaxe :(
      :          : My pickaxe broke! :(
      @>Change Weapons: [Pickaxe] - 1
      @>Control Switches: [0001:First Time Use PA] = OFF
      @>
:     Else
      @>Text: -, -, Normal, Bottom
       :          : That caused \V[19] damage to my pickaxe :(
       :          : My pickaxe health is now \V[20].
      @>
:     Branch End
@>Control Self Switch: A=OFF
@>Control Self Switch: B=ON
@>Label: End
@>



Page 3

CODE
Graphic: None
Conditions: Self Switch B is ON
Priority: Below Characters
Trigger: Parallel Process

@>Wait: 300 Frame(s)
@>Control Self Switch: B =OFF
@>



Okay, this is what is meant to happen:

Page 1 finds out whether you have a pickaxe or not. It then finds out if this is the first time that you are using the pickaxe. If so, it assigns a random number between15 and 20; this is the pickaxe's health. If it has already been used, the number carries over from the previous time. It then also assigns a random number between 0 and 20 to the variable 'mining ore'.

Page 2 then uses the random number for 'mining ore' to decide how much ore you mine. It also generates a random number between 0 and 10 and this is the damage dealt to the pickaxe caused by the mining of the ore. This is subtracted from the pickaxe's current health, leaving variable 'pickaxe health' as the new health.

Page 3 allows for the ore to come back after a cool-down period.

My problem is when the pickaxe runs out of life. If you mine an ore, get some units of ore and then lose the pickaxe, if you go to mine another ore, it says 'you need a pickaxe...'. However, if you mine the same ore that you mined when the pickaxe broke (after the cool-down period), it allows you to do so and the pickaxe will start to have a minus health!

Can anybody help and tell me why?!

I don't think screenshots are necessary but I will supply them if needed.

Thank you to all in advance,

~TDW
diamondandplatinum3
Provide screenshots if this doesn't work... But

QUOTE
CODE
@>Conditional Branch: Variable [0020:Pickaxe Health] <= 0
     @>Text: -, -, Normal, Bottom
      :          : That caused \V[19] damage to my pickaxe :(
      :          : My pickaxe broke! :(
      @>Change Weapons: [Pickaxe] - 1
      @>Control Switches: [0001:First Time Use PA] = OFF

Make the pick-axe health return to 0.

I think it's giving you a negative number because of the way maths works.
When you add on to a negative number it actually makes it even more negative rather than positive.

So when you decrement the health the way you are and allow it to hit a negative number, you need to be sure that the pickaxe health will always be zero or a positive number.
TheDreamWriter
QUOTE
Make the pick-axe health return to 0.


Thanks, DP3. That has fixed the problem. You really are my saviour! tongue.gif

~TDW
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.