NWScript :
//:///
//:: ly_theft.nss
//:: Updated Lylver 2006-03-04
//:: Created Lylver 2006-01-08
//:///
// Return Item inventory width
// Uses Get2DAString
#include "NW_I0_GENERIC"
#include "X0_I0_SPELLS"
int GetInvSlotWidth(int nBaseType, object o2da)
{
int nSlotWidth = GetLocalInt(o2da,"baseitemsInvSlotWidth"+IntToString(nBaseType));
if( nSlotWidth == 0 ){
nSlotWidth = StringToInt(Get2DAString("baseitems","InvSlotWidth",nBaseType)) ;
SetLocalInt(o2da,"baseitemsInvSlotWidth"+IntToString(nBaseType),nSlotWidth);
}
return nSlotWidth ;
}
int GetInvSlotHeigth(int nBaseType, object o2da)
{
int nSlotHeight = GetLocalInt(o2da,"baseitemsInvSlotHeight"+IntToString(nBaseType));
if( nSlotHeight == 0 ){
nSlotHeight = StringToInt(Get2DAString("baseitems","InvSlotHeight",nBaseType)) ;
SetLocalInt(o2da,"baseitemsInvSlotHeight"+IntToString(nBaseType),nSlotHeight);
}
return nSlotHeight ;
}
int GetWeaponSize(int nBaseType, object o2da)
{
int nWeaponSize = GetLocalInt(o2da,"baseitemsWeaponSize"+IntToString(nBaseType));
if( nWeaponSize == 0 ){
nWeaponSize = StringToInt(Get2DAString("baseitems","WeaponSize",nBaseType)) ;
SetLocalInt(o2da,"baseitemsWeaponSize"+IntToString(nBaseType),nWeaponSize);
}
return nWeaponSize ;
}
int GetItemWeight(int nBaseType, object o2da)
{
int nTenthLBS = GetLocalInt(o2da,"baseitemsTenthLBS"+IntToString(nBaseType));
if( nTenthLBS == 0 ){
nTenthLBS = StringToInt(Get2DAString("baseitems","TenthLBS",nBaseType)) ;
SetLocalInt(o2da,"baseitemsTenthLBS"+IntToString(nBaseType),nTenthLBS);
}
return nTenthLBS ;
}
void main(){
object o2da = GetLocalObject(GetModule(),"DB_2DA");
object oVictim = OBJECT_SELF ;
object oThief = GetLocalObject(oVictim,"THIEF") ;
DeleteLocalObject(oVictim,"THIEF");
object oItem = GetLocalObject(oVictim,"ITEM") ;
DeleteLocalObject(oVictim,"ITEM");
int nItStackSize = GetLocalInt(oVictim,"ITSTACKSIZE") ;
DeleteLocalInt(oVictim,"ITSTACKSIZE");
int nBaseType = GetBaseItemType(oItem);
int nHeight = GetInvSlotHeigth(nBaseType,o2da) ;
int nWidth = GetInvSlotWidth(nBaseType,o2da) ;
int nWeight = GetItemWeight(nBaseType,o2da) ;
int nSize = GetWeaponSize(nBaseType,o2da) ;
SendMessageToPC(oThief,"Entree dans ly_theft.nss");
string sInfo = " Debug :\n"+"Largeur de l'objet : "+IntToString(nWidth)+
" Hauteur de l'objet : "+IntToString(nHeight)+
" Taille de l'objet : "+IntToString(nSize)+
" Poids de l'objet (TenLBS): "+IntToString(nWeight)+
" Victime : "+GetName(oVictim)+
" Voleur : "+GetName(oThief)+
" Objet : "+GetName(oItem) ;
WriteTimestampedLogEntry(sInfo);
SendMessageToAllDMs(sInfo);
// 2006-04-09 Gestion des TrapKits
if( GetItemHasItemProperty(oItem,ITEM_PROPERTY_TRAP) ){
object oTrap = GetNearestTrapToObject(oVictim,FALSE);
if( GetIsObjectValid(oTrap) ){
if( GetTrapCreator(oTrap) == oVictim ){
RemoveSpecificEffect(EFFECT_TYPE_INVISIBILITY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_IMPROVEDINVISIBILITY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_SANCTUARY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_ETHEREAL, oVictim);
if( GetActionMode(oVictim,ACTION_MODE_STEALTH) ){
SetActionMode(oVictim,ACTION_MODE_STEALTH,FALSE);
}
}
int nDetectDC = GetTrapDetectDC(oTrap);
int nDisarmDC = GetTrapDisarmDC(oTrap);
string sMesg = "Piege pose par "+GetName(oVictim)+
", SpotDC : "+IntToString(nDetectDC)+", DisarmDC : "+
IntToString(nDisarmDC);
SendMessageToAllDMs(sMesg);
WriteTimestampedLogEntry(sMesg);
}
}
//
// vol ?
if( (GetLastDisturbed() == oThief) && GetIsPC(oThief) ){
// bah oui...
SendMessageToPC(oThief,""+GetName(oVictim));
}
if( GetInventoryDisturbItem() == oItem ){
SendMessageToPC(oThief,"");
// meme item
}
if( GetInventoryDisturbType() == INVENTORY_DISTURB_TYPE_STOLEN ){
SendMessageToPC(oThief,"");
}
if( GetIsPC(oVictim) ){
SendMessageToPC(oVictim,
"Vol de "+GetName(oItem)+" par "+GetName(oThief)+sInfo );
}
if( GetIsPC(oThief) ){
SendMessageToPC(oThief,
"Vol de "+GetName(oItem)+" sur "+GetName(oVictim)+sInfo );
}
if( ( (nHeight * nWidth >= 4) && ( nWeight >= 10 ) ) ||
( (nHeight * nWidth >= 2) && ( nWeight >= 30 ) ) ){
SendMessageToPC(oThief,"Objet hors norme, restitution");
SendMessageToPC(oVictim,"Objet hors norme, restitution");
object oItemRetour = CopyItem(oItem, oVictim, TRUE) ;
SetPlotFlag(oItemRetour, GetPlotFlag(oItem));
SetStolenFlag(oItemRetour, FALSE);
SetIdentified(oItemRetour, GetIdentified(oItem)) ;
int nValue = GetGoldPieceValue(oItem)/5 ;
// pour correspondre au prix de vente des objets voles sur le Bouchon
DestroyObject(oItem) ;
int nPick = GetSkillRank(SKILL_PICK_POCKET,oThief) + d20() ;
int nDetect = GetSkillRank(SKILL_SPOT,oVictim) + d20() ;
if( nPick > nDetect ){
float fMarge = pow(10.0, IntToFloat((7 + nPick - nDetect)/10) ) ;
if( FloatToInt(fMarge) < nValue ) nValue = FloatToInt(fMarge) ;
SendMessageToPC(oThief,"compensation pour talent PickPocket : "+IntToString(nValue)+"");
SendMessageToAllDMs("compensation pour talent PickPocket : "+IntToString(nValue)+"");
GiveGoldToCreature(oThief,nValue) ;
SendMessageToPC(oVictim,"compensation pour talent PickPocket : "+IntToString(nValue)+"");
AssignCommand(oVictim,TakeGoldFromCreature(nValue,oVictim,TRUE));
// 3 de marge = 10 po, 6 => 20 po, 10 => 50po, 13 etc
}
}
// }
// }
// }
}Note : le code affiché ci-dessus n'est pas rendu tel qu'il devrait l'être réellement, en particulier des sauts de lignes sont automatiquement insérés pour éviter de casser la mise en page. En le copiant/collant, vous résoudrez ce problème.
//:///
//:: ly_theft.nss
//:: Updated Lylver 2006-03-04
//:: Created Lylver 2006-01-08
//:///
// Return Item inventory width
// Uses Get2DAString
#include "NW_I0_GENERIC"
#include "X0_I0_SPELLS"
int GetInvSlotWidth(int nBaseType, object o2da)
{
int nSlotWidth = GetLocalInt(o2da,"baseitemsInvSlotWidth"+IntToString(nBaseType));
if( nSlotWidth == 0 ){
nSlotWidth = StringToInt(Get2DAString("baseitems","InvSlotWidth",nBaseType)) ;
SetLocalInt(o2da,"baseitemsInvSlotWidth"+IntToString(nBaseType),nSlotWidth);
}
return nSlotWidth ;
}
int GetInvSlotHeigth(int nBaseType, object o2da)
{
int nSlotHeight = GetLocalInt(o2da,"baseitemsInvSlotHeight"+IntToString(nBaseType));
if( nSlotHeight == 0 ){
nSlotHeight = StringToInt(Get2DAString("baseitems","InvSlotHeight",nBaseType)) ;
SetLocalInt(o2da,"baseitemsInvSlotHeight"+IntToString(nBaseType),nSlotHeight);
}
return nSlotHeight ;
}
int GetWeaponSize(int nBaseType, object o2da)
{
int nWeaponSize = GetLocalInt(o2da,"baseitemsWeaponSize"+IntToString(nBaseType));
if( nWeaponSize == 0 ){
nWeaponSize = StringToInt(Get2DAString("baseitems","WeaponSize",nBaseType)) ;
SetLocalInt(o2da,"baseitemsWeaponSize"+IntToString(nBaseType),nWeaponSize);
}
return nWeaponSize ;
}
int GetItemWeight(int nBaseType, object o2da)
{
int nTenthLBS = GetLocalInt(o2da,"baseitemsTenthLBS"+IntToString(nBaseType));
if( nTenthLBS == 0 ){
nTenthLBS = StringToInt(Get2DAString("baseitems","TenthLBS",nBaseType)) ;
SetLocalInt(o2da,"baseitemsTenthLBS"+IntToString(nBaseType),nTenthLBS);
}
return nTenthLBS ;
}
void main(){
object o2da = GetLocalObject(GetModule(),"DB_2DA");
object oVictim = OBJECT_SELF ;
object oThief = GetLocalObject(oVictim,"THIEF") ;
DeleteLocalObject(oVictim,"THIEF");
object oItem = GetLocalObject(oVictim,"ITEM") ;
DeleteLocalObject(oVictim,"ITEM");
int nItStackSize = GetLocalInt(oVictim,"ITSTACKSIZE") ;
DeleteLocalInt(oVictim,"ITSTACKSIZE");
int nBaseType = GetBaseItemType(oItem);
int nHeight = GetInvSlotHeigth(nBaseType,o2da) ;
int nWidth = GetInvSlotWidth(nBaseType,o2da) ;
int nWeight = GetItemWeight(nBaseType,o2da) ;
int nSize = GetWeaponSize(nBaseType,o2da) ;
SendMessageToPC(oThief,"Entree dans ly_theft.nss");
string sInfo = " Debug :\n"+"Largeur de l'objet : "+IntToString(nWidth)+
" Hauteur de l'objet : "+IntToString(nHeight)+
" Taille de l'objet : "+IntToString(nSize)+
" Poids de l'objet (TenLBS): "+IntToString(nWeight)+
" Victime : "+GetName(oVictim)+
" Voleur : "+GetName(oThief)+
" Objet : "+GetName(oItem) ;
WriteTimestampedLogEntry(sInfo);
SendMessageToAllDMs(sInfo);
// 2006-04-09 Gestion des TrapKits
if( GetItemHasItemProperty(oItem,ITEM_PROPERTY_TRAP) ){
object oTrap = GetNearestTrapToObject(oVictim,FALSE);
if( GetIsObjectValid(oTrap) ){
if( GetTrapCreator(oTrap) == oVictim ){
RemoveSpecificEffect(EFFECT_TYPE_INVISIBILITY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_IMPROVEDINVISIBILITY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_SANCTUARY, oVictim);
RemoveSpecificEffect(EFFECT_TYPE_ETHEREAL, oVictim);
if( GetActionMode(oVictim,ACTION_MODE_STEALTH) ){
SetActionMode(oVictim,ACTION_MODE_STEALTH,FALSE);
}
}
int nDetectDC = GetTrapDetectDC(oTrap);
int nDisarmDC = GetTrapDisarmDC(oTrap);
string sMesg = "Piege pose par "+GetName(oVictim)+
", SpotDC : "+IntToString(nDetectDC)+", DisarmDC : "+
IntToString(nDisarmDC);
SendMessageToAllDMs(sMesg);
WriteTimestampedLogEntry(sMesg);
}
}
//
// vol ?
if( (GetLastDisturbed() == oThief) && GetIsPC(oThief) ){
// bah oui...
SendMessageToPC(oThief,""+GetName(oVictim));
}
if( GetInventoryDisturbItem() == oItem ){
SendMessageToPC(oThief,"");
// meme item
}
if( GetInventoryDisturbType() == INVENTORY_DISTURB_TYPE_STOLEN ){
SendMessageToPC(oThief,"");
}
if( GetIsPC(oVictim) ){
SendMessageToPC(oVictim,
"Vol de "+GetName(oItem)+" par "+GetName(oThief)+sInfo );
}
if( GetIsPC(oThief) ){
SendMessageToPC(oThief,
"Vol de "+GetName(oItem)+" sur "+GetName(oVictim)+sInfo );
}
if( ( (nHeight * nWidth >= 4) && ( nWeight >= 10 ) ) ||
( (nHeight * nWidth >= 2) && ( nWeight >= 30 ) ) ){
SendMessageToPC(oThief,"Objet hors norme, restitution");
SendMessageToPC(oVictim,"Objet hors norme, restitution");
object oItemRetour = CopyItem(oItem, oVictim, TRUE) ;
SetPlotFlag(oItemRetour, GetPlotFlag(oItem));
SetStolenFlag(oItemRetour, FALSE);
SetIdentified(oItemRetour, GetIdentified(oItem)) ;
int nValue = GetGoldPieceValue(oItem)/5 ;
// pour correspondre au prix de vente des objets voles sur le Bouchon
DestroyObject(oItem) ;
int nPick = GetSkillRank(SKILL_PICK_POCKET,oThief) + d20() ;
int nDetect = GetSkillRank(SKILL_SPOT,oVictim) + d20() ;
if( nPick > nDetect ){
float fMarge = pow(10.0, IntToFloat((7 + nPick - nDetect)/10) ) ;
if( FloatToInt(fMarge) < nValue ) nValue = FloatToInt(fMarge) ;
SendMessageToPC(oThief,"compensation pour talent PickPocket : "+IntToString(nValue)+"");
SendMessageToAllDMs("compensation pour talent PickPocket : "+IntToString(nValue)+"");
GiveGoldToCreature(oThief,nValue) ;
SendMessageToPC(oVictim,"compensation pour talent PickPocket : "+IntToString(nValue)+"");
AssignCommand(oVictim,TakeGoldFromCreature(nValue,oVictim,TRUE));
// 3 de marge = 10 po, 6 => 20 po, 10 => 50po, 13 etc
}
}
// }
// }
// }
}