| Mirage Source http://miragesource.net/forums/ |
|
| Dead Bodies http://miragesource.net/forums/viewtopic.php?f=210&t=825 |
Page 1 of 1 |
| Author: | Dragoons Master [ Mon Dec 11, 2006 2:32 am ] |
| Post subject: | Dead Bodies |
I think nobody never posted a tut like this. This is my way to do it. I made it a long ago and I decided to post it here to share it w/ you guys. Author: Dragoons Master Difficulty: 2/5 (Copy/Paste Tut/Understand) That's what you should do, first Client side. modGlobals: Header: Under "Public MapNpc(1 To MAX_MAP_NPCS) As MapNpcRec" add this: Code: Public MapNpcDBody(1 To MAX_MAPS, 1 To MAX_MAP_NPCS) As DeadBodyRec Under "' Maximum classes" stuff add this: Code: Type DeadBodyRec Blit As Boolean Time As Long X As Byte Y As Byte Timer As Byte StartTimer As Byte End Type Sub GameLogic: Under "Sub BltNpc" stuff add this new sub: Code: Sub BltNpcDBody(ByVal MapNpcNum As Long) Dim X As Long, Y As Long Dim i As Long ' Check to see if we want to stop making him attack Dim DBMap As Integer For i = 1 To MAX_MAPS If MapNpcDBody(i, MapNpcNum).Blit = True Then If MapNpcDBody(i, MapNpcNum).Time + 20000 - (MapNpcDBody(i, MapNpcNum).StartTimer * 1250) < GetTickCount Then MapNpcDBody(i, MapNpcNum).Blit = False MapNpcDBody(i, MapNpcNum).Time = 0 MapNpcDBody(i, MapNpcNum).X = 0 MapNpcDBody(i, MapNpcNum).Y = 0 MapNpcDBody(i, MapNpcNum).Timer = 0 End If If MapNpcDBody(i, MapNpcNum).Time + ((MapNpcDBody(i, MapNpcNum).Timer + 1) * 1250) < GetTickCount Then MapNpcDBody(i, MapNpcNum).Timer = MapNpcDBody(i, MapNpcNum).Timer + 1 End If End If Next i If GetPlayerMap(MyIndex) = 0 Then Exit Sub DBMap = GetPlayerMap(MyIndex) rec.Top = 142 * PIC_Y 'I use 142 as a sprite in the spritesurf, use any number you want. rec.Bottom = rec.Top + PIC_Y rec.Left = (MapNpcDBody(DBMap, MapNpcNum).Timer + MapNpcDBody(DBMap, MapNpcNum).StartTimer) * PIC_X rec.RIGHT = rec.Left + PIC_X X = MapNpcDBody(DBMap, MapNpcNum).X * PIC_X Y = MapNpcDBody(DBMap, MapNpcNum).Y * PIC_Y ' Check if its out of bounds because of the offset If Y < 0 Then Y = 0 rec.Top = rec.Top + (Y * -1) End If If MapNpcDBody(DBMap, MapNpcNum).Blit = True Then Call DD_BackBuffer.BltFast(X, Y, DD_SpriteSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) End If End Sub OBS: Change the 142 to the sprite you want. modHandleData: Sub HandleData: Add this, you know where... Code: ' :::::::::::::::::::::::::: ' :: Npc Dead Body Packet :: ' :::::::::::::::::::::::::: If LCase(Parse(0)) = "npcbody" Then MapNpcDBody(Val(Parse(4)), Val(Parse(1))).Blit = True MapNpcDBody(Val(Parse(4)), Val(Parse(1))).X = Val(Parse(2)) MapNpcDBody(Val(Parse(4)), Val(Parse(1))).Y = Val(Parse(3)) MapNpcDBody(Val(Parse(4)), Val(Parse(1))).StartTimer = Val(Parse(5)) MapNpcDBody(Val(Parse(4)), Val(Parse(1))).Timer = 0 MapNpcDBody(Val(Parse(4)), Val(Parse(1))).Time = GetTickCount Exit Sub End If modGameLogic: Sub GameLoop: Add this under "' Blit out tiles layers ground/anim1/anim2" stuff: Code: ' Blit out the npcs dead body For i = 1 To MAX_MAP_NPCS Call BltNpcDBody(i) Next i Server side modServerTCP: Add this subs to the module: Code: Sub SendNDeadBodyToMap(ByVal MapNum As Long, ByVal MapNpcNum As Long) Dim Packet As String Packet = Chr(235) & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).X & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Y & SEP_CHAR & MapNum & SEP_CHAR & MapNpcDBody(MapNum, MapNpcNum).Timer & END_CHAR Call SendDataToMap(MapNum, Packet) End Sub Sub SendDBodiesLogin(ByVal Index As Long) Dim I As Long Dim J As Long For I = 1 To MAX_MAPS For J = 1 To MAX_MAP_NPCS If MapNpcDBody(I, J).Blit = True Then Call SendNDeadBodyTo(Index, I, J) End If Next J Next I End Sub Sub SendDBodiesMap(ByVal Index As Long) Dim J As Long Dim PlayerMap As Long PlayerMap = GetPlayerMap(Index) If PlayerMap <= 0 Or PlayerMap > MAX_MAPS Then Exit Sub For J = 1 To MAX_MAP_NPCS If MapNpcDBody(PlayerMap, J).Blit = True Then Call SendNDeadBodyTo(Index, PlayerMap, J) End If Next J End Sub modGameLogic: Sub AttackNpc: Under "Call SendDataToMap(MapNum, "NPCDEAD" & SEP_CHAR & MapNpcNum & SEP_CHAR & END_CHAR)" add: Code: MapNpcDBody(MapNum, MapNpcNum).Blit = True MapNpcDBody(MapNum, MapNpcNum).Time = GetTickCount MapNpcDBody(MapNum, MapNpcNum).Timer = 0 Call SendNDeadBodyToMap(MapNum, MapNpcNum) Sub PlayerWarp: Under "' Check if there is an npc on the map and say hello if so" stuff add: Code: Call SendDBodiesMap(Index) Sub JoinGame: Under "' Send the flag so they know they can start doing stuff" stuff add: Code: Call SendDBodiesLogin(Index) modGlobals: Header: Under "Public MapNpc(1 To MAX_MAPS, 1 To MAX_MAP_NPCS) As MapNpcRec" add this: Code: Public MapNpcDBody(1 To MAX_MAPS, 1 To MAX_MAP_NPCS) As DeadBodyRec Under "' Maximum classes" stuff add this: Code: Type DeadBodyRec Blit As Boolean Time As Long X As Byte Y As Byte Timer As Byte StartTimer As Byte End Type modGeneral: Sub GameAI: Find "' // This is used for checking if an NPC is dead or not //" and you will see that it is totaly quoted. Keep it like that, don't edit it, only add this piece of code under that stuff: Code: For x = 1 To MAX_MAP_NPCS
If MapNpcDBody(y, x).Blit = True Then If MapNpcDBody(y, x).Time + 20000 < TickCount Then MapNpcDBody(y, x).Blit = False MapNpcDBody(y, x).Time = 0 MapNpcDBody(y, x).x = 0 MapNpcDBody(y, x).y = 0 MapNpcDBody(y, x).Timer = 0 End If If MapNpcDBody(y, x).Time + ((MapNpcDBody(y, x).Timer + 1) * 1250) < TickCount Then MapNpcDBody(y, x).Timer = MapNpcDBody(y, x).Timer + 1 End If End If Next x I think that's all, maybe I forgot something. Someone plx test and see if it works ^^ EDIT: here is an example of a blood img, like a body.
PLX DON'T USE THIS ONE IT IS A CUSTOM ONE, MADE BY MY PIXEL ARTIST! EDIT2: Just fixed the wrong missing subs. They shouldn't be there xD |
|
| Author: | Forte [ Mon Dec 11, 2006 3:22 am ] |
| Post subject: | |
lol woah this is awesome! lol nice dude, im adding this right now to my game, ill tell you if i get any errors hey btw does the animation stay there? or once its done moving does it dissapear? |
|
| Author: | Shannara [ Mon Dec 11, 2006 3:55 am ] |
| Post subject: | |
Congrats on the tutorial. |
|
| Author: | Rian [ Mon Dec 11, 2006 6:44 am ] |
| Post subject: | |
It's missing a couple subs. PlayerDBody SendPDeadBodyToMap SendNDeadBodyToMap I could be wrong. I didn't try hardly any debugging. |
|
| Author: | Dragoons Master [ Mon Dec 11, 2006 11:00 am ] |
| Post subject: | |
Sonire wrote: It's missing a couple subs.
PlayerDBody SendPDeadBodyToMap SendNDeadBodyToMap I could be wrong. I didn't try hardly any debugging. Sry guys, I realy did a few things wrong. I have players dead body too, but this is not a tut for players and yes for npc, so I removed the player part. Shouldn't be hard to change that =P Sry about that but now it is fully working. |
|
| Author: | TheRealDamien [ Mon Dec 11, 2006 11:07 am ] |
| Post subject: | |
Now this is a tutorial to die for... Get it? lol. |
|
| Author: | Reece [ Mon Dec 11, 2006 4:35 pm ] |
| Post subject: | |
Bad joke Nice tute man very nice |
|
| Author: | Dragoons Master [ Mon Dec 11, 2006 9:56 pm ] |
| Post subject: | |
Tnx all you guys ^^ It's a nice stuff to add to your game, or the idea it selfs. Btw, this is the tut I'm posting for the contest ok? I'm not sure if the contest still up but if it does, this is my tutorial for it ^^ |
|
| Author: | franqetesh [ Thu Jan 31, 2008 12:26 pm ] |
| Post subject: | Re: Dead Bodies |
SORRY FOR THE NECROPOST :S...But, how I do to set the body's image? |
|
| Author: | Dragoons Master [ Thu Jan 31, 2008 4:16 pm ] |
| Post subject: | Re: Dead Bodies |
Client side, at Sub BltNpcDBody, change the 142 the sprite number... Code: rec.Top = 142 * PIC_Y 'I use 142 as a sprite in the spritesurf, use any number you want.
|
|
| Author: | Mozza [ Mon Apr 28, 2008 3:29 pm ] |
| Post subject: | Re: Dead Bodies |
Missing Sub Code: SendNDeadBodyTo
|
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|