Hmm Simpler. Well I am not sure if what i am going to suggest will be simpler for you or not. I can only stat the way I would do it.
Since you have a lot going on that could become hard to keep track of. It sounds to me like an Ideal case for making an event handler. The Event Handler woud basicly be what drives the entire system. It is nothing more then a single placeable that when ever anything happens It get sent a singnal. Then it maks the dicision of what to do. It just help to keep all the main code in one place.
Event handler also normally use an include file to keep basic Data easy to reach. Here is a simple example with just your timmer added.
File:inc_event
const int EVENT_BARREL_PLACED = 2010;
const int EVENT_SEND_SAPER = 2020;
const int EVENT_3 = 2030;
const int EVENT_4 = 2040;
const float THREE_TICKS = 18.0;
const string EVENT_HANDLER_TAG = "Tag of Event Handlet";
const string EVENT_HANDLER = "EVENT_HANDLER";
const string BARRELS_PLACED = "NUMBER_OF_BARRELS_PLACED";
const string TIMMER_CHECK = "NUMBER_OF DELAYS_PASSED";
object GetEventHandler();
object GetEventHandler()
{
object oHandler = GetLocalObject(GetArea(OBJECT_SELF),EVENT_HANDLER);
if ( !GetIsObjectValid(oHandler))
{
oHandler = GetObjectByTag( EVENT_HANDLER_TAG);
SetLocalObject(GetArea(OBJECT_SELF),EVENT_HANDLER,oHandler);
}
return oHandler;
}
File: EVENT Handler. The name of the file does not matter. It just need to be placed on the OnUserDefined Event of an object.
//::///////////////////////////////////////////////
//:: Custom User Defined Event
//:: FileName
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
#include "inc_event"
void main()
{
object oEventHandler = GetEventHandler();
int nEvent = GetUserDefinedEventNumber();
switch (nEvent)
{
case EVENT_BARREL_PLACED:
{
int nBarrelsPlaced= GetLocalInt( oEventHandler,BARRELS_PLACED);
SetLocalInt(oEventHandler,BARRELS_PLACED,nBarrelsPlaced+1);
event eEvent = EventUserDefined(EVENT_SEND_SAPER);
DelayCommand (THREE_TICKS,SignalEvent(oEventHandler, eEvent));
}
break;
case EVENT_SEND_SAPER:
{
int nTM_Check = GetLocalInt(oEventHandler,TIMMER_CHECK) +1;
SetLocalInt(oEventHandler,TIMMER_CHECK,nTM_Check );
if (nTM_Check == GetLocalInt( oEventHandler,BARRELS_PLACED))
{
//Enter code to send saper here.
}
}
break;
case EVENT_3:
{
}
break;
case EVENT_4:
{
}
break;
}
}
Then for however you are detecting the barrels being placed the code would be a simple as:
#include "inc_event"
void main ()
{
event eEvent = EventUserDefined(EVENT_BARREL_PLACED);
SignalEvent(GetEventHandler(), eEvent));
}
Hope this is helpfull and gives you some ideas.
L8