in the following code, multiple debug statements fail to display. "Debug: NPCequipright switch entered 1" exists only in this script, so I am 100% positive this script is being run.
SendMessageToPC(oPC, "Debug: NPCequipright switch entered"); fails to display
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 finished"); also fails to display, despite being the next line following a previous debug message.
At the bottom is a screenshot of the behavior. Anyone have any ideas?
//Call before activities that need right hand item with no armor
void NpcEquipItemRight(object oNpc)
{
object oPC = GetFirstPC(); //only for debug. kamal
object oArmor = GetItemInSlot (1, oNpc);
object oCheck = GetItemInSlot (4, oNpc);
int nAct = GetLocalInt(oNpc, "nCurrentActivity");
string sItem = GetItemString (oNpc, nAct);
SendMessageToPC(oPC, "Debug: NPCequipright equipping item " + sItem);
if (oArmor != OBJECT_INVALID) {NpcDisarm (oNpc);}
if (oCheck != OBJECT_INVALID) {return;}
if (oCheck == OBJECT_INVALID) {SetLocalInt (oNpc, "armed", 0);}
int nArmed = GetLocalInt (oNpc,"armed");
int nEquip = GetLocalInt (oNpc, "equipcounter");
{switch (nArmed)
{
SendMessageToPC(oPC, "Debug: NPCequipright switch entered");
case 0:
{switch (nEquip)
{
default:
ClearFlags (oNpc);
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 finished");
EquipNewItem(oNpc, sItem, 4);
DelayCommand (0.4, EquipNewItem(oNpc, sItem, 4, FALSE));
SendMessageToPC(oPC, "Debug: NPCequipright switch 1 delay finished");
SetLocalInt (oNpc, "equipcounter",1);
SetLocalInt (oNpc, "armed", 1);
SendMessageToPC(oPC, "Debug: NPCequipright switch 1 before break");
break;
case 1:
ClearFlags (oNpc);
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 2");
EquipNewItem(oNpc, sItem, 4);
DelayCommand (0.4, EquipNewItem(oNpc, sItem, 4, FALSE));
SetLocalInt (oNpc, "equipcounter",2);
SetLocalInt (oNpc, "armed", 1);
break;
case 2:
ClearFlags (oNpc);
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 3");
CreateItemOnObject(sItem, oNpc, 1);
ActionEquipMostDamagingMelee();
SetLocalInt (oNpc, "equipcounter",3);
SetLocalInt (oNpc, "armed", 1);
break;
case 3:
break;
}
}
break;
default:
break;
}
}
SendMessageToPC(oPC, "Debug: NPCequipright ending");
}
600x300http://dl.dropbox.com/u/3879894/NWN2_SS_032412_161109.jpg[/img]
Debug messages failing to display.
Débuté par
kamal_
, mars 24 2012 08:33
#1
Posté 24 mars 2012 - 08:33
#2
Posté 24 mars 2012 - 08:42
I suggest you add debug lines to display the values of nEquip and nArmed.
Also, I don't think your switch-case statements are structured properly. They should look like this:
switch(iGroup2)
{
case 1:
{
sUnitGroup2 = "gfightally";
break;
}
case 2:
{
sUnitGroup2 = "garchally";
break;
}
case 3:
{
sUnitGroup2 = "ironally";
break;
}
}
Also, I don't think your switch-case statements are structured properly. They should look like this:
switch(iGroup2)
{
case 1:
{
sUnitGroup2 = "gfightally";
break;
}
case 2:
{
sUnitGroup2 = "garchally";
break;
}
case 3:
{
sUnitGroup2 = "ironally";
break;
}
}
Modifié par Kaldor Silverwand, 24 mars 2012 - 08:49 .
#3
Posté 24 mars 2012 - 08:48
I just switched it to
int nArmed = GetLocalInt (oNpc,"armed");
SendMessageToPC(oPC, "Debug: NPCequipright nArmed "+ IntToString(nArmed));
int nEquip = GetLocalInt (oNpc, "equipcounter");
SendMessageToPC(oPC, "Debug: NPCequipright nEquip "+ IntToString(nEquip));
neither debug message plays.
and remember I have:
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 finished");
and only the first of those plays.
I am thoroughly confused.
int nArmed = GetLocalInt (oNpc,"armed");
SendMessageToPC(oPC, "Debug: NPCequipright nArmed "+ IntToString(nArmed));
int nEquip = GetLocalInt (oNpc, "equipcounter");
SendMessageToPC(oPC, "Debug: NPCequipright nEquip "+ IntToString(nEquip));
neither debug message plays.
and remember I have:
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 finished");
and only the first of those plays.
I am thoroughly confused.
#4
Posté 24 mars 2012 - 08:49
The script is from UncleFB's npc control scripts btw. I just tried and adding the extra brackets makes no difference.
Modifié par kamal_, 24 mars 2012 - 08:55 .
#5
Posté 24 mars 2012 - 08:58
override and hak check for duplicate scripts?
#6
Posté 24 mars 2012 - 08:59
Forget to compile?
#7
Posté 24 mars 2012 - 09:06
Override is clean and there is no hak. Also did compile (and saved the module and restarted the toolset). Still happening.
This is the test module. if you load it, you can talk to the time woman to advance the time to nighttime, when the woodsman routine runs as seen in the screenshot.
http://dl.dropbox.co...9894/ai_test.7z
This is the test module. if you load it, you can talk to the time woman to advance the time to nighttime, when the woodsman routine runs as seen in the screenshot.
http://dl.dropbox.co...9894/ai_test.7z
#8
Posté 24 mars 2012 - 10:15
Well, you can modify the debug message just to make sure you don't have a duplicate anywhere.
Does "SendMessageToPC(oPC, "Debug: NPCequipright switch entered");"
even run, since it's outside of a case structure?
Is anything going on in the function 'ClearFlags'? An infinite loop can cause a script to end abruptly, though I don't know how that stops the scripts after one more line.
Does "SendMessageToPC(oPC, "Debug: NPCequipright switch entered");"
even run, since it's outside of a case structure?
Is anything going on in the function 'ClearFlags'? An infinite loop can cause a script to end abruptly, though I don't know how that stops the scripts after one more line.
#9
Posté 24 mars 2012 - 10:26
It runs for me exactly as shown, with the only debug lines I see being
SendMessageToPC(oPC, "Debug: NPCequipright equipping item " + sItem);
and
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
ClearFlags is an UncleFB function that clears things like plot flags. I commented it out, compiled and re-ran. No difference.
SendMessageToPC(oPC, "Debug: NPCequipright equipping item " + sItem);
and
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
ClearFlags is an UncleFB function that clears things like plot flags. I commented it out, compiled and re-ran. No difference.
#10
Posté 24 mars 2012 - 11:07
If this is a campaign script, maybe there a duplicate script in the module script? I think that happened to me one time.
#11
Posté 24 mars 2012 - 11:11
try this: change the line
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
to
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 - new test");
and recompile. Just to see if it really is recompling ....
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1");
to
SendMessageToPC(oPC, "Debug: NPCequipright switch entered 1 - new test");
and recompile. Just to see if it really is recompling ....
#12
Posté 24 mars 2012 - 11:48
Ok, figured it out. The script itself would compile without issue, but if you compiled the parent heartbeat script that was calling the script this comes from as an include, it would identify an error in this child script (despite the fact if you compiled it there would not be an error). Once I walked through it compiling at the parent script level and working out some bugs identified that way, I was able to have things work correctly.
Odd that compiling the script did not produce the errors and apparently did not update the compiled script, but compiling the script that called it produced the errors in it.
Now on to fixing other bugs in it, like a timing bug affecting activity selecting for the npc. Those should at least be more straightforward.
Incidentally, a bug in my code resulted in the npc playing the lute animation with a handaxe, METAL! :-)
Odd that compiling the script did not produce the errors and apparently did not update the compiled script, but compiling the script that called it produced the errors in it.
Now on to fixing other bugs in it, like a timing bug affecting activity selecting for the npc. Those should at least be more straightforward.
Incidentally, a bug in my code resulted in the npc playing the lute animation with a handaxe, METAL! :-)
#13
Posté 25 mars 2012 - 12:03
iirc the standard compiler will 'compile' an include file, and ignore lots of errors.
in honesty, i put your testMod directory through Skywing's ASC via batch script, and i got pinned to the wall .. when recovered, i put my woodsman outfit on and eventually got the primary HB script to compile properly,
keep it, keep it!!
in honesty, i put your testMod directory through Skywing's ASC via batch script, and i got pinned to the wall .. when recovered, i put my woodsman outfit on and eventually got the primary HB script to compile properly,
kamal_ wrote...
Incidentally, a bug in my code resulted in the npc playing the lute animation with a handaxe, METAL! :-)
keep it, keep it!!
#14
Posté 25 mars 2012 - 01:19
so Kamal...
Does the Uncle FB script mean you're working on the Commoner AI Project?
Just patiently wondering.
Does the Uncle FB script mean you're working on the Commoner AI Project?
Just patiently wondering.
#15
Posté 25 mars 2012 - 01:44
It does. I work on it periodically until I get frustrated by the size and complexity (I'm not a great scripter), then move on to other things that need to be worked on. It'll work anf get released eventually. I need it for my campaign.bealzebub wrote...
so Kamal...
Does the Uncle FB script mean you're working on the Commoner AI Project?
Just patiently wondering.
#16
Posté 25 mars 2012 - 02:51
kamal_ wrote...
Ok, figured it out. The script itself would compile without issue, but if you compiled the parent heartbeat script that was calling the script this comes from as an include, it would identify an error in this child script (despite the fact if you compiled it there would not be an error).
I had a similar problem with an include script for my werewolf system - the include compiled and in test it actually worked despite the fact that the functions were wrong! When I went to compile the calling script it gave a syntax error. I was unable to leave it that way because the calling script needed more work. Following that in the attempt to correct ther syntax error I had to redesign the include until I got the desired results. Strange behaviour.
That was before I installed Skywings compiler plug-in.





Retour en haut







