Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[Game] 2 Person Game [SourceOnly]

A pre-topic about this topic.

Is a 2p game, which get can 2 players attack each other

This is what I already have:
  • GetStats from WebHost

  • GetPlayerName

  • GetAttackerName

  • GetPlayerHealth

  • GetPlayerAttackLevel

  • GetPlayerDefenceLevel

  • GetPlayerBlockLevel

  • GetEnemyHealth

  • GetEnemyAttackLevel

  • GetEnemyDefenseLevel

  • GetEnemyBlockLevel

  • BlockSkill(No function to get it yet)

  • Attack (Attack>Block(Yes/No)>No>Health = Down

  • RandomNumbers for Attack/Block

  • Save at logout

  • Get Saved at login

  • Uses Block Level

  • Added a 'Block' Function

  • You can level your skills by killing people

  • People can die now

  • Pre-Fixed 'Attack' function

  • Added Money (Get after hitting Formula = Health * Attack / Defense )

  • Added ItemShop (Not the form version, the codes (Helmet,Sword,Armor,Ring)

  • Added PregradeCenter (Update your skills Health,Attack,Defense)(No Block because you will be to strong)

  • Block only added when randomize(1,5) = 2




Code
Imports System.Net
Public Class Form1
    Dim NHealth As String = Label2.Text
    Dim OldH As String
#Region "Attack User"
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Hit Clicked
        Dim Defence_E As Single = GetE_Defense() 'Defense_Enemey
        Dim Block As String = "0"
        RandomNBlock()
        If RandomNBlock() = 1 Then ' Level 1 - 10
            Block = RandomNumber(1, 20) ' Gets a number between 1 and 20
        ElseIf RandomNBlock() = 2 Then ' Level 10 - 30
            Block = RandomNumber(1, 17) ' Gets a number between 1 and 17
        ElseIf RandomNBlock() = 3 Then 'Level 30 - 10000
            Block = RandomNumber(1, 15) ' Gets a number between 1 and 15
        End If
        If RandomNBlock() = 1 Then
            If Block = "1" > "2" Then ' If its 1,2
                GoTo StopSub ' Blocked
            Else
                Hit()
            End If
        ElseIf RandomNBlock() = 2 Then
            If Block = "1" > "5" Then ' If its 1,2,3,4,5
                GoTo StopSub ' Blocked
            Else
                Hit()
            End If
        ElseIf RandomNBlock() = 3 Then
            If Block = "1" > "10" Then ' If its 1,2,3,4,5,6,7,8,9,10
                GoTo StopSub ' Blocked
            Else : Hit()
            End If
        End If
StopSub:
    End Sub
    Public Sub Hit()
        Dim Defence_E As Single = GetDefence() 'Defense_Enemey
        Dim Attack_A As Single = GetAttack() 'Attack_Attacker
        Dim Health_E As String = GetHealth() 'Health_Enemey
        Dim NewHealth_E As String = GetHealth() 'NewHealth_Enemey
        OldH = Health_E ' Save current health
        NewHealth_E = Defence_E - Attack_A
        Health_E = Health_E - NewHealth_E
        NewHealth(Health_E)
        DamageDone()
    End Sub
    Public Sub DamageDone()
        Dim NewH As String
        Dim OldHH As String
        Dim Defense As String
        Dim Health As String
        Dim Attack As String
        Dim PreMoney As String
        OldHH = OldH
        NewH = GetE_Health()
        If OldHH = NewH Then
            MsgBox("Attack has been blocked!")
        Else
            Dim Calc As String
            Calc = OldHH - NewH
            If Calc = -10000 > 0.99999 Then ' If player died
                MsgBox("Player died!")
                Me.Close()
                Form3.Show() ' You won
            Else
                MsgBox("New enemey health = " & Calc) ' If its not dead
                Label3.Text = Label3.Text + 1 ' Block + 1
                Label4.Text = Label4.Text + 1 ' Attack +1
                Label1.Text = Label1.Text + 1 ' Defense +1
                Attack = GetAttack()
                Defense = GetDefence()
                Health = GetHealth()
                PreMoney = Health * Attack / Defense
                Label6.Text = PreMoney
            End If
        End If
    End Sub
#End Region
#Region "Get Current User"
    Public Function GetDefence()
        Dim Player As Integer
        Dim Defence As String
        Dim PlayerStats As String
        PlayerStats = GetPlayerStats(Defence)
        Return PlayerStats(Defence)
    End Function
    Public Function GetAttack()
        Dim Attack As String
        Dim PlayerStats As String
        PlayerStats = GetPlayerStats(Attack)
        Return PlayerStats(Attack)
    End Function
    Public Sub NewHealth(ByVal input As String)
        Dim NewHealthh As String
        NewHealthh = input
        NHealth = NewHealthh
    End Sub
    Public Function GetHealth()
        Dim Health As String
        Dim PlayerStats As String
        PlayerStats = GetPlayerStats(Health)
        Return PlayerStats(Health)
    End Function
    Public Function GetBlock()
        Dim Block As String
        Dim PlayerStats As String
        PlayerStats = GetPlayerStats(Block)
        Return PlayerStats(Block)
    End Function
    Public Function GetMoney()
        Dim Money As String
        Dim PlayerStats As String
        PlayerStats = GetPlayerStats(Money)
        Return PlayerStats(Money)
    End Function
#End Region
#Region "Get Enemey Stats"
    Public Function GetE_Attack()
        Dim Attack As String
        Dim PlayerStats As String
        PlayerStats = GetEnemeyStats(Attack)
        Return PlayerStats(Attack)
    End Function
    Public Function GetE_Defense()
        Dim Defense As String
        Dim PlayerStats As String
        PlayerStats = GetEnemeyStats(Defense)
        Return PlayerStats(Defense)
    End Function
    Public Function GetE_Health()
        Dim Health As String
        Dim PlayerStats As String
        PlayerStats = GetEnemeyStats(Health)
        Return PlayerStats(Health)
    End Function
    Public Function GetE_Block()
        Dim Block As String
        Dim PlayerStats As String
        PlayerStats = GetEnemeyStats(Block)
        Return PlayerStats(Block)
    End Function
    Public Function GetE_Money()
        Dim Money As String
        Dim PlayerStats As String
        PlayerStats = GetEnemeyStats(Money)
        Return PlayerStats(Money)
    End Function
#End Region
#Region "Get Player/Enemy Stats / Other Info"
    Public Function GetPlayerStats(ByVal input As String)
        Dim wc As New WebClient
        Dim CurUser As String = GetUser()
        Dim Defence As String = Label1.Text
        Dim Attack As String = Label3.Text
        Dim Health As String = Label2.Text
        Dim Block As String = Label4.Text
        If input = Defence Then
            Return Defence
        ElseIf input = Attack Then
            Return Attack
        ElseIf input = Health Then
            Return Health
        End If
    End Function
    Public Function GetEnemeyStats(ByVal input As String)
        Dim wc As New WebClient
        Dim EnemeyUser As String = GetAttacker()
        Dim Defence As String = wc.DownloadString("www.yourhost.com/Stats/Users/" & EnemeyUser & "/Defence.txt")
        Dim Attack As String = wc.DownloadString("www.yourhost.com/Stats/Users/" & EnemeyUser & "/Attack.txt")
        Dim Health As String = wc.DownloadString("www.yourhost.com/Stats/Users/" & EnemeyUser & "/Health.txt")
        Dim Block As String = wc.DownloadString("www.yourhost.com/Stats/Users/" & EnemeyUser & "/Block.txt")
        Dim Money As String = wc.DownloadString("www.yourhost.com/Stats/Users/" & EnemeyUser & "/Money.txt")
        If input = Defence Then
            Return Defence
        ElseIf input = Attack Then
            Return Attack
        ElseIf input = Health Then
            Return Health
        End If
    End Function
    Public Function GetAttacker()
        Dim Enemy As String = Label4.Text ' Label4.text Shows the attacker
        Return Enemy
    End Function
    Public Function GetUser()
        Dim User As String = Label1.Text ' Label1.text Shows the users name
        Return User
    End Function

    Public Function BuyItems(ByVal input As String)
        If input = "helmet" Then
            Add(1)
            Return (1)
        ElseIf input = "ring" Then
            Add(2)
            Return (2)
        ElseIf input = "armor" Then
            Add(3)
            Return (3)
        ElseIf input = "sword" Then
            Add(4)
            Return (4)
        End If
    End Function

    Public Function UpgradeSkills(ByVal input As String)
        If input = "health" Then
            Add(5)
            Return (5)
        ElseIf input = "attack" Then
            Add(6)
            Return (6)
        ElseIf input = "defense" Then
            Add(7)
            Return (7)
        End If
    End Function

    Public Sub Add(ByVal input As String)
        If input = 1 Then
            Label1.Text = Label1.Text + 1
        ElseIf input = 2 Then
            Label1.Text = Label1.Text + 1
            Label3.Text = Label3.Text + 1
        ElseIf input = 3 Then
            Label1.Text = Label1.Text + 5
        ElseIf input = 4 Then
            Label3.Text = Label3.Text + 5
        ElseIf input = 5 Then
            Label2.Text = Label2.Text + 7
        ElseIf input = 6 Then
            Label3.Text = Label3.Text + 3
        ElseIf input = 7 Then
            Label1.Text = Label1.Text + 3
        End If
    End Sub
#End Region

    Public Function RandomNumber(ByVal MaxNumber As Integer, Optional ByVal MinNumber As Integer = 0) As Integer
        Dim r As New Random(System.DateTime.Now.Millisecond)
        If MinNumber > MaxNumber Then
            Dim t As Integer = MinNumber
            MinNumber = MaxNumber
            MaxNumber = t
        End If
        Return r.Next(MinNumber, MaxNumber)
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Logout
        WebBrowser1.Navigate("www.yourhost.com/save.php") ' Host to save /Users/.txt
        Dim Block As String = Label4.Text
        Dim Defense As String = Label1.Text
        Dim Health As String = Label2.Text
        Dim Attack As String = Label3.Text
        Dim Name_U As String = Label5.Text
        Dim Money As String = Label6.text
        WebBrowser1.Document.GetElementById("nickname").SetAttribute("Value", Name_U)
        WebBrowser1.Document.GetElementById("defense").SetAttribute("Value", Defense)
        WebBrowser1.Document.GetElementById("block").SetAttribute("Value", Block)
        WebBrowser1.Document.GetElementById("health").SetAttribute("Value", Health)
        WebBrowser1.Document.GetElementById("attack").SetAttribute("Value", Attack)
        WebBrowser1.Document.GetElementById("money").SetAttribute("Value", Money)
        WebBrowser1.Document.GetElementById("submit").InvokeMember("click")
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Login
        Dim Login As String
        Dim Block As String
        Dim Defense As String
        Dim Health As String
        Dim Attack As String
        Dim Name_U As String
        Login = My.Settings.login ' Saved at login screen
        WebBrowser1.Navigate("www.<yourhost>.com/Users/" & Login & ".txt") ' Host, saved .txt
        Name_U = WebBrowser1.Document.GetElementById("nickname").ToString
        If Name_U = Login Then
            Defense = WebBrowser1.Document.GetElementById("defense").ToString
            Block = WebBrowser1.Document.GetElementById("block").ToString
            Health = WebBrowser1.Document.GetElementById("health").ToString
            Attack = WebBrowser1.Document.GetElementById("attack").ToString
            Label1.Text = Defense
            Label2.Text = Health
            Label3.Text = Attack
            Label4.Text = Block
            Label5.Text = Name_U
        Else
            MsgBox("Wrong Login")
            Me.Close()
            Form2.Show() ' Show Login Screen agin
        End If
    End Sub
    Public Function RandomNBlock()
        Dim Block As String
        Block = GetBlock()
        If Block = 1 > 10 Then ' Level 1 - 10
            Return (1)
        ElseIf Block = 10 > 30 Then ' Level 10 - 30
            Return (2)
        ElseIf Block = 30 > 100000 Then ' Level 30 - 100000
            Return (3)
        End If
    End Function
End Class

Criticizing it please :)
If you need something, feel free to copy/use it.
FR1908
Picture of what it would look like would be nice. =)
(Apr 16, 2010 07:32 AM)Kink Wrote:  Picture of what it would look like would be nice. =)

Im just helping someone with coding, just want to get it criticized.
FR1908
Looks good, would like to see when it is finished
thanks for going to thew this im thankful, mines done now with download

https://hackforums.net/showthread.php?tid=370095
Added:
Code
You can level your skills by killing people
People can die now
Pre-Fixed 'Attack' function

Thanks for the feedbacks:)
FR1908
yea im going to add a xp thing mabey we could do a game together
(Apr 16, 2010 08:33 AM)lyncsta Wrote:  yea im going to add a xp thing mabey we could do a game together

I just like coding stuff. Not making the programs.

Code
Added Money (Get after hitting Formula = Health * Attack / Defense )
Added ItemShop (Not the form version, the codes (Helmet,Sword,Armor,Ring)
Added PregradeCenter (Update your skills Health,Attack,Defense)(No Block because you will be to strong)
Block only added when randomize(1,5) = 2
FR1908
Is there no one who need this?
FR1908
(Apr 17, 2010 01:58 AM)The-One Wrote:  Is there no one who need this?
kann you upload the full source ? include save.php and Form1.vb ,Form2.vb ,Form3.vb ?😊

mfg
TheCrackEr