![]() |
Spawn Npc Attribute - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Spawn Npc Attribute (/showthread.php?tid=38) |
Spawn Npc Attribute - Tutorial Bot - 01-06-2006 Author: funkynut Difficulty: 2/5 "Okay, this is a Guide to adding your very own NPC Spawn Tile. Now then What I’ll pretty just doing is simple, just making a new form so you can select the NPC to spawn, adding a new tile attribute and making the server check for spawn NPC tiles and if there is a Spawn NPC Tile, spawn the NPC on that spot, and skip the rest of the routine that will try to spawn the NPC somewhere else." :: SERVER & CLIENT SIDE :: First let’s add the Tile Constant to both the client and server so find: Code: Public Const TILE_TYPE_KEYOPEN = 6 Code: Public Const TILE_TYPE_NPCSPAWN = 7 :: SERVER SIDE :: Find sub SpawnNPC. Now, just above: Code: ' Well try 100 times to randomly place the sprite Code: 'Check if theres a spawn tile for the specific npc Now we need to mod a bit of existing code so that we can skip it if we have already spawned an NPC so just below what you’ve added, change: Code: For i = 1 To 100 Code: If Not Spawned Then :: CLIENT SIDE :: Now we need to Blt the letter on top of the tiles so find: Code: If .Type = TILE_TYPE_KEYOPEN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "O", QBColor(White)) Code: If .Type = TILE_TYPE_NPCSPAWN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "NS", QBColor(Yellow)) This is the whole section: Code: With Map.Tile(x, y) The ‘TexthDC’ is kind of like the address or directions to the back buffer surface, and tells it what to write the text on, the next two sections tell the routine where to Blt the text, the next section is what is going to be bltted and the last section if the colour. Okay, now we have to be able to add this tile type to any tile we click on so find: Code: If frmMirage.optKeyOpen.Value = True Then Code: If frmMirage.optNpcSpawn.Value = True Then Okay, we need somewhere to input the tile properties into so add a new form call ‘frmMapSpawnNpc’ and on it at a list box called ‘lstNpc’ and two command button named cmdOk, cmdCancel. When we load this form, we need to load each npc that is spawned on the map into the list box so that the user can select the npc they wish to spawn, so in form load add: Code: Dim n As Long Now we need a variable to remember what npc we need to spawn at the spawn point when we place it on the map so find: Code: Public KeyOpenEditorY As Long Below it, add: Code: ' Used for SpawnNpc editor Code: SpawnNpcNum = lstNpc.ListIndex + 1 ‘Now we just need to add the option button to frmmirage, so goto frmMirage, on the frame with the tile attribs on them, add a new option button called ‘optNpcSpawn’ and on the click event add: Code: frmMapSpawnNpc.Show vbModal |