home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
demowot_english.exe
/
Script
/
Source
/
convoycontrol.inc
< prev
next >
Wrap
Text File
|
2005-03-11
|
8KB
|
234 lines
// Use only on maps with Convoy!
// variables used:
/*
const gConvoyTotal = 1; //the number of convoys controlled
new gConvoyArray[gConvoyTotal][] = {}; //the actual position of the convoy
new gConvoyNames[gConvoyTotal][25] = {}; //the name basic of the convoy
new gConvoyWPNames[gConvoyTotal][25] = {}; //the name basic of the convoy waypoints
new gConvoyCount[gConvoyTotal] = {}; //the number of the convoy members
new gConvoyWPCount[gConvoyTotal] = {}; //the number of the convoy waypoints
new Float:gConvoyStartDelays[gConvoyTotal] = {}; //the delay beetween convoy members start
#include "convoycontrol.inc"
*/
public ReachedAPoint(DrID:WhoReached)
{
new WichPoint = GetMsgParamInt();
new TheReacher[25];
new lTmpStr[66];
new i;
new lTmpInt1;
new lTmpInt2;
GetPropertyString( WhoReached, "StringID", 20, TheReacher );
//debugging
ConcatString( lTmpStr, 66, "Evented: ", TheReacher);
DebugMessage( lTmpStr, DL_BEHAVIOR )
//debugging
for(i=0;i<gConvoyTotal;i++)
{
ConcatString( lTmpStr, 25, "", gConvoyNames[i] );
if((StrFind(TheReacher,lTmpStr) != -1))
{
ConcatString( lTmpStr, 25, "", TheReacher );
lTmpInt1 = strlen(gConvoyNames[i]);
lTmpInt2 = strlen(lTmpStr);
lTmpInt1--;
lTmpInt2--;
StrMid(lTmpStr,lTmpStr,lTmpInt2, lTmpInt2 -lTmpInt1);
gConvoyArray[i][(Str2Int(lTmpStr)-1)] = WichPoint;
//debugging
Int2Str( WichPoint, lTmpStr, 66);
ConcatString( lTmpStr, 66, " is at ", lTmpStr);
ConcatString( lTmpStr, 66, TheReacher, lTmpStr );
DebugMessage( lTmpStr, DL_BEHAVIOR )
//debugging
}
}
}
stock ResetConvoy(RC_ConvNum, RC_Start=0, RC_End=0)
{
if(RC_End==0||RC_End>gConvoyCount[RC_ConvNum])
{
RC_End=gConvoyCount[RC_ConvNum]-1;
}
if(RC_End<RC_Start)
{
return;
}
new i;
for(i=RC_Start;i<=RC_End;i++)
{
gConvoyArray[RC_ConvNum][i]=0;
}
}
stock ConvoyGo(ConvNum,eQueuing:ConvoyStyle = Q_ENQUEUE, eMoveFlag:MoveStyle = MF_OVERRUN )
{
new i;
new Float:ActStartDelay = 0.0;
for(i=1;i<=gConvoyCount[ConvNum];i++)
{
ConvoyMover(gConvoyNames[ConvNum],i,gConvoyWPNames[ConvNum],gConvoyWPCount[ConvNum],ActStartDelay,i,(gConvoyArray[ConvNum][i-1]+1),ConvoyStyle, MoveStyle);
ActStartDelay = ActStartDelay + gConvoyStartDelays[ConvNum];
}
}
stock ConvoyGoMember(ConvNum,ConvMemb,eQueuing:ConvoyStyle = Q_ENQUEUE, eMoveFlag:MoveStyle = MF_OVERRUN)
{
ConvoyMover(gConvoyNames[ConvNum],ConvMemb,gConvoyWPNames[ConvNum],gConvoyWPCount[ConvNum],0.0,ConvMemb,(gConvoyArray[ConvNum][ConvMemb-1]+1),ConvoyStyle, MoveStyle);
}
stock ConvoyStop(ConvNum)
{
new i;
new lTmpStr[25];
for(i=1;i<=gConvoyCount[ConvNum];i++)
{
Int2Str( i, lTmpStr, 25, "" );
ConcatString( lTmpStr, 25, gConvoyNames[ConvNum], lTmpStr );
CmdStop( GetEntity(lTmpStr), Q_OVERRIDE );
RemoveEntityEvent( "ReachedAPoint", GetEntity( lTmpStr ));
if(!GetEntity(lTmpStr))
DebugMessage( "Invalid entity asked to stop", DL_ERROR )
}
}
stock ConvoyStopMember(ConvNum,ConvMemb)
{
new lTmpStr[25];
Int2Str( ConvMemb, lTmpStr, 25, "" );
ConcatString( lTmpStr, 25, gConvoyNames[ConvNum], lTmpStr );
CmdStop( GetEntity(lTmpStr), Q_OVERRIDE );
RemoveEntityEvent( "ReachedAPoint" GetEntity( lTmpStr ));
if(!GetEntity(lTmpStr))
DebugMessage( "Invalid entity asked to stop", DL_ERROR )
}
//----Convoy mover script ... requested-----
stock ConvoyMover(ConvoyName[],ConvoyMembs,WayPointName[],WayPointNum,Float:StartDelay=0.0, MemberNumber = 1, WaypointNumber = 1, eQueuing:QueueStyle = Q_ENQUEUE, eMoveFlag:MoveStyle = MF_OVERRUN, bool:ContinueWhatDoing=false)
{
new MemberNo = 1;
new ActMember[255];
new ActWaypoint[255];
new WaypointNo = 1;
new Float:ActDelay = StartDelay;
new lTmpStr[255];
if(ConvoyMembs<1 || ConvoyMembs < MemberNumber)
{
DebugMessage( "akcommon.inc:ConvoyMover: Convoy Member less than 1!", DL_ERROR );
return false;
}
if(WayPointNum<1)
{
DebugMessage( "akcommon.inc:ConvoyMover: Waypoint Number less than 1!", DL_ERROR );
return false;
}
if(WayPointNum < WaypointNumber && QueueStyle == Q_ENQUEUE)
{
DebugMessage( "akcommon.inc:ConvoyMover: Waypoint Number less than 1 and ENQUEUE style!", DL_ERROR );
return false;
}
if(!(QueueStyle == Q_CYCLE || QueueStyle == Q_ENQUEUE))
{
DebugMessage( "akcommon.inc:ConvoyMover: Invalid Queue Style!", DL_ERROR );
return false;
}
for(MemberNo = MemberNumber; MemberNo <= ConvoyMembs; MemberNo++)
{
Int2Str( MemberNo, ActMember, 3, "" );
ConcatString( ActMember, 19, ConvoyName, ActMember);
if(GetEntity( ActMember ))
{
for (WaypointNo = WaypointNumber; WaypointNo <= WayPointNum; WaypointNo++)
{
Int2Str( WaypointNo,ActWaypoint, 3, "" );
ConcatString( ActWaypoint, 255, WayPointName, ActWaypoint);
if(GetEntity( ActWaypoint ))
{
if(WaypointNo == WaypointNumber)
{
if(!ContinueWhatDoing)
CmdWait(GetEntity( ActMember ), Q_OVERRIDE, ActDelay);
if(WaypointNumber==1)
CmdMoveToEnt( GetEntity (ActMember), GetEntity( ActWaypoint) , QueueStyle, MoveStyle );
CmdThrowEvent( GetEntity (ActMember), QueueStyle, WaypointNo );
ConcatString( lTmpStr, 166,"ConvoyMover: First waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") added to ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_MESSAGE );
}
else
{
if(WaypointNo < WayPointNum)
{
CmdMoveToEnt( GetEntity (ActMember), GetEntity( ActWaypoint) , QueueStyle, MoveStyle );
CmdThrowEvent( GetEntity (ActMember), QueueStyle, WaypointNo );
ConcatString( lTmpStr, 166,"ConvoyMover: Waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") added to ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_BEHAVIOR );
}
else
{
CmdMoveToEnt( GetEntity (ActMember), GetEntity( ActWaypoint), Q_CYCLE, MoveStyle ); // this is the last waypoint
CmdThrowEvent( GetEntity (ActMember), QueueStyle, WaypointNo );
ConcatString( lTmpStr, 166,"ConvoyMover: Last waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") added to ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_MESSAGE );
}
}
}
else
{
ConcatString( lTmpStr, 166,"ConvoyMover: Waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") doesn't exists! Requested by: ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_ERROR );
}
}
if(QueueStyle == Q_CYCLE)
{
for (WaypointNo = 1; WaypointNo <= WaypointNumber; WaypointNo++)
{
Int2Str( WaypointNo,ActWaypoint, 3, "" );
ConcatString( ActWaypoint, 255, WayPointName, ActWaypoint);
if(GetEntity( ActWaypoint ))
{
CmdMoveToEnt( GetEntity (ActMember), GetEntity( ActWaypoint) , QueueStyle, MoveStyle );
CmdThrowEvent( GetEntity (ActMember), QueueStyle, WaypointNo );
ConcatString( lTmpStr, 166,"ConvoyMover.patrol: Waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") added to ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_BEHAVIOR );
}
else
{
ConcatString( lTmpStr, 166,"ConvoyMover: Waypoint (", ActWaypoint);
ConcatString( lTmpStr, 166, lTmpStr, ") doesn't exists! Requested by: ");
ConcatString( lTmpStr, 166, lTmpStr, ActMember );
DebugMessage( lTmpStr , DL_ERROR );
}
}
}
AddAKEntityEvent( "ReachedAPoint", GetEntity(ActMember), CMD_EVENT );
}
else
{
ConcatString( lTmpStr, 166,"ConvoyMover: Entity (", ActMember);
ConcatString( lTmpStr, 166, lTmpStr, ") doesn't exists!");
DebugMessage( lTmpStr , DL_ERROR );
}
ActDelay = ActDelay + StartDelay;
}
return true;
}