DMH-Online

Dungeon Masters Helper · Est. 2005

Placeables Scripts

NWN Script: fair_loot.htm

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
    }
}
⌂ All Scripts ← PreviousNext → 👁 Category List

All Placeables Scripts

📄 cast_haste 📄 check_fire 📄 chest_puzzle 📄 close_door 📄 close_door_002 📄 close_door_003 📄 close_door_004 📄 create_item_with_delay 📄 darklamp 📄 darklamp_002 📄 day_night_lights 📄 day_night_lights_002 📄 destroy_spawned_items 📄 destroy_spawned_items_002 📄 door_guard 📄 door_lock_item 📄 dragging_placeables 📄 encounter_on_open 📄 encounter_on_open_002 📄 fair_loot 📄 fire_burns 📄 guarded_chest 📄 kill_attacker 📄 kill_nearby 📄 lights_on_off 📄 linked_doors 📄 moveable_placeables 📄 multi_door 📄 open_doors 📄 poly_attacker 📄 polymorph_pc 📄 polymorph_pc_002 📄 random_teleport 📄 refil_chest 📄 refil_chest_002 📄 refil_chest_003 📄 refil_chest_004 📄 refil_chest_005 📄 refil_chest_006 📄 refil_chest_007 📄 remove_with_item 📄 respawner 📄 smart_doors 📄 spit_treasure 📄 talkable_placeables 📄 talking_door 📄 talking_sign 📄 talking_sign_002 📄 talking_sign_003 📄 talking_sign_004 📄 teleporting_chairs 📄 useable_bedroll 📄 useable_birdcage 📄 useable_cannon 📄 useable_catapult 📄 useable_chair 📄 useable_chair_002 📄 useable_chair_003 📄 useable_chair_004 📄 useable_couch 📄 useable_divining_pool 📄 useable_gong 📄 useable_kegs 📄 useable_kegs_002 📄 useable_placeables_002 📄 useable_sign 📄 useable_sign_002 📄 useable_sundial 📄 useable_sundial_002 📄 useable_sundial_003 📄 useable_sundial_004 📄 useable_sundial_005 📄 useable_sundial_006 📄 useable_training_dummy 📄 useable_training_dummy_002 📄 useable_training_dummy_003 📄 useable_training_dummy_004 📄 useable_trapdoor 📄 useable_trapdoor_002 📄 useable_trapdoor_003 📄 useable_trapdoor_004 📄 weapon_spawn_per_class 📄 worth