Can anyone spot anything potentially weird with this creature ondeath quest update script?

I’m janking around with nw_c2_default7, the bioware ondeath for creatures event script

I already have stuff from a pw xp script in there that executes a script and a workaround for double xp messages if the critter somehow kills itself. Im leaving out the default9 code and the other stuff from the pw xp script I got off the vault and just showing what I wrote

Its a code that only kicks in if the area the murder happens in has a local int variable called QAREABOO set to 1 and the creature that was killed had a string variable called KILLQ set on it other than “” Then it increments KILLQ by one - the purpose of this is: quests where you need to go kill # of monsters in so and so area, so I dont have to have them drop a rat ear or whatever.

It also is designed to update the quest for every PC in the area, even if they are not in the same party - while this theoretically can be exploited, I dont plan to implement it in a fashion where it would be particularly more rewarding than just adventuring. Im doing it outside of GetNextFactionMember looping because its a common griefer methodology to kill quest spawns so other players have to wait for a respawn. So, Ive come to use GetFirst/NextObjectinArea for that function.

Its non-persistent, so they can do the quest again after a reset.

This snippet wont compile if you c/p it unless you c/p it into default7 - it does compile but I just wanna see if anyone can spot extraneous issues within as I am monkeying with like, vital organs of the game here, metaphorically speaking.

//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT7
/*
... more bioware script

*/
// if there is a string variable called KILLQ with a value other than nil
//set on the creature, then killing this creature was part of a quest
//and the quest is incremented by one, via the string value being set as
//a persistant integer on the PC - this script also cross checks a boolean int
//variable on the area called QAREABOO to make sure the character killed the correct
//creature as creatures are reused in different areas

if(GetLocalString(OBJECT_SELF, "KILLQ") == "") return;
object oThisArea = GetArea(OBJECT_SELF);
object oKillQuester = GetFirstObjectInArea(oThisArea);
string sAreaBoolean = "QAREABOO";


int iKill;
while (((oKillQuester) != OBJECT_INVALID) && (GetLocalInt(oThisArea, sAreaBoolean) != 0))
    {
        if
        (GetIsPC(oKillQuester) == TRUE)
            {
            int iKill = iKill++;
            SetLocalInt(oKillQuester, "KILLQ", iKill);
            }
        else GetNextObjectInArea(oThisArea);
        break;

    }

If I’ve understood what you’re trying to do, this script won’t work, as it stands.

The concept is fine, and will work in a death script, but the logic is flawed.

As it stands, you’re setting KILLQ to the number of PCs found at the time of updating the PC. I imagine it should be the number of kills achieved by that PC. Instead of using iKill,

SetLocalInt(oKillQuester, "KILLQ", GetLocalInt(oKillQuester, "KILLQ") + 1);

You don’t need the “else” - for the loop to work, you need to get the next object unconditionally.

You don’t want the “break” either.

For simplicity, you could move the condition involving sAreaBoolean into a simple “if” statement like the first one. Checking it on every iteration of the loop is redundant because nothing in the loop can change it, and it makes the code harder to read.

1 Like

Ah ok thanks, Im extremely rusty at the moment and I have a weird (mild) version of dyslexia that doesnt involve reading but rather boolean logic where I reverse everything if Im not focused or uncertain. If you’ve ever heard of left-right confusion, its the same thing but it also applies to my handwriting - if I write with my left hand. Im just a weird freak, Ill literally write bad mirror writing for a while until I get used to using my other hand.

So, Ill try this out

       if(GetLocalString(OBJECT_SELF, "KILLQ") == "") return;
       object oThisArea = GetArea(OBJECT_SELF);
       object oKillQuester = GetFirstObjectInArea(oThisArea);
       string sAreaBoolean = "QAREABOO";
       if (((oKillQuester) != OBJECT_INVALID) && (GetLocalInt(oThisArea, sAreaBoolean)  != 0))
 	        {
	        SetLocalInt(oKillQuester, "KILLQ", GetLocalInt(oKillQuester, "KILLQ") + 1);
	        }

Its like, stupidly bad right now because I stayed up all night fixing scripts, most of them work now but that one above and this conditional related to it because my head keeps flipping the TRUE and FALSE with the >= thing

///
// 666 cond q kill
// conversation tree conditional script
// for conditionals that require a certain int variable other than 1
// intended mainly for the KILLQ variable in my modified nw_c2_default7
// so that after the PC has killed the required number of critters,
// the quest can be advanced at the NPC
// set an int variable called MUSTKILL with a value equal to the number
//of creatures the PC needs to kill on the conversation holder NPC
//this script will check the KILLQ string variable’s int total
//and if it is equal to or greater than MUSTKILL, the conditional is TRUE

int StartingConditional()
{
int iMustKill = GetLocalInt(OBJECT_SELF, "MUSTKILL");
int iDidKill = GetLocalInt(GetPCSpeaker(), "KILLQ");
if(iDidKill >= iMustKill) return TRUE;
else return FALSE;
}