Aller au contenu

Photo

Need help triggering a fight between two hostiles


1 réponse à ce sujet

#1
Sonmeister

Sonmeister
  • Members
  • 167 messages
I'm trying to trigger some creatures to appear (which is working) but then I want them to fight each other before they attack my pc but instead they all charge at me.  Tell me what I am doing wrong - here's the basic original script, I've also tried these variations  UT_CombatStart(oAttacker, oTarget, TRUE, TRUE);  UT_CombatStart(oAttacker, oTarget, FALSE, TRUE);  UT_CombatStart(oAttacker, oTarget, TRUE, FALSE);

//::///////////////////////////////////////////////
//:: Trigger Events Template
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Trigger events : Activate fight
*/
//:://////////////////////////////////////////////
//:: Created By: 
//:: Created On: 
//:://////////////////////////////////////////////

#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"

const int TEAM_ONE = 333;
const int TEAM_TWO = 334;

const string OGRE = "mr_ogre";
const string DRAKE = "mr_drake";

object oAttacker = GetObjectByTag(OGRE);
object oTarget = GetObjectByTag(DRAKE);

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    string sDebug;
    object oPC = GetHero();
    object oParty = GetParty(oPC);
    int nEventHandled = FALSE;

    switch(nEventType)
    {
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: The object spawns into the game. This can happen only once,
        //       regardless of save games.
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_SPAWN:
        {
            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: A creature enters the trigger
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_ENTER:
        {
            object oCreature = GetEventCreator(ev);
            int nOnce = GetLocalInt(OBJECT_SELF,TRIGGER_DO_ONCE_A);

            if (nOnce == FALSE)
            {
                SetLocalInt(OBJECT_SELF, TRIGGER_DO_ONCE_A, TRUE);

                //Activate the teams
                UT_TeamAppears(TEAM_ONE);
                UT_TeamAppears(TEAM_TWO);

                // Start a fight between the teams
                UT_CombatStart(oAttacker, oTarget);
            }


            break;
        }
        ////////////////////////////////////////////////////////////////////////
        // Sent by: The engine
        // When: A creature exits the trigger
        ////////////////////////////////////////////////////////////////////////
        case EVENT_TYPE_EXIT:
        {
            object oCreature = GetEventCreator(ev);

            break;
        }

    }
    if (!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_TRIGGER_CORE);
    }
}

#2
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
I can't say for certain what is happening in the original code, because I don't know the starting groups of the creatures. Combat start does a number of different things depending on the situation, but generally it moves creatures into the hostile group if they are told to attack the PC, or it generates hostility between the groups of the two creatures specified. If the two creatures are in the same group, it does nothing.

Be very careful about setting creature groups to arbitrary numbers and changing the hostility between those groups. Groups 0-3 are the PC group, the hostile group, the friendly group and the neutral group. module_core will set up the hostility for those groups, and past that point they shouldn't be touched.

If you want to creatures to attack each other, you probably want them to have custom groups. Groups can be any number, but be aware of the possibility of a number being used elsewhere. If you're in your own module that's not a big deal, but keep track of it somewhere. If you're making an add-in to Single Player, avoid any group number less than 60, because they are used in the campaign. Modifying the hostility between those groups could cause problems somewhere. To avoid conflicts with DLC or Awakening, I'd stay over 100000. Again, that's only for add-ins, custom modules should be fine with anything over 3, although avoiding 36 is important if you take advantage of the "fake dead" zombie ambush system.

Killrog's code works, but it's using the existing hostile and friendly groups. The creature in group 1 will be hostile to the player, while the creature in group 2 will show up as an ally. If that is desired, then great, the only change I'd make is to use the constants GROUP_HOSTILE and GROUP_FRIENDLY instead of the numbers. If it's not desired, I'd pick a couple of large numbers and use those groups instead.

Note: one thing to be clear on is that teams and groups are very different things. Group is used to determine hostility. Team is a helpful way to lump creatures together and grab them through scripting.

Modifié par DavidSims, 05 juillet 2010 - 03:48 .