ok thanks for the advice, should have thought of that earlier -_- but i figured out whats actually crashing it i think
Code:
Sub AttackNPC(ByVal Index As Integer, ByVal NPCnum As Integer)
Dim PlayerDmg As Integer
Dim NPCDmg As Integer
Dim PlayerDef As Integer
Dim NPCDef As Integer
Dim BattleFinished As Boolean
Dim battlecount As Byte
Dim LastSec As Integer
BattleFinished = False
battlecount = 0
LastSec = 0
Call AddText("in attack sub", vbBlack)
Do Until BattleFinished = True
If ServerSecond <= LastSec + 5 Then
If GetUserWeaponSlot(Index) <> 0 Then
PlayerDmg = (GetUserSTR(Index) + Item(GetUserWeaponSlot(Index)).Data1) / 2 + Rand(0, 2)
Else
PlayerDmg = (GetUserSTR(Index) + Rand(0, 2))
End If
If GetUserBodySlot(Index) <> 0 Then
PlayerDef = ((GetUserDEF(Index) + Item(GetUserBodySlot(Index)).Data1) / 2)
Else
PlayerDef = (GetUserDEF(Index))
End If
If GetUserShieldSlot(Index) <> 0 Then
PlayerDef = PlayerDef + (Item(GetUserShieldSlot(Index)).Data1 / 2)
End If
If GetUserHelmetSlot(Index) <> 0 Then
PlayerDef = PlayerDef + (Item(GetUserHelmetSlot(Index)).Data1 / 2)
End If
If GetUserPantSlot(Index) <> 0 Then
PlayerDef = PlayerDef + (Item(GetUserPantSlot(Index)).Data1 / 2)
End If
NPCDmg = ((Npc(NPCnum).STR + Rand(0, 2)) / 2)
NPCDef = (Npc(NPCnum).DEF)
PlayerDmg = PlayerDmg - NPCDef
If PlayerDmg <= 0 Then
PlayerDmg = 1
End If
NPCDmg = NPCDmg - PlayerDef
If NPCDmg < 0 Then
NPCDmg = 0
End If
'If battlecount = 0 Then
'If GetUserWeaponSlot(Index) = Item_Type_Rifle Or Item_Type_MachineGun Or Item_Type_SMG Or Item_Type_Pistol Then
'User(Index).Battle.PlayerReport(0) = User(Index).Name & " spots a " & Npc(NPCnum).Name & " in the distance. " & User(Index).Name & " pulls out his " & Item(GetUserWeaponSlot(Index)).Name & " and fires at the enemy. Damage = " & PlayerDmg
'User(Index).Battle.NPCReport(0) = Npc(NPCnum).Name & " takes a hit from " & User(Index).Name & "'s weapon. Blood spurts out of the wound, but " & Npc(Index).Name & " lunges at " & User(Index).Name & ". Damage = " & NPCDmg
'End If
'If BattleCount >= 1 Then
'User(Index).Battle.PlayerReport(BattleCount) = User(Index).Name & " spots a " & Npc(NPCnum).Name & " in the distance. " & User(Index).Name & " pulls out his " & Item(GetUserWeaponSlot(Index)).Name & " and fires at the enemy. Damage = " & PlayerDmg
'User(Index).Battle.NPCReport(BattleCount) = Npc(NPCnum).Name & " takes a hit from " & User(Index).Name & "'s weapon. Blood spurts out of the wound, but " & Npc(Index).Name & " lunges at " & User(Index).Name & ". Damage = " & NPCDmg
'End If
User(Index).Battle.PlayerReport(battlecount) = GetUserName(Index) & " dealt " & PlayerDmg & " damage. " & Npc(NPCnum).Name & " health left = " & Npc(NPCnum).HP - PlayerDmg
User(Index).Battle.NPCReport(battlecount) = Npc(NPCnum).Name & " dealt " & NPCDmg & " damage. " & GetUserName(Index) & " health left = " & User(Index).HP - NPCDmg
User(Index).HP = User(Index).HP - NPCDmg
Npc(Index).HP = Npc(Index).HP - PlayerDmg
Call SendBattleReport(Index, battlecount)
If GetUserHP(Index) <= 0 Then
BattleFinished = True
ElseIf Npc(NPCnum).HP <= 0 Then
BattleFinished = True
'ElseIf User(Index).Battle.flee = True Then
'BattleFinished = True
ElseIf battlecount >= 10 Then
BattleFinished = True
End If
battlecount = battlecount + 1
LastSec = ServerSecond
Call AddText("finished attack loop", vbBlack)
End If
Loop
End Sub
hope you can sort through that.