DMH-Online

Dungeon Masters Helper · Est. 2005

Creatures Scripts

NWN Script: random_death_effect.htm

Author Sticky: Post Working Scripts Here
FiannaTiger Posted: Tuesday, 25 June 11:20PM
EDIT: script fixed.

Script Name: DeathSpawn

What it Does: This script can be used to fire off random generation of treasure, random visual effect, and even random "famous last words". It's origional intent was to spawn up to 3 predefined magic items using CreateObject (Still haven't figured that one out yet) to drop when the creature dies. This is a userdefined event triggered by the ondeath event.


NWScript:
void main()
{
    int nUser = GetUserDefinedEventNumber();
    if(nUser == 1007) // DEATH
    {
    int iChance = d100( );
    int iItem1, iItem2, iItem3, iITEM;
    int iCheck = 0;
    int iItemsDropped = 0;
    int i;
    if(iChance >= 90)       // 10% chance of 3 items
        iItemsDropped = 3;
    else if(iChance >= 50)  // 40 % chance of 2 items
        iItemsDropped = 2;
    else                    // 50 % chance of 1 item
        iItemsDropped =1;
    iItem1 = d8(1); // the d8() can be changed suit any
    iITEM = iItem1; // number of items or events just
    iItem2 = d8(1); // make sure to change all occurances
    iItem3 = d8(1); // and add that many case statements
    for(i = 1; i <= iItemsDropped; i++)
    {
        if (iCheck == 2){
            iITEM = iItem3;
        }
        if(iCheck == 1){
            iITEM = iItem2;
            iCheck =2;
        }
        if (iCheck == 0){
            while(iITEM == iItem2 || iITEM == iItem3 || iItem2 == iItem3){
                iItem2 = d8( );  // makes sure the items 
                iItem3 = d8( );  // aren't all the same
                }
        iCheck = 1;
        }
    switch(iITEM){
        case 1:
            //add your item spawn or whatever here
            break;
        case 2:
            //add your item spawn or whatever here
            break;
        case 3:
            //add your item spawn or whatever here
            break;
        case 4:
            //add your item spawn or whatever here
            break;
        case 5:
            //add your item spawn or whatever here
            break;
        case 6:
            //add your item spawn or whatever here
            break;
        case 7:
            //add your item spawn or whatever here
            break;
        case 8:
            //add your item spawn or whatever here
        } //end of switch
    } //end of for loop
    }
}



_________________
Fianna Tiger - And the tigers come at night, their voice as soft as thunder. They tear your dreams apart they turn your life to shame.

⌂ 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