Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Alatar's Quest System v1.2


Alatar
 Share

Recommended Posts

  • Replies 703
  • Created
  • Last Reply

Top Posters In This Topic

I have seen this question asked a few times, So I will add this here. Its really simple people who are having troubles…

How to add the quest button with the others.

Inside _Client.vbp_

In **ModConstants** find:

```
Public Const MAX_MAINBUTTONS As Long = 6
```
Change to:

```
Public Const MAX_MAINBUTTONS As Long = 7
```
In **ModGeneral** find:

```
' main - party
    With MainButton(6)
        .fileName = "party"
        .state = 0 ' normal
    End With
```
Below add this:

```
' main - quest
    With MainButton(7)
        .fileName = "quest"
        .state = 0 ' normal
    End With
```
Inside **frmMain** copy and paste an existing button:

Now change the properties to:

```
Required button Properties
Name: imgButton
Index: 7

```
Next in Sub **imgButton** **Click** find:

```
Case 6
            ' show the window
            picCharacter.Visible = False
            picInventory.Visible = False
            picSpells.Visible = False
            picOptions.Visible = False
            picParty.Visible = True
            picQuestLog.Visible = False
            ' play sound
            PlaySound Sound_ButtonClick
```
Below it add:

```
Case 7
            If Not picQuestLog.Visible Then
            ' show the window
            picCharacter.Visible = False
            picInventory.Visible = False
            picSpells.Visible = False
            picOptions.Visible = False
            picParty.Visible = False
            picQuestLog.Visible = True
            ' play sound
            PlaySound Sound_ButtonClick
            End If
```
Also add the below code to Cases 1,2,3,4,6 skipping 5

```
picQuestLog.Visible = False
```

Now simply create 3 buttons with the others using the name quest_norm, quest_hover, quest_click.

If I forgot something let me know.
Link to comment
Share on other sites

  • 2 weeks later...
maybe no :D its now ok .. ;) i copy full client .. and make new button for quest .. but its too bad .. :( if i click on char .. and click quest now i see my quests but if i want click to Inventory .. i see quest still …. :( (i must click to quest for cancel quest list :|
Link to comment
Share on other sites

@karpaz:

> maybe no :D its now ok .. ;) i copy full client .. and make new button for quest .. but its too bad .. :( if i click on char .. and click quest now i see my quests but if i want click to Inventory .. i see quest still …. :( (i must click to quest for cancel quest list :|

"Pic.questlog = false"

@hazeygaming:

> I have seen this question asked a few times, So I will add this here. Its really simple people who are having troubles…
>
> How to add the quest button with the others.
>
> Inside _Client.vbp_
>
> In **ModConstants** find:
>
> ```
> Public Const MAX_MAINBUTTONS As Long = 6
> ```
> Change to:
>
> ```
> Public Const MAX_MAINBUTTONS As Long = 7
> ```
> In **ModGeneral** find:
>
> ```
> ' main - party
>     With MainButton(6)
>         .fileName = "party"
>         .state = 0 ' normal
>     End With
> ```
> Below add this:
>
> ```
> ' main - quest
>     With MainButton(7)
>         .fileName = "quest"
>         .state = 0 ' normal
>     End With
> ```
> Inside **frmMain** copy and paste an existing button:
>
> Now change the properties to:
>
> ```
> Required button Properties
> Name: imgButton
> Index: 7
>
> ```
> Next in Sub **imgButton** **Click** find:
>
> ```
> Case 6
>             ' show the window
>             picCharacter.Visible = False
>             picInventory.Visible = False
>             picSpells.Visible = False
>             picOptions.Visible = False
>             picParty.Visible = True
>             picQuestLog.Visible = False
>             ' play sound
>             PlaySound Sound_ButtonClick
> ```
> Below it add:
>
> ```
> Case 7
>             If Not picQuestLog.Visible Then
>             ' show the window
>             picCharacter.Visible = False
>             picInventory.Visible = False
>             picSpells.Visible = False
>             picOptions.Visible = False
>             picParty.Visible = False
>             picQuestLog.Visible = True
>             ' play sound
>             PlaySound Sound_ButtonClick
>             End If
> ```
> Also add the below code to Cases 1,2,3,4,6 skipping 5
>
> ```
> picQuestLog.Visible = False
> ```
>
> Now simply create 3 buttons with the others using the name quest_norm, quest_hover, quest_click.
>
> If I forgot something let me know.
Link to comment
Share on other sites

I got a problem with an GOKILL quest type.

I have two quests, there are quest with killing other players
and the second where the player must slay npc's.

When I kill player it's adding +1 to task count but to all of player quests.

In Case QUEST_TYPE_GOKILL there are no check like:
```
If TargetIndex = Quest(QuestNum).Task(ActualTask).Resource Then

```what is already in GOTRAIN quest type and any other cases.

I don't have idea what to do with that.
Link to comment
Share on other sites

  • 2 weeks later...
Ok… here is an sceen of my npc, and quest editor and at the bottom you can see what the quest giver say...

[![](http://www7.pic-upload.de/thumb/20.03.12/bxj2qj2tdy.png)](http://www.pic-upload.de/view-13425364/Unbenannt.png.html)

I got Team Viewer if anyone want take a look…
Because im from switzerland and my english is bad so its very hard to explain...
Link to comment
Share on other sites

@Mortal:

> Ok… here is an sceen of my npc, and quest editor and at the bottom you can see what the quest giver say...
>
> [![](http://www7.pic-upload.de/thumb/20.03.12/bxj2qj2tdy.png)](http://www.pic-upload.de/view-13425364/Unbenannt.png.html)
>
> I got Team Viewer if anyone want take a look…
> Because im from switzerland and my english is bad so its very hard to explain...

Make his behaviour Quest.
Link to comment
Share on other sites

@Erwin:

> Make his behaviour Quest.

Wrong, that was the older version, this one has a checkbox for quest giver and the behaviour should be set to friendly.

@ Mortal Angels
The problem is most likely that you placed the stuff in modCombat in the wrong spot and that is giving you a logic error.

Post your CanPlayerAttackNPC Sub, its the place most people have the hardest time adding this.
Link to comment
Share on other sites

>! Option Explicit
>! ' ################################
' ##      Basic Calculations    ##
' ################################
>! Function GetPlayerMaxVital(ByVal Index As Long, ByVal Vital As Vitals) As Long
'Mortal Angels
Dim i As Long
'/Mortal Angels
    If Index > MAX_PLAYERS Then Exit Function
    Select Case Vital
        Case HP
            Select Case GetPlayerClass(Index)
                Case 1 ' Warrior
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Endurance) / 2)) * 15 + 150
                Case 2 ' Mage
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Endurance) / 2)) * 5 + 65
                Case Else ' Anything else - Warrior by default
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Endurance) / 2)) * 15 + 150
            End Select
            'Mortal Angels
                        For i = 1 To 10
                If TempPlayer(Index).Buffs(i) = BUFF_ADD_HP Then
                    GetPlayerMaxVital = GetPlayerMaxVital + TempPlayer(Index).BuffValue(i)
>!                 End If
                If TempPlayer(Index).Buffs(i) = BUFF_SUB_HP Then
                    GetPlayerMaxVital = GetPlayerMaxVital - TempPlayer(Index).BuffValue(i)
                End If
            Next
            '/Mortal Angels
        Case MP
            Select Case GetPlayerClass(Index)
                Case 1 ' Warrior
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Intelligence) / 2)) * 5 + 25
                Case 2 ' Mage
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Intelligence) / 2)) * 30 + 85
                Case Else ' Anything else - Warrior by default
                    GetPlayerMaxVital = ((GetPlayerLevel(Index) / 2) + (GetPlayerStat(Index, Intelligence) / 2)) * 5 + 25
            End Select
            'Mortal Angels
            For i = 1 To 10
                If TempPlayer(Index).Buffs(i) = BUFF_ADD_MP Then
                    GetPlayerMaxVital = GetPlayerMaxVital + TempPlayer(Index).BuffValue(i)
                End If
                If TempPlayer(Index).Buffs(i) = BUFF_SUB_MP Then
                    GetPlayerMaxVital = GetPlayerMaxVital - TempPlayer(Index).BuffValue(i)
                End If
            Next
            '/Mortal Angels
    End Select
End Function
>! Function GetPlayerVitalRegen(ByVal Index As Long, ByVal Vital As Vitals) As Long
    Dim i As Long
>!     ' Prevent subscript out of range
    If IsPlaying(Index) = False Or Index <= 0 Or Index > MAX_PLAYERS Then
        GetPlayerVitalRegen = 0
        Exit Function
    End If
>!     Select Case Vital
        Case HP
            i = (GetPlayerStat(Index, Stats.Willpower) * 0.8) + 6
        Case MP
            i = (GetPlayerStat(Index, Stats.Willpower) / 4) + 12.5
    End Select
>!     If i < 2 Then i = 2
    GetPlayerVitalRegen = i
End Function
>! Function GetPlayerDamage(ByVal Index As Long) As Long
'Mortal Angels
Dim i As Long
'/Mortal Angels
    Dim weaponNum As Long

    GetPlayerDamage = 0
>!     ' Check for subscript out of range
    If IsPlaying(Index) = False Or Index <= 0 Or Index > MAX_PLAYERS Then
        Exit Function
    End If
    If GetPlayerEquipment(Index, Weapon) > 0 Then
        weaponNum = GetPlayerEquipment(Index, Weapon)
        GetPlayerDamage = 0.085 * 5 * GetPlayerStat(Index, Strength) * Item(weaponNum).Data2 + (GetPlayerLevel(Index) / 5)
    Else
        GetPlayerDamage = 0.085 * 5 * GetPlayerStat(Index, Strength) + (GetPlayerLevel(Index) / 5)
    End If
    For i = 1 To 10
        If TempPlayer(Index).Buffs(i) = BUFF_ADD_ATK Then
            GetPlayerDamage = GetPlayerDamage + TempPlayer(Index).BuffValue(i)
        End If
        If TempPlayer(Index).Buffs(i) = BUFF_SUB_ATK Then
            GetPlayerDamage = GetPlayerDamage - TempPlayer(Index).BuffValue(i)
        End If
    Next
End Function
'Mortal Angels
Function GetPlayerDef(ByVal Index As Long) As Long
    Dim i As Long
    Dim DefNum As Long
    Dim Def As Long

    GetPlayerDef = 0
    Def = 0
    ' Check for subscript out of range
    If IsPlaying(Index) = False Or Index <= 0 Or Index > MAX_PLAYERS Then
        Exit Function
    End If

    If GetPlayerEquipment(Index, Armor) > 0 Then
        DefNum = GetPlayerEquipment(Index, Armor)
        Def = Def + Item(DefNum).Data2
    End If

    If GetPlayerEquipment(Index, Helmet) > 0 Then
        DefNum = GetPlayerEquipment(Index, Helmet)
        Def = Def + Item(DefNum).Data2
    End If

    If GetPlayerEquipment(Index, Shield) > 0 Then
        DefNum = GetPlayerEquipment(Index, Shield)
        Def = Def + Item(DefNum).Data2
    End If

  If Not GetPlayerEquipment(Index, Armor) > 0 And Not GetPlayerEquipment(Index, Helmet) > 0 And Not GetPlayerEquipment(Index, Shield) > 0 Then
        GetPlayerDef = 0.085 * GetPlayerStat(Index, Endurance) + (GetPlayerLevel(Index) / 5)
    Else
        GetPlayerDef = 0.085 * GetPlayerStat(Index, Endurance) * Def + (GetPlayerLevel(Index) / 5)
    End If
    For i = 1 To 10
        If TempPlayer(Index).Buffs(i) = BUFF_ADD_DEF Then
            GetPlayerDef = GetPlayerDef + TempPlayer(Index).BuffValue(i)
        End If
        If TempPlayer(Index).Buffs(i) = BUFF_SUB_DEF Then
            GetPlayerDef = GetPlayerDef - TempPlayer(Index).BuffValue(i)
        End If
    Next
End Function
'/Mortal Angels
Function GetNpcMaxVital(ByVal npcNum As Long, ByVal Vital As Vitals) As Long
    Dim x As Long
>!     ' Prevent subscript out of range
    If npcNum <= 0 Or npcNum > MAX_NPCS Then
        GetNpcMaxVital = 0
        Exit Function
    End If
>!     Select Case Vital
        Case HP
            GetNpcMaxVital = NPC(npcNum).HP
        Case MP
            GetNpcMaxVital = 30 + (NPC(npcNum).Stat(Intelligence) * 10) + 2
    End Select
>! End Function
>! Function GetNpcVitalRegen(ByVal npcNum As Long, ByVal Vital As Vitals) As Long
    Dim i As Long
>!     'Prevent subscript out of range
    If npcNum <= 0 Or npcNum > MAX_NPCS Then
        GetNpcVitalRegen = 0
        Exit Function
    End If
>!     Select Case Vital
        Case HP
            i = (NPC(npcNum).Stat(Stats.Willpower) * 0.8) + 6
        Case MP
            i = (NPC(npcNum).Stat(Stats.Willpower) / 4) + 12.5
    End Select

    GetNpcVitalRegen = i
>! End Function
>! Function GetNpcDamage(ByVal npcNum As Long) As Long
    GetNpcDamage = 0.085 * 5 * NPC(npcNum).Stat(Stats.Strength) * NPC(npcNum).Damage + (NPC(npcNum).Level / 5)
End Function
>! ' ###############################
' ##      Luck-based rates    ##
' ###############################
>! Public Function CanPlayerBlock(ByVal Index As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanPlayerBlock = False
>!     rate = 0
    ' TODO : make it based on shield lulz
End Function
>! Public Function CanPlayerCrit(ByVal Index As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanPlayerCrit = False
>!     rate = GetPlayerStat(Index, Agility) / 52.08
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanPlayerCrit = True
    End If
End Function
>! Public Function CanPlayerDodge(ByVal Index As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanPlayerDodge = False
>!     rate = GetPlayerStat(Index, Agility) / 83.3
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanPlayerDodge = True
    End If
End Function
>! Public Function CanPlayerParry(ByVal Index As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanPlayerParry = False
>!     rate = GetPlayerStat(Index, Strength) * 0.25
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanPlayerParry = True
    End If
End Function
>! Public Function CanNpcBlock(ByVal npcNum As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanNpcBlock = False
>!     rate = 0
    ' TODO : make it based on shield lol
End Function
>! Public Function CanNpcCrit(ByVal npcNum As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanNpcCrit = False
>!     rate = NPC(npcNum).Stat(Stats.Agility) / 52.08
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanNpcCrit = True
    End If
End Function
>! Public Function CanNpcDodge(ByVal npcNum As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanNpcDodge = False
>!     rate = NPC(npcNum).Stat(Stats.Agility) / 83.3
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanNpcDodge = True
    End If
End Function
>! Public Function CanNpcParry(ByVal npcNum As Long) As Boolean
Dim rate As Long
Dim rndNum As Long
>!     CanNpcParry = False
>!     rate = NPC(npcNum).Stat(Stats.Strength) * 0.25
    rndNum = RAND(1, 100)
    If rndNum <= rate Then
        CanNpcParry = True
    End If
End Function
>! ' ###################################
' ##      Player Attacking NPC    ##
' ###################################
>! Public Sub TryPlayerAttackNpc(ByVal Index As Long, ByVal mapNpcNum As Long)
Dim blockAmount As Long
Dim npcNum As Long
Dim mapnum As Long
Dim Damage As Long
>!     Damage = 0
>!     ' Can we attack the npc?
    If CanPlayerAttackNpc(Index, mapNpcNum) Then

        mapnum = GetPlayerMap(Index)
        npcNum = MapNpc(mapnum).NPC(mapNpcNum).Num

        ' check if NPC can avoid the attack
        If CanNpcDodge(npcNum) Then
            SendActionMsg mapnum, "Dodge!", Pink, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
            Exit Sub
        End If
        If CanNpcParry(npcNum) Then
            SendActionMsg mapnum, "Parry!", Pink, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
            Exit Sub
        End If
>!         ' Get the damage we can do
        Damage = GetPlayerDamage(Index)

        ' if the npc blocks, take away the block amount
        blockAmount = CanNpcBlock(mapNpcNum)
        Damage = Damage - blockAmount

        ' take away armour
        Damage = Damage - RAND(1, (NPC(npcNum).Stat(Stats.Agility) * 2))
        ' randomise from 1 to max hit
        Damage = RAND(1, Damage)

        ' * 1.5 if it's a crit!
        If CanPlayerCrit(Index) Then
            Damage = Damage * 1.5
            SendActionMsg mapnum, "Critical!", BrightCyan, 1, (GetPlayerX(Index) * 32), (GetPlayerY(Index) * 32)
        End If

        If Damage > 0 Then
            Call PlayerAttackNpc(Index, mapNpcNum, Damage)
        Else
            Call PlayerMsg(Index, "Your attack does nothing.", BrightRed)
        End If
    End If
End Sub
>! Public Function CanPlayerAttackNpc(ByVal attacker As Long, ByVal mapNpcNum As Long, Optional ByVal IsSpell As Boolean = False) As Boolean
    Dim mapnum As Long
    Dim npcNum As Long
    Dim NpcX As Long
    Dim NpcY As Long
    Dim attackspeed As Long
>!     ' Check for subscript out of range
    If IsPlaying(attacker) = False Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Then
        Exit Function
    End If
>!     ' Check for subscript out of range
    If MapNpc(GetPlayerMap(attacker)).NPC(mapNpcNum).Num <= 0 Then
        Exit Function
    End If
>!     mapnum = GetPlayerMap(attacker)
    npcNum = MapNpc(mapnum).NPC(mapNpcNum).Num

    ' Make sure the npc isn't already dead
    If MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) <= 0 Then
        Exit Function
    End If
>!     ' Make sure they are on the same map
    If IsPlaying(attacker) Then

        ' exit out early
        If IsSpell Then
            If npcNum > 0 Then
                If NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then
                    CanPlayerAttackNpc = True
                    Exit Function
                End If
            End If
        End If
>!         ' attack speed from weapon
        If GetPlayerEquipment(attacker, Weapon) > 0 Then
            attackspeed = Item(GetPlayerEquipment(attacker, Weapon)).Speed
        Else
            attackspeed = 1000
        End If
>!         If npcNum > 0 And GetTickCount > TempPlayer(attacker).AttackTimer + attackspeed Then
            ' Check if at same coordinates
            Select Case GetPlayerDir(attacker)
                Case DIR_UP
                    NpcX = MapNpc(mapnum).NPC(mapNpcNum).x
                    NpcY = MapNpc(mapnum).NPC(mapNpcNum).y + 1
                Case DIR_DOWN
                    NpcX = MapNpc(mapnum).NPC(mapNpcNum).x
                    NpcY = MapNpc(mapnum).NPC(mapNpcNum).y - 1
                Case DIR_LEFT
                    NpcX = MapNpc(mapnum).NPC(mapNpcNum).x + 1
                    NpcY = MapNpc(mapnum).NPC(mapNpcNum).y
                Case DIR_RIGHT
                    NpcX = MapNpc(mapnum).NPC(mapNpcNum).x - 1
                    NpcY = MapNpc(mapnum).NPC(mapNpcNum).y
            End Select
>!             If NpcX = GetPlayerX(attacker) Then
                If NpcY = GetPlayerY(attacker) Then
                    If NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then
                        CanPlayerAttackNpc = True
                    Else
                                            If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then
                            Call CheckTasks(attacker, QUEST_TYPE_GOTALK, npcNum)
                            Call CheckTasks(attacker, QUEST_TYPE_GOGIVE, npcNum)
                            Call CheckTasks(attacker, QUEST_TYPE_GOGET, npcNum)

                            If NPC(npcNum).Quest = YES Then
                                If CanStartQuest(attacker, NPC(npcNum).QuestNum) Then
                                    'if can start show the request message (chat1)
                                    QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(1)), NPC(npcNum).QuestNum
                                    Exit Function
                                End If
                                If QuestInProgress(attacker, NPC(npcNum).QuestNum) Then
                                    'if the quest is in progress show the meanwhile message (chat2)
                                    PlayerMsg attacker, Trim$(NPC(npcNum).Name) + ": " + Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), BrightGreen
                                    'QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), 0
                                    Exit Function
                                End If
                            End If
                        End If
                        If Len(Trim$(NPC(npcNum).AttackSay)) > 0 Then
                            PlayerMsg attacker, Trim$(NPC(npcNum).Name) & ": " & Trim$(NPC(npcNum).AttackSay), White
                        End If
                    End If
                End If
            End If
        End If
    End If
>! End Function
>! Public Sub PlayerAttackNpc(ByVal attacker As Long, ByVal mapNpcNum As Long, ByVal Damage As Long, Optional ByVal spellnum As Long, Optional ByVal overTime As Boolean = False)
    Dim Name As String
    Dim exp As Long
    Dim n As Long
    Dim i As Long
    Dim STR As Long
    Dim Def As Long
    Dim mapnum As Long
    Dim npcNum As Long
    Dim Buffer As clsBuffer
>!     ' Check for subscript out of range
    If IsPlaying(attacker) = False Or mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or Damage < 0 Then
        Exit Sub
    End If
>!     mapnum = GetPlayerMap(attacker)
    npcNum = MapNpc(mapnum).NPC(mapNpcNum).Num
    Name = Trim$(NPC(npcNum).Name)
    If npcNum < 1 Then Exit Sub

    ' Check for weapon
    n = 0
>!     If GetPlayerEquipment(attacker, Weapon) > 0 Then
        n = GetPlayerEquipment(attacker, Weapon)
    End If

    ' set the regen timer
    TempPlayer(attacker).stopRegen = True
    TempPlayer(attacker).stopRegenTimer = GetTickCount
>!     If Damage >= MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) Then

        SendActionMsg GetPlayerMap(attacker), "-" & MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP), BrightRed, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
        SendBlood GetPlayerMap(attacker), MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y

        ' send the sound
        If spellnum > 0 Then SendMapSound attacker, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y, SoundEntity.seSpell, spellnum

        ' send animation
        If n > 0 Then
            If Not overTime Then
                If spellnum = 0 Then Call SendAnimation(mapnum, Item(GetPlayerEquipment(attacker, Weapon)).Animation, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y)
            End If
        End If
>!         ' Calculate exp to give attacker
        exp = NPC(npcNum).exp
>!         ' Make sure we dont get less then 0
        If exp < 0 Then
            exp = 1
        End If
>!         ' in party?
        If TempPlayer(attacker).inParty > 0 Then
            ' pass through party sharing function
            Party_ShareExp TempPlayer(attacker).inParty, exp, attacker
        Else
            ' no party - keep exp for self
            GivePlayerEXP attacker, exp
        End If

        'Drop the goods if they get it
    For n = 1 To MAX_NPC_DROPS
        If NPC(npcNum).DropItem(n) = 0 Then Exit For
>!         If Rnd <= NPC(npcNum).DropChance(n) Then
            Call SpawnItem(NPC(npcNum).DropItem(n), NPC(npcNum).DropItemValue(n), mapnum, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y)
        End If
    Next
        ' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range)
        MapNpc(mapnum).NPC(mapNpcNum).Num = 0
        MapNpc(mapnum).NPC(mapNpcNum).SpawnWait = GetTickCount
        MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) = 0

        ' clear DoTs and HoTs
        For i = 1 To MAX_DOTS
            With MapNpc(mapnum).NPC(mapNpcNum).DoT(i)
                .Spell = 0
                .Timer = 0
                .Caster = 0
                .StartTime = 0
                .Used = False
            End With

            With MapNpc(mapnum).NPC(mapNpcNum).HoT(i)
                .Spell = 0
                .Timer = 0
                .Caster = 0
                .StartTime = 0
                .Used = False
            End With
        Next

        Call CheckTasks(attacker, QUEST_TYPE_GOSLAY, npcNum)
        ' send death to the map
        Set Buffer = New clsBuffer
        Buffer.WriteLong SNpcDead
        Buffer.WriteLong mapNpcNum
        SendDataToMap mapnum, Buffer.ToArray()
        Set Buffer = Nothing

        'Loop through entire map and purge NPC from targets
        For i = 1 To Player_HighIndex
            If IsPlaying(i) And IsConnected(i) Then
                If Player(i).Map = mapnum Then
                    If TempPlayer(i).targetType = TARGET_TYPE_NPC Then
                        If TempPlayer(i).target = mapNpcNum Then
                            TempPlayer(i).target = 0
                            TempPlayer(i).targetType = TARGET_TYPE_NONE
                            SendTarget i
                        End If
                    End If
                End If
            End If
        Next
    Else
        ' NPC not dead, just do the damage
        MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) = MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) - Damage
>!         ' Check for a weapon and say damage
        SendActionMsg mapnum, "-" & Damage, BrightRed, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
        SendBlood GetPlayerMap(attacker), MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y

        ' send the sound
        If spellnum > 0 Then SendMapSound attacker, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y, SoundEntity.seSpell, spellnum

        ' send animation
        If n > 0 Then
            If Not overTime Then
                If spellnum = 0 Then Call SendAnimation(mapnum, Item(GetPlayerEquipment(attacker, Weapon)).Animation, 0, 0, TARGET_TYPE_NPC, mapNpcNum)
            End If
        End If
>!         ' Set the NPC target to the player
        MapNpc(mapnum).NPC(mapNpcNum).targetType = 1 ' player
        MapNpc(mapnum).NPC(mapNpcNum).target = attacker
>!         ' Now check for guard ai and if so have all onmap guards come after'm
        If NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Behaviour = NPC_BEHAVIOUR_GUARD Then
            For i = 1 To MAX_MAP_NPCS
                If MapNpc(mapnum).NPC(i).Num = MapNpc(mapnum).NPC(mapNpcNum).Num Then
                    MapNpc(mapnum).NPC(i).target = attacker
                    MapNpc(mapnum).NPC(i).targetType = 1 ' player
                End If
            Next
        End If

        ' set the regen timer
        MapNpc(mapnum).NPC(mapNpcNum).stopRegen = True
        MapNpc(mapnum).NPC(mapNpcNum).stopRegenTimer = GetTickCount

        ' if stunning spell, stun the npc
        If spellnum > 0 Then
            If Spell(spellnum).StunDuration > 0 Then StunNPC mapNpcNum, mapnum, spellnum
            ' DoT
            If Spell(spellnum).Duration > 0 Then
                AddDoT_Npc mapnum, mapNpcNum, spellnum, attacker
            End If
        End If

        SendMapNpcVitals mapnum, mapNpcNum
    End If
>!     If spellnum = 0 Then
        ' Reset attack timer
        TempPlayer(attacker).AttackTimer = GetTickCount
    End If
End Sub
>! ' ###################################
' ##      NPC Attacking Player    ##
' ###################################
>! Public Sub TryNpcAttackPlayer(ByVal mapNpcNum As Long, ByVal Index As Long)
Dim mapnum As Long, npcNum As Long, blockAmount As Long, Damage As Long
>!     ' Can the npc attack the player?
    If CanNpcAttackPlayer(mapNpcNum, Index) Then
        mapnum = GetPlayerMap(Index)
        npcNum = MapNpc(mapnum).NPC(mapNpcNum).Num

        ' check if PLAYER can avoid the attack
        If CanPlayerDodge(Index) Then
            SendActionMsg mapnum, "Dodge!", Pink, 1, (Player(Index).x * 32), (Player(Index).y * 32)
            Exit Sub
        End If
        If CanPlayerParry(Index) Then
            SendActionMsg mapnum, "Parry!", Pink, 1, (Player(Index).x * 32), (Player(Index).y * 32)
            Exit Sub
        End If
>!         ' Get the damage we can do
        Damage = GetNpcDamage(npcNum)

        ' if the player blocks, take away the block amount
        blockAmount = CanPlayerBlock(Index)
        Damage = Damage - blockAmount

        ' take away armour
        Damage = Damage - RAND(1, (GetPlayerStat(Index, Agility) * 2))

        ' randomise for up to 10% lower than max hit
        Damage = RAND(1, Damage)

        ' * 1.5 if crit hit
        If CanNpcCrit(Index) Then
            Damage = Damage * 1.5
            SendActionMsg mapnum, "Critical!", BrightCyan, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
        End If
        'Mortal Angels
        Damage = Damage - GetPlayerDef(Index)
        '/Mortal Angels
        If Damage > 0 Then
            Call NpcAttackPlayer(mapNpcNum, Index, Damage)
        End If
    End If
End Sub
>! Function CanNpcAttackPlayer(ByVal mapNpcNum As Long, ByVal Index As Long) As Boolean
    Dim mapnum As Long
    Dim npcNum As Long
>!     ' Check for subscript out of range
    If mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or Not IsPlaying(Index) Then
        Exit Function
    End If
>!     ' Check for subscript out of range
    If MapNpc(GetPlayerMap(Index)).NPC(mapNpcNum).Num <= 0 Then
        Exit Function
    End If
>!     mapnum = GetPlayerMap(Index)
    npcNum = MapNpc(mapnum).NPC(mapNpcNum).Num
>!     ' Make sure the npc isn't already dead
    If MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) <= 0 Then
        Exit Function
    End If
>!     ' Make sure npcs dont attack more then once a second
    If GetTickCount < MapNpc(mapnum).NPC(mapNpcNum).AttackTimer + 1000 Then
        Exit Function
    End If
>!     ' Make sure we dont attack the player if they are switching maps
    If TempPlayer(Index).GettingMap = YES Then
        Exit Function
    End If
>!     MapNpc(mapnum).NPC(mapNpcNum).AttackTimer = GetTickCount
>!     ' Make sure they are on the same map
    If IsPlaying(Index) Then
        If npcNum > 0 Then
>!             ' Check if at same coordinates
            If (GetPlayerY(Index) + 1 = MapNpc(mapnum).NPC(mapNpcNum).y) And (GetPlayerX(Index) = MapNpc(mapnum).NPC(mapNpcNum).x) Then
                CanNpcAttackPlayer = True
            Else
                If (GetPlayerY(Index) - 1 = MapNpc(mapnum).NPC(mapNpcNum).y) And (GetPlayerX(Index) = MapNpc(mapnum).NPC(mapNpcNum).x) Then
                    CanNpcAttackPlayer = True
                Else
                    If (GetPlayerY(Index) = MapNpc(mapnum).NPC(mapNpcNum).y) And (GetPlayerX(Index) + 1 = MapNpc(mapnum).NPC(mapNpcNum).x) Then
                        CanNpcAttackPlayer = True
                    Else
                        If (GetPlayerY(Index) = MapNpc(mapnum).NPC(mapNpcNum).y) And (GetPlayerX(Index) - 1 = MapNpc(mapnum).NPC(mapNpcNum).x) Then
                            CanNpcAttackPlayer = True
                        End If
                    End If
                End If
            End If
        End If
    End If
End Function
>! Sub NpcAttackPlayer(ByVal mapNpcNum As Long, ByVal victim As Long, ByVal Damage As Long)
    Dim Name As String
    Dim exp As Long
    Dim mapnum As Long
    Dim i As Long
    Dim Buffer As clsBuffer
>!     ' Check for subscript out of range
    If mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or IsPlaying(victim) = False Then
        Exit Sub
    End If
>!     ' Check for subscript out of range
    If MapNpc(GetPlayerMap(victim)).NPC(mapNpcNum).Num <= 0 Then
        Exit Sub
    End If
>!     mapnum = GetPlayerMap(victim)
    Name = Trim$(NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Name)

    ' Send this packet so they can see the npc attacking
    Set Buffer = New clsBuffer
    Buffer.WriteLong SNpcAttack
    Buffer.WriteLong mapNpcNum
    SendDataToMap mapnum, Buffer.ToArray()
    Set Buffer = Nothing

    If Damage <= 0 Then
        Exit Sub
    End If

    ' set the regen timer
    MapNpc(mapnum).NPC(mapNpcNum).stopRegen = True
    MapNpc(mapnum).NPC(mapNpcNum).stopRegenTimer = GetTickCount
>!     If Damage >= GetPlayerVital(victim, Vitals.HP) Then
        ' Say damage
        SendActionMsg GetPlayerMap(victim), "-" & GetPlayerVital(victim, Vitals.HP), BrightRed, 1, (GetPlayerX(victim) * 32), (GetPlayerY(victim) * 32)

        ' send the sound
        SendMapSound victim, GetPlayerX(victim), GetPlayerY(victim), SoundEntity.seNpc, MapNpc(mapnum).NPC(mapNpcNum).Num

        ' kill player
        KillPlayer victim

        ' Player is dead
        Call GlobalMsg(GetPlayerName(victim) & " has been killed by " & Name, BrightRed)
>!         ' Set NPC target to 0
        MapNpc(mapnum).NPC(mapNpcNum).target = 0
        MapNpc(mapnum).NPC(mapNpcNum).targetType = 0
    Else
        ' Player not dead, just do the damage
        Call SetPlayerVital(victim, Vitals.HP, GetPlayerVital(victim, Vitals.HP) - Damage)
        Call SendVital(victim, Vitals.HP)
        Call SendAnimation(mapnum, NPC(MapNpc(GetPlayerMap(victim)).NPC(mapNpcNum).Num).Animation, 0, 0, TARGET_TYPE_PLAYER, victim)

        ' send vitals to party if in one
        If TempPlayer(victim).inParty > 0 Then SendPartyVitals TempPlayer(victim).inParty, victim

        ' send the sound
        SendMapSound victim, GetPlayerX(victim), GetPlayerY(victim), SoundEntity.seNpc, MapNpc(mapnum).NPC(mapNpcNum).Num

        ' Say damage
        SendActionMsg GetPlayerMap(victim), "-" & Damage, BrightRed, 1, (GetPlayerX(victim) * 32), (GetPlayerY(victim) * 32)
        SendBlood GetPlayerMap(victim), GetPlayerX(victim), GetPlayerY(victim)

        ' set the regen timer
        TempPlayer(victim).stopRegen = True
        TempPlayer(victim).stopRegenTimer = GetTickCount
    End If
>! End Sub
>! Sub NpcSpellPlayer(ByVal mapNpcNum As Long, ByVal victim As Long, SpellSlotNum As Long)
    Dim mapnum As Long
    Dim i As Long
    Dim n As Long
    Dim spellnum As Long
    Dim Buffer As clsBuffer
    Dim InitDamage As Long
    Dim Damage As Long
    Dim MaxHeals As Long
>!     ' Check for subscript out of range
    If mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or IsPlaying(victim) = False Then
        Exit Sub
    End If
>!     ' Check for subscript out of range
    If MapNpc(GetPlayerMap(victim)).NPC(mapNpcNum).Num <= 0 Then
        Exit Sub
    End If

    If SpellSlotNum <= 0 Or SpellSlotNum > MAX_NPC_SPELLS Then Exit Sub
>!     ' The Variables
    mapnum = GetPlayerMap(victim)
    spellnum = NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Spell(SpellSlotNum)

    ' Send this packet so they can see the person attacking
    Set Buffer = New clsBuffer
    Buffer.WriteLong SNpcAttack
    Buffer.WriteLong mapNpcNum
    SendDataToMap mapnum, Buffer.ToArray()
    Set Buffer = Nothing

    ' CoolDown Time
    If MapNpc(mapnum).NPC(mapNpcNum).SpellTimer(SpellSlotNum) > GetTickCount Then Exit Sub

    ' Spell Types
        Select Case Spell(spellnum).Type
            ' AOE Healing Spells
            Case SPELL_TYPE_HEALHP
            ' Make sure an npc waits for the spell to cooldown
            MaxHeals = 1 + NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Stat(Stats.Intelligence) \ 25
            If MapNpc(mapnum).NPC(mapNpcNum).Heals >= MaxHeals Then Exit Sub
                If MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) <= NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).HP * 0.3 Then
                    If Spell(spellnum).IsAoE Then
                        For i = 1 To MAX_MAP_NPCS
                            If MapNpc(mapnum).NPC(i).Num > 0 Then
                                If MapNpc(mapnum).NPC(i).Vital(Vitals.HP) > 0 Then
                                    If isInRange(Spell(spellnum).AoE, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y, MapNpc(mapnum).NPC(i).x, MapNpc(mapnum).NPC(i).y) Then
                                        InitDamage = Spell(spellnum).Vital + (NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Stat(Stats.Intelligence) / 2)

                                        MapNpc(mapnum).NPC(i).Vital(Vitals.HP) = MapNpc(mapnum).NPC(i).Vital(Vitals.HP) + InitDamage
                                        SendActionMsg mapnum, "+" & InitDamage, BrightGreen, 1, (MapNpc(mapnum).NPC(i).x * 32), (MapNpc(mapnum).NPC(i).y * 32)
                                        Call SendAnimation(mapnum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_NPC, mapNpcNum)

                                        If MapNpc(mapnum).NPC(i).Vital(Vitals.HP) > NPC(MapNpc(mapnum).NPC(i).Num).HP Then
                                            MapNpc(mapnum).NPC(i).Vital(Vitals.HP) = NPC(MapNpc(mapnum).NPC(i).Num).HP
                                        End If

                                        MapNpc(mapnum).NPC(mapNpcNum).Heals = MapNpc(mapnum).NPC(mapNpcNum).Heals + 1

                                        MapNpc(mapnum).NPC(mapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount + Spell(spellnum).CDTime * 1000
                                        Exit Sub
                                    End If
                                End If
                            End If
                        Next
                    Else
                    ' Non AOE Healing Spells
                        InitDamage = Spell(spellnum).Vital + (NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Stat(Stats.Intelligence) / 2)

                        MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) = MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) + InitDamage
                        SendActionMsg mapnum, "+" & InitDamage, BrightGreen, 1, (MapNpc(mapnum).NPC(mapNpcNum).x * 32), (MapNpc(mapnum).NPC(mapNpcNum).y * 32)
                        Call SendAnimation(mapnum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_NPC, mapNpcNum)

                        If MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) > NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).HP Then
                            MapNpc(mapnum).NPC(mapNpcNum).Vital(Vitals.HP) = NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).HP
                        End If

                        MapNpc(mapnum).NPC(mapNpcNum).Heals = MapNpc(mapnum).NPC(mapNpcNum).Heals + 1

                        MapNpc(mapnum).NPC(mapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount + Spell(spellnum).CDTime * 1000
                        Exit Sub
                    End If
                End If

            ' AOE Damaging Spells
            Case SPELL_TYPE_DAMAGEHP
            ' Make sure an npc waits for the spell to cooldown
                If Spell(spellnum).IsAoE Then
                    For i = 1 To Player_HighIndex
                        If IsPlaying(i) Then
                            If GetPlayerMap(i) = mapnum Then
                                If isInRange(Spell(spellnum).AoE, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y, GetPlayerX(i), GetPlayerY(i)) Then
                                    InitDamage = Spell(spellnum).Vital + (NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Stat(Stats.Intelligence) / 2)
                                    Damage = InitDamage - Player(i).Stat(Stats.Willpower)
                                        If Damage <= 0 Then
                                            SendActionMsg GetPlayerMap(i), "RESIST!", Pink, 1, (GetPlayerX(i) * 32), (GetPlayerY(i) * 32)
                                            Exit Sub
                                        Else
                                            NpcAttackPlayer mapNpcNum, i, Damage
                                            SendAnimation mapnum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, mapNpcNum
                                            MapNpc(mapnum).NPC(mapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount + Spell(spellnum).CDTime * 1000
                                            Exit Sub
                                        End If
                                End If
                            End If
                        End If
                    Next
                ' Non AoE Damaging Spells
                Else
                    If isInRange(Spell(spellnum).Range, MapNpc(mapnum).NPC(mapNpcNum).x, MapNpc(mapnum).NPC(mapNpcNum).y, GetPlayerX(victim), GetPlayerY(victim)) Then
                    InitDamage = Spell(spellnum).Vital + (NPC(MapNpc(mapnum).NPC(mapNpcNum).Num).Stat(Stats.Intelligence) / 2)
                    Damage = InitDamage - Player(victim).Stat(Stats.Willpower)
                        If Damage <= 0 Then
                            SendActionMsg GetPlayerMap(victim), "RESIST!", Pink, 1, (GetPlayerX(victim) * 32), (GetPlayerY(victim) * 32)
                            Exit Sub
                        Else
                            NpcAttackPlayer mapNpcNum, victim, Damage
                            SendAnimation mapnum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, victim
                            MapNpc(mapnum).NPC(mapNpcNum).SpellTimer(SpellSlotNum) = GetTickCount + Spell(spellnum).CDTime * 1000
                            Exit Sub
                        End If
                    End If
                End If
            End Select
End Sub
>! ' ###################################
' ##    Player Attacking Player    ##
' ###################################
>! Public Sub TryPlayerAttackPlayer(ByVal attacker As Long, ByVal victim As Long)
Dim blockAmount As Long
Dim npcNum As Long
Dim mapnum As Long
Dim Damage As Long
>!     Damage = 0
>!     ' Can we attack the npc?
    If CanPlayerAttackPlayer(attacker, victim) Then

        mapnum = GetPlayerMap(attacker)

        ' check if NPC can avoid the attack
        If CanPlayerDodge(victim) Then
            SendActionMsg mapnum, "Dodge!", Pink, 1, (GetPlayerX(victim) * 32), (GetPlayerY(victim) * 32)
            Exit Sub
        End If
        If CanPlayerParry(victim) Then
            SendActionMsg mapnum, "Parry!", Pink, 1, (GetPlayerX(victim) * 32), (GetPlayerY(victim) * 32)
            Exit Sub
        End If
>!         ' Get the damage we can do
        Damage = GetPlayerDamage(attacker)

        ' if the npc blocks, take away the block amount
        blockAmount = CanPlayerBlock(victim)
        Damage = Damage - blockAmount

        ' take away armour
        Damage = Damage - RAND(1, (GetPlayerStat(victim, Agility) * 2))

        ' randomise for up to 10% lower than max hit
        Damage = RAND(1, Damage)

        ' * 1.5 if can crit
        If CanPlayerCrit(attacker) Then
            Damage = Damage * 1.5
            SendActionMsg mapnum, "Critical!", BrightCyan, 1, (GetPlayerX(attacker) * 32), (GetPlayerY(attacker) * 32)
        End If
        'Mortal Angels
        Damage = Damage - GetPlayerDef(victim)
        '/Mortal Angels
        If Damage > 0 Then
            Call PlayerAttackPlayer(attacker, victim, Damage)
        Else
            Call PlayerMsg(attacker, "Your attack does nothing.", BrightRed)
        End If
    End If
End Sub
>! Function CanPlayerAttackPlayer(ByVal attacker As Long, ByVal victim As Long, Optional ByVal IsSpell As Boolean = False, Optional ByVal IsProjectile As Boolean = False) As Boolean
>!     If Not IsSpell And Not IsProjectile Then
        ' Check attack timer
        If GetPlayerEquipment(attacker, Weapon) > 0 Then
Link to comment
Share on other sites

EDIT: oops sorry mortal angel i was answering Goldsides question got mixed up
In CanPlayerAttackNpc find this:
```
If NpcX = GetPlayerX(attacker) Then
                If NpcY = GetPlayerY(attacker) Then
                    If NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And NPC(npcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER Then
                        CanPlayerAttackNpc = True
                    Else
                                            If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then
                            Call CheckTasks(attacker, QUEST_TYPE_GOTALK, npcNum)
                            Call CheckTasks(attacker, QUEST_TYPE_GOGIVE, npcNum)
                            Call CheckTasks(attacker, QUEST_TYPE_GOGET, npcNum)

                            If NPC(npcNum).Quest = YES Then
                                If CanStartQuest(attacker, NPC(npcNum).QuestNum) Then
                                    'if can start show the request message (chat1)
                                    QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(1)), NPC(npcNum).QuestNum
                                    Exit Function
                                End If
                                If QuestInProgress(attacker, NPC(npcNum).QuestNum) Then
                                    'if the quest is in progress show the meanwhile message (chat2)
                                    PlayerMsg attacker, Trim$(NPC(npcNum).Name) + ": " + Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), BrightGreen
                                    'QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), 0
                                    Exit Function
                                End If
                            End If
                        End If
                        If Len(Trim$(NPC(npcNum).AttackSay)) > 0 Then
                            PlayerMsg attacker, Trim$(NPC(npcNum).Name) & ": " & Trim$(NPC(npcNum).AttackSay), White
                        End If
                    End If
                End If
            End If
        End If
    End If

End Function
```
Change it to:
```
If NpcX = GetPlayerX(Attacker) Then
                If NpcY = GetPlayerY(Attacker) Then

                        If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then
                            Call CheckTasks(Attacker, QUEST_TYPE_GOTALK, npcNum)
                            Call CheckTasks(Attacker, QUEST_TYPE_GOGIVE, npcNum)
                            Call CheckTasks(Attacker, QUEST_TYPE_GOGET, npcNum)
                            If NPC(npcNum).Quest = YES Then
                                If CanStartQuest(Attacker, NPC(npcNum).QuestNum) Then
                                    'if can start show the request message (chat1)
                                    QuestMessage Attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(1)), NPC(npcNum).QuestNum
                                    Exit Function
                                End If
                                If QuestInProgress(Attacker, NPC(npcNum).QuestNum) Then
                                    'if the quest is in progress show the meanwhile message (chat2)
                                    PlayerMsg Attacker, Trim$(NPC(npcNum).Name) + ": " + Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), BrightGreen
                                    'QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), 0
                                    Exit Function
                                End If
                            End If
                            If NPC(npcNum).Quest = NO Then
                                If NPC(npcNum).Convo = False Then
                                  If Len(Trim$(NPC(npcNum).AttackSay)) > 0 Then
                                    PlayerMsg Attacker, Trim$(NPC(npcNum).Name) & ": " & Trim$(NPC(npcNum).AttackSay), White
                                  End If
                                Else
                                    InitChat Attacker, mapNum, mapNpcNum
                                End If
                                Exit Function
                            End If
                            End If

                            CanPlayerAttackNpc = True
                        End If

                        End If
                    End If
                End If
End Function
```
Link to comment
Share on other sites

Compile error…
Method or Data member not found

> If NpcX = GetPlayerX(attacker) Then
>                 If NpcY = GetPlayerY(attacker) Then
>
>                         If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then
>                             Call CheckTasks(attacker, QUEST_TYPE_GOTALK, npcNum)
>                             Call CheckTasks(attacker, QUEST_TYPE_GOGIVE, npcNum)
>                             Call CheckTasks(attacker, QUEST_TYPE_GOGET, npcNum)
>                             If NPC(npcNum).Quest = YES Then
>                                 If CanStartQuest(attacker, NPC(npcNum).QuestNum) Then
>                                     'if can start show the request message (chat1)
>                                     QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(1)), NPC(npcNum).QuestNum
>                                     Exit Function
>                                 End If
>                                 If QuestInProgress(attacker, NPC(npcNum).QuestNum) Then
>                                     'if the quest is in progress show the meanwhile message (chat2)
>                                     PlayerMsg attacker, Trim$(NPC(npcNum).Name) + ": " + Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), BrightGreen
>                                     'QuestMessage attacker, NPC(npcNum).QuestNum, Trim$(Quest(NPC(npcNum).QuestNum).Chat(2)), 0
>                                     Exit Function
>                                 End If
>                             End If
>                             If NPC(npcNum).Quest = NO Then
>                                 If NPC(npcNum)**.Convo** = False Then
>                                   If Len(Trim$(NPC(npcNum).AttackSay)) > 0 Then
>                                     PlayerMsg attacker, Trim$(NPC(npcNum).Name) & ": " & Trim$(NPC(npcNum).AttackSay), White
>                                   End If
>                                 Else
>                                     InitChat attacker, mapnum, mapNpcNum
>                                 End If
>                                 Exit Function
>                             End If
>                             End If
>                            
>                             CanPlayerAttackNpc = True
>                         End If
>                        
>                         End If
>                     End If
>                 End If
> End Function
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...