Aller au contenu

Photo

Creature spawn problems on trigger (solved)


6 réponses à ce sujet

#1
Sonmeister

Sonmeister
  • Members
  • 167 messages
I'm trying to use a trigger to spawn some spiders.  I found the template below.  Compiles fine.  My spiders team is 7.  I'm wanting the spiders to appear (from the ceiling).  Instead the spiders are already there just milling around.
So, what am I missing?

I have the spiders set to inactive and neutral.

I have the TRIGGER_DO_ONCE_A variable set at a numerical value of 1 on the trigger. 

Should any other variables be set?

Do I need to set a variable on my creature (spiders)?

Should the script be attached to the area or the trigger? 











//::///////////////////////////////////////////////
//:: Trigger Events Template
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Trigger events : Activate the spider fight
*/
//:://////////////////////////////////////////////
//:: Created By:  Keith Warner
//:: Created On:  11/06/08
//:://////////////////////////////////////////////

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

#include "ntb_constants_h"

const int TEAM_MY_CREATURE = 7;

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 spiders
                UT_TeamAppears(TEAM_MY_CREATURE);

            }


            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);
    }
}

Modifié par Sonmeister, 15 mai 2010 - 05:31 .


#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
If you select a creature in the area editor and see its properties, youl will see it has a property called "Active". Set it to false.
The UT_TeamAppears() function changes that "Active" property to true, but if it is already true, it won't do anything.

****************

TRIGGER_DO_ONCE_A should be set to 0. The script you have posted uses that variable to check if the trigger has already been fired. If its value is 1, then it will never be fired.

// Here you are getting the current value of the TRIGGER_DO_ONCE_A local variable.  
int nOnce = GetLocalInt(OBJECT_SELF,TRIGGER_DO_ONCE_A);

// Here you are checking that its value is FALSE, that's 0
if (nOnce == FALSE) 
{
    // Here you are setting its value to TRUE, that's 1, so the next time this event is catched, it will not enter the if block.
    SetLocalInt(OBJECT_SELF, TRIGGER_DO_ONCE_A, TRUE);
    ...
}


****************

If you want your spiders to attack the player, then you should set their group as _Hostile

Modifié par _L_o_B_o_, 15 mai 2010 - 05:34 .


#3
Sonmeister

Sonmeister
  • Members
  • 167 messages
OK, so I had Active and Interactive mixed up



Do I put the script on the area or the trigger?

#4
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
 Trigger:wizard:

#5
Sonmeister

Sonmeister
  • Members
  • 167 messages
Yep, got it! Thanks!  Realized after looking at the Trigger_core statement at the end...duh...

Modifié par Sonmeister, 15 mai 2010 - 05:36 .


#6
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
"I have the TRIGGER_DO_ONCE_A variable set at a numerical value of 1 on the trigger."

So you're pre-setting that variable to 1? 1 is the same as TRUE. If you're using the script you posted, the trigger shouldn't do anything, because nOnce is not equal to FALSE, it's been pre-set to TRUE. For that type of do once, TRIGGER_DO_ONCE should be 0 by default, and only set to 1 by the script.

Modifié par DavidSims, 16 mai 2010 - 01:24 .


#7
Sonmeister

Sonmeister
  • Members
  • 167 messages
Yeah, I put the TRIGGER_DO_ONCE_A set back to 0 to get it to work right.