Aller au contenu

Photo

Debug messages failing to display.


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
kamal_

kamal_
  • Members
  • 5 254 messages
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]

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
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;
   }
}

Modifié par Kaldor Silverwand, 24 mars 2012 - 08:49 .


#3
kamal_

kamal_
  • Members
  • 5 254 messages
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.

#4
kamal_

kamal_
  • Members
  • 5 254 messages
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
Morbane

Morbane
  • Members
  • 1 883 messages
override and hak check for duplicate scripts?

#6
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
Forget to compile?

#7
kamal_

kamal_
  • Members
  • 5 254 messages
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

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
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.

#9
kamal_

kamal_
  • Members
  • 5 254 messages
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.

#10
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
If this is a campaign script, maybe there a duplicate script in the module script? I think that happened to me one time.

#11
kevL

kevL
  • Members
  • 4 070 messages
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 ....

#12
kamal_

kamal_
  • Members
  • 5 254 messages
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! :-)

#13
kevL

kevL
  • Members
  • 4 070 messages
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,

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
bealzebub

bealzebub
  • Members
  • 352 messages
so Kamal...

Does the Uncle FB script mean you're working on the Commoner AI Project?
Just patiently wondering. :)

#15
kamal_

kamal_
  • Members
  • 5 254 messages

bealzebub wrote...

so Kamal...

Does the Uncle FB script mean you're working on the Commoner AI Project?
Just patiently wondering. :)

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.

#16
Morbane

Morbane
  • Members
  • 1 883 messages

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.