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.