Bem, na versão 1.0, foi criado um tipo de npc como 'objeto', e conseguimos empurrar/chutar o npc. Agora, iremos 'Carregar' o npc.
Funções 1.1:
- Carregar o npc com a tecla: Shift;
- Deixar o npc-objeto com a tecla: Shift;
- Objetos segurados, não podem ser chutados/empurrados;
- Colocar o npc-objeto em outro npc-objeto, destrói o objeto;
- Objetos não podem ser colocados fora do mapa, carregados entre mapas, ou pegos quando já foram pegos, evitando erros críticos;
- Se tiver carregando o objeto: quit, morte, mudança de mapa = limpa o npc-objeto.
Como é 1.1, requer o sistema(clique para ir): [E.O 2.0] - Npc Objeto (v1.0)
Vamos lá que é bem rapidinho, primeiramente abra seu 'client.vbp' , e em "ModTypes" , em "Private Type PlayerRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
Ainda em "ModTypes", em "Private Type MapNpcRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
Agora, em "ModGameLogic" , na "Function CheckDirection" , procure por isso:
E substitua isto por isso:
Ainda em "ModGameLogic" , no final adicione isso:
Ainda em "ModGameLogic", na "Sub CheckMovement()" , procure por isso:
E substitua isto, por isso:
Agora, em "MoGlobals", procure por:
E abaixo disto, adicione isso:
Agora, em "ModInput", na "Public Sub CheckKeys()", procure por:
E abaixo distto, adicione isso:
Aina em "ModInput", na "Public Sub CheckInputKeys()" , procure por:
E substitua por isso:
Agora, no final de "ModDirectDraw7" , adicione isso:
Ainda em "ModDirectdraw7" , na "Public Sub Render_Graphics" procure por isso:
E substitua isto por isso:
Ainda em "ModDirectdraw7" , na "Public Sub Render_Graphics" procure por isso:
E substitua isto por isso:
Agora, em "ModHandleData" , na "Public Sub InitMessages()" , procure por isso:
E acima disto, adicione isso:
Ainda em "ModHandleData" , na "Private Sub HandleMapNpcData" , procure por:
E acima disto, adicione isso:
Ainda em "ModHandleData" , no final adicione isso:
Agora, em "ModEnumerations" , procure por isso:
E acima disto, adicione isso:
Ainda em "ModEnumerations" , procure por isso:
E acima disto, adicione isso:
Agora, em "ModText" , na "Public Sub DrawNpcName(ByVal Index As Long)" , procure por isso:
E abaixo disto, adicione isso:
E a parte do cliente foi finalizada. Agora vamos ao ~Server Side~
Primeiramente, abra seu server.vbp.
Agora em "ModTypes" , em "Private Type TempPlayerRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
Ainda em "ModTypes", em "Private Type MapNpcRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
Agora, em "ModEnumerations" , procure por isso:
E acima disto, adicione isso:
Ainda em "ModEnumerations" , procure por isso:
E acima disto, adicione isso:
Agora, em "ModPlayer" , na "Sub JoinGame" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModPlayer" , mais abaixo na "Sub LeftGame" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModPlayer" , mais abaixo na "Sub PlayerWarp" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModPlayer" , mais abaixo na "Sub PlayerMove" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModPlayer" , na "Sub PlayerMove" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModPlayer", na "Sub OnDeath" , procure por:
E abaixo disto, adicione isso:
Agora, finalmente para o "ModPlayer" , adicione no final isso:
Agora, na "Public Sub InitMessages()", mais abaixo, antes o primeiro "End Sub" , adicione isso:
Ainda em "ModHandleData" , na "Sub HandleRequestNewMap" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModHandleData" , na "Sub HandleQuit" , procure por:
E acima disto, adicione isso:
Agora, no final do "ModHanleData", aicione isso:
Agora, em "ModServerTCP" , na "Sub CloseSocket" , procure por:
E abaixo disto, adicione isso:
Ainda em "ModServerTCP" , na "Sub SendMapNpcsTo" , procure por:
E acima disto, adicione isso:
Ainda em "ModServerTCP" , na "Sub SendMapNpcsToMap" , procure por:
E acima disto, adicione isso:
E finalmente, no final de "ModServerTCP" , adicione isso:
Por fim, em "ModCombat" na "Public Function CanPlayerAttackNpc", procure por:
E substitua por isso:
E pronto, agora você tem npc-objeto podendo ser carregado!
Qualquer BUG ou dúvida, entre em contato!
Funções 1.1:
- Carregar o npc com a tecla: Shift;
- Deixar o npc-objeto com a tecla: Shift;
- Objetos segurados, não podem ser chutados/empurrados;
- Colocar o npc-objeto em outro npc-objeto, destrói o objeto;
- Objetos não podem ser colocados fora do mapa, carregados entre mapas, ou pegos quando já foram pegos, evitando erros críticos;
- Se tiver carregando o objeto: quit, morte, mudança de mapa = limpa o npc-objeto.
Como é 1.1, requer o sistema(clique para ir): [E.O 2.0] - Npc Objeto (v1.0)
Vamos lá que é bem rapidinho, primeiramente abra seu 'client.vbp' , e em "ModTypes" , em "Private Type PlayerRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
- Spoiler:
- HoldingObject As Long
Ainda em "ModTypes", em "Private Type MapNpcRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
- Spoiler:
- BeingHold As Long
Agora, em "ModGameLogic" , na "Function CheckDirection" , procure por isso:
- Spoiler:
' Check to see if a npc is already on that tile
For i = 1 To Npc_HighIndex
If MapNpc(i).Num > 0 Then
If MapNpc(i).X = X Then
If MapNpc(i).Y = Y Then
CheckDirection = True
Exit Function
End If
End If
End If
Next
E substitua isto por isso:
- Spoiler:
' Check to see if a npc is already on that tile
For i = 1 To Npc_HighIndex
If MapNpc(i).Num > 0 Then
If MapNpc(i).X = X Then
If MapNpc(i).Y = Y Then
If MapNpc(i).BeingHold = 0 Then
CheckDirection = True
End If
Exit Function
End If
End If
End If
Next
Ainda em "ModGameLogic" , no final adicione isso:
- Spoiler:
Public Sub CheckCarry()
Dim buffer As clsBuffer
Dim AttackSpeed As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If CarryDown Then
If SpellBuffer > 0 Then Exit Sub ' currently casting a spell, can't attack
If StunDuration > 0 Then Exit Sub ' stunned, can't attack
' speed from weapon
If GetPlayerEquipment(MyIndex, Weapon) > 0 Then
AttackSpeed = Item(GetPlayerEquipment(MyIndex, Weapon)).speed
Else
AttackSpeed = 1000
End If
If Player(MyIndex).AttackTimer + AttackSpeed < GetTickCount Then
If Player(MyIndex).Attacking = 0 Then
With Player(MyIndex)
.Attacking = 1
.AttackTimer = GetTickCount
End With
Set buffer = New clsBuffer
buffer.WriteLong CCarry
SendData buffer.ToArray()
Set buffer = Nothing
End If
End If
End If
' Error handler
Exit Sub
errorhandler:
HandleError "CheckCarry", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Ainda em "ModGameLogic", na "Sub CheckMovement()" , procure por isso:
- Spoiler:
' Check if player has the shift key down for running
If ShiftDown Then
Player(MyIndex).Moving = MOVING_RUNNING
Else
Player(MyIndex).Moving = MOVING_WALKING
End If
E substitua isto, por isso:
- Spoiler:
' Check if player has the shift key down for running
If ShiftDown Or CarryDown Then
Player(MyIndex).Moving = MOVING_RUNNING
Else
Player(MyIndex).Moving = MOVING_WALKING
End If
Agora, em "MoGlobals", procure por:
- Spoiler:
Public ControlDown As Boolean
E abaixo disto, adicione isso:
- Spoiler:
- Public CarryDown As Boolean
Agora, em "ModInput", na "Public Sub CheckKeys()", procure por:
- Spoiler:
If GetAsyncKeyState(VK_SHIFT) >= 0 Then ShiftDown = False
E abaixo distto, adicione isso:
- Spoiler:
If GetAsyncKeyState(VK_SHIFT) >= 0 Then CarryDown = False
Aina em "ModInput", na "Public Sub CheckInputKeys()" , procure por:
- Spoiler:
If GetKeyState(vbKeyShift) < 0 Then
ShiftDown = True
Else
ShiftDown = False
End If
E substitua por isso:
- Spoiler:
If GetKeyState(vbKeyShift) < 0 Then
ShiftDown = True
CarryDown = True
Else
ShiftDown = False
CarryDown = False
End If
Agora, no final de "ModDirectDraw7" , adicione isso:
- Spoiler:
- Public Sub BltHoldObj(ByVal Index As Long)
Dim Anim As Byte, i As Long, X As Long, Y As Long
Dim Sprite As Long, spritetop As Long
Dim rec As DxVBLib.RECT
Dim AttackSpeed As Long
Dim holdNum As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If Player(Index).HoldingObject <= 0 Then Exit Sub
If MapNpc(Player(Index).HoldingObject).Num <= 0 Then Exit Sub
Sprite = Npc(MapNpc(Player(Index).HoldingObject).Num).Sprite
If Sprite < 1 Or Sprite > NumCharacters Then Exit Sub
CharacterTimer(Sprite) = GetTickCount + SurfaceTimerMax
If DDS_Character(Sprite) Is Nothing Then
Call InitDDSurf("characters\" & Sprite, DDSD_Character(Sprite), DDS_Character(Sprite))
End If
' speed from weapon
If GetPlayerEquipment(Index, Weapon) > 0 Then
AttackSpeed = Item(GetPlayerEquipment(Index, Weapon)).speed
Else
AttackSpeed = 1000
End If
' Reset frame
If Player(Index).Step = 3 Then
Anim = 0
ElseIf Player(Index).Step = 1 Then
Anim = 2
End If
' Check for attacking animation
If Player(Index).AttackTimer + (AttackSpeed / 2) > GetTickCount Then
If Player(Index).Attacking = 1 Then
Anim = 3
End If
Else
' If not attacking, walk normally
Select Case GetPlayerDir(Index)
Case DIR_UP
If (Player(Index).YOffset > 8) Then Anim = Player(Index).Step
Case DIR_DOWN
If (Player(Index).YOffset < -8) Then Anim = Player(Index).Step
Case DIR_LEFT
If (Player(Index).XOffset > 8) Then Anim = Player(Index).Step
Case DIR_RIGHT
If (Player(Index).XOffset < -8) Then Anim = Player(Index).Step
End Select
End If
' Check to see if we want to stop making him attack
With Player(Index)
If .AttackTimer + AttackSpeed < GetTickCount Then
.Attacking = 0
.AttackTimer = 0
End If
End With
' Set the left
Select Case GetPlayerDir(Index)
Case DIR_UP
spritetop = 3
Case DIR_RIGHT
spritetop = 2
Case DIR_DOWN
spritetop = 0
Case DIR_LEFT
spritetop = 1
End Select
With rec
.top = spritetop * (DDSD_Character(Sprite).lHeight / 4)
.Bottom = .top + (DDSD_Character(Sprite).lHeight / 4)
.Left = Anim * (DDSD_Character(Sprite).lWidth / 4)
.Right = .Left + (DDSD_Character(Sprite).lWidth / 4)
End With
' Calculate the X
X = GetPlayerX(Index) * PIC_X + Player(Index).XOffset - ((DDSD_Character(Sprite).lWidth / 4 - 32) / 2)
' Is the player's height more than 32..?
If (DDSD_Character(Sprite).lHeight) > 32 Then
' Create a 32 pixel offset for larger sprites
Y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - ((DDSD_Character(Sprite).lHeight / 4) - 32)
Else
' Proceed as normal
Y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset
End If
' render the actual sprite
Call BltSprite(Sprite, X, Y - 32, rec)
' check for paperdolling
For i = 1 To UBound(PaperdollOrder)
If GetPlayerEquipment(Index, PaperdollOrder(i)) > 0 Then
If Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll > 0 Then
Call BltPaperdoll(X, Y, Item(GetPlayerEquipment(Index, PaperdollOrder(i))).Paperdoll, Anim, spritetop)
End If
End If
Next
' Error handler
Exit Sub
errorhandler:
HandleError "BltHoldObj", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Ainda em "ModDirectdraw7" , na "Public Sub Render_Graphics" procure por isso:
- Spoiler:
If NumCharacters > 0 Then
' Players
For i = 1 To Player_HighIndex
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
If Player(i).Y = Y Then
Call BltPlayer(i)
End If
End If
Next
' Npcs
For i = 1 To Npc_HighIndex
If MapNpc(i).Y = Y Then
Call BltNpc(i)
End If
Next
End If
E substitua isto por isso:
- Spoiler:
If NumCharacters > 0 Then
' Players
For i = 1 To Player_HighIndex
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
If Player(i).Y = Y Then
Call BltPlayer(i)
If Player(i).HoldingObject > 0 Then
Call BltHoldObj(i)
End If
If Player(i).Pet.Alive = YES Then
Call BltPet(i)
End If
End If
End If
Next
' Npcs
For i = 1 To Npc_HighIndex
If MapNpc(i).Y = Y And MapNpc(i).BeingHold = 0 Then
Call BltNpc(i)
End If
Next
End If
Ainda em "ModDirectdraw7" , na "Public Sub Render_Graphics" procure por isso:
- Spoiler:
' draw npc names
For i = 1 To Npc_HighIndex
If MapNpc(i).Num > 0 Then
Call DrawNpcName(i)
End If
Next
E substitua isto por isso:
- Spoiler:
' draw npc names
For i = 1 To Npc_HighIndex
If MapNpc(i).Num > 0 And MapNpc(i).BeingHold = 0 Then
Call DrawNpcName(i)
End If
Next
Agora, em "ModHandleData" , na "Public Sub InitMessages()" , procure por isso:
- Spoiler:
- ' Error handler
E acima disto, adicione isso:
- Spoiler:
HandleDataSub(SPObj) = GetAddress(AddressOf HandlePlayerObj)
Ainda em "ModHandleData" , na "Private Sub HandleMapNpcData" , procure por:
- Spoiler:
End With
Next
Set buffer = Nothing
E acima disto, adicione isso:
- Spoiler:
- .BeingHold = buffer.ReadLong
Ainda em "ModHandleData" , no final adicione isso:
- Spoiler:
Private Sub HandlePlayerObj(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim i As Long
Dim holdNum As Long
Dim buffer As clsBuffer
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
Set buffer = New clsBuffer
buffer.WriteBytes data()
i = buffer.ReadLong
holdNum = buffer.ReadLong
Set buffer = Nothing
Player(i).HoldingObject = holdNum
' Error handler
Exit Sub
errorhandler:
HandleError "HandlePlayerObj", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Agora, em "ModEnumerations" , procure por isso:
- Spoiler:
' Make sure SMSG_COUNT is below everything else
SMSG_COUNT
End Enum
E acima disto, adicione isso:
- Spoiler:
- SPObj
Ainda em "ModEnumerations" , procure por isso:
- Spoiler:
' Make sure CMSG_COUNT is below everything else
CMSG_COUNT
End Enum
E acima disto, adicione isso:
- Spoiler:
- CCarry
Agora, em "ModText" , na "Public Sub DrawNpcName(ByVal Index As Long)" , procure por isso:
- Spoiler:
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
E abaixo disto, adicione isso:
- Spoiler:
If MapNpc(Index).BeingHold > 0 Then Exit Sub
E a parte do cliente foi finalizada. Agora vamos ao ~Server Side~
Primeiramente, abra seu server.vbp.
Agora em "ModTypes" , em "Private Type TempPlayerRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
- Spoiler:
- HoldingObject As Long
Ainda em "ModTypes", em "Private Type MapNpcRec" , declare um TIPO, descendo, antes do primeiro "End Type" , declare isso:
- Spoiler:
- BeingHold As Long
Agora, em "ModEnumerations" , procure por isso:
- Spoiler:
' Make sure SMSG_COUNT is below everything else
SMSG_COUNT
End Enum
E acima disto, adicione isso:
- Spoiler:
- SPObj
Ainda em "ModEnumerations" , procure por isso:
- Spoiler:
' Make sure CMSG_COUNT is below everything else
CMSG_COUNT
End Enum
E acima disto, adicione isso:
- Spoiler:
- CCarry
Agora, em "ModPlayer" , na "Sub JoinGame" , procure por:
- Spoiler:
' Send welcome messages
Call SendWelcome(index)
E abaixo disto, adicione isso:
- Spoiler:
'They can't be hold anything
TempPlayer(index).HoldingObj = 0
SendObjectsHold index
Ainda em "ModPlayer" , mais abaixo na "Sub LeftGame" , procure por:
- Spoiler:
' Check if player was the only player on the map and stop npc processing if so
If GetTotalMapPlayers(GetPlayerMap(index)) < 1 Then
PlayersOnMap(GetPlayerMap(index)) = NO
End If
E abaixo disto, adicione isso:
- Spoiler:
'They are holding something
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).X = GetPlayerX(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).Y = GetPlayerY(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
'only send if there's players on map to update for them
'other hand a 'log in' or 'map warp' will do it
If PlayersOnMap(GetPlayerMap(index)) = YES Then
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
SendObjectsHold index
End If
Ainda em "ModPlayer" , mais abaixo na "Sub PlayerWarp" , procure por:
- Spoiler:
' clear target
TempPlayer(index).Target = 0
TempPlayer(index).TargetType = TARGET_TYPE_NONE
SendTarget index
E abaixo disto, adicione isso:
- Spoiler:
'They are holding something
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).X = GetPlayerX(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).Y = GetPlayerY(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
'only send if there's players on map to update for them
'other hand a 'log in' or 'map warp' will do it
If PlayersOnMap(GetPlayerMap(index)) = YES Then
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
SendObjectsHold index
End If
Ainda em "ModPlayer" , mais abaixo na "Sub PlayerMove" , procure por:
- Spoiler:
Dim X As Long, Y As Long
E abaixo disto, adicione isso:
- Spoiler:
Dim PObjNum As Long
Ainda em "ModPlayer" , na "Sub PlayerMove" , procure por:
- Spoiler:
Call SetPlayerDir(index, Dir)
Moved = NO
MapNum = GetPlayerMap(index)
E abaixo disto, adicione isso:
- Spoiler:
'Get the object player is holding
PObjNum = TempPlayer(index).HoldingObj
If PObjNum > 0 Then
'Check if object wasn't broken or don't exist anymore
If MapNpc(MapNum).Npc(PObjNum).Num = 0 Then
MapNpc(MapNum).Npc(PObjNum).BeingHold = 0
TempPlayer(index).HoldingObj = 0
SendObjectsHold index
Else
MapNpc(MapNum).Npc(PObjNum).BeingHold = index
End If
End If
Ainda em "ModPlayer", na "Sub OnDeath" , procure por:
- Spoiler:
' Warp player away
Call SetPlayerDir(index, DIR_DOWN)
E abaixo disto, adicione isso:
- Spoiler:
'Is holding while dead
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
SendObjectsHold index
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
Agora, finalmente para o "ModPlayer" , adicione no final isso:
- Spoiler:
Public Sub CheckObject(ByVal index As Long, ByVal MapNpcNum As Long, ByVal X As Long, ByVal Y As Long)
Dim MapNum As Long
Dim npcX As Long, npcY As Long
Dim NpcNum As Long
'Check for errors
If index <= 0 Or index > MAX_PLAYERS Then Exit Sub
If TempPlayer(index).InGame = False Then Exit Sub
MapNum = GetPlayerMap(index)
If MapNum <= 0 Or MapNum > MAX_MAPS Then Exit Sub
If X < 0 Or X > Map(MapNum).MaxX Then Exit Sub
If Y < 0 Or Y > Map(MapNum).MaxY Then Exit Sub
If MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Then Exit Sub
NpcNum = MapNpc(MapNum).Npc(MapNpcNum).Num
'System in development
With MapNpc(MapNum).Npc(MapNpcNum)
' Check if at same coordinates
Select Case GetPlayerDir(index)
Case DIR_UP
npcX = .X
npcY = .Y + 1
Case DIR_DOWN
npcX = .X
npcY = .Y - 1
Case DIR_LEFT
npcX = .X + 1
npcY = .Y
Case DIR_RIGHT
npcX = .X - 1
npcY = .Y
End Select
If npcX = GetPlayerX(index) Then
If npcY = GetPlayerY(index) Then
If Npc(NpcNum).Behaviour = NPC_BEHAVIOUR_OBJECT Then
'Object is already being hold
If MapNpc(MapNum).Npc(MapNpcNum).BeingHold > 0 Then
'Reset Attack timer
TempPlayer(index).AttackTimer = GetTickCount
Exit Sub
End If
'Check if player is already holding an object
If TempPlayer(index).HoldingObj > 0 Then
'Reset Attack timer
TempPlayer(index).AttackTimer = GetTickCount
Exit Sub
End If
TempPlayer(index).HoldingObj = MapNpcNum
MapNpc(MapNum).Npc(MapNpcNum).BeingHold = index
SendObjectsHold index
Call SendMapNpcsToMap(MapNum)
End If
End If
End If
End With
'Reset Attack timer
TempPlayer(index).AttackTimer = GetTickCount
End Sub
Agora, na "Public Sub InitMessages()", mais abaixo, antes o primeiro "End Sub" , adicione isso:
- Spoiler:
HandleDataSub(CCarry) = GetAddress(AddressOf HandleCarry)
Ainda em "ModHandleData" , na "Sub HandleRequestNewMap" , procure por:
- Spoiler:
' Prevent hacking
If Dir < DIR_UP Or Dir > DIR_RIGHT Then
Exit Sub
End If
E abaixo disto, adicione isso:
- Spoiler:
'They are holding something
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).X = GetPlayerX(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).Y = GetPlayerY(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
If PlayersOnMap(GetPlayerMap(index)) = YES Then
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
SendObjectsHold index
End If
Ainda em "ModHandleData" , na "Sub HandleQuit" , procure por:
- Spoiler:
- Call CloseSocket(index)
E acima disto, adicione isso:
- Spoiler:
'They are holding something
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).X = GetPlayerX(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).Y = GetPlayerY(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
If PlayersOnMap(GetPlayerMap(index)) = YES Then
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
SendObjectsHold index
End If
Agora, no final do "ModHanleData", aicione isso:
- Spoiler:
Sub HandleCarry(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim i As Long
Dim n As Long
Dim Damage As Long
Dim TempIndex As Long
Dim X As Long, Y As Long
Dim MapNum As Long
Dim ObjNum As Long
Dim p As Long
If index <= 0 Or index > MAX_PLAYERS Then Exit Sub
If TempPlayer(index).InGame = False Then Exit Sub
' can't attack whilst casting
If TempPlayer(index).spellBuffer.Spell > 0 Then Exit Sub
' can't attack whilst stunned
If TempPlayer(index).StunDuration > 0 Then Exit Sub
' Send this packet so they can see the person attacking
SendAttack index
MapNum = GetPlayerMap(index)
If TempPlayer(index).HoldingObj > 0 Then
ObjNum = TempPlayer(index).HoldingObj
If MapNpc(MapNum).Npc(ObjNum).Num > 0 Then
' Check tradeskills
Select Case GetPlayerDir(index)
Case DIR_UP
If GetPlayerY(index) = 0 Then Exit Sub
X = GetPlayerX(index)
Y = GetPlayerY(index) - 1
'object over object, break it
'Future add: objects over others
For p = 1 To MAX_MAP_NPCS
If MapNpc(MapNum).Npc(p).Y = Y Then
'Kill Object
SendActionMsg MapNum, "*crack*", White, 0, (MapNpc(MapNum).Npc(p).X * 32), (MapNpc(MapNum).Npc(p).Y * 32)
MapNpc(MapNum).Npc(ObjNum).Num = 0
MapNpc(MapNum).Npc(ObjNum).SpawnWait = GetTickCount
MapNpc(MapNum).Npc(ObjNum).Vital(Vitals.HP) = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Exit Sub
End If
Next
MapNpc(MapNum).Npc(ObjNum).X = X
MapNpc(MapNum).Npc(ObjNum).Y = Y
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Case DIR_DOWN
If GetPlayerY(index) = Map(GetPlayerMap(index)).MaxY Then Exit Sub
X = GetPlayerX(index)
Y = GetPlayerY(index) + 1
'object over object, break it
'Future add: objects over others
For p = 1 To MAX_MAP_NPCS
If MapNpc(MapNum).Npc(p).Y = Y Then
'Kill Object
SendActionMsg MapNum, "*crack*", White, 0, (MapNpc(MapNum).Npc(p).X * 32), (MapNpc(MapNum).Npc(p).Y * 32)
MapNpc(MapNum).Npc(ObjNum).Num = 0
MapNpc(MapNum).Npc(ObjNum).SpawnWait = GetTickCount
MapNpc(MapNum).Npc(ObjNum).Vital(Vitals.HP) = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Exit Sub
End If
Next
MapNpc(MapNum).Npc(ObjNum).X = X
MapNpc(MapNum).Npc(ObjNum).Y = Y
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Case DIR_LEFT
If GetPlayerX(index) = 0 Then Exit Sub
X = GetPlayerX(index) - 1
Y = GetPlayerY(index)
'object over object, break it
'Future add: objects over others
For p = 1 To MAX_MAP_NPCS
If MapNpc(MapNum).Npc(p).X = X Then
'Kill Object
SendActionMsg MapNum, "*crack*", White, 0, (MapNpc(MapNum).Npc(p).X * 32), (MapNpc(MapNum).Npc(p).Y * 32)
MapNpc(MapNum).Npc(ObjNum).Num = 0
MapNpc(MapNum).Npc(ObjNum).SpawnWait = GetTickCount
MapNpc(MapNum).Npc(ObjNum).Vital(Vitals.HP) = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Exit Sub
End If
Next
MapNpc(MapNum).Npc(ObjNum).X = X
MapNpc(MapNum).Npc(ObjNum).Y = Y
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Case DIR_RIGHT
If GetPlayerX(index) = Map(GetPlayerMap(index)).MaxX Then Exit Sub
X = GetPlayerX(index) + 1
Y = GetPlayerY(index)
'object over object, break it
'Future add: objects over others
For p = 1 To MAX_MAP_NPCS
If MapNpc(MapNum).Npc(p).X = X Then
'Kill Object
SendActionMsg MapNum, "*crack*", White, 0, (MapNpc(MapNum).Npc(p).X * 32), (MapNpc(MapNum).Npc(p).Y * 32)
MapNpc(MapNum).Npc(ObjNum).Num = 0
MapNpc(MapNum).Npc(ObjNum).SpawnWait = GetTickCount
MapNpc(MapNum).Npc(ObjNum).Vital(Vitals.HP) = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
Exit Sub
End If
Next
MapNpc(MapNum).Npc(ObjNum).X = X
MapNpc(MapNum).Npc(ObjNum).Y = Y
MapNpc(MapNum).Npc(ObjNum).BeingHold = 0
TempPlayer(index).HoldingObj = 0
Call SendMapNpcsToMap(MapNum)
SendObjectsHold index
End Select
End If
Else
For i = 1 To MAX_MAP_NPCS
'it exists
If MapNpc(MapNum).Npc(i).Num > 0 Then
' Check tradeskills
Select Case GetPlayerDir(index)
Case DIR_UP
If GetPlayerY(index) = 0 Then Exit Sub
X = GetPlayerX(index)
Y = GetPlayerY(index) - 1
If MapNpc(MapNum).Npc(i).X = X And MapNpc(MapNum).Npc(i).Y = Y Then
ObjNum = i
Exit For
End If
Case DIR_DOWN
If GetPlayerY(index) = Map(GetPlayerMap(index)).MaxY Then Exit Sub
X = GetPlayerX(index)
Y = GetPlayerY(index) + 1
If MapNpc(MapNum).Npc(i).X = X And MapNpc(MapNum).Npc(i).Y = Y Then
ObjNum = i
Exit For
End If
Case DIR_LEFT
If GetPlayerX(index) = 0 Then Exit Sub
X = GetPlayerX(index) - 1
Y = GetPlayerY(index)
If MapNpc(MapNum).Npc(i).X = X And MapNpc(MapNum).Npc(i).Y = Y Then
ObjNum = i
Exit For
End If
Case DIR_RIGHT
If GetPlayerX(index) = Map(GetPlayerMap(index)).MaxX Then Exit Sub
X = GetPlayerX(index) + 1
Y = GetPlayerY(index)
If MapNpc(MapNum).Npc(i).X = X And MapNpc(MapNum).Npc(i).Y = Y Then
ObjNum = i
Exit For
End If
End Select
End If
Next
CheckObject index, ObjNum, X, Y
End If
End Sub
Agora, em "ModServerTCP" , na "Sub CloseSocket" , procure por:
- Spoiler:
If index > 0 Then
E abaixo disto, adicione isso:
- Spoiler:
'They are holding something
If TempPlayer(index).HoldingObj > 0 Then
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).X = GetPlayerX(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).Y = GetPlayerY(index)
MapNpc(GetPlayerMap(index)).Npc(TempPlayer(index).HoldingObj).BeingHold = 0
TempPlayer(index).HoldingObj = 0
If PlayersOnMap(GetPlayerMap(index)) = YES Then
Call SendMapNpcsToMap(GetPlayerMap(index))
End If
SendObjectsHold index
End If
Ainda em "ModServerTCP" , na "Sub SendMapNpcsTo" , procure por:
- Spoiler:
Next
SendDataTo index, Buffer.ToArray()
E acima disto, adicione isso:
- Spoiler:
Buffer.WriteLong MapNpc(MapNum).Npc(i).BeingHold
Ainda em "ModServerTCP" , na "Sub SendMapNpcsToMap" , procure por:
- Spoiler:
Next
SendDataToMap MapNum, Buffer.ToArray()
E acima disto, adicione isso:
- Spoiler:
Buffer.WriteLong MapNpc(MapNum).Npc(i).BeingHold
E finalmente, no final de "ModServerTCP" , adicione isso:
- Spoiler:
Sub SendObjectsHold(ByVal index As Long)
Dim Buffer As clsBuffer
If index <= 0 Or index > MAX_PLAYERS Then Exit Sub
Set Buffer = New clsBuffer
Buffer.WriteLong SPObj
Buffer.WriteLong index
Buffer.WriteLong TempPlayer(index).HoldingObj
SendDataToMap GetPlayerMap(index), Buffer.ToArray()
Set Buffer = Nothing
End Sub
Por fim, em "ModCombat" na "Public Function CanPlayerAttackNpc", procure por:
- Spoiler:
'Check for objects
If Npc(NpcNum).Behaviour = NPC_BEHAVIOUR_OBJECT Then
E substitua por isso:
- Spoiler:
'Check for objects
If Npc(NpcNum).Behaviour = NPC_BEHAVIOUR_OBJECT And MapNpc(MapNum).Npc(MapNpcNum).BeingHold = 0 Then
E pronto, agora você tem npc-objeto podendo ser carregado!
Qualquer BUG ou dúvida, entre em contato!
~Créditos~
Kotol