Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 9:41 am

All times are UTC




Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Overhead Damage
PostPosted: Thu Jun 01, 2006 9:41 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 7:43 am 
Offline
Newbie

Joined: Sat Jul 01, 2006 4:28 am
Posts: 2
Sounds very good, i won't implement this code into the game im working on

But i will use the idea of overhead damage, if i do leech off your code credit will be given.

Thats a awesome code, i hope it works :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 11:12 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
nofan wrote:
Sounds very good, i won't implement this code into the game im working on

But i will use the idea of overhead damage, if i do leech off your code credit will be given.

Thats a awesome code, i hope it works :wink:


GodSentDeath made this, so give him credits

grimsk8ter11 wrote:
Original Code - GodSentDeath


And it does work, GSD added it into Konfuze, and so it is in all Elysium bi-products (unless removed)

~Kite


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 4:55 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
Yea i wrote the original tutorial, i just ripped it from Konfuze i think...

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 5:33 pm 
Offline
Knowledgeable
User avatar

Joined: Thu Jun 29, 2006 12:11 am
Posts: 120
Allright thanks got no problem at compiling =D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 8:00 am 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Just because you have no trouble complining, doesnt mean the everythings working perfectly fine. There might be a logic error, something that the complier wouldnt pick up, since the syntax is correct. Just a thought to keep in the back of your mind.. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 6:23 pm 
Offline
Knowledgeable
User avatar

Joined: Thu Jun 29, 2006 12:11 am
Posts: 120
Yep I noticed but that was a noobish post when I just started long ago xD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 7:34 pm 
Offline
Pro

Joined: Mon May 29, 2006 1:40 pm
Posts: 430
long ago? that was today lol.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 7:38 pm 
Offline
Knowledgeable
User avatar

Joined: Thu Jun 29, 2006 12:11 am
Posts: 120
Exactly 1 day is alot for me >.>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 8:43 pm 
Offline
Knowledgeable

Joined: Wed Jun 14, 2006 10:15 pm
Posts: 169
Maybe it's just me, but after adding this it compiles fine, yet the damage isn't displayed...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 8:46 pm 
Offline
Knowledgeable
User avatar

Joined: Thu Jun 29, 2006 12:11 am
Posts: 120
Its not you I have that problem too xD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 9:42 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
The only problem (that could possibly exist), is where i had written...

Quote:
' Lock the backbuffer so we can draw text and names


There is 1 line of code underneath that, i dont remember exactly what is is... but it needs to go after that...

So it should be like this... (and this should fix your problem.. if you're getting one)

Code:
' Lock the backbuffer so we can draw text and names
'*Should Be a Line here already*

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 check that out, that should be the only reason your code may not work....

If you put this chunk of code BEFORE the line, that comes after the " ' Lock the backbuffer so we can draw text and names " part, you won't see any text. So make sure, you have the Comment, the original line directly after the comment and then that part of the code. I didn't write that part too well when i made the original tutorial.

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 10:09 pm 
Offline
Knowledgeable

Joined: Wed Jun 14, 2006 10:15 pm
Posts: 169
Oh you mean this?

Quote:
' Lock the backbuffer so we can draw text and names
TexthDC = DD_BackBuffer.GetDC


I did put it after that... I mean, I'm dumb, but not that dumb :P no offence to anyone who put it before :o

BTW: Still doesn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 7:02 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
If it doesnt work, just nip over to elysium and rip it out.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 2:53 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
it's odd, because on the backup forum, everyone that tried it had it working, so i dont know why simply moving to this forum... would result in people having errors :?

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 9:09 pm 
Offline
Knowledgeable

Joined: Wed Jun 14, 2006 10:15 pm
Posts: 169
^^^^

Thats what I thought... but I just went over there and tried copying it from there and it still didn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 4:39 am 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
Just want to expand on this a bit and consider blitting the exp after you kill the npc. Currently I have it sending the data from the server to the client, but I am not sure how to get it to blit when the npc is killed, could anybody help?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 5:59 am 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
I don't have a project open, but this is how I would go about doing it...

Find the sub the tell the NPC to drop the goods when they die, and have the exp sent then, and then have that packet call sub blt_exp


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 1:50 pm 
Offline
Pro

Joined: Mon May 29, 2006 1:40 pm
Posts: 430
you would need to have it as a timer or in the game loop, cause if you just call blt_exp it will only be shown quickly, so maybe set a variable or something.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 10:01 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
i actually redid this entire system, so you can send any overhead message you like, and define who you send it over. I use it to send damage over a players and npcs head, during a fight, so everyone on the map can see how well/bad that player is doing... it also blts exp, when a player takes potions, and a few other things.

i might just post a tutorial for that, cause it seems to be a pretty "wanted" feature i've noticed.

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 10:33 pm 
Offline
Knowledgeable
User avatar

Joined: Thu Jun 29, 2006 12:11 am
Posts: 120
Yes please I will give u a cookie =D


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 10:44 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Aug 17, 2006 5:27 pm
Posts: 866
Location: United Kingdom
Just been looking over the old forums (the backup) and i found this post seemed to help some people make it work:

----------------------------------------------------------

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

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

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


moo!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 2:04 am 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
it doesnt work because oif all of GSDs offsets for scrolling, you need to remove them

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 6:18 am 
Offline
Regular
User avatar

Joined: Tue Jul 04, 2006 5:50 am
Posts: 98
Basically what grim said :P I wrote this tutorial using the Elysium Source a while back. I totally forgot to fix it up for MS... bleh, and probably never will! :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 3:08 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
OMG GSD PLX GTALK NOW

lol. whered you go O_O.

back on topic, ill probably fix it sometime today when i finish my damage class.

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group