| Mirage Source http://web.miragesource.net/forums/ |
|
| Stop killing the NPC! http://web.miragesource.net/forums/viewtopic.php?f=201&t=4094 |
Page 1 of 1 |
| Author: | jsventor [ Sun Aug 03, 2008 2:07 am ] |
| Post subject: | Stop killing the NPC! |
Ok so I added quests, no errors, but they're bugs. Ok, so basically I had to change the CanAttackNpc function DUH, but for some reason it kills Quest type NPC's... its weird, and when I attack em, it does not even start the quest, but if I add a Call playerMsg it gives a message.. Code: Function CanAttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long) As Boolean
Dim MapNum As Long, npcnum As Long Dim x As Long Dim y As Long CanAttackNpc = False ' 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), MapNpcNum).Num <= 0 Then Exit Function End If MapNum = GetPlayerMap(Attacker) npcnum = MapNpc(MapNum, MapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(MapNum, MapNpcNum).HP <= 0 Then Exit Function End If ' Make sure they are on the same map If npcnum > 0 And GetTickCount > Player(Attacker).AttackTimer + 950 Then ' Check if at same coordinates x = DirToX(GetPlayerX(Attacker), GetPlayerDir(Attacker)) y = DirToY(GetPlayerY(Attacker), GetPlayerDir(Attacker)) If (MapNpc(MapNum, MapNpcNum).y = y) And (MapNpc(MapNum, MapNpcNum).x = x) Then 'If (MapNpc(MapNum, MapNpcNum).y + 1 = GetPlayerY(Attacker)) And (MapNpc(MapNum, MapNpcNum).x = GetPlayerX(Attacker)) Then If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER And Npc(npcnum).Behavior <> NPC_BEHAVIOR_QUEST Then CanAttackNpc = True Else If Npc(npcnum).Behavior = NPC_BEHAVIOR_QUEST Then Call DoQuest(Npc(npcnum).Quest, Attacker, npcnum) Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim(Npc(npcnum).Name) & "!", BrightBlue) End If ' End If End If End If End If End Function |
|
| Author: | Asrrin29 [ Sun Aug 03, 2008 3:21 am ] |
| Post subject: | Re: Stop killing the NPC! |
because of this: Code: If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER And Npc(npcnum).Behavior <> NPC_BEHAVIOR_QUEST Then [b]CanAttackNpc = True[/b] Else If the NPC Type is NOT friendly or a shopkeeper then it executes this code, you need to add in NPC_BEHAVIOR_QUEST to the list of exceptions for it to work. |
|
| Author: | jsventor [ Sun Aug 03, 2008 3:31 am ] |
| Post subject: | Re: Stop killing the NPC! |
Its in there lol |
|
| Author: | Asrrin29 [ Sun Aug 03, 2008 3:38 am ] |
| Post subject: | Re: Stop killing the NPC! |
Make sure that you have the right constant value for NPC_BEHAVIOR_QUEST and also add an Exit Function after the msg lets you know it's a quest NPC. if it still doesn't work just add CanAttackNpc = False after the msg line. |
|
| Author: | jsventor [ Sun Aug 03, 2008 3:55 am ] |
| Post subject: | Re: Stop killing the NPC! |
None of it works, I tried that all |
|
| Author: | Lea [ Sun Aug 03, 2008 3:59 am ] |
| Post subject: | Re: Stop killing the NPC! |
use breakpoints to see if CanAttackNPC = True is being called when the NPC is in fact a quest NPC. It could be an error with the client side npc editor sending the wrong value, it could be different between client and server, it could be some freaky modification being done at random times, etc. Hard to tell with what you give us and no debugging on your own |
|
| Author: | Asrrin29 [ Sun Aug 03, 2008 4:00 am ] |
| Post subject: | Re: Stop killing the NPC! |
put a Stop in the sub and F8 through it to find out what the variables are and compare them to what they are supposed to be. My guess is that it's calling some sub or function or doing something to end the sub prematurely and flubbing the whole thing. |
|
| Author: | Lea [ Sun Aug 03, 2008 4:02 am ] |
| Post subject: | Re: Stop killing the NPC! |
also fix your nesting please, it confused me at first |
|
| Author: | jsventor [ Sun Aug 03, 2008 4:07 am ] |
| Post subject: | Re: Stop killing the NPC! |
I reviewed EVERYTHING, the quest editor, everything, its weird, and I just provided that code because I figured that's where the bug was, I'll go over the packets again |
|
| Author: | Rian [ Sun Aug 03, 2008 5:04 pm ] |
| Post subject: | Re: Stop killing the NPC! |
I had the same problem with my quests man. It really is strange. I tried every variant I could think of to make sure the code was executed only when the npc isn't attackable. I ended up making a function that checks if you're standing next to a friendly npc with a quest and say the the words "hi", "hey", and "hello" to start the quest process. |
|
| Author: | Leighland [ Tue Aug 05, 2008 4:04 pm ] |
| Post subject: | Re: Stop killing the NPC! |
Try this: Code: Function CanAttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long) As Boolean Dim MapNum As Long, npcnum As Long CanAttackNpc = False ' 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), MapNpcNum).Num <= 0 Then Exit Function End If MapNum = GetPlayerMap(Attacker) npcnum = MapNpc(MapNum, MapNpcNum).Num ' Make sure the npc isn't already dead If MapNpc(MapNum, MapNpcNum).HP <= 0 Then Exit Function End If ' Make sure they are on the same map If IsPlaying(Attacker) Then If npcnum > 0 And GetTickCount > Player(Attacker).AttackTimer + 950 Then ' Check if at same coordinates Select Case GetPlayerDir(Attacker) Case DIR_UP If (MapNpc(MapNum, MapNpcNum).y + 1 = GetPlayerY(Attacker)) And (MapNpc(MapNum, MapNpcNum).x = GetPlayerX(Attacker)) Then If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER and Npc(npcnum).Behavior <> NPC_BEHAVIOR_QUEST Then CanAttackNpc = True Else If Npc(npcnum).Behavior = NPC_BEHAVIOR_QUEST Then Call DoQuest(Npc(npcnum).Quest, Attacker, npcnum) Exit Sub Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim(Npc(npcnum).Name) & "!", BrightBlue) End If End If End If Case DIR_DOWN If (MapNpc(MapNum, MapNpcNum).y - 1 = GetPlayerY(Attacker)) And (MapNpc(MapNum, MapNpcNum).x = GetPlayerX(Attacker)) Then If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim$(Npc(npcnum).Name) & "!", BrightBlue) End If End If Case DIR_LEFT If (MapNpc(MapNum, MapNpcNum).y = GetPlayerY(Attacker)) And (MapNpc(MapNum, MapNpcNum).x + 1 = GetPlayerX(Attacker)) Then If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim$(Npc(npcnum).Name) & "!", BrightBlue) End If End If Case DIR_RIGHT If (MapNpc(MapNum, MapNpcNum).y = GetPlayerY(Attacker)) And (MapNpc(MapNum, MapNpcNum).x - 1 = GetPlayerX(Attacker)) Then If Npc(npcnum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(npcnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim$(Npc(npcnum).Name) & "!", BrightBlue) End If End If End Select End If End If End Function Don't forget to put the checks in for each possible direction |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|