Aller au contenu

Photo

SOLVED: Idle NPC's during combat, Post Combat Commands unreliable, NPC's idle after AOE attack


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

#26
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
FIXED: well dang...I still occasionally get a sticky archer...hmmm....only occasionally though...weird.
== Moved archers to be the last set of commands at the end of the script...and removed one more _FRIENDLY from the == mix...I think I am just pushing the ambient envelope...generally working well (fingers crossed)...

Things continue to work nicely, however, in the second(response) and third(final) battles, I've noticed that when the majority of the _HOSTILE's have been killed, many of the _FRIENDLY's stay in combat mode, but do not attack (this is not the case in the first battle).

Keeping in mind that I read somewhere that the threat table is 5 deep, it is interesting to note that when there is one _HOSTILE left, only five creatures attack, including oHero. Perhaps I should post another question, this seems another topic...something is causing a difference in this behaviour between the first and subsequent battles...how do I 'clear the cache' ??

Modifié par RecklezzRogue, 12 avril 2010 - 08:54 .


#27
Magic

Magic
  • Members
  • 187 messages
Hey, hey, nice. Well done! Now my creatures also return to their ambient behavior after being blasted ^^ by a fireball - thanks to your hint. :) I reworked that again and am now using the ambient system alone for any movement outside combat. No rubberband system, i.e. no UT_QuickMove() as well! Didn't expect so many possible interrupts.

#28
Magic

Magic
  • Members
  • 187 messages
Oops, missed the second page. Here's the discussion on the threat table.
http://social.biowar...1326927#1347589
I'm using the manual threat update myself, haven't encountered any lazy combatants since!

Modifié par Magic, 12 avril 2010 - 05:17 .


#29
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages

Magic wrote...

Oops, missed the second page. Here's the discussion on the threat table.
http://social.biowar...1326927#1347589
I'm using the manual threat update myself, haven't encountered any lazy combatants since!


too funnny, that is where I got some of your code already - the threat table discussion...you seem to be everywhere ;-)
since I already put that piece of code in there, I'll read through more carefully...but - it's official - everything works (besides lazy combatants at the end), it looks freaking cool, especially (moment of pride) the archer patrols regrouping on the hill, then setting off on their respective patrols again....well that only took two months....I should have this campaign done in about 20 years. ;-)


ps - I need to plug DAToolChest right alongside you for the help - that tool is a lifesaver for looking up scripting references...surprised such capabilities (like searching scripts) is not part of the toolset... :-/

pps - I still have a mix of Ambient & UT_ commands to move NPC's...on the next area (or the return to this area), I'll try doing as much as possible with Ambient...did that smooth things out for you? Less calls?

Modifié par RecklezzRogue, 12 avril 2010 - 07:26 .


#30
Magic

Magic
  • Members
  • 187 messages
Could you narrow down why the creatures are doing nothing? Like stuck performing a command, not receiving events, threat table empty, or such.

Concerning the toolset I can't blame BioWare. I don't know so many commercial companies which give away code for free ... And the programmers who worked on the game on a workday basis probably learned pretty quickly where to look. :)

No. I'm using the ambient system when I need animations because the rubberband system intereferes a bit with the ambient behavior system, for me at least. For ambient movement only, I actually suggest the rubberband system (e.g. UT_QuickMove()). This, of course, becomes trivial if one redirects EVENT_TYPE_COMMAND_COMPLETE, or modifies the system directly.

Naturally behaving NPCs are a beautiful sight, I agree. :)

#31
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Besides the scripting errors I had - this was really fixed over here:



http://social.biowar...index/1326927/2

#32
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
EDIT - CORRECTED SCRIPT BELOW (was misahandling maincontrolled)

Ok for completeness here - posting my final fixes as I hpoe the script examples steps I took will help others...(if not clear, see the link in the post above this one):


UPDATE --

In order to control when the following script actually intercepts events, I have done the following (thanks to some help form David Sims in another thread)


RecklezzRogue     said..

David - thank you - you got me there - I can now do event intercepts, without impacting (in any noticeable way) other modules...here's what I did in the end:


1 - created a 2da override for var_module wherein the variable DMO001_EVENT_INTERCEPT is defined as an int with a default value of '0'


2 - used Manage Modules/Properties/Variables to set DMO001_EVENT_INTERCEPT to '1'


3 - check for value of DMO001_EVENT_INTERCEPT in my events override script as follows:


        case EVENT_TYPE_PERCEPTION_DISAPPEAR:
        {
            // If this isn't Dark Alliances, bail to default handler
            //
            object oModule = GetModule();
            if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
            {
                HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
            }



4 - Placed my engineevents.gda, my var_module.gda, dmo001_event_intercept.nss & ncs in ../addin/core/override



And everything works...now I'll post this where someone trying to solve this will find it - clearly the wrong thread now that I found the root cause...

THANK YOU!



Following is the latest, and fully functional, event override script:

// Event Intercept Script to solve NPC behaviour problems
//
// File: dmo001_event_intercept.nss
// Module: Dark Alliances
// Sources: code from Magic (Bioware Social) & DA Builder Wiki
// Sources: David Sims forum assistance with module variables vs. constants ;-)
// Author: RecklezzRogue    
// Date: 5-5-2010
// Revision 0.11
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "sys_ambient_h"
#include "ai_main_h_2"

void main()
{
    event ev   = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    object oOwner = GetEventObject(ev,0);
    object oHero = GetHero();
    int bEventHandled = FALSE;
//    DisplayFloatyMessage(GetHero(), "Event Intercept Called", FLOATY_MESSAGE, 16777215,5.0); //Debug
   
    switch (nEvent)
    {
        // If a hostile creature disappeared, update the threat table with the
        // remaining perceived enemies.
        //
        // This code solves the problem of NPC's standing and taunting in combat
        // mode, but not attacking visible combatant hostiles unless they are
        // directly attacked
        //
        case EVENT_TYPE_PERCEPTION_DISAPPEAR:
        {
            // If this isn't Dark Alliances, bail to default handler
            //
            object oModule = GetModule();
            if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
            {
//                DisplayFloatyMessage(GetHero(), "Event Int Exit - Line 42", FLOATY_MESSAGE, 16777215,5.0); //Debug
                HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
            }
            //Perception Fix Follows
            //
            if ((IsObjectHostile(OBJECT_SELF,GetEventObject(ev,0)))
             && OBJECT_SELF != GetMainControlled()
              && !IsPartyMember(OBJECT_SELF))
            {
//                DisplayFloatyMessage(GetHero(), "Event Int - Perception", FLOATY_MESSAGE, 16777215,5.0); //Debug
                int i;
                object[] oEnemies = GetNearestObjectByGroup(OBJECT_SELF,TRUE,OBJECT_TYPE_CREATURE,AI_THREAT_SIZE,TRUE,TRUE);
                int nEnemyCount = GetArraySize(oEnemies);
                if (GetThreatTableSize(OBJECT_SELF)<nEnemyCount)
                {
                        for (i = 0; i<nEnemyCount; i++)
                        {
                            if (GetThreatValueByObjectID(OBJECT_SELF,oEnemies[i])==0.0)
                            {
                                AI_Threat_UpdateEnemyAppeared(OBJECT_SELF,oEnemies[i]);
                            }
                        }
                 int bEventHandled = FALSE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
            }
         break;
        }
        // NPC's Re-engage after an AOE effect (fireball, freeze, etc)
        //
        // This solves the problem of NPC's disengaging from combat
        // after recoveing from an AOE attack, especially Fireballs.
        //
        case EVENT_TYPE_COMMAND_COMPLETE:
        {
            // If this isn't Dark Alliances, bail to default handler
            //
            object oModule = GetModule();
            if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
            {
            HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
            }
            // Creature finished the ExecuteEffect command
            //
            if ((GetEventInteger(ev,0)==32) && (bEventHandled == FALSE)
             && !IsPartyMember(OBJECT_SELF)
              && OBJECT_SELF != GetMainControlled())
            {
//                DisplayFloatyMessage(GetHero(), "Event Int - EV = 32", FLOATY_MESSAGE, 16777215,5.0); //Debug
                WR_ClearAllCommands(OBJECT_SELF,TRUE);
                AI_DetermineCombatRound();
                int bEventHandled = TRUE;
            }
            // The following code makes sure that NPC's go home after the battle
            // Using this means that you will need to use commands that
            // Rubber_SetHome (like UT_Quickmove) to keep NPC's at waypoints.
            // This code also accomodates Ambient move patterns, but those with
            // active move patterns still risk being stuck after battle...
            //
            else if (GetCommandType(GetCurrentCommand(OBJECT_SELF))==COMMAND_TYPE_INVALID
             && GetCommandQueueSize(OBJECT_SELF)==0
              && !IsPartyMember(OBJECT_SELF)
               && OBJECT_SELF != GetMainControlled())
            {
                DisplayFloatyMessage(GetHero(), "Event Int - EV = RGH", FLOATY_MESSAGE, 16777215,5.0); //Debug
                // Issue Rubber_GoHome and Ambient_Start if not fighting, not at
                // home wp, event not handled, and there is no ambient move
                // pattern variable set (other than 0 or FALSE), and the Ambient
                // system is enabled (the creature associated with the event)
                //
                // Adding conditional for PartyMembers...(must be false)
                //
                if (!GetCombatState(OBJECT_SELF)
                  && GetDistanceBetweenLocations(GetLocation(OBJECT_SELF),Rubber_GetHome())>1.0
                   && bEventHandled == FALSE
                    && !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
                     && !IsPartyMember(OBJECT_SELF)
                      && OBJECT_SELF != GetMainControlled())
                {
                    Rubber_GoHome();
                    int bEventHandled = FALSE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
                if (GetLocalInt(OBJECT_SELF,AMBIENT_SYSTEM_STATE) & AMBIENT_SYSTEM_ENABLED
                  && bEventHandled == FALSE
                   && !GetCombatState(OBJECT_SELF)
                    && !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
                     && !IsPartyMember(OBJECT_SELF)
                      && OBJECT_SELF != GetMainControlled())
                {
                    Ambient_Start();
                    int bEventHandled = TRUE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
            }
            break;
        }
    }
    if (!bEventHandled)
    {
      HandleEvent(ev); // pass to the event to the default handler for Event
    }
}
// --- script end ---

 
edit - final area script in next post...

Modifié par RecklezzRogue, 06 mai 2010 - 05:27 .


#33
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Final Area Script Follows:


Note - there are about a dozen trigger scripts and other scripts for this area, cutscene, dialogue, etc. So - if you try to step through this some it may not make sense...there's my disclaimer ;-)


// Area Core Script for Foul Lake (dafl001d.are)
//
// File: dmo001_area_core_dafl001d.nss
// Module: Dark Alliances
// Sources: DA Builder Wiki & Forums
// Author: RecklezzRogue
// Date: 5-5-2010
// Revision: 0.15
//
// Teams 1-20 = Bad Guys
// Teams 21-40 = Good Guys
// Teams 41-60 = Variable
//
// Patrol control related plot flags:
//
//  6 = Foul Lake Cleared Once
//  17 = Team 41 Patrol Control
//  18 = Team 42 Patrol Control
//  19 = Team 43 Patrol Control
//  20 = Team 44 Patrol Control
//  21 = Team 41 Regroup Control (obsolete)
//  22 = Team 42 Regroup Control (obsolete)
//  23 = Team 43 Regroup Control (obsolete)
//  24 = Team 44 Regroup Control (obsolete)
//  25 = Post combat patrols regroup flag  (obsolete)
//  26 = All patrols active flag
//  27 = Team 41 Death Flag
//  28 = Team 42 Death Flag
//  29 = Team 43 Death Flag
//  30 = Team 44 Death Flag
//
#include "events_h"
#include "plt_dmo001_dafl001d_plot"
#include "plt_dmo001_party_plot"
#include "wrappers_h"
#include "utility_h"
#include "plot_h"
#include "log_h"
#include "sys_ambient_h"
#include "placeable_h"
#include "item_constants_h"
//#include "dmo001_module_constants_h"

    //
    // Clear Event Handled
    int nEventHandled = FALSE;

    //
    //Setup Woodlander Merc Archer Patrol creatures, home waypoints, plot flags
    //
    // Setup archers on patrol as objects
    object oAS1 = GetObjectByTag("dmo001_fl_mercarcher_f41");
    object oAS2 = GetObjectByTag("dmo001_fl_mercarcher_f42");
    object oAS3 = GetObjectByTag("dmo001_fl_mercarcher_f43");
    object oAS4 = GetObjectByTag("dmo001_fl_mercarcher_f44");
    //
    // Setup patrol regroup waypoints (post combat)
    object oASHwp1 = GetObjectByTag("mercarhcer_regroup_1");
    object oASHwp2 = GetObjectByTag("mercarhcer_regroup_2");
    object oASHwp3 = GetObjectByTag("mercarhcer_regroup_3");
    object oASHwp4 = GetObjectByTag("mercarhcer_regroup_4");
    //
    // Setup Woodlander Merchant Camp NPC's & Home WP's (for post combat)
    //
    // Combatants
    object oPC = GetHero();
    object oArkin = GetObjectByTag("dmo001_wood_arkin");
    object oGriggs = GetObjectByTag("dmo001_wood_griggs");
    object oNausica = GetObjectByTag("dmo001_party_nausica");
    object oAnna = GetObjectByTag("dmo001_wood_anna");
    object oMercGuard45 = GetObjectByTag("merc_guard_duel_m_45");
    object oMercGuard46 = GetObjectByTag("merc_guard_duel_m_46");
    object oMercGuard47 = GetObjectByTag("merc_guard_duel_m_47");
    object oArkinHWP = GetObjectByTag("ap_dmo001_wood_arkin_01");
    object oGriggsHWP = GetObjectByTag("ap_dmo001_wood_griggs_01");
    object oNausicaHWP = GetObjectByTag("ap_dmo001_party_nausica_01");
    object oAnnaHWP = GetObjectByTag("ap_dmo001_party_anna_01");
    //
    // Non-Combatants
    object oLynn = GetObjectByTag("dmo001_wood_lynn");
    object oRalph = GetObjectByTag("dmo001_wood_ralph");
    object oLara = GetObjectByTag("dmo001_wood_lara");
    object oShane = GetObjectByTag("dmo001_wood_shane");
    object oJohn = GetObjectByTag("dmo001_wood_john");
    object oLarson = GetObjectByTag("dmo001_wood_larson");
    //
    // Setup Woodwitch Talia (future party member candidate - using standin)
    //
    object oTaliaStandin = GetObjectByTag ("dm001_talia_standin");
    object oTaliaFWP = GetObjectByTag("dmo001_wp_talia_3");
    //
    // Handle general setup & flow of area action
    //
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

void main()
{

    switch(nEventType)
    {
        case EVENT_TYPE_AREALOAD_PRELOADEXIT:
        {
        //
        // Load the entry cutscene (draft)if plot flag
        // FOUL_LAKE_TALIA_ENTER_CUT has not been set
        if (!WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT,38))
        {
            CS_LoadCutscene( R"dmo001_dafl001d_talia_enter.cut",PLT_DMO001_DAFL001D_PLOT, 38);
        }
        //
        // Get the traps (team 88) & make them friendly
        object[] arTraps = UT_GetTeam(88, OBJECT_TYPE_PLACEABLE);
        int nTrapIndex;
        int nAllTrapsCount = GetArraySize(arTraps);
        for ( nTrapIndex = 0; nTrapIndex < nAllTrapsCount; nTrapIndex++)
        {
            object oTrap = arTraps[nTrapIndex];
            SetLocalObject(oTrap,PLC_TRAP_OWNER,oPC);
        }
/*        // DEBUG DEBUG DEBUG DEBUG DEBUGE (DIALOGUE-ARKIN/GRIGGS)
          //
          WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,6,TRUE);
*/
        //
        // Setup  archer patrol control plot flags
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,17, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,18, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,19, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,20, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,21, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,22, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,23, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,24, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,25, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,27, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,28, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,29, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,30, FALSE);
        WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,26, TRUE);
        //
        // Talia's exit
        Rubber_SetHome(oTaliaStandin,oTaliaFWP);
        //
        // Set Thug responders to neutral so they can move into position
        // pre-combat ('go hotsile on perceive' set to 1, short range)
        UT_TeamGoesHostile (1, FALSE);
        UT_TeamGoesHostile (2, FALSE);
        UT_TeamGoesHostile (3, FALSE);
        UT_TeamGoesHostile (4, FALSE);
        UT_TeamGoesHostile (5, FALSE);
        UT_TeamGoesHostile (7, FALSE);
        UT_TeamGoesHostile (8, FALSE);
        UT_TeamGoesHostile (9, FALSE);
        UT_TeamGoesHostile (11, FALSE);
        //
        // Talia Moves along ridge above starting
        // wp at area start (moved to cutscene script)
        //
        // UT_TeamMove(21, "dmo001_wp_talia_1", FALSE, 5.0, TRUE);
        // UT_TeamMove(25, "dmo001_wp_wolf_1", FALSE, 5.0, TRUE);
        //
        // Start Ambient Behaviour for archer patrols
        Ambient_Start (oAS1,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_41");
        Ambient_Start (oAS2,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_42");
        Ambient_Start (oAS3,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_43");
        Ambient_Start (oAS4,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_44");
        //
        // Talia Moves along ridge above starting
        // wp at area start (cutscene planned)
        //
        // DEBUG - CUTSCENE POST MOVE NOT WORKING - MOVED TO CUT SCENE END
        // Script
        //
        //        UT_TeamMove(21, "dmo001_wp_talia_1", FALSE, 5.0, TRUE);
        //        UT_TeamMove(25, "dmo001_wp_wolf_1", FALSE, 5.0, TRUE);
 

        //
        // Load the entry cutscene (draft)if plot flag
        // FOUL_LAKE_TALIA_ENTER_CUT has not been set
        if (!WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT,38))
        {
          PlayCutscene();
        }
        int nEventHandled = FALSE;
        break;
        }
    }
    // Handle Combat tranisitions
    //
    switch(nEventType)
    {
        case EVENT_TYPE_TEAM_DESTROYED:
        {
            // Merchants went Hostile and were slain
            // FOUL_LAKE_WOODLANDERS_DESTROYED
            //
            if(GetEventInteger(ev,0) == 60)
            {
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,11,TRUE);
            }

            // Archer Patrol Control - track deaths with plot flags
            // FOUL_LAKE_ARCHER_PATROL_TEAMxx_DEAD
            //
            if(GetEventInteger(ev,0) == 41)
            {
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,27,TRUE);
//                DisplayFloatyMessage(GetHero(), "Plot 27", FLOATY_MESSAGE, 16777215,35.0); //Debug
            }
            if(GetEventInteger(ev,0) == 42)
            {
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,28,TRUE);
//                DisplayFloatyMessage(GetHero(), "Plot 28", FLOATY_MESSAGE, 16777215,35.0); //Debug
            }
            if(GetEventInteger(ev,0) == 43)
            {
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,29,TRUE);
//                DisplayFloatyMessage(GetHero(), "Plot 29", FLOATY_MESSAGE, 16777215,35.0); //Debug
            }
            if(GetEventInteger(ev,0) == 44)
            {
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT,30,TRUE);
//                DisplayFloatyMessage(GetHero(), "Plot 30", FLOATY_MESSAGE, 16777215,35.0); //Debug
            }
            // Initial Thug response to loss of first battle
            //
            if(GetEventInteger(ev,0) == 1)
            {
                // set Plot flag for first fight -
                // original thugs killed - TEAM1_DESTROYED
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 0, TRUE);

                // Activate First Responder Bandit parties and march towards
                // merchant camp (hostile on trigger or perceive hero)
                UT_TeamAppears(3);
                UT_TeamMove (3,"archers_go_here1", TRUE, 0.0, TRUE);
                UT_TeamAppears(7);
                UT_TeamMove (7,"archers_go_here2", TRUE, 0.0, TRUE);
                UT_TeamAppears(8);
                UT_TeamMove (8,"archers_go_here3", TRUE, 0.0, TRUE);
                UT_TeamAppears(9);
                UT_TeamMove (9,"archers_go_here4", TRUE, 0.0, TRUE);
                UT_TeamAppears(2);
                UT_TeamMove (2,"bandits_go_here1", TRUE, 5.0, TRUE);
                UT_TeamMerge (3,2);
                UT_TeamMerge (7,2);
                UT_TeamMerge (8,2);
                UT_TeamMerge (9,2);
                object oThugChief1 = GetObjectByTag("dmo001_assasin_chief_01");
                object oThugAssassin1 = GetObjectByTag("dmo001_thug_assasin_01");
                UT_QuickMoveObject(oThugChief1,"bandits_go_here1", TRUE, FALSE, TRUE, TRUE);
                UT_QuickMoveObject(oThugAssassin1,"bandits_go_here1", TRUE, FALSE, TRUE, TRUE);
                // Allies Position themselves in advance
                // of 1st responder conflict
                Ambient_Stop (oAS1);
                Ambient_Stop (oAS2);
                Ambient_Stop (oAS3);
                Ambient_Stop (oAS4);
                UT_QuickMoveObject(oArkin,"leaders_rally_here_1",TRUE,FALSE,TRUE, TRUE);
                UT_QuickMoveObject(oGriggs,"leaders_rally_here_2",TRUE,FALSE,TRUE, TRUE);
                UT_QuickMoveObject(oNausica,"leaders_rally_here_5",TRUE,FALSE,TRUE, TRUE);
                UT_TeamMove (41,"dafl001d_merchant_archer_1", TRUE, 0.0, FALSE);
                UT_TeamMove (42,"dafl001d_merchant_archer_2", TRUE, 0.0, FALSE);
                UT_TeamMove (43,"dafl001d_merchant_archer_3", TRUE, 0.0, FALSE);
                UT_TeamMove (44,"dafl001d_merchant_archer_4", TRUE, 0.0, FALSE);
                UT_TeamMove (45,"dafl001d_merchant_guard_1", TRUE, 0.0, TRUE);
                UT_TeamMove (46,"dafl001d_merchant_guard_2", TRUE, 0.0, TRUE);
                UT_TeamMerge (46,45);
                UT_TeamAppears(47);
                UT_TeamMove (47,"dafl001d_merchant_guard_3", TRUE, 5.0, TRUE);
                UT_TeamMerge (47,45);
                UT_QuickMoveObject(oAnna,"dafl001d_anna_rally_here_0",TRUE,FALSE,TRUE, TRUE);
            }
                // Trigger Final (2nd) Thug response
                else if(GetEventInteger(ev,0) == 2)
                {
                    // set Plot Flag TEAM2_DESTROYED
                    WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 1, TRUE);
                    // Final Thug wave & out of bounds conflict between
                    // TaliaStandin & Thug Archers
                    UT_TeamAppears(4);
                    UT_TeamMove (4,"bandits_go_here1",TRUE, 5.0, TRUE);
                    UT_TeamMerge (2,4);
                    UT_TeamAppears(5);
                    UT_TeamMove (5,"bandits_go_here1",TRUE, 5.0, TRUE);
                    UT_TeamMerge (5,4);
                    UT_TeamAppears (6);
                    UT_TeamMove (6,"offmap_archers_go_here",TRUE, 5.0, TRUE);
                    //
                    // Allies Position themselves
                    UT_QuickMoveObject(oArkin,"leaders_rally_here_3",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oGriggs,"leaders_rally_here_4",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oNausica,"leaders_rally_here_6",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oAS1,"dafl001d_archers_rally_here_1",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oAS2,"dafl001d_archers_rally_here_2",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oAS3,"dafl001d_archers_rally_here_3",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oAS4,"dafl001d_archers_rally_here_4",TRUE,FALSE,TRUE, TRUE);
                    UT_QuickMoveObject(oAnna,"dafl001d_anna_rally_here_1",TRUE,FALSE,TRUE, TRUE);
                    UT_TeamMerge(45,40);
                }
               // Talia wins vs. out of bounds archers & main body is still
               // fighting - she moves to engage
               else if((GetEventInteger(ev,0) == 6) && (WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 3) == FALSE))
               {
                   //set plot flag TEAM6_DESTROYED
                   WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 5, TRUE);
                   UT_TeamGoesHostile (4, TRUE); //debug
                   //reposition talia & wolf
                   UT_TeamMove(21,"dmo001_wp_talia_2", TRUE, 5.0, FALSE);
                   UT_TeamMove(25,"dmo001_wp_wolf_2", TRUE, 5.0, FALSE);
              }
                // Talia moves to overlook to finish off team 6 (off map archers)
                else if ((GetEventInteger(ev,0) == 4) && (WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 5) == FALSE))
                {
                //                DisplayFloatyMessage(GetHero(), "Team 4 dies & team 6 alive", FLOATY_MESSAGE, 16777215,15.0); //Debug
                    //Set plot flag Team 4 dead
                    WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 3, TRUE);
                    UT_TeamGoesHostile (6, TRUE); //debug
                    //Thug Archers Regroup to figh talia (out of bounds)
                    UT_TeamMove (6,"offmap_archers_go_here", TRUE, 5.0, TRUE);
                    //Talia & Alpha Wolf regroup to finish archers (out of bounds)
                    UT_TeamMove(21, "dmo001_wp_talia_0", TRUE, 0.0, FALSE);
                    UT_TeamMove(25, "dmo001_wp_wolf_0", TRUE, 0.0, FALSE);
                }
            // Talia wins vs. out of bound archers & main thug (team4)wave has
            // been killed - she leaves WORKS
            if ((GetEventInteger(ev,0) == 6) && (WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 3) == TRUE))
            {
                //set plot flag TEAM6_DESTROYED
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 5, TRUE);
                //set plot flag FOUL_LAKE_CLEARED_ONCE
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 6, TRUE);
            }
           // Main thug wave (team 4) destroyed, team 6 already dead
           if((GetEventInteger(ev,0) == 4) && (WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 5) == TRUE))
            {
                //set plot flag TEAM4_DESTROYED
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 3, TRUE);
                //set plot flag FOUL_LAKE_CLEARED_ONCE
                WR_SetPlotFlag(PLT_DMO001_DAFL001D_PLOT, 6, TRUE);
            }
        int nEventHandled = TRUE;
        break;
        }
    }
    // Post Combat Clean-up
    //
    switch(nEventType)
    {
        case EVENT_TYPE_TEAM_DESTROYED:
        {
            if (WR_GetPlotFlag(PLT_DMO001_DAFL001D_PLOT,6) == TRUE)
            {
                    // Talia & Wolf move to self destruct trigger (out of sight)
                    UT_TeamMove (21,"dmo001_wp_talia_3", FALSE, 0.0, TRUE);
                    UT_TeamMove (25,"dmo001_wp_talia_3", FALSE, 0.0, TRUE);
                    // Merchants go to home waypoints, start post combat ambient
                    if (IsDead(oNausica)== FALSE)
                    {
                        UT_QuickMoveObject(oNausica,"ap_dmo001_party_nausica_01", FALSE, FALSE, TRUE, TRUE);
                        Ambient_Start(oNausica,AMBIENT_SYSTEM_ENABLED,AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE,4);
                    }
                    if (IsDead(oArkin)== FALSE)
                    {
                        UT_QuickMoveObject(oArkin,"ap_dmo001_wood_arkin_01", FALSE, FALSE, TRUE, TRUE);
                        Ambient_Start(oArkin,AMBIENT_SYSTEM_ENABLED,AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE,21,AMBIENT_ANIM_FREQ_ORDERED);//merchant wander
                        Ability_DeactivateModalAbility(oArkin, 10400);
                    }
                    if (IsDead(oGriggs)== FALSE)
                    {
                        UT_QuickMoveObject(oGriggs,"ap_dmo001_wood_griggs_01", FALSE, FALSE, TRUE, TRUE);
                        Ambient_Start(oGriggs,AMBIENT_SYSTEM_ENABLED,AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE,24,AMBIENT_ANIM_FREQ_RANDOM);//guard wander right
                        Ability_DeactivateModalAbility(oGriggs,705);
                        UT_LocalJump(oGriggs, "ap_dmo001_wood_griggs_01");// debug
                    }
                    if (IsDead(oAnna)== FALSE)
                    {
                        UT_QuickMoveObject(oAnna,"ap_dmo001_wood_anna_01", FALSE, FALSE, TRUE, TRUE);
                        Ambient_Start(oAnna,AMBIENT_SYSTEM_ENABLED,AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE,37);//wizard conjuring
                    }
                    // Set the non-combatants amibient state (post combat)
                    Ambient_Start(oLynn, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 129);// Female Sit Ground Loop
                    Ambient_Start(oRalph, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 98);// Wandering Slob
                    Ambient_Start(oLara, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 9);// Crouching Praying
                    Ambient_Start(oShane, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 9);// Distressed_1
                    Ambient_Start(oJohn, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 89); // Crazy Hermit
                    Ambient_Start(oLarson, AMBIENT_SYSTEM_ENABLED, AMBIENT_MOVE_INVALID,AMBIENT_MOVE_PREFIX_NONE, 36);// Sitting on ground begging
                    // Re-sync patrols after Combat & start patrolling again via
                    // trigger script.
                    //
                    // Clear Patrol Plot Flags
                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,17, FALSE, TRUE);
                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,18, FALSE, TRUE);
                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,19, FALSE, TRUE);
                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,20, FALSE, TRUE);
                    // Regroup Flag Set
//                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,25, TRUE, TRUE);
                    // Patrol Active Flag unset
                    WR_SetPlotFlag (PLT_DMO001_DAFL001D_PLOT,26, TRUE, TRUE);
                    // Send Patrol units back to patrol waypoints/triggers
                    //
                    // Patrol 4143
                    if (IsDead(oAS1)== FALSE)
                    {
                        Ability_DeactivateModalAbility(oAS1,705);
                        WR_ClearAllCommands(oAS1, TRUE);
                        Ambient_Start (oAS1,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_41");
                    }
                    if (IsDead(oAS3)== FALSE)
                    {
                        Ability_DeactivateModalAbility(oAS3,705);
                        WR_ClearAllCommands(oAS3, TRUE);
                        Ambient_Start (oAS3,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_43");
                    }
                    //
                    // Patrol 4244
                    if (IsDead(oAS2)== FALSE)
                    {
                        Ability_DeactivateModalAbility(oAS2,705);
                        WR_ClearAllCommands(oAS2, TRUE);
                        Ambient_Start (oAS2,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_42");
                    }
                    if (IsDead(oAS4)== FALSE)
                    {
                        Ability_DeactivateModalAbility(oAS4,705);
                        WR_ClearAllCommands(oAS4, TRUE);
                        Ambient_Start (oAS4,19, AMBIENT_MOVE_LOOP,"ap_merc_guard_archer_f_44");
                    }
                    //
                    //set plot flat TALIA_FIRST_ENCOUNTER
                    WR_SetPlotFlag(PLT_DMO001_PARTY_PLOT, 8, TRUE);
            }
            int nEventHandled = TRUE;
            break;
        }
    }
    if (!nEventHandled)
    {

Modifié par RecklezzRogue, 06 mai 2010 - 02:11 .


#34
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
UPDATE --- FIXED SOME ISSUES...namely, the player would get back up after dying...oops...

// Event Intercept Script to solve NPC behaviour problems
//
// File: dmo001_event_intercept.nss
// Module: Dark Alliances
// Sources: code from Magic (Bioware Social) & DA Builder Wiki
// Sources: David Sims forum assistance with module variables vs. constants ;-)
// Author: RecklezzRogue
// Date: 5-5-2010
// Update: 6-20-2010
// Update: 7-5-2010 --- corrected pass of to core scripts (player & rules)
// Revision 0.16

#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "sys_ambient_h"
#include "ai_main_h_2"


void main()
{
    event ev   = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    object oOwner = GetEventObject(ev,0);
    object oHero = GetHero();
    object oModule = GetModule();
    int bEventHandled = FALSE;
    //
    // Intercepts follow
    switch (nEvent)
    {

        // If a hostile creature disappeared, update the threat table with the
        // remaining perceived enemies.
        //
        // This code solves the problem of NPC's standing and taunting in combat
        // mode, but not attacking visible combatant hostiles unless they are
        // directly attacked
        //
        case EVENT_TYPE_PERCEPTION_DISAPPEAR:
        {


            //
            // If this isn't Dark Alliances, bail to default handler
            //
            // Send creatures to creature core
            object oModule = GetModule();
            if ((GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
             || (OBJECT_SELF == GetMainControlled()))
            {
                HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
            }

            //
            //Perception Fix Follows
            if (IsObjectHostile(OBJECT_SELF,GetEventObject(ev,0)))
            {
                int i;
                object[] oEnemies = GetNearestObjectByGroup(OBJECT_SELF,TRUE,OBJECT_TYPE_CREATURE,AI_THREAT_SIZE,TRUE,TRUE);
                int nEnemyCount = GetArraySize(oEnemies);
                if (GetThreatTableSize(OBJECT_SELF)<nEnemyCount)
                {
                        for (i = 0; i<nEnemyCount; i++)
                        {
                            if (GetThreatValueByObjectID(OBJECT_SELF,oEnemies[i])==0.0)
                            {
                                AI_Threat_UpdateEnemyAppeared(OBJECT_SELF,oEnemies[i]);
                            }
                        }
                 int bEventHandled = FALSE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
            }
         break;
        }

        // NPC's Re-engage after an AOE effect (fireball, freeze, etc)
        //
        // This solves the problem of NPC's disengaging from combat
        // after recoveing from an AOE attack, especially Fireballs.
        //
        case EVENT_TYPE_COMMAND_COMPLETE:
        {
            //
            // If this isn't Dark Alliances, bail to default handler
            //
            // Send creatures to creature core
            if ((GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
             || (OBJECT_SELF == GetMainControlled()))
            {
                HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
            }

            //
            // Creature finished the ExecuteEffect command
            if ((GetEventInteger(ev,0)==32) && (bEventHandled == FALSE)
             && !IsPartyMember(OBJECT_SELF))
            {
                WR_ClearAllCommands(OBJECT_SELF,TRUE);
                AI_DetermineCombatRound();
                int bEventHandled = TRUE;
            }

            //
            // The following code makes sure that NPC's go home after the battle
            // Using this means that you will need to use commands that
            // Rubber_SetHome (like UT_Quickmove) to keep NPC's at waypoints.
            // This code also accomodates Ambient move patterns, but those with
            // active move patterns still risk being stuck after battle...
            else if (GetCommandType(GetCurrentCommand(OBJECT_SELF))==COMMAND_TYPE_INVALID
             && GetCommandQueueSize(OBJECT_SELF)==0
              && !IsPartyMember(OBJECT_SELF))
            {
                //
                // Issue Rubber_GoHome and Ambient_Start if not fighting, not at
                // home wp, event not handled, and there is no ambient move
                // pattern variable set (other than 0 or FALSE), and the Ambient
                // system is enabled (the creature associated with the event)
                //
                // Adding conditional for PartyMembers...(must be false)
                if (!GetCombatState(OBJECT_SELF)
                  && GetDistanceBetweenLocations(GetLocation(OBJECT_SELF),Rubber_GetHome())>1.0
                   && bEventHandled == FALSE
                    && !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
                     && !IsPartyMember(OBJECT_SELF))
                {
                    Rubber_GoHome();
                    int bEventHandled = FALSE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);

                if (GetLocalInt(OBJECT_SELF,AMBIENT_SYSTEM_STATE) & AMBIENT_SYSTEM_ENABLED
                  && bEventHandled == FALSE
                   && !GetCombatState(OBJECT_SELF)
                    && !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
                     && !IsPartyMember(OBJECT_SELF))
                {
                    Ambient_Start();
                    int bEventHandled = TRUE;
                }
                else
                HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
            }
            break;
        }
    }

    if (!bEventHandled)

    {
      HandleEvent(ev); // pass to the event to the default handler for Event
    }
}
// --- script end ---



//                DisplayFloatyMessage(GetHero(), "Event Int - EV = RGH", FLOATY_MESSAGE, 16777215,5.0); //Debug

Modifié par RecklezzRogue, 06 juillet 2010 - 06:52 .