Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Overhead Damage
#1
Original Code - GodSentDeath

Difficulty - 2/5

:::::::::::::::::::::
::CLIENT SIDE::
:::::::::::::::::::::

In modClientTCP (or modHandleData, depending on which version of MS you're using) go to the sub "HandleData" and at the bottom before

Code:
end sub

add

Code:
' ::::::::::::::::::::::::
    ' :: Blit Player Damage ::
    ' ::::::::::::::::::::::::
    If LCase(Parse(0)) = "blitplayerdmg" Then
        DmgDamage = Val(Parse(1))
        NPCWho = Val(Parse(2))
        DmgTime = GetTickCount
        iii = 0
        Exit Sub
    End If
    
    ' :::::::::::::::::::::
    ' :: Blit NPC Damage ::
    ' :::::::::::::::::::::
    If LCase(Parse(0)) = "blitnpcdmg" Then
        NPCDmgDamage = Val(Parse(1))
        NPCDmgTime = GetTickCount
        ii = 0
        Exit Sub
    End If

Now go into modGameLogic, at the top of that module, in the declares statements, add these statements

Code:
Public DmgDamage As Long
Public DmgTime As Long
Public NPCDmgDamage As Long
Public NPCDmgTime As Long
Public NPCWho As Long
Public ii As Long, iii As Long

' Variables
Public NewPlayerX As Long
Public NewPlayerY As Long
Public NewXOffset As Long
Public NewYOffset As Long
Public NewX As Long
Public NewY As Long
Public sx as Long

The "Variables" listed above, may be duplicates of something you already have, if they are, you can just delete them. Now, still in modGameLogic go into the GameLoop Sub and under the comment that says

' Lock the backbuffer so we can draw text and names

add this code

Code:
If NPCWho > 0 Then
              If MapNpc(NPCWho).Num > 0 Then
        If GetTickCount < NPCDmgTime + 2000 Then        
              Call DrawText(TexthDC, (Player(MyIndex).x) * PIC_X + sx + (Int(Len(NPCDmgDamage)) / 2) * 3 + Player(MyIndex).XOffset - NewXOffset, (Player(MyIndex).y) * PIC_Y + sx - 30 + Player(MyIndex).YOffset - NewYOffset - ii, NPCDmgDamage, QBColor(BrightRed))
        End If
              ii = ii + 1
              End If
        End If
              
                  If NPCWho > 0 Then
                      If MapNpc(NPCWho).Num > 0 Then
                                    If GetTickCount < DmgTime + 2000 Then
                                          Call DrawText(TexthDC, (MapNpc(NPCWho).x - NewPlayerX) * PIC_X + sx + (Int(Len(DmgDamage)) / 2) * 3 + MapNpc(NPCWho).XOffset - NewXOffset, (MapNpc(NPCWho).y - NewPlayerY) * PIC_Y + sx - 57 + MapNpc(NPCWho).YOffset - NewYOffset - iii, DmgDamage, QBColor(White))
                                    End If
                            iii = iii + 1
                      End If
                  End If

If you have ANY problems with this code, view the note at the bottom of this tutorial.

Carrying on...

::::::::::::::::::::::
::SERVER SIDE::
::::::::::::::::::::::

In modGameLogic the sub NPCAttackPlayer, at the bottom of the sub, but before the

Code:
end sub

add

Code:
Call SendDataTo(Victim, "BLITNPCDMG" & SEP_CHAR & Damage & SEP_CHAR & END_CHAR)

Now in modServerTCP (or possibly modHandleData... does the MSE server use modHandleData for both?) find the HandleDataSub find the "Player Attack Packet" the parse line looks like

Code:
If LCase(Parse(0)) = "attack" Then

Ok, now scroll down in that code, just before the bottom of that packet there is a line that looks like this
Code:
' Try to attack a npc

if you scroll down just a little bit further, you will see a line that looks like

Code:
If Damage > 0 Then

from that line to the FIRST EXIT SUB should be changed to look like this

Code:
If Damage > 0 Then
                      Call AttackNpc(Index, i, Damage)
                      Call SendDataTo(Index, "BLITPLAYERDMG" & SEP_CHAR & Damage & SEP_CHAR & i & SEP_CHAR & END_CHAR)
                  Else
                      Call PlayerMsg(Index, "Your attack does nothing.", BrightRed)
                      Call SendDataTo(Index, "BLITPLAYERDMG" & SEP_CHAR & Damage & SEP_CHAR & i & SEP_CHAR & END_CHAR)
                  End If
                  Exit Sub

Okay, that is all if you have problems with the red text (npcs attacking you) then you may need to change that line to look like

Code:
Call DrawText(TexthDC, (Int(Len(NPCDmgDamage)) / 2) * 3 + NewX + sx, NewY - 22 - ii + sx, NPCDmgDamage, QBColor(BrightRed))

That code did not work for me, so i rewrote it as shown at the beginning of the tutorial. Please Post Any Comments/Mistakes.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)