Area heartbeat
#26
Posté 09 décembre 2009 - 09:52
#27
Posté 09 décembre 2009 - 10:23
Axe_Murderer wrote...
Is it not the case that when you redirect it to the PC that the "heartbeat" will run all the time, even when the player is not in the area? If you only want it going for that one area I believe you must send the events specifically to the area, kick it off when they enter, and stop re-sending them when the player exits.
That's a good question. If an area script did a DelayEvent to send an event to itself, does it still get the event if the player leaves the area before it fires? That would mean you would be running an area script for an area that is not currently loaded. I would be surprised if that worked in any kind of predictable way. That would mean that you probably need to re-kick the heartbeat when the player returns to the area, though it warrants more testing.
#28
Posté 09 décembre 2009 - 10:33
/me volunteers FalloutBoy
#29
Posté 10 décembre 2009 - 03:28
I made an area script template with a heartbeat event every 6 seconds and posted it here:
http://social.biowar...m/project/1261/
Or you can cut and paste it from this, assuming it pastes correctly:
//::///////////////////////////////////////////////
//:: Area Core
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
Handles global area events
*/
//:://////////////////////////////////////////////
//:: Created By: Yaron
//:: Created On: July 17th, 2006
//:://////////////////////////////////////////////
#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "2da_constants_h"
const float HEARTBEAT_LENGTH = 6.0;
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
string sDebug;
object oPC = GetHero();
object oParty = GetParty(oPC);
int nEventHandled = FALSE;
switch(nEventType)
{
case EVENT_TYPE_HEARTBEAT:
{
// Replace this line with your heartbeat code.
DisplayFloatyMessage( GetHero(), "HB " + GetName(OBJECT_SELF), FLOATY_MESSAGE, 0xffffff, 2.0 );
DelayEvent( HEARTBEAT_LENGTH, OBJECT_SELF, Event(EVENT_TYPE_HEARTBEAT) );
break;
}
///////////////////////////////////////////////////////////////////////
// Sent by: The engine
// When: it is for playing things like cutscenes and movies when
// you enter an area, things that do not involve AI or actual game play
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_AREALOAD_SPECIAL:
{
break;
}
///////////////////////////////////////////////////////////////////////
// Sent by: The engine
// When: for things you want to happen while the load screen is still up,
// things like moving creatures around
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_AREALOAD_PRELOADEXIT:
{
break;
}
////////////////////////////////////////////////////////////////////////
// Sent by: The engine
// When: fires at the same time that the load screen is going away,
// and can be used for things that you want to make sure the player sees.
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_AREALOAD_POSTLOADEXIT:
{
// Kick start the heartbeat
DelayEvent( HEARTBEAT_LENGTH, OBJECT_SELF, Event(EVENT_TYPE_HEARTBEAT) );
break;
}
////////////////////////////////////////////////////////////////////////
// Sent by: The engine
// When: A creature enters the area
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_ENTER:
{
object oCreature = GetEventCreator(ev);
break;
}
////////////////////////////////////////////////////////////////////////
// Sent by: The engine
// When: A creature exits the area
////////////////////////////////////////////////////////////////////////
case EVENT_TYPE_EXIT:
{
object oCreature = GetEventCreator(ev);
break;
}
}
if (!nEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
}
}
#30
Posté 10 décembre 2009 - 05:23
Thanks.
#31
Posté 10 décembre 2009 - 06:22
#32
Posté 10 décembre 2009 - 08:54
Modifié par Sunjammer, 10 décembre 2009 - 08:55 .
#33
Posté 10 décembre 2009 - 06:13





Retour en haut






