Jump to content

Home

Script to add saber isn't working


Achilles

Recommended Posts

For all my scripting n00bness, I was still pretty sure that this was going to work :(

 

//:: source code for baosbr.ncs
void main() { 

    object oNPC = GetObjectByTag("BaoDur", 0);
    object oWeapon1 = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON ,oNPC);
    object oWeapon2 = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON ,oNPC);


    /*
     I don't want to destroy any items he may have equipped so I'm 
     having him unequip them instead. Since the game won't let you 
     equip a melee weapon in your main hand if you have a ranged 
     weapon in your off hand, I'm unequipping both slots, just in 
     case the NPC is double-wielding. Also, I'm removing the weapon
     in left hand first, since the engine doesn't like lefties 
    */

    if (GetIsObjectValid (oWeapon2))
       {
       AssignCommand(oNPC, ActionUnequipItem(oWeapon2));
       }

    if (GetIsObjectValid (oWeapon1))
       {
       AssignCommand(oNPC, ActionUnequipItem(oWeapon1));
       }


    //:: NPC can't equip/flourish their new weapon without 
    //:: weapon proficiency - lightsaber.
    GrantFeat(43, oNPC); 

    //:: If BaoDur is LS, give him the LS lsabre... 
    if ((GetAlignmentGoodEvil(oNPC)) > 49){				

           object oLsabre1 = CreateItemOnObject("g_w_lghtsbr01", OBJECT_SELF);
   	     ActionEquipItem(oLsabre1, INVENTORY_SLOT_RIGHTWEAPON);
           ActionWait(0.5);
           ActionDoCommand(CreatureFlourishWeapon(OBJECT_SELF));


      //:: ...otherwise give him the DS lsaber. 
} else {

               object oLsabre2 = CreateItemOnObject("g_w_lghtsbr02", OBJECT_SELF); 
               ActionEquipItem(oLsabre2, INVENTORY_SLOT_RIGHTWEAPON);
               ActionWait(0.5);
               ActionDoCommand(CreatureFlourishWeapon(OBJECT_SELF));

	}

}

Everything works except the part where he get a blue saber if LS aligned. At this point he gets a red saber, no matter what.

 

FWIW, I'm firing this via ExecuteScript inside a_makejedi.

 

   // If Param = 1, then it's Bao-Dur. (Trying to make it consistent with the CNPC integers.)
   if ( nScriptNumber == 1 ) {
       AddMultiClass (CLASS_TYPE_JEDICONSULAR, GetObjectByTag ("BaoDur") );
       ExecuteScript("baosbr", OBJECT_SELF);
   }

I know that some scripts don't like ExecuteScript. Is this going to be one of those cases?

 

I know that I'm probably just missing something obvious, but I've been staring at it too long to see it at this point. A problem compounded by the fact that I really have no idea what I'm doing.

 

If any of you veterans have any suggestions, I would love to hear them. Thanks in advance.

Link to comment
Share on other sites

You should use GetGoodEvilValue rather than GetAlignmentGoodEvil in the if-statement:

     //:: If BaoDur is LS, give him the LS lsabre... 
    if (GetGoodEvilValue(oNPC) > 49){

GetAlignmentGoodEvil does not return the exact alignment value. It only returns a value between 0 and 3 for a rough alignment classification. See the ALIGNMENT_ constants in nwscript.nss.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...