Auto-Loot

It’d be cool to see an auto-loot mechanism in place in the options menu. Playing as a wizard using teleport or summon can be annoying when grabbing items. If I can find the old auto-loot script used in NWN, maybe I can post it here so you could consider adding it to the game. It may only serve as a general concept since NWN 1 used a different language and the use of the code was probably quite different in terms of input used in the script, but it may be a starting point so that you don’t have to modify everything quite as much.

Here is the script that I found, if multiplayer is added to the game, a splitting system would be beneficial anyways… but maybe you can take something from it to use it in the game?

All information here is as listed in the contact info, and I do not own or have association with any of the listed info in this quote.

[quote]ERF V1.0 a H f ð T DE ExportInfo õa pals_main Ùa pals_main Úa pals_onacquire Úa pals_onacquire Ùa pals_onunacquire Ùa pals_onunacquire Úa € > ¾ B. 4 4  ˜J ˜ 0L G wM z GFF V3.28
° Ð P ^ ® ` 0 ÿÿÿÿ ( 0 8 @ H P X

à Ùa ê Ùa ù Ùa
Ùa Úa Úa - Ùa < Ùa M Úa a , Mod_MinGameVer Expansion_Pack Comments Top ResRef ResType Dependencies Missing 1.23Ô PALS - Party Auto-Loot Split system.
This automatically distributes party treasure through the group regardless of who picks it up.

By: Tom ‘Magi’ Smallwood
e-mail: tomsmallwood@yahoo.com
Version 1.0
August 2002 pals_mainpals_onacquirepals_onunacquire pals_main pals_mainpals_onacquirepals_onacquirepals_onunacquirepals_onunacquire
a
a //::///////////////////////////////////////////////
//:: Name: pals_main
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script automatically divides loot for
the party. Gold is evenly split and given
to the players. Regular items are randomly
distributed. Plot items go to the person who
picked them up.
*/
//:://////////////////////////////////////////////
//:: Created By: Tom ‘Magi’ Smallwood (tomsmallwood@yahoo.com)
//:: Created On: August 2002
//:: Version 1.0
//:://////////////////////////////////////////////

string GetUnidentifedDescription(object oItem);
void AutoSplitItem(object oItem, object oPC);
void AutoSplitGold(object oContainer, object oPC);
void MarkInv(object oContainer, int iStatus);
void DoPALSAcquired(object oItem, object oPC);
void DoPALSUnAcquired(object oItem);

//

string GetUnidentifiedDescriptin(object oItem)
//return the base type of an item
//this is used if the item is unidentified
{
string sType;
int iItemType = GetBaseItemType(oItem);
switch(iItemType)
{
case BASE_ITEM_AMULET : sType = “Amulet”; break;
case BASE_ITEM_ARMOR : sType = “Armor”; break;
case BASE_ITEM_ARROW : sType = “Arrows”; break;
case BASE_ITEM_BASTARDSWORD : sType = “Bastard Sword”; break;
case BASE_ITEM_BATTLEAXE : sType = “Battleaxe”; break;
case BASE_ITEM_BELT : sType = “Belt”; break;
case BASE_ITEM_BOLT : sType = “Bolts”; break;
case BASE_ITEM_BOOK : sType = “Book”; break;
case BASE_ITEM_BOOTS : sType = “Boots”; break;
case BASE_ITEM_BRACER : sType = “Bracer”; break;
case BASE_ITEM_BULLET : sType = “Bullets”; break;
case BASE_ITEM_CBLUDGWEAPON : sType = “Bludgeoning weapon”; break;
case BASE_ITEM_CLOAK : sType = “Cloak”; break;
case BASE_ITEM_CLUB : sType = “Club”; break;
case BASE_ITEM_CPIERCWEAPON : sType = “Creature Piercing Weapon”; break;
case BASE_ITEM_CSLASHWEAPON : sType = “Creature Slashing Weapon”; break;
case BASE_ITEM_CSLSHPRCWEAP : sType = “Creature Slashing and Piercing Weapon”; break;
case BASE_ITEM_DAGGER : sType = “Dagger”; break;
case BASE_ITEM_DART : sType = “Dart”; break;
case BASE_ITEM_DIREMACE : sType = “Dire Mace”; break;
case BASE_ITEM_DOUBLEAXE : sType = “Double Axe”; break;
case BASE_ITEM_GEM : sType = “Gem”; break;
case BASE_ITEM_GLOVES : sType = “Gloves”; break;
case BASE_ITEM_GOLD : sType = “Gold”; break;
case BASE_ITEM_GREATAXE : sType = “Greataxe”; break;
case BASE_ITEM_GREATSWORD : sType = “Greatsword”; break;
case BASE_ITEM_HALBERD : sType = “Halberd”; break;
case BASE_ITEM_HANDAXE : sType = “Handaxe”; break;
case BASE_ITEM_HEALERSKIT : sType = “Healer’s Kit”; break;
case BASE_ITEM_HEAVYCROSSBOW : sType = “Heavy Crossbow”; break;
case BASE_ITEM_HEAVYFLAIL : sType = “Heavy Flail”; break;
case BASE_ITEM_HELMET : sType = “Helmet”; break;
case BASE_ITEM_INVALID : sType = “Invalid Object”; break;
case BASE_ITEM_KAMA : sType = “Kama”; break;
case BASE_ITEM_KATANA : sType = “Katana”; break;
case BASE_ITEM_KEY : sType = “Key”; break;
case BASE_ITEM_KUKRI : sType = “Kukri”; break;
case BASE_ITEM_LARGEBOX : sType = “Large Box”; break;
case BASE_ITEM_LARGESHIELD : sType = “Large Shield”; break;
case BASE_ITEM_LIGHTCROSSBOW : sType = “Light Crossbow”; break;
case BASE_ITEM_LIGHTFLAIL : sType = “Light Flail”; break;
case BASE_ITEM_LIGHTHAMMER : sType = “Light Hammer”; break;
case BASE_ITEM_LIGHTMACE : sType = “Light Mace”; break;
case BASE_ITEM_LONGBOW : sType = “Longbow”; break;
case BASE_ITEM_LONGSWORD : sType = “Longsword”; break;
case BASE_ITEM_MAGICROD : sType = “Magic Rod”; break;
case BASE_ITEM_MAGICSTAFF : sType = “Magic Staff”; break;
case BASE_ITEM_MAGICWAND : sType = “Magic Wand”; break;
case BASE_ITEM_MISCLARGE : sType = “Miscellaneous item”; break;
case BASE_ITEM_MISCMEDIUM : sType = “Miscellaneous item”; break;
case BASE_ITEM_MISCSMALL : sType = “Miscellaneous item”; break;
case BASE_ITEM_MISCTALL : sType = “Miscellaneous item”; break;
case BASE_ITEM_MISCTHIN : sType = “Miscellaneous item”; break;
case BASE_ITEM_MISCWIDE : sType = “Miscellaneous item”; break;
case BASE_ITEM_MORNINGSTAR : sType = “Morningstar”; break;
case BASE_ITEM_POTIONS : sType = “Potion”; break;
case BASE_ITEM_QUARTERSTAFF : sType = “Quarterstaff”; break;
case BASE_ITEM_RAPIER : sType = “Rapier”; break;
case BASE_ITEM_RING : sType = “Ring”; break;
case BASE_ITEM_SCIMITAR : sType = “Scimitar”; break;
case BASE_ITEM_SCROLL : sType = “Magical Scroll”; break;
case BASE_ITEM_SCYTHE : sType = “Scythe”; break;
case BASE_ITEM_SHORTBOW : sType = “Shortbow”; break;
case BASE_ITEM_SHORTSPEAR : sType = “Short Spear”; break;
case BASE_ITEM_SHORTSWORD : sType = “Short Sword”; break;
case BASE_ITEM_SHURIKEN : sType = “Shuriken”; break;
case BASE_ITEM_SICKLE : sType = “Sickle”; break;
case BASE_ITEM_SLING : sType = “Sling”; break;
case BASE_ITEM_SMALLSHIELD : sType = “Small Shield”; break;
case BASE_ITEM_SPELLSCROLL : sType = “Magical Scroll”; break;
case BASE_ITEM_THIEVESTOOLS : sType = “Thieves’ Tools”; break;
case BASE_ITEM_THROWINGAXE : sType = “Throwing Axe”; break;
case BASE_ITEM_TORCH : sType = “Torch”; break;
case BASE_ITEM_TOWERSHIELD : sType = “Tower Shield”; break;
case BASE_ITEM_TRAPKIT : sType = “Trap Kit”; break;
case BASE_ITEM_TWOBLADEDSWORD: sType = “Two-bladed Sword”; break;
case BASE_ITEM_WARHAMMER : sType = “Warhammer”; break;
default : sType = “Object”; break;
}
return sType;
}

void MarkInv(object oContainer, int iStatus)
{
//this marks all items in a chest to be autosplit
//It is called from the chest’s OnOpen event
//only items with a pals_owner of 1 get split
//
//posible values for pals_owner are:
// 0 = (default) never owned, don’t autosplit. Useually something that starts on the ground
// 1 = treasure, autosplit (marked in this proceedure
// 2 = dropped by a pc, don’t autosplit

object oItem=GetFirstItemInInventory(oContainer);
while(oItem!=OBJECT_INVALID)
{
//note this does not check for equiped items, but is designed for chests anyway
//all container gold is given when object is opened so destroy it here
if(GetTag(oItem)==“NW_IT_GOLD001”)
DestroyObject(oItem);
else
SetLocalInt(oItem,“pals_owner”,iStatus);
oItem=GetNextItemInInventory(oContainer);
}
}

void AutoSplitItem(object oItem, object oPC)
{
//this procedure splits items when they are picked up
//only items with a pals_owner variable set to 1 will be picked up

object oNewObject;

//Don’t distribute the item unless it has a tag of 1 (no tag indicates already owned)
if(GetLocalInt(oItem,“pals_owner”)==1)
{
int iNumPlayers = 1;
int iShare;
object oNextFactionMember;
object oFactionLead=GetFirstFactionMember(oPC);
string sName;

//if identifed, get the name, otherwise, get the unideintifed base type
if (GetIdentified(oItem))
  sName=GetName(oItem);
else
  sName="Unidentifed "+GetUnidentifiedDescriptin(oItem);//"Unidentifed";

//count people in the party
while(GetNextFactionMember(oPC)!=OBJECT_INVALID)
  iNumPlayers++;

//pick a random loot winner
int x=Random(iNumPlayers)+1;
int y=1;
object oWinner=GetFirstFactionMember(oPC);
while(y!=x)
{
  oWinner=GetNextFactionMember(oPC);
  y++;
}

//if it is a plot item, give it to the person who picked it up
if(GetPlotFlag(oItem))
  oWinner=oPC;

int iStackSize=GetNumStackedItems(oItem);

//Give the item to the winner, unless the person who picks it up wins.
//don't destroy/create if it goes to the person who picked it up (saves on spam)
if(oWinner!=oPC)
{
  oNewObject=CreateItemOnObject(GetTag(oItem),oWinner,iStackSize);
  SetLocalInt(oNewObject,"pals_owner",2);
  DestroyObject(oItem);
} else
{
  SetLocalInt(oItem,"pals_owner",2);
}

//Send message to whole party about who got what
object oParty=GetFirstFactionMember(oPC);
while(oParty!=OBJECT_INVALID)
{
  if(iStackSize>1)
    SendMessageToPC(oParty,"The party has aquired an item ["+sName+" ("+IntToString(iStackSize)+")] which goes to "+GetName(oWinner));
  else
    SendMessageToPC(oParty,"The party has aquired an item ["+sName+"] which goes to "+GetName(oWinner));
  oParty=GetNextFactionMember(oPC);
}
//if it is a plot item, let the DM know it was picked up
if(GetPlotFlag(oItem))
  SendMessageToAllDMs(GetName(oWinner)+" picked up the plot item: "+GetName(oItem));

}
}

//Evenly distribute an amount of gold to all characters in oPC’s party.
//Note that a few gold pieces may be created to make sure everyone gets an even share.
void AutoSplitGold(object oContainer, object oPC)
{
//if there is no gold, don’t split it
if(GetGold(oContainer)==0) return;
int iNumPlayers = 0;
int iShare;

//if pet or familiar kills the critter, assign to the master.
if(!GetIsPC(oPC))
oPC=GetMaster(oPC);

//if the critter was not killed by a player, just drop the gold and don’t distribute it
if(!GetIsPC(oPC) || (oPC==OBJECT_INVALID))
return; //not killed by a player;

object oWinner=GetFirstFactionMember(oPC);
int iGold=GetGold(oContainer);
TakeGoldFromCreature(iGold,oContainer,TRUE);

//if creatures possesess an item with the tag of NoGoldDrop, then don’t drop gold on death
if(GetItemPossessedBy(oContainer,“NoGoldDrop”)!=OBJECT_INVALID)
return;

//count the players
while(oWinner!=OBJECT_INVALID)
{
iNumPlayers++;
oWinner=GetNextFactionMember(oPC);
}

if(iNumPlayers==0) iNumPlayers=1;//a divide by zero check
iShare=FloatToInt(iGold/iNumPlayers+0.5);//calculate individule shares, round up
if(iShare>0)
{
PlaySound(“it_coins”);
oWinner=GetFirstFactionMember(oPC);
while(oWinner!=OBJECT_INVALID)
{
SendMessageToPC(oWinner,“Your share of the party treasure is “+IntToString(iShare)+” gold pieces.”);
GiveGoldToCreature(oWinner,iShare);
oWinner=GetNextFactionMember(oPC);
}
}
}

void DoPALSAcquire(object oItem, object oPC)
//If an item is picked up and marked for splitting in the party (pals_owner=1)
//this script calls AutoSplitLoot to divide it into the party.
//If it is not marked for autosplitting, it makes sure the item is marked as player owned
//changing the default of 0 if needed.
//
//This is called from the OnAcquiredItem event
{
if(GetLocalInt(oItem,“pals_owner”)==1)
{
AutoSplitItem(oItem,oPC);
} else
{
if(GetIsPC(GetItemPossessor(oItem)))
SetLocalInt(oItem,“pals_owner”,2);//make the item as player owned
}

}

void DoPALSUnAcquired(object oItem)
{
//This script marks dropped items to be set for autolooting (pals_owner = 1)
//unless they were already owned by a PC (pals_owner = 2)
if(GetLocalInt(oItem,“pals_owner”)!=2)//this sets a dropped item to be autosplit
{
SetLocalInt(oItem,“pals_owner”,1);
}
}

NCS V1.0B NCS V1.0B 
pals_ownerÿÿÿø 3 "ÿÿÿø ÿÿÿø S Eÿÿÿü Ù -
pals_ownerÿÿÿô 7 e ÿÿÿø
pals_ownerÿÿÿô 3 < ÿÿÿø e ÿÿÿü ÿÿÿà |ÿÿÿø e ÿÿÿüÿÿÿä L 'ÿÿÿä ýÿÿÿø e ÿÿÿü 6 Unidentifed ÿÿÿÜ ·#ÿÿÿø e ÿÿÿü ÿÿÿÜ } " ÿÿÿì $ÿÿÿèe ÿÿÿü ÿÿÿËÿÿÿè ÿÿÿø e ÿÿÿü ÿÿÿø e ÿÿÿü ÿÿÿÐ |ÿÿÿø e ÿÿÿüÿÿÿø ÿÿÿð A ÿÿÿÐ }ÿÿÿø e ÿÿÿüÿÿÿø $ÿÿÿôe ÿÿÿü ÿÿÿ³ÿÿÿØ Ç "ÿÿÿÔ ÿÿÿø e ÿÿÿü ÿÿÿÔ Ûÿÿÿø e ÿÿÿüÿÿÿø ÿÿÿÌ " pÿÿÿü ÿÿÿô ÿÿÿÌ ¨ ÿÿÿÔ e ÿÿÿü
pals_ownerÿÿÿÐ 7 ÿÿÿÐ ñ '
pals_ownerÿÿÿÌ 7 ÿÿÿÈ |ÿÿÿø e ÿÿÿüÿÿÿü " ÿÿÿø ƒ The party has aquired an item [ÿÿÿä # (#ÿÿÿô \# )] which goes to #ÿÿÿð ý#ÿÿÿø v e The party has aquired an item [ÿÿÿä # ] which goes to #ÿÿÿð ý#ÿÿÿø v ÿÿÿÈ }ÿÿÿø e ÿÿÿü ÿÿþ×ÿÿÿÐ Ç Mÿÿÿô ý picked up the plot item: #ÿÿÿÌ ý# 3 e ÿÿÿØ e ÿÿÿüe ÿÿÿø ÿÿÿô ÿÿÿø e ÿÿÿüÿÿÿü ÿÿÿü % ”ÿÿÿü % œÿÿÿü % £ÿÿÿü % «ÿÿÿü % ºÿÿÿü % Åÿÿÿü % Ëÿÿÿü J % Òÿÿÿü % Øÿÿÿü N % ßÿÿÿü e % çÿÿÿü G % ðÿÿÿü P % aÿÿÿü % aÿÿÿü F % aÿÿÿü E % a+ÿÿÿü H % aEÿÿÿü % alÿÿÿü % atÿÿÿü % azÿÿÿü ! % a…ÿÿÿü M % a‘ÿÿÿü $ % a–ÿÿÿü L % ažÿÿÿü % a¤ÿÿÿü
% a®ÿÿÿü
% aºÿÿÿü & % aÃÿÿÿü ’ % aÌÿÿÿü % aÚÿÿÿü # % aêÿÿÿü % a÷ÿÿÿü % aÿÿÿÿü ( % ÿÿÿü ) % ÿÿÿü A % ÿÿÿü * % "ÿÿÿü B % )ÿÿÿü 8 % 4ÿÿÿü a % Bÿÿÿü % Rÿÿÿü % % _ÿÿÿü % mÿÿÿü % yÿÿÿü % ‚ÿÿÿü , % ÿÿÿü - % ˜ÿÿÿü . % ¥ÿÿÿü " % ±ÿÿÿü % Åÿÿÿü % Ùÿÿÿü + % íÿÿÿü O % ÿÿÿü D % ÿÿÿü / % )ÿÿÿü 1 % 6ÿÿÿü 2 % >ÿÿÿü 3 % Lÿÿÿü 4 % Tÿÿÿü 5 % Zÿÿÿü 6 % dÿÿÿü 7 % tÿÿÿü % |ÿÿÿü : % †ÿÿÿü % “ÿÿÿü ; % ÿÿÿü < % ªÿÿÿü = % ²ÿÿÿü % ¹ÿÿÿü K % Çÿÿÿü > % ×ÿÿÿü ? % çÿÿÿü % õÿÿÿü 9 % üÿÿÿü @ %

ÿÿÿü %
ÿÿÿü %
&
A Amuletÿÿÿð e ÿÿÿü
A Armorÿÿÿð e ÿÿÿü
$ Arrowsÿÿÿð e ÿÿÿü

Bastard Swordÿÿÿð e ÿÿÿü á Battleaxeÿÿÿð e ÿÿÿü À Beltÿÿÿð e ÿÿÿü ¤ Boltsÿÿÿð e ÿÿÿü ‡ Bookÿÿÿð e ÿÿÿü k Bootsÿÿÿð e ÿÿÿü N Bracerÿÿÿð e ÿÿÿü 0 aBulletsÿÿÿð e ÿÿÿü Bludgeoning weaponÿÿÿð e ÿÿÿü ç Cloakÿÿÿð e ÿÿÿü Ê Clubÿÿÿð e ÿÿÿü ® Creature Piercing Weaponÿÿÿð e ÿÿÿü ~ Creature Slashing Weaponÿÿÿð e ÿÿÿü N %Creature Slashing and Piercing Weaponÿÿÿð e ÿÿÿü Daggerÿÿÿð e ÿÿÿü aó Dartÿÿÿð e ÿÿÿü a× Dire Maceÿÿÿð e ÿÿÿü a¶
Double Axeÿÿÿð e ÿÿÿü a” Gemÿÿÿð e ÿÿÿü ay Glovesÿÿÿð e ÿÿÿü a[ Goldÿÿÿð e ÿÿÿü a? Greataxeÿÿÿð e ÿÿÿü a
Greatswordÿÿÿð e ÿÿÿü ý aHalberdÿÿÿð e ÿÿÿü Þ aHandaxeÿÿÿð e ÿÿÿü ¿ Healer’s Kitÿÿÿð e ÿÿÿü › Heavy Crossbowÿÿÿð e ÿÿÿü u Heavy Flailÿÿÿð e ÿÿÿü R Helmetÿÿÿð e ÿÿÿü 4 Invalid Objectÿÿÿð e ÿÿÿü Kamaÿÿÿð e ÿÿÿü ò Katanaÿÿÿð e ÿÿÿü Ô Keyÿÿÿð e ÿÿÿü ¹ Kukriÿÿÿð e ÿÿÿü œ Large Boxÿÿÿð e ÿÿÿü { Large Shieldÿÿÿð e ÿÿÿü W Light Crossbowÿÿÿð e ÿÿÿü 1 Light Flailÿÿÿð e ÿÿÿü Light Hammerÿÿÿð e ÿÿÿü ê
Light Maceÿÿÿð e ÿÿÿü È aLongbowÿÿÿð e ÿÿÿü © Longswordÿÿÿð e ÿÿÿü ˆ Magic Rodÿÿÿð e ÿÿÿü g Magic Staffÿÿÿð e ÿÿÿü D
Magic Wandÿÿÿð e ÿÿÿü " Miscellaneous itemÿÿÿð e ÿÿÿü ø Miscellaneous itemÿÿÿð e ÿÿÿü Î Miscellaneous itemÿÿÿð e ÿÿÿü ¤ Miscellaneous itemÿÿÿð e ÿÿÿü z Miscellaneous itemÿÿÿð e ÿÿÿü P Miscellaneous itemÿÿÿð e ÿÿÿü & Morningstarÿÿÿð e ÿÿÿü Potionÿÿÿð e ÿÿÿü å Quarterstaffÿÿÿð e ÿÿÿü Á Rapierÿÿÿð e ÿÿÿü £ Ringÿÿÿð e ÿÿÿü ‡ Scimitarÿÿÿð e ÿÿÿü g Magical Scrollÿÿÿð e ÿÿÿü A Scytheÿÿÿð e ÿÿÿü # Shortbowÿÿÿð e ÿÿÿü Short Spearÿÿÿð e ÿÿÿü à Short Swordÿÿÿð e ÿÿÿü ½ Shurikenÿÿÿð e ÿÿÿü  Sickleÿÿÿð e ÿÿÿü  Slingÿÿÿð e ÿÿÿü b Small Shieldÿÿÿð e ÿÿÿü > Magical Scrollÿÿÿð e ÿÿÿü Thieves’ Toolsÿÿÿð e ÿÿÿü ò Throwing Axeÿÿÿð e ÿÿÿü Î Torchÿÿÿð e ÿÿÿü ± Tower Shieldÿÿÿð e ÿÿÿü  Trap Kitÿÿÿð e ÿÿÿü m Two-bladed Swordÿÿÿð e ÿÿÿü E Warhammerÿÿÿð e ÿÿÿü $ Objectÿÿÿð e ÿÿÿü e ÿÿÿüÿÿÿø ÿÿÿì e ÿÿÿô e ÿÿÿüe ÿÿÿøe ÿÿÿü #include “pals_main”
/*
PALS - Party Auto-Loot Split system.
This automatically distributes party treasure through the group regardless of who picks it up.

By: Tom 'Magi' Smallwood
[tomsmallwood@yahoo.com](mailto:tomsmallwood@yahoo.com)
Version 1.0
August 2002

*/

void main()
{
//Take care of autospliting loot
DoPALSAcquire(GetModuleItemAcquired(),GetItemPossessor(GetModuleItemAcquired()));
}
#include “pals_main”
/*
PALS - Party Auto-Loot Split system.
This automatically distributes party treasure through the group regardless of who picks it up.

By: Tom 'Magi' Smallwood
[tomsmallwood@yahoo.com](mailto:tomsmallwood@yahoo.com)
Version 1.0
August 2002

*/
void main()
{
DoPALSUnAcquired(GetModuleItemLost());
}
NCS V1.0B z $
pals_ownerÿÿÿø 3 -
pals_ownerÿÿÿô 7 e ÿÿÿü [/quote]

Auto loot as in whenever something drops it automatically goes into your inventory from whenever it is in the map?

Correct.

Well… this might be a bit of a spoiler… but we plan on having a method for items being picked up automatically ( to a degree ) for you. Don’t think we’ll straight up pick everything that drops automatically, as that’s slightly overly convenient, and takes away a bit from the other mechanic we plan on introducing.

More like an item affix that ups the range of “loot take”

Envoyé de mon iPod touch à l’aide de Tapatalk

Or another kind of pet with that kind of ability sounds nice :smile: