Author Sticky: Post Working Scripts Here
VorpalBlade Posted: Sunday, 21 July 03:41PM
This is a revision on my Fair Loot Controller

1. Script: Fair Loot Controller & Container Respawner

2. What it does: Generates one loot item for each new PC upon opening or bashing it. Respawns the object if it was bashed for the loot.

3. Notes: Create a template for each container type you plan on using, each with a Tag identical to it's ResRef and this script in the OnOpened and OnDeath events.

NWScript:
//::///////////////////////////////////////////////

//:: Name: Fair Loot Controller & Container Respawner

//:: FileName: lootcontroller

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

Generates a random loot item in inventory only once

for each player. If the object has been bashed, create

a new in its place.

*/

//:://////////////////////////////////////////////

//:: Created By: VorpalBlade

//:: Created On: 7/21/02

//:://////////////////////////////////////////////

#include "NW_O2_CONINCLUDE"

void RespawnObject(int nType, string sTemp, location lRespawn);

void main()

{

// Create a unique ID for this object using its location.

    location lMyLoc = GetLocation(OBJECT_SELF);

    vector vMyVec = GetPositionFromLocation(lMyLoc);

    float fMyFloat = VectorToAngle(vMyVec);

    string sMyID = GetTag(GetArea(OBJECT_SELF)) + FloatToString(fMyFloat);

    object oLastOpener = GetLastOpener();

// Check to see if this player has opened this inventory before.

    if (GetLocalInt(oLastOpener, sMyID) == FALSE)

    {

// Generate loot for the first time looter

        GenerateLowTreasure(oLastOpener, OBJECT_SELF);

// Create a LocalInt with the last opener's Tag so this wont run

// again for the same PC.

        SetLocalInt(oLastOpener, sMyID, TRUE);

        ShoutDisturbed();

    }

// Find out if this object has been bashed to death for the loot.

    if (GetIsDead(OBJECT_SELF)){

// Get the object's spawn point, Type and the template name as the Tag.

        location lSpawn = GetLocation(OBJECT_SELF);

        string sTemplate = GetTag(OBJECT_SELF);

        int nObjectType = GetObjectType(OBJECT_SELF);

// Send Respawn command to the module so it will execute even

// after this object is dead and buried

        AssignCommand(GetModule(), DelayCommand(10.0, RespawnObject(nObjectType, sTemplate, lSpawn)));

    }

}

void RespawnObject(int nType, string sTemp, location lRespawn)

{

    CreateObject(nType, sTemp, lRespawn);

}
Sticky: Post Working Scripts Here
VorpalBlade Posted: Sunday, 21 July 11:17AM
    }

}