Stopping Early

C++, C#, Java, PHP, ect...
Post Reply
greasontim
Posts: 73
Joined: Tue Feb 15, 2011 3:14 pm

Stopping Early

Post by greasontim »

For some reason it is stopping at 2/16 even though its setup to go all the way to 16/16 or X/X
I Know I still have to edit it to stop it from going over the character's max HP but that is easy to do.
Any ideas what I am doing wrong?

Timer

Code: Select all

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Dim Heal1, Heal2 As Integer
        Dim regain1 As Integer = Math.Ceiling(My.Settings.MHealth / 100)
        Dim regain2 As Integer = Math.Ceiling(My.Settings.MMana / 100)
        Label4.Text = regain1
        Label5.Text = regain2
        If My.Settings.Health <= My.Settings.MHealth Then
            Heal1 = Math.Round(regain1 * (My.Settings.HPRegen + 100) / 100)
            My.Settings.Health = My.Settings.Health + Heal1
            If My.Settings.Health >= My.Settings.MHealth Then
                'My.Settings.Health = My.Settings.MHealth
            End If
        End If
        If My.Settings.Mana <= My.Settings.MMana Then
            Heal2 = Math.Round(regain2 * (My.Settings.MPRegen + 100) / 100)
            My.Settings.Mana = My.Settings.Mana + Heal2
            If My.Settings.Mana >= My.Settings.MMana Then
                My.Settings.Mana = My.Settings.MMana
            End If
        End If
        Reload()
    End Sub
Reload

Code: Select all

        Label2.Text = "Health: " & My.Settings.Health & " / " & My.Settings.MHealth
        Label3.Text = "Mana:  " & My.Settings.Mana & " / " & My.Settings.MMana
        Inn = Math.Round((My.Settings.MHealth - My.Settings.Health) / 3)
        Inn += Math.Round((My.Settings.MMana - My.Settings.Mana) * 2)
        Label1.Text = "Cost: " & Inn
        If My.Settings.Health = My.Settings.MHealth And _
            My.Settings.Mana = My.Settings.MMana Then
            Timer1.Stop()
        End If
Last edited by greasontim on Sun Sep 09, 2012 4:23 pm, edited 1 time in total.
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Stopping Early

Post by Callan S. »

I might not know anything about this, but what language is that? It has a reload - is it like php pages? If so it's not going to remember regular values between page refreshes, and so it'd keep starting from zero/the start.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Stopping Early

Post by Jackolantern »

I am assuming this is a Visual Basic.NET WinForms project? If so, there is a lot going on besides what is just in your code. Do you know how to use the debugger, Locals Windows, Watched List, etc.? It seems like those could probably make easy work of this issue, as I don't really know enough about the program to see an issue in this code (of course I am also quite tired, too lol). :)
The indelible lord of tl;dr
greasontim
Posts: 73
Joined: Tue Feb 15, 2011 3:14 pm

Re: Stopping Early

Post by greasontim »

Yes Jack, but can you take another look when your fully awake?

The Health stops at 2 and mana goes all the way till it maxs out, so I really don't know what is going on seeing how the code was made for health first than I copied and pasted and changed the my.settings for Mana. Yet mana works fully and health does not.

Edit: Nevermind fixed it, changed my.settings.health/Mana into integers and now it works perfectly. Never hit a problem with my.settings before.
Post Reply

Return to “Coding”