Files
dsrc/sku.0/sys.server/compiled/game/script/city/bestine/tusken_spawner.script
T
2013-09-10 23:17:15 -07:00

114 lines
2.5 KiB
Plaintext

include library.create;
include library.utils;
include library.ai_lib;
include library.xp;
include library.group;
include library.weapons;
const string HEAD = "object/tangible/loot/quest/tusken_head.iff";
const string BATON = "object/weapon/melee/baton/victor_baton_gaderiffi.iff";
const string CARVED = "object/tangible/loot/quest/carved_stone.iff";
const string SMOOTH = "object/tangible/loot/quest/smooth_stone.iff";
trigger OnDeath(obj_id killer, obj_id corpseId)
{
obj_id spawner = getObjIdObjVar(self, "spawner");
//need target for messageTo
messageTo(spawner, "doDeathRespawn", null, 10, false);
return SCRIPT_CONTINUE;
}
messageHandler aiCorpsePrepared()
{
obj_id winner = getObjIdObjVar(self, xp.VAR_TOP_GROUP);
if ( isIdValid( winner ) )
{
obj_id[] permitted = null;
if ( group.isGroupObject(winner) )
{
permitted = getGroupMemberIds(winner);
}
else
{
permitted = new obj_id[1];
permitted[0] = winner;
}
if ( (permitted == null) || (permitted.length == 0) )
{
return SCRIPT_CONTINUE;
}
else
{
obj_id looter = null;
for ( int i = 0; i < permitted.length; i++ )
{
looter = permitted[i];
if ( looter != null )
{
if ( hasObjVar(looter, "bestine.tuskenquest") )
{
createTheirLoot(self);
return SCRIPT_CONTINUE;
}
}
}
}
}
return SCRIPT_CONTINUE;
}
void createTheirLoot(obj_id self)
{
obj_id corpseInventory = utils.getInventoryContainer(self);
if ( corpseInventory == null )
return;
string creatureName = ai_lib.getCreatureName(self);
if ( creatureName == "tusken_executioner" )
{
// create loot for tusken executioner: quest items and chance for rare stones
// create the tusken head quest item
//debugSpeakMsg(self, "Look! I'm an executioner!");
obj_id item = createObject( HEAD, corpseInventory, "" );
checkForLoot (self);
}
else
{
checkForLoot (self);
//debugSpeakMsg(self, "Look! Phat Lewt!");
// create loot for his underlings: chance for rare stones
}
}
void checkForLoot (obj_id self)
{
obj_id corpseInventory = utils.getInventoryContainer(self);
if ( corpseInventory == null )
return;
int chance = rand(0, 7000);
if ( (chance >= 0) && (chance <= 70) )
{
obj_id item = createObject( CARVED, corpseInventory, "" );
return;
}
if ( (chance >= 71) && (chance <= 300) )
{
obj_id item = createObject( SMOOTH, corpseInventory, "" );
return;
}
if ( (chance >= 301) && (chance <= 500) )
{
obj_id item = weapons.createWeapon(BATON, corpseInventory, rand(0.75f, 1.0f));
return;
}
}