( it’d probly be better to set all contents stolen in the OnOpen but it could work here also )
there’s some code probs there…
GetModuleItemAcquired() returns an object, but it’s being compared against a string. objects can be compared only against objects, and/or strings against strings.
and yep that’s an infinite loop (if it could compile…). The basics of a loop go like this: First you want to set a variable. Then compare that variable against something (of the same type). Then do something to the variable while inside the loop, so that the condition gets tested again (and hence should end at some value of said variable).
object oItemInContainer = GetFirstItemInInventory(OBJECT_SELF);
// this is testing 'oItemInContainer' against 'OBJECT_INVALID' -
// they are the same type, but not necessarily the same value.
while (GetIsObjectValid(oItemInContainer))
{
SetStolenFlag(oItemInContainer, TRUE);
// this will change the value of 'oItemInContainer' to OBJECT_INVALID
// when there are no more items in the container to iterate over.
oItemInContainer = GetNextItemInInventory(OBJECT_SELF);
}
and, since the item that was picked out of the container is (probably) not in the container anymore, set it to stolen also:
This script isn’t used in the OC (it isn’t attached to any object). If you want to set a Stolen flag on the looted items use the OnAcquire module script.
Is the K mod script for every item acquired? I do not want to flag every single acquired item.
Cleaned up.
// 11_a_stealing
/*
Give the player chaos points if they steal from the object this script is attached to.
*/
// JYL 03/16/06
#include "ginc_misc"
void main()
{
object oTarget = GetLastDisturbed();
object oArea = GetArea(OBJECT_SELF);
string sName = GetName(oTarget);
object oItem = GetFirstItemInInventory(OBJECT_SELF); //picks up first item in called object - the container
if (GetLocalInt(oArea, sName) != 1)
{
AdjustAlignment(oTarget, ALIGNMENT_CHAOTIC, 1);
AdjustAlignment(oTarget, ALIGNMENT_EVIL, 1);
SetLocalInt(oArea, sName, 1);
while ( GetIsObjectValid(oItem)); //cycle all items looted, goes into the align change function
{
SendMessageToPC(GetFirstPC(),"You thief you"); // XD
SetStolenFlag(oItem, TRUE); //flag looted item as stolen
oItem = GetNextItemInInventory(OBJECT_SELF); // move to next object
}
}
SendMessageToPC(GetFirstPC(),"Pillager!"); // XD
SetStolenFlag(GetInventoryDisturbItem(), TRUE); //since the item that was picked out of the container is (probably) not in the container anymore, set it to stolen also:
}
I remember seeing align changes while rifling one of the houses in West Harbor, or its just my imagination. Anyway i’ll try it again.
// 11_a_stealing
/*
Give the player chaos points if they steal from the object this script is attached to.
*/
// JYL 03/16/06
#include "ginc_misc"
void main()
{
object oTarget = GetLastDisturbed();
object oArea = GetArea(OBJECT_SELF);
string sName = GetName(oTarget);
object oItem = GetFirstItemInInventory(OBJECT_SELF); //picks up first item in called object - the container
if (GetLocalInt(oArea, sName) != 1)
{
AdjustAlignment(oTarget, ALIGNMENT_CHAOTIC, 2);
AdjustAlignment(oTarget, ALIGNMENT_EVIL, 2);
SetLocalInt(oArea, sName, 1);
while ( GetIsObjectValid(oItem)) //cycle all items looted, goes into the align change function
{
SendMessageToPC(GetFirstPC(),"You thief you"); // XD
SetStolenFlag(oItem, TRUE); //flag looted item as stolen
oItem = GetNextItemInInventory(OBJECT_SELF); // move to next object
}
}
SendMessageToPC(GetFirstPC(),"Pillager!"); // XD
SetStolenFlag(GetInventoryDisturbItem(), TRUE); //since the item that was picked out of the container is (probably) not in the container anymore, set it to stolen also:
}
the while loop will not fire if you use loot all button… perhaps putting it in onopen is better…