Got a problem - basically I have a script where all I want it to do is that when three books are acquired (all have same tag) an effect is played and a variable changed. I've gone through lilac soul's on acquire item method and made sure everything is set up so that the books are a tagged module item. My problem is i don't know how to convert the module item in the script so it is counted as a value of nbooks which will then fire the 'if' statement script.
void main()
{
object oPC = GetModuleItemAcquiredBy();
object oItem;
oItem = GetModuleItemAcquired();
if (!GetIsPC(oPC)) return;
//int nBooks = oItem;
//int nBooks = GetNumItems(oPC, "Conjugation");
if (nBooks == 3)
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_L),oPC, 0.0);
SetLocalString(oPC, "hasbooks", "TRUE");
return;
}
onInventoryDisturbed script
Débuté par
TrekSL
, juil. 21 2011 01:15
#1
Posté 21 juillet 2011 - 01:15
#2
Posté 21 juillet 2011 - 01:36
Could try:
if( GetNumItems( oPC, "Conjugation" ) == 3)
if( GetNumItems( oPC, "Conjugation" ) == 3)
#3
Posté 21 juillet 2011 - 01:40
You may want to make sure that the acquiring of anything else does not accidently fire that by enclosing that in another if.
IE:
if( GetTag( oItem ) == "Conjugation" )
{
if( GetNumItems( oPC, "Conjugation" ) == 3 )
{
// Do stuff here
}
}
IE:
if( GetTag( oItem ) == "Conjugation" )
{
if( GetNumItems( oPC, "Conjugation" ) == 3 )
{
// Do stuff here
}
}
#4
Posté 21 juillet 2011 - 01:54
trying that - it returns no right bracket on expression for the second if statement (if's and nested if's confuse the heck out of me)
EDIT - ahh missed out an include
EDIT - ahh missed out an include
Modifié par TrekSL, 21 juillet 2011 - 02:09 .
#5
Posté 21 juillet 2011 - 04:42
you shouldn't use a LocalString , you should use a LocalInt. it doesn't make sense to save a string "TRUE" you should set it to true. Baragg safty step isn't good enough. the player can drop a book and pick it up again and fire the effect part each time.
Use your Local Variable as protection instead.
Use your Local Variable as protection instead.
#6
Posté 21 juillet 2011 - 05:17
Here's a script that I use to allow a player to take up to 3 items out of a chest. While there are more choices available, they can only pick/take 3. Written for NWN2 so may need some edits. Also, this destroys any remaining inventory in the chest and then destroys the chest itself (used as a "reward chest"):
void main()
{
object oSelf = OBJECT_SELF; // This is the chest that has this script OnInventoryDisturbed
object oMasterPC = GetFirstPC(TRUE);
object oPC = GetFirstPC(FALSE);
int nRewardValue = 3;
int nCurrentValue = 0;
// If we have not yet taken 3 items from chest
if(nCurrentValue != nRewardValue)
{
// Add +1 each time an item is taken
nCurrentValue += 1;
SetLocalInt(oSelf, "CurrentValue", nCurrentValue);
int nNewValue = GetLocalInt(oSelf, "CurrentValue");
// If we have taken 3 items, close the GUI screen, destroy inventory and destroy chest
if(nNewValue == nRewardValue)
{
CloseGUIScreen( oPC, "SCREEN_CONTAINER_DEFAULT");
object oInv = GetFirstItemInInventory(oSelf);
while(oInv != OBJECT_INVALID)
{
DestroyObject(oInv, 0.0, FALSE);
oInv = GetNextItemInInventory(oSelf);
}
if(oInv == OBJECT_INVALID)
{
DestroyObject(oSelf, 0.0f, FALSE);
}
}
}
}
void main()
{
object oSelf = OBJECT_SELF; // This is the chest that has this script OnInventoryDisturbed
object oMasterPC = GetFirstPC(TRUE);
object oPC = GetFirstPC(FALSE);
int nRewardValue = 3;
int nCurrentValue = 0;
// If we have not yet taken 3 items from chest
if(nCurrentValue != nRewardValue)
{
// Add +1 each time an item is taken
nCurrentValue += 1;
SetLocalInt(oSelf, "CurrentValue", nCurrentValue);
int nNewValue = GetLocalInt(oSelf, "CurrentValue");
// If we have taken 3 items, close the GUI screen, destroy inventory and destroy chest
if(nNewValue == nRewardValue)
{
CloseGUIScreen( oPC, "SCREEN_CONTAINER_DEFAULT");
object oInv = GetFirstItemInInventory(oSelf);
while(oInv != OBJECT_INVALID)
{
DestroyObject(oInv, 0.0, FALSE);
oInv = GetNextItemInInventory(oSelf);
}
if(oInv == OBJECT_INVALID)
{
DestroyObject(oSelf, 0.0f, FALSE);
}
}
}
}
#7
Posté 21 juillet 2011 - 08:25
Here's a tag based script for OnAcquire. Just give it the same name as the tag of your book. Should work:
#include "x2_inc_switches"
#include "nw_i0_plot"
void main()
{
int iEvent = GetUserDefinedItemEventNumber();
if (iEvent != X2_ITEM_EVENT_ACQUIRE) return;
object oBook = GetModuleItemAcquired();
object oPC = GetModuleItemAcquiredBy();
if (GetNumItems(oPC, GetTag(oBook)) == 3)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_L),oPC, 0.0);
SetLocalString(oPC, "hasbooks", "TRUE");
}
}
#include "x2_inc_switches"
#include "nw_i0_plot"
void main()
{
int iEvent = GetUserDefinedItemEventNumber();
if (iEvent != X2_ITEM_EVENT_ACQUIRE) return;
object oBook = GetModuleItemAcquired();
object oPC = GetModuleItemAcquiredBy();
if (GetNumItems(oPC, GetTag(oBook)) == 3)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HEALING_L),oPC, 0.0);
SetLocalString(oPC, "hasbooks", "TRUE");
}
}
#8
Posté 22 juillet 2011 - 11:46
CID-78 wrote...
you shouldn't use a LocalString , you should use a LocalInt. it doesn't make sense to save a string "TRUE" you should set it to true. Baragg safty step isn't good enough. the player can drop a book and pick it up again and fire the effect part each time.
Use your Local Variable as protection instead.
Dag nab it, I forgot that they will be sneaky like that, lol.





Retour en haut






