Skip to content

Starting Conversation While In Combat

ZephiriusZephirius Member Posts: 419
edited May 2021 in Builders - Toolset
I just keep getting a message that the PC is "busy" right now... :smile: (

I put it on the NPC's OnDamaged handler...
object oPC = GetLastDamager();
    if (!GetIsPC(oPC)) return;

    int nCurrentHP = GetCurrentHitPoints();
    int nMaxHP = GetMaxHitPoints();

        if (nCurrentHP < (nMaxHP/2))
        {
            if (GetIsInCombat(oPC) && GetIsEnemy(OBJECT_SELF, oPC))
                {
                 ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);


          AssignCommand(OBJECT_SELF,  ClearAllActions());

          ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_HEAD));

          AddJournalQuestEntry("Lord Zuul's Proposal", 1, oPC, TRUE, FALSE);

          AssignCommand(OBJECT_SELF, ActionStartConversation(oPC, "lord_zuul"));

        }
    }
}

Yeah...

Comments

  • ZephiriusZephirius Member Posts: 419
    OOPS! Thought I posted this in scripting,
  • ProlericProleric Member Posts: 1,316
    To allow the PC to speak immediately, you first need
    AssignCommand(oPC, ClearAllActions(TRUE));
    

    Normally, after combat, there is a cool down before the PC can speak. TRUE by-passes that.

    If associates or others could be attacking the victim, you also need the victim to SurrenderToEnemies() after changing faction.
  • ZephiriusZephirius Member Posts: 419
    Thanks P! Gonna check it out now.
  • ZephiriusZephirius Member Posts: 419
    edited May 2021
    The script works, sort of.
    After a quarter of the NPC's HP's are gone, the conversation starts, then immediately stops and the attack resumes. No time to talk, I guess. :)

    Can you guys figure this out. I'm at a loss.
  • ProlericProleric Member Posts: 1,316
    Can you post your revised script?

    Who is attacking whom, exactly?

    If the victim is attacking the PC, ensure they ClearAllActions(TRUE), too.
  • ZephiriusZephirius Member Posts: 419
    Proleric wrote: »
    Can you post your revised script?

    Who is attacking whom, exactly?

    If the victim is attacking the PC, ensure they ClearAllActions(TRUE), too.

    This is the revised version:
    object oPC = GetLastDamager();
        if (!GetIsPC(oPC)) return;
    
        int nCurrentHP = GetCurrentHitPoints();
        int nMaxHP = GetMaxHitPoints();
    
            if (nCurrentHP < (nMaxHP /2))
               {
    
               if (GetIsInCombat(oPC) && GetIsEnemy(OBJECT_SELF, oPC))
                    {
                     SetCommandable(TRUE, OBJECT_SELF);
    
                     AssignCommand(OBJECT_SELF, ClearAllActions(TRUE));
    
                     ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
    
                     AdjustReputation(OBJECT_SELF, oPC, 100);
    
                     AssignCommand(oPC, ClearAllActions(TRUE));
    
                     ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_HEAD));
    
                     AddJournalQuestEntry("Lord Zuul's Proposal", 1, oPC, TRUE, FALSE);
    
                     AssignCommand(OBJECT_SELF, ActionStartConversation(oPC, "cf_lord_zuul"));
                   }
           }
    }
    
    The guy who is being attacked is the owner of the script - OBJECT_SELF
  • ProlericProleric Member Posts: 1,316
    I had a look at the code I use in this situation. Try
    object oPC = GetLastDamager();
        if (!GetIsPC(oPC)) return;
    
        int nCurrentHP = GetCurrentHitPoints();
        int nMaxHP = GetMaxHitPoints();
    
            if (nCurrentHP < (nMaxHP /2))
               {
    
               if (GetIsInCombat(oPC) && GetIsEnemy(OBJECT_SELF, oPC))
                    {
    //                 SetCommandable(TRUE, OBJECT_SELF); // Is this necessary?
    
     //                AssignCommand(OBJECT_SELF, ClearAllActions(TRUE));
    
                     ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
                     SurrenderToEnemies();
                     ForceRest(oNPC);                            
    
    //                 AdjustReputation(OBJECT_SELF, oPC, 100);
    
                     AssignCommand(oPC, ClearAllActions(TRUE));
    
                     ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_HEAD));
    
                     AddJournalQuestEntry("Lord Zuul's Proposal", 1, oPC, TRUE, FALSE);
    
                     DelayCommand(0.5, AssignCommand(OBJECT_SELF, ActionStartConversation(oPC, "cf_lord_zuul")));
                   }
           }
    }
    

    ForceRest is only necessary if OBJECT_SELF is a spellcaster. It's the only way I know to stop spells that have already been unleashed turning folk hostile again. Unfortunately, it also restores full HP.

    I see from my notes that the brief delay on starting the conversation is to ensure that the PC has cleared all actions (when you assign commands to two creatures at the same time, there's no telling which will execute first).

    I've left the new faction as Commoner, but personally I always use a neutral custom faction for safety, in an abundance of caution, just in case some bug turns Commoners hostile.

    Hope that works for you.
Sign In or Register to comment.