Mirage Source
http://miragesource.net/forums/

problem With critical Hits
http://miragesource.net/forums/viewtopic.php?f=142&t=6367
Page 1 of 1

Author:  jsventor [ Fri Oct 30, 2009 1:05 am ]
Post subject:  problem With critical Hits

Code:
 If CanPlayerCriticalHit(Index) = False Then
                        Damage = GetPlayerDamage(Index) - Int(Npc(MapNpc(GetPlayerMap(Index), i).num).DEF / 2) + (Rnd * 5) - 2
                        'Call SendDataToMap(GetPlayerMap(Index), SOUND_CHAR & SEP_CHAR & "Blow" & Int(Rnd * 7) + 1 & END_CHAR)
                        Call SendSound(Index, ATTACK_SOUND, SDTM)
                    Else
                    Agi = GetPlayerAgil(Index)
Spd = GetPlayerSPEED(Index)
lvl = GetPlayerLevel(Index)
STR = GetPlayerSTR(Index)

Num1 = (500 + lvl) / (Agi + Spd) + (lvl / 90)

Rand = Random(1, Num1 + (Num1 * 2))


                        N = GetPlayerDamage(Index)
                        'Damage = N + (Random((str + ((str / 2) + Num1)), ((str + ((str / 2) + Num1))) * 2)) - Int(Npc(MapNpc(GetPlayerMap(index), i).num).DEF / 2) + (Rnd * 5) - 2
                        Damage = N + (Random((STR + ((STR / 2) + Num1)), ((STR + ((STR / 2) + Num1))) * 2))
                        Call BattleMsg(Index, "You feel a surge of energy upon swinging!", BrightCyan, 0)


The CanPlayerCriticalHit Function is

Code:
Function CanPlayerCriticalHit(ByVal Index As Long) As Boolean
    Dim i As Long, N As Long
Dim Num1 As Long
Dim Agi As Long
Dim Spd As Long
Dim lvl As Long
Dim STR As Long

Dim Rand As Long

CanPlayerCriticalHit = False


Agi = GetPlayerAgil(Index)
Spd = GetPlayerSPEED(Index)
lvl = GetPlayerLevel(Index)
STR = GetPlayerSTR(Index)

Num1 = (500 + lvl) / (Agi + Spd) + (lvl / 90)

Rand = Random(1, Num1 + (Num1 * 2))



    If GetPlayerWeaponSlot(Index) > 0 Then
        N = Rand

        If N > 6 Then
        CanPlayerCriticalHit = False

            If N <= 6 Then
                CanPlayerCriticalHit = True
            End If
        End If
    Call PlayerMsg(Index, N, White)
    End If

End Function


I made it send a message in the function to see what the number was I was getting. They were all less then 6 which is what it takes for Can Player critical hit = True, but it never critical hits and I dont know why.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/