Print Page | Close Window

blting Overhead Damage

Printed From: Mirage Source
Category: Tutorials
Forum Name: Approved Tutorials
Forum Discription: All tutorials shown to actually work with MSE are moved here.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=52
Printed Date: 20 December 2006 at 6:01pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: blting Overhead Damage
Posted By: Sync
Subject: blting Overhead Damage
Date Posted: 07 February 2006 at 6:31pm
Originally posted by Obsidian

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

end sub


add

' ::::::::::::::::::::::::
    ' :: 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

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

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

end sub


add

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

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
' Try to attack a npc


if you scroll down just a little bit further, you will see a line that looks like
If Damage > 0 Then


from that line to the FIRST EXIT SUB should be changed to look like this
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
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.

~Obsidian





Replies:
Posted By: Sync
Date Posted: 07 February 2006 at 6:31pm
Approved



Posted By: William
Date Posted: 08 February 2006 at 11:14am
I cant see no text at all. im using MSE. SO it should work. I tryed to place a End command when the drawtext is and the program ended, so it all works until the text should be blt'ed. So what can be the problem?


Posted By: shortybsd
Date Posted: 09 February 2006 at 4:50am
it doesn't work for me either


Posted By: William
Date Posted: 09 February 2006 at 8:33am
So this is a not functinal/working tutorial thats been approved, not a good start :P hehe


Posted By: funkynut
Date Posted: 09 February 2006 at 9:28am
You shouldnt place end commands to check if its working, by doing that you leave the directx stuff sttuck in memory.

If you need to check if somethings working, just place a breakpoint


Posted By: Misunderstood
Date Posted: 09 February 2006 at 1:47pm
Breakpoint, or  Debug.print ;)
I personally like he debug.print better :P


Posted By: Obsidian
Date Posted: 09 February 2006 at 3:29pm
It should work will, it worked for a blank MSE that i tested with, and it's the exact code i used for Phoenix 


Posted By: funkynut
Date Posted: 09 February 2006 at 3:30pm
I prefer breakpoint, easier to get rid of when done


Posted By: Obsidian
Date Posted: 09 February 2006 at 3:32pm
Make sure, when you see this

' Lock the backbuffer so we can draw text and names

There is a code directly below it. I dont remember what the code is, but make sure you place

If NPCWho > 0 Then
             If MapNpc(NPCWho).Num > 0 Then
        If GetTickCount < NPCDmgTime + 2000 Then        
         &nbs p;   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
         &nbs p;                               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


Place that AFTER

' Lock the backbuffer so we can draw text and names
W/e The Code is that is here



Posted By: William
Date Posted: 09 February 2006 at 3:57pm
Lol, thats my misstake, I was thinking "why the hell" should I place it after: ' Lock the backbuffer so we can draw text and names

And not above. My dead brain didnt understand that. Thanks  


Posted By: shortybsd
Date Posted: 09 February 2006 at 8:09pm

        ' Lock the backbuffer so we can draw text and names
        TexthDC = DD_BackBuffer.GetDC
        For i = 1 To MAX_PLAYERS
             If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                 Call BltPlayerName(i)
             End If
        Next i

[then paste the code!!!]

If NPCWho > 0 Then
             If MapNpc(NPCWho).Num > 0 Then
        If GetTickCount < NPCDmgTime + 2000 Then        
         &n bs p;   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
         &n bs p;                               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

 

everything works perfect, great work man !



Posted By: Obsidian
Date Posted: 09 February 2006 at 10:12pm
sorry guys i figured that was rather common sense.


Posted By: William
Date Posted: 10 February 2006 at 3:02am
Yeha, my common sense was lost some years ago :P


Posted By: Da Undead
Date Posted: 05 March 2006 at 2:33pm
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
I can't find any declare statements or anything similar to this. WTF!!!


Posted By: Da Undead
Date Posted: 05 March 2006 at 2:33pm
NVM, i just placed it at very top of the module and it worked lol...


Posted By: funkynut
Date Posted: 05 March 2006 at 5:30pm
putting public is the same as declaring


Posted By: Obsidian
Date Posted: 06 March 2006 at 9:41pm
Originally posted by Obsidian

add these statements





Posted By: Leighland
Date Posted: 13 March 2006 at 2:21pm
Works perfect for me, thanks :)


Posted By: Memphis
Date Posted: 27 March 2006 at 2:18am
Works PERFECTLY!



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info