Destroying Object_Self from conversation
vonstorm
Member Posts: 66
Trying to destroy a placable object from a conversation (with object).
The object fades out then comes back. The curious thing is that it works on my henchmen. The plot flag is not set (although the lexicon says this doesn't matter). Any tips as to what could be causing this to happen?
void main()
{
object oSelf = OBJECT_SELF;
// Get the PC who is in this conversation.
object oPC = GetPCSpeaker();
// Give "fieldsmelter" to the PC.
CreateItemOnObject("fieldfletching", oPC);
AssignCommand(oSelf, ActionDoCommand(SetIsDestroyable(TRUE, FALSE, FALSE)));
// Destroy an object (not fully effective until this script ends).
DestroyObject(oSelf,1.0);
}
The object fades out then comes back. The curious thing is that it works on my henchmen. The plot flag is not set (although the lexicon says this doesn't matter). Any tips as to what could be causing this to happen?
1
Comments
I've taken the delay out because it's redundant (DestroyObject will not happen until the script has finished). Sometimes the module seems to have permission to do stuff that placeables don't.
...all the same, given the behaviour, I can't help wondering whether some other script is respawning the placeable?
create code:
void main() { object oSpawn; object oPC = GetItemActivator(); object oActTarget = GetItemActivatedTarget(); location lActTarget = GetItemActivatedTargetLocation(); // This item must target a location (not an object). if ( GetIsObjectValid(oActTarget) ) { SendMessageToPC(oPC, "Improper use of this item!"); return; } // Spawn "workstation". oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "fsmelter", lActTarget); }Am I going insane?
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
I think it's internal game stuff, never looked into it
This is the simplest way I've seen to do tag based item activation.
OnActivateItem:
// Simple on activate redirect. void main() { object oItem = GetItemActivated(); object oPC = GetItemActivator(); if(GetIsObjectValid(oItem)) { ExecuteScript(GetTag(oItem), oPC); } }The script with the same name as the tag of the activated item:void main() { // Gets if the item was targeted on an object. object oTarget = GetSpellTargetObject(); if(GetIsObjectValid(oTarget)) { // Do the stuff with oTarget return; } // Gets if the item was targeted on the ground. location lLoc = GetSpellTargetLocation(); // Do stuff with lLoc }The pre-implemented system uses those variables to track how much interaction is going on between an NPC and a player. AI_LEVEL_VERY_HIGH actually just means that they are in combat. AI_LEVEL_VERY_LOW means there's no players in the same area.
Maybe something similar is going on with MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS.
This has nothing to do with AI_LEVEL.
Tag based scripting is very simple, it's added right into the various x2_mod_def* module scripts and does pretty much exactly what your wrapper does. It sets the userdefineditemeventnumber and then executes the script. But it does it for acquire, activate, equip, unequip, unacquire etc. So the tag based script itself should check and do the right thing for the right event number.