Mirage Engine
NPCs Always Drop Gold - Printable Version

+- Mirage Engine (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: NPCs Always Drop Gold (/showthread.php?tid=344)



NPCs Always Drop Gold - Tutorial Bot - 02-10-2006

Author: Leighland
Difficulty: 1/5

:: SERVER SIDE ::
In modGameLogic, and find Sub AttackNpc, find:
Code:
' Drop the goods if they get it
        n = Int(Rnd * Npc(NpcNum).DropChance) + 1
        If n = 1 Then
            Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
        End If
Replace with:
Code:
' Drop the goods if they get it
        n = Int(Rnd * Npc(NpcNum).DropChance) + 1
        Call SpawnItem(1, Npc(NpcNum).STR, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
        If n = 1 Then
            Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
        End If

You'll need to change the "1" highlighted below, to whatever the item number of your gold is:
Quote:Call SpawnItem(1, Npc(NpcNum).STR, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
There you have it. NPCs always drop gold equal to the amount of strength they have.

If you want, you can change it to drop gold ONLY when the regular item assigned to the NPC is dropped. Like this:
Code:
' Drop the goods if they get it
        n = Int(Rnd * Npc(NpcNum).DropChance) + 1
        If n = 1 Then
            Call SpawnItem(1, Npc(NpcNum).STR, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
            Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
        End If

If you want to modify how much gold is dropped, change the bolded text below to whatever you wish:
Quote:' Drop the goods if they get it
n = Int(Rnd * Npc(NpcNum).DropChance) + 1
If n = 1 Then
Call SpawnItem(1, Npc(NpcNum).STR, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).y)
End If
That's all!