home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
demowot_english.exe
/
Script
/
Source
/
Test
/
visibility-test.sma
< prev
Wrap
Text File
|
2005-03-11
|
4KB
|
162 lines
#include "script.inc"
new DrID:gWatchers[20];
new DrID:gTargets[20];
new gWatcherGroup[10] = "Allied";
new gTargetGroup[10] = "Axis";
public main() CommonAKMain();
new gActualWatcherIdx = -1; // elol noveljuk, ezert egyel kisebb erteket adunk itt meg 0 helyett
new gActualTargetIdx;
new Float:gWatcherOrigPos[vec3];
new Float:gTargetOrigPos[vec3];
const Float:gDiff = 0.2;
const Float:gFade = 3.0;
const Float:gTreshold = 2.0; // ennyi meter hiba meg elfogadhato
new DrID:PreviousTarget;
//======================================================================================================
public PostGameStart()
{
CommonAKInit();
new Iterator:i = Iterate( gWatcherGroup );
new j = 0;
while( ItNext(i))
gWatchers[j++] = ItEntity(i);
ItStop(i);
i = Iterate( gTargetGroup );
j = 0;
while( ItNext(i))
gTargets[j++] = ItEntity(i);
ItStop(i);
SetCameraTargetPos( Float:{180.0, 128.0, 0.0} );
ProcessNextWatcher();
}
public EnemySeen()
{
new DrID:Watcher = gWatchers[gActualWatcherIdx];
new DrID:Target = gTargets[gActualTargetIdx];
new Float:SenseDistance = DistanceAKe2e( Watcher, Target );
new TmpStr[40];
new Message[200] = " senses ";
GetPropertyString( Watcher, "Name", 40, TmpStr );
ConcatString( Message, 200, TmpStr, Message );
GetPropertyString( Target, "Name", 40, TmpStr );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, " from " );
Float2Str( SenseDistance, TmpStr, 40 );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, " m. The calculated distance is " );
// Display correct info if incorrect
new Float:FowRadius = GetPropertyFloat( GetBaseEntity( Watcher ), "FOWRangeRadius" );
new Float:SightingModifier = GetPropertyFloat( GetBaseEntity( Target ), "SightingModifier" );
new Float:CorrectValue = FowRadius * SightingModifier - gFade;
Float2Str( CorrectValue, TmpStr, 40 );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, "m ( " );
Float2Str( FowRadius, TmpStr, 40 );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, " * " );
Float2Str( SightingModifier, TmpStr, 40 );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, " - " );
Float2Str( gFade, TmpStr, 40 );
ConcatString( Message, 200, Message, TmpStr );
ConcatString( Message, 200, Message, " ) " );
if( FloatAbs( SenseDistance - CorrectValue) > gTreshold ) {
ConcatString( Message, 200, Message, " Incorrect!" );
ConcatString( Message, 200, "!!! ", Message );
}
else {
ConcatString( Message, 200, Message, " Correct!" );
ConcatString( Message, 200, " ", Message );
}
ShowShortMessage( Message );
Log( Message, "proglog\scriptlog" );
// Go back
CmdStop( PreviousTarget, Q_OVERRIDE );
CmdMove( PreviousTarget, Q_ENQUEUE, gTargetOrigPos, MF_TELEPORT );
ProcessNextTarget();
}
public ProcessNextWatcher()
{
gActualWatcherIdx++;
gActualTargetIdx = -1;
new Float:TmpSpeed = 8.0;
SetGameSpeed( TmpSpeed );
new DrID:WatcherID = gWatchers[gActualWatcherIdx];
if( !WatcherID ) { // Ha mar vegigertunk.
ShowShortMessage( "Finished." );
SetGameSpeed( Float:1.0 );
return;
}
if( gActualWatcherIdx != 0 ) { // az elso kulonos elbiralast igenyel
CmdMove( gWatchers[gActualWatcherIdx-1], Q_OVERRIDE, gWatcherOrigPos, MF_TELEPORT );
}
GetPropertyVec3( WatcherID, "Pos", gWatcherOrigPos );
CmdMove( WatcherID, Q_OVERRIDE, Float:{ 200.0, 128.0, 0.0}, MF_TELEPORT );
RemoveEvent( "EnemySeen" );
AddAKEntityEvent( "EnemySeen", WatcherID, UNIT_ENEMY_SEEN );
ProcessNextTarget();
}
public ProcessNextTarget()
{
gActualTargetIdx++;
new DrID:TargetID = gTargets[gActualTargetIdx];
if( !TargetID ) { // Ha nincs tobb
ProcessNextWatcher();
return;
}
GetPropertyVec3( TargetID, "Pos", gTargetOrigPos );
CmdMove( TargetID, Q_OVERRIDE, Float:{ 160.0, 128.0, 0.0}, MF_TELEPORT );
CmdMove( TargetID, Q_ENQUEUE, Float:{ 200.0, 128.0, 0.0}, MF_NONE );
PreviousTarget = TargetID;
}