DMH-Online

Dungeon Masters Helper · Est. 2005

Creatures Scripts

NWN Script: random_drops.htm

Author Sticky: Post Working Scripts Here
Allroy Posted: Tuesday, 25 June 07:55PM
Script name: Randomtreasure

What it does: On the death of a NPC this script rolls a random number to determine what items are dropped. Items must be pre-existing items. (this does not generate new ones.

NWScript:
//::
//:: Set NPC to drop treasure from a pregenerated list
//:: of loot.
//::  RandomTresure
//::  Copyright (c) 2002 Chris Wilson
//::
/*
    This script rolls a d100 (100 sided die) and then
    determines the reward by the number that is rolled.
*/
//
//:: Created By: Chris Wilson
//:: Created On: June 26, 2002
//::

void main()
{
  int nDiceRoll = d100(1);
  if(nDiceRoll <= 10)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else if(nDiceRoll <= 20)
    {
    CreateItemOnObject("item,", OBJECT_SELF, 1);
    }
     else if(nDiceRoll <= 30)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
     else  if(nDiceRoll <= 40)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
     else if(nDiceRoll <= 50)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else if(nDiceRoll <= 60)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
     else  if(nDiceRoll <= 70)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else if(nDiceRoll <= 80)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else if(nDiceRoll <= 90)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else if(nDiceRoll <= 95)
    {
    CreateItemOnObject("item", OBJECT_SELF, 1);
    }
    else
     CreateItemOnObject("item", OBJECT_SELF, 1);

 }



In the OnDeath script for the NPC put this command in the line:

ExecuteScript("TresureSelector");

In the "item" areas put the BlueprintResRef name there.
Bam, random Treasure from a preselected loot table.
If you want more than one item just add more CreateItemOnObject statements within the brackets.

Hope this helps.

_________________
I don't hold a grudge. I have no surviving enemies... at all.

- Galen

⌂ All Scripts ← PreviousNext → 👁 Category List

All Creatures Scripts

📄 apply_spell_effect 📄 aurak_draconian 📄 baaz_draconian 📄 boss_spawner 📄 change_light_spawn_pt_on_death 📄 clone_mob 📄 collect_loot 📄 create_unique_objectIDs 📄 creature_proc 📄 explode_ondeath 📄 explode_ondeath_002 📄 explode_ondeath_003 📄 exploding_chickens 📄 fire_death 📄 inverse_mob 📄 iron_statue 📄 lich 📄 lootable_corpse 📄 lootable_corpse_002 📄 lootable_corpse_002a 📄 lootable_corpse_oo2 📄 mob_respawn 📄 mob_respawn_002 📄 multi_creature_spawn 📄 night_time 📄 random_death_effect 📄 random_drops 📄 random_drops_002 📄 random_drops_003 📄 random_enc_onrest 📄 random_hps 📄 sivac_draconian 📄 spawn 📄 spawn_on_hearbeat 📄 summon_last_hostile 📄 summon_mob 📄 trolls 📄 trolls_002 📄 vampire_coffin 📄 werewolf