home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
demowot_english.exe
/
Script
/
Source
/
akcommon.inc
< prev
next >
Wrap
Text File
|
2005-03-11
|
72KB
|
2,498 lines
#if defined _akcommon_inc
#endinput
#endif
#define _akcommon_inc
stock gPlayerTeam = -1;
// stock eDebugLevel:gSettingsIniDL = eDebugLevel:-1; // Ha veletlenul nem olvasnank be kesobb, akkor FORBID
// stock eDebugLevel:gDLOverwrite = eDebugLevel:9999; // ezzel jelezzuk, hogy invalid
// stock eDebugLevel:gDLOverwriteMin = eDebugLevel:10;
// stock eDebugLevel:gDLOverwriteMax = eDebugLevel:15;
stock eDebugLevel:gDL;
stock eDebugLevel:gDLMin = eDebugLevel:10;
stock eDebugLevel:gDLMax = eDebugLevel:15;
stock gDebugMessageStyle[50] = "#d#";
stock gTigerVal=-1;
stock gPZIIINVal=-1;
stock gShermanVal=-1;
stock gDaimlerIIVal=-1;
stock forbidden_grp_num;
stock gForbiddenGroups[10][30];
//======================================================================================================
stock Abs( Value )
{
if( Value < 0 )
return -Value;
return Value;
}
//======================================================================================================
stock AddAKEntityEvent( FunctionName[], const DrID:TargetObject, const Event[], Float:Delay = 0.0 )
// A function, which maps the hard to remember ClassName-MessageID pair
// to a simplier EventID. For event names see the macros.inc file.
{
new tmp[255];
ConcatString(tmp, 255, "", Event);
new ClassName[CLASSNAME_MAXLENGTH];
new MessageID;
new Pos;
for( Pos = 0; Event[Pos] != ','; Pos++ )
ClassName[Pos] = Event[Pos];
MessageID = (Event[Pos+1]-'0')*10 + Event[Pos+2]-'0';
AddEntityEvent( FunctionName, TargetObject, ClassName, MessageID, Delay );
}
//======================================================================================================
stock AddAKSelectorEvent( FunctionName[], Selector[], const Event[], Float:Delay = 0.0 )
// A function, which maps the hard to remember ClassName-MessageID pair
// to a simplier EventID. For event names see the macros.inc file.
{
new ClassName[CLASSNAME_MAXLENGTH];
new MessageID;
new Pos;
for( Pos = 0; Event[Pos] != ','; Pos++ )
ClassName[Pos] = Event[Pos];
MessageID = (Event[Pos+1]-'0')*10 + Event[Pos+2]-'0';
AddSelectorEvent( FunctionName, Selector, ClassName, MessageID, Delay );
}
//======================================================================================================
stock DrID:AddMapTickToEnt( DrID:Unit, Float:Time, spriteFileName[] = "", entityType[] = "" , toolTip[] = "", Float:heightOffset=0.0)
{
if(Unit==DrID:0)
{
DebugMessage( "akcommon.inc:AddMapTickToEnt: INVALID ENTITY!!!", DL_ERROR );
return DrID:0;
}
new Float:lTmpVec3[vec3];
GetPropertyVec3( Unit, "LogicalPos_", lTmpVec3);
return AddMapTick( lTmpVec3, Time, spriteFileName, entityType, toolTip, heightOffset );
}
//======================================================================================================
stock AddRGBA( Float:Vec1[rgba], Float:Vec2[rgba], Float:Sum[rgba] )
{
Sum[quat:r] = Vec1[quat:r] + Vec2[quat:r];
Sum[quat:g] = Vec1[quat:g] + Vec2[quat:g];
Sum[quat:b] = Vec1[quat:b] + Vec2[quat:b];
Sum[quat:a] = Vec1[quat:a] + Vec2[quat:a];
}
//======================================================================================================
stock AddVec2( Float:Vec1[vec2], Float:Vec2[vec2], Float:Sum[vec2] )
{
Sum[vec3:x] = Vec1[vec3:x] + Vec2[vec3:x];
Sum[vec3:y] = Vec1[vec3:y] + Vec2[vec3:y];
}
//======================================================================================================
stock AddVec3( Float:Vec1[vec3], Float:Vec2[vec3], Float:Sum[vec3] )
{
Sum[vec3:x] = Vec1[vec3:x] + Vec2[vec3:x];
Sum[vec3:y] = Vec1[vec3:y] + Vec2[vec3:y];
Sum[vec3:z] = Vec1[vec3:z] + Vec2[vec3:z];
}
stock SubVec3( Float:Vec1[vec3], Float:Vec2[vec3], Float:Diff[vec3] )
{
Diff[vec3:x] = Vec1[vec3:x] - Vec2[vec3:x];
Diff[vec3:y] = Vec1[vec3:y] - Vec2[vec3:y];
Diff[vec3:z] = Vec1[vec3:z] - Vec2[vec3:z];
}
stock Float:Vec3Length(Float:vec[vec3])
{
return sqrt(vec[vec3:x] * vec[vec3:x] + vec[vec3:y] * vec[vec3:y] + vec[vec3:z] * vec[vec3:z]);
}
stock NormalizeVec3(Float:vec[vec3])
{
new Float:l = 1.0 / Vec3Length(vec);
vec[vec3:x] *= l;
vec[vec3:y] *= l;
vec[vec3:z] *= l;
}
//======================================================================================================
stock StopBurning(DrID:SB_Entity)
{
if(SB_Entity==DrID:0)
{
DebugMessage( "StopBurning: DrID:0 asked ...", DL_ERROR );
return;
}
new DrID:FlamComp=GetComponent( SB_Entity, "cFlammability");
if(FlamComp==DrID:0)
{
DebugMessage( "StopBurning: The requested Entity has no Flammability Component", DL_ERROR )
}
SetPropertyFloat( FlamComp, "Temperature", 0.0 );
}
stock BurnEntity(DrID:BE_Entity)
{
if(BE_Entity==DrID:0)
{
DebugMessage( "BurnEntity: What do you want to burn? DrID:0?", DL_ERROR );
return;
}
new DrID:FireStarter=CreateEntity2Ent("sys_firestarter", BE_Entity);
SetPropertyInt( FireStarter, "Team", 7 );
DamageEntity( FireStarter, 100.0, 49 );
}
//======================================================================================================
#define CLEAR_HQ_INIT 0
#define CLEAR_HQ_FIND_TARGET 1
#define CLEAR_HQ_STOP 2
stock ClearHQ( Group[], HQ[], TeamToKill, InnerMode = 0, OptParam = 0 ) // Egy idoben csak egy ClearHQ futhat!
{
static mGroup[200];
static mHQ[200];
static mArea[200];
static mTeam;
switch( InnerMode )
{
case CLEAR_HQ_INIT:
{
// Beallitjuk kezdoertekeket:
DebugMessage( "ClearHQ: Initializing.", DL_MESSAGE );
ConcatString( mGroup, 199, Group, "" );
ConcatString( mHQ, 199, HQ, "" );
mTeam = TeamToKill;
// HQ-hoz csinalunk areat jol
new Float:Pos[vec3];
GetPropertyVec3( GetEntity( mHQ ), "LogicalPos_", Pos );
new DrID:Area = CreateEntity( "sys_circlearea", Pos );
GetPropertyString( Area, "StringID", 199, mArea );
SetPropertyFloat( Area, "Radius", GetPropertyFloat( GetEntity( mHQ ), "Radius" ));
SetPropertyInt( Area, "Team", mTeam );
SetPropertyBool( GetEntity( mArea ) , "IncludeBuildingMountedSoldiers", false );
RefreshArea( Area );
if( IsDebugLevelOK( DL_MESSAGE ))
Test_ListEntitiesInSelector( mArea );
ClearHQ( "", "", 0, CLEAR_HQ_FIND_TARGET );
}
case CLEAR_HQ_FIND_TARGET:
{
DebugMessage( "ClearHQ: Searching for target...", DL_MESSAGE );
RemoveEvent( "ClearHQ_QueueEmpty" );
new DrID:Target = GetFirstLivingUnit( mArea );
if( Target ) // Ha van meg celpont.
{
CmdGroupAttack( mGroup, Q_OVERRIDE, Target, AF_FORCE );
// AddAKEntityEvent( "ClearHQ_QueueEmpty", ANY_ENTITY, UNIT_DIED );
AddAKSelectorEvent( "ClearHQ_QueueEmpty", mArea, UNIT_DIED );
DebugMessage( "ClearHQ: Target Found.", DL_MESSAGE );
}
else // Mar nincs unit.
{
DebugMessage( "ClearHQ: There are no unmounted units in the area.", DL_MESSAGE );
if( GetPropertyBool( GetEntity( mArea ), "IncludeBuildingMountedSoldiers" )) // Ha mar epuleteket is neztunk, akkor vege
{
DebugMessage( "ClearHQ: Job's done.", DL_MESSAGE );
}
else // Nezzunk epuleteket is
{
DebugMessage( "ClearHQ: Let's see, who is hiding there...", DL_MESSAGE );
SetPropertyBool( GetEntity( mArea ) , "IncludeBuildingMountedSoldiers", true );
ClearHQ( "", "", 0, CLEAR_HQ_FIND_TARGET );
}
}
} // Find target
case CLEAR_HQ_STOP:
{
RemoveEvent( "ClearHQ_QueueEmpty" );
DebugMessage( "ClearHQ: Stopped.", DL_MESSAGE );
DeActivateEntity( GetEntity( mArea ));
if( OptParam )
CmdGroupStop( mGroup, Q_OVERRIDE );
}
}
}
public ClearHQ_QueueEmpty( DrID:Sender )
{
DebugMessage( "ClearHQ_QueueEmpty: somebody died.", DL_MESSAGE );
ClearHQ( "", "", 0, CLEAR_HQ_FIND_TARGET );
}
stock ClearHQ_Stop( bool:StopCommand = true )
{
DebugMessage( "ClearHQ_Stop.", DL_MESSAGE );
ClearHQ( "", "", 0, CLEAR_HQ_STOP, _:StopCommand );
}
//======================================================================================================
stock CmdMoveToEnt( DrID:Unit, DrID:TargetEntity, eQueuing:Queuing = Q_OVERRIDE, eMoveFlag:flags = MF_NONE, Float:Reach = 0.0)
{
new Float:TmpVec3[vec3];
GetPropertyVec3( TargetEntity, "LogicalPos_", TmpVec3 );
CmdMove( Unit, Queuing, TmpVec3, flags, Reach);
}
//======================================================================================================
stock CmdGroupMoveToEnt( Selector[], DrID:TargetEntity, eQueuing:Queuing = Q_OVERRIDE, eMoveFlag:flags = MF_NONE, Float:Distance=0.0)
{
new Float:TmpVec3[vec3];
GetPropertyVec3( TargetEntity , "LogicalPos_", TmpVec3 );
CmdGroupMove( Selector, Queuing, TmpVec3, flags, Distance );
}
//======================================================================================================
stock CmdGroupRandomWait( Group[], Float:RandomMax, eQueuing:Queuing )
{
new Iterator:i = Iterate( Group );
while( ItNext( i ))
CmdWait( ItEntity( i ), Queuing, FloatRnd( 0.0, RandomMax ));
ItStop( i );
}
//======================================================================================================
stock CmdGroupTurnToEnt( Selector[], DrID:TargetEntity, eQueuing:Queuing = Q_OVERRIDE, flags = TF_NONE )
{
new Float:TmpVec3[vec3];
GetPropertyVec3( TargetEntity , "LogicalPos_", TmpVec3 );
CmdGroupTurnToPos( Selector, Queuing, TmpVec3, flags );
}
//======================================================================================================
stock CmdTurnToEnt( DrID:Unit, DrID:TargetEntity, eQueuing:Queuing = Q_OVERRIDE, flags = TF_NONE )
{
new Float:TmpVec3[vec3];
GetPropertyVec3( TargetEntity , "LogicalPos_", TmpVec3 );
CmdTurnToPos( Unit, Queuing, TmpVec3, flags );
}
stock CmdTurnWpToEnt( DrID:Unit, DrID:TargetEntity, eQueuing:Queuing = Q_OVERRIDE )
{
new Float:TmpVec3[vec3];
GetPropertyVec3( TargetEntity , "LogicalPos_", TmpVec3 );
CmdTurnWpToPos( Unit, Queuing, TmpVec3);
}
//======================================================================================================
stock CommonAKMain() // Ide kerulnek olyan altalanos dolgok, amik jo esellyel minden palyara kellenek.
{
// gSettingsIniDL = eDebugLevel:floatround( GetNumberSetting( "script", "debuglevel" ));
gDL = eDebugLevel:floatround( GetNumberSetting( "script", "debuglevel" ));
DebugMessage( "CommonAKMain started...", DL_MESSAGE );
// Common things executed after game start
AddAKEntityEvent( "PostGameStart", GetEntity( "World"), POSTGAMESTART );
DebugMessage( " Event 'POSTGAMESTART' added -> function 'PostGameStart'.", DL_MESSAGE );
if( eDebugLevel:floatround( GetNumberSetting( "script", "debuglevel" )) != DL_FORBID ) {
AddAKEntityEvent( "IterateDebugLevels", ANY_ENTITY, DEBUG_EVENT );
DebugMessage( " DebugLevel != -1 => Event 'DEBUG_EVENT' added -> funciton 'IterateDebugLevels'.", DL_MESSAGE );
}
DebugMessage( "CommonAKMain executed.", DL_MESSAGE );
}
//======================================================================================================
stock CommonAKInit()
{
DebugMessage( "CommonAKInit started...", DL_MESSAGE );
gPlayerTeam = GetPropertyInt( GetWorld(), "PlayerTeam" );
gShermanVal=GetPropertyInt( GetBaseComponentBase( GetEntityBase( "al_M4 Sherman" ), "cManagementBase"), "Value" );
gTigerVal=GetPropertyInt( GetBaseComponentBase( GetEntityBase( "ax_Tiger" ), "cManagementBase"), "Value" );
gPZIIINVal=GetPropertyInt( GetBaseComponentBase( GetEntityBase( "ax_PzIIIN" ), "cManagementBase"), "Value" );
gDaimlerIIVal=GetPropertyInt( GetBaseComponentBase( GetEntityBase( "al_DaimlerII" ), "cManagementBase"), "Value" );
DebugMessage( "CommonAKInit executed.", DL_MESSAGE );
}
//======================================================================================================
//======================================================================================================
stock CopyRGBA( Float:Source[rgba], Float:Dest[rgba] )
{
Dest[rgba:r] = Source[rgba:r];
Dest[rgba:g] = Source[rgba:g];
Dest[rgba:b] = Source[rgba:b];
Dest[rgba:a] = Source[rgba:a];
}
//======================================================================================================
stock CopyVec2( Float:Source[vec2], Float:Dest[vec2] )
{
Dest[vec2:x] = Source[vec2:x];
Dest[vec2:y] = Source[vec2:y];
}
//======================================================================================================
stock CopyVec3( Float:Source[vec3], Float:Dest[vec3] )
{
Dest[vec3:x] = Source[vec3:x];
Dest[vec3:y] = Source[vec3:y];
Dest[vec3:z] = Source[vec3:z];
}
//======================================================================================================
stock CountLiving( DrID:... ) // Megszamolja, hany el a felsorolt unitok kozul
{
new Counter = 0;
for( new i = 0; i < numargs(); i++ )
if( IsAlive(DrID:getarg(i)))
Counter++;
return Counter;
}
//======================================================================================================
stock CountEntitiesInSelector( Selector[] , const ClassType[] = "cAKEntity" ) // Megszamlalja, a szelektornak hany eleme van.
{
new NoOfEntities = 0;
new Iterator:i = Iterate( Selector , ClassType);
while( ItNext(i))
NoOfEntities++;
ItStop(i);
return NoOfEntities;
}
//======================================================================================================
stock CountInCircleArea( Selector[], DrID:CircleArea , const ClassType[] = "cAKEntity")
{
new Counter = 0;
new Float:Radius = GetPropertyFloat( CircleArea, "Radius" );
new Iterator:i = Iterate( Selector , ClassType );
while( ItNext(i))
if( DistanceAKe2e( ItEntity(i), CircleArea ) < Radius )
Counter++;
ItStop(i);
return Counter;
}
//======================================================================================================
stock CountLivingMatesCircle( Selector[], Team, DrID:CircleArea ) // Count living mates in circle area
// Ha lehet, hasznalj helyette CountLivingInSelector-t, mert az gyorsabb
{
new Counter = 0;
new DrID:Unit;
new Float:Radius = GetPropertyFloat( CircleArea, "Radius" );
new Iterator:i = Iterate( Selector );
while( ItNext(i)) {
Unit = ItEntity(i);
if(
IsAlive(Unit) &&
GetPropertyInt( Unit, "Team" ) == Team &&
IsEntityActive( Unit )
) {
if( DistanceAKe2e( Unit, CircleArea ) < Radius )
Counter++;
}
}
ItStop(i);
return Counter;
}
//======================================================================================================
stock CountLivingInSelector( Selector[] ) // Counts living and active entities in selector
{
new NoOfLivingActive = 0;
new Iterator:i = Iterate( Selector );
while( ItNext(i))
{
new DrID:Entity = ItEntity(i)
if( IsAlive( Entity) && IsEntityActive( Entity))
NoOfLivingActive++;
}
ItStop(i);
return NoOfLivingActive;
}
//======================================================================================================
stock CountLivingIn2Selector( Selector1[], Selector2[] ) // Counts living and active entities in the intersection
{
new NoOfLivingActive = 0;
new Iterator:i = Iterate( Selector1 );
while( ItNext(i))
{
new DrID:Entity = ItEntity(i);
if( IsAlive( Entity ) && IsEntityActive( Entity) && IsInSelector( Entity, Selector2 ))
NoOfLivingActive++;
}
ItStop(i);
return NoOfLivingActive;
}
//======================================================================================================
stock CountLivingMates( Selector[], Team )
{
new Counter = 0;
new DrID:Unit;
new Iterator:i = Iterate( Selector );
while( ItNext(i)) {
Unit = ItEntity(i);
if(
IsAlive(Unit)&&
GetPropertyInt( Unit, "Team" ) == Team &&
IsEntityActive( Unit )
)
Counter++;
}
ItStop(i);
return Counter;
}
//======================================================================================================
stock DrID:CreateEntity2Ent(Base[], DrID:Entity, bool:UseDir=true, Float:ReqDir=90.0)
{
//native DrID:CreateEntity( const Base[], Float:Pos[vec3], Float:dir = 90.0 );
if(Entity==DrID:0)
{
DebugMessage( "CreateEntity2Ent: Invalid Entity requested!", DL_ERROR );
return DrID:0;
}
new Float:Pos[vec3];
GetPropertyVec3( Entity, "LogicalPos_", Pos );
new Float:EntDir
if(UseDir)
{
EntDir=GetEntityDir( Entity, DB_X_AXIS );
}
else
{
EntDir=ReqDir;
}
new DrID:NewEntity=CreateEntity( Base, Pos, EntDir );
if(NewEntity==DrID:0)
{
DebugMessage( "CreateEntity2Ent: Entity creation FAILED!", DL_ERROR );
}
return NewEntity;
}
//======================================================================================================
stock CropString(StringToCrop[],StartPos,EndPos)
{
EndPos++;
if(StartPos > strlen(StringToCrop) || EndPos > strlen(StringToCrop) || StartPos < 0 || EndPos < 0)
{
DebugMessage( "akcommon.inc:CropString:One of the positions is out of String", DL_ERROR );
if(StartPos > strlen(StringToCrop))
StartPos = strlen(StringToCrop);
if(EndPos > strlen(StringToCrop))
EndPos = strlen(StringToCrop);
if(StartPos < 0)
StartPos = 0;
if(EndPos < 0)
EndPos = 0;
DebugMessage( "akcommon.inc:CropString:MODIFIED TO CORRECT VALUE!", DL_ERROR );
}
if(StartPos >EndPos)
{
DebugMessage( "akcommon.inc:CropString:Starting Position is after End Position!", DL_ERROR );
return false;
}
StringToCrop[EndPos]=0;
ConcatString( StringToCrop, 100, StringToCrop[StartPos], "" );
return true;
}
stock DiffVec3(Float:DV3Source[vec3],Float:DV3Target[vec3],Float:DV3Difference[vec3])
{
DV3Difference[vec3:x]=DV3Target[vec3:x]-DV3Source[vec3:x];
DV3Difference[vec3:y]=DV3Target[vec3:y]-DV3Source[vec3:y];
DV3Difference[vec3:z]=DV3Target[vec3:z]-DV3Source[vec3:z];
}
//======================================================================================================
stock DebugMessage( Message[], eDebugLevel:Level = DL_MESSAGE )
{
if( IsDebugLevelOK( Level ) ) {
// Determine if print to viewport is needed:
new PrintToViewport = false;
if( gDL >= eDebugLevel:10 )
PrintToViewport = true;
new tmpMessage[301];
ConcatString( tmpMessage, 300, gDebugMessageStyle, Message );
switch( Level ) {
case DL_CRITICAL: ConcatString( tmpMessage, 300, "#cred#CRITICAL ERROR: ", tmpMessage );
case DL_ERROR: ConcatString( tmpMessage, 300, "#cred#ERROR: ", tmpMessage );
case DL_WARNING: ConcatString( tmpMessage, 300, "#cyellow#WARNING: ", tmpMessage );
case DL_MESSAGE: ConcatString( tmpMessage, 300, "DEBUG INFO: ", tmpMessage );
case DL_BEHAVIOR: ConcatString( tmpMessage, 300, "#cyellow#BEHAVIOR: ", tmpMessage );
}
// Output the message:
Log( tmpMessage, "proglog\\scriptlog" );
if( PrintToViewport )
ShowShortMessage( tmpMessage );
}
}
//======================================================================================================
stock DebugMessageP1( Message[], Param, eDebugLevel:Level)
{
if( IsDebugLevelOK( Level )) {
new tmpstr[301];
Int2Str( Param, tmpstr, 300 );
ConcatString( tmpstr, 300, Message, tmpstr );
DebugMessage( tmpstr, Level );
}
}
//======================================================================================================
stock Float:DegToRad( Float:Value )
return (Value * PI / 180);
//======================================================================================================
stock Float:DistanceAKe2e( DrID:Entity1, DrID:Entity2 )
{
new Float:Pos1[vec3];
new Float:Pos2[vec3];
GetPropertyVec3( Entity1, "LogicalPos_", Pos1 );
GetPropertyVec3( Entity2, "LogicalPos_", Pos2 );
Pos1[vec3:z] = Pos2[vec3:z] = 0.0;
return Distance( Pos1, Pos2 );
}
//======================================================================================================
stock Float:DistanceAKe2p( DrID:Entity, Float:Pos1[vec3] )
{
new Float:Pos2[vec3];
GetPropertyVec3( Entity, "LogicalPos_", Pos2 );
Pos1[vec3:z] = Pos2[vec3:z] = 0.0;
return Distance( Pos1, Pos2 );
}
//======================================================================================================
stock Float:DistanceAKp2p( Float:Pos1[vec3], Float:Pos2[vec3] ) // Int tavolsagot ad vissza, z koordinatat figyelmen kivul hagyja
{
Pos1[vec3:z] = Pos2[vec3:z] = 0.0;
return Distance( Pos1, Pos2 );
}
//======================================================================================================
//returns true if the unit can phisically see an other unit from the queried selector
stock bool:DoesSeeSelector(DrID:UndWho, UndSelector[])
{
if(UndWho==DrID:0)
{
DebugMessage( "DoesSeeEnemy: Invalid DrID!", DL_ERROR )
return false;
}
if(!IsAlive(UndWho))
{
DebugMessage( "DoesSeeEnemy: Queried DrID is DEAD!", DL_ERROR )
return false;
}
new Float:lTmpFloat=GetPropertyFloat( UndWho, "FOWRangeInnerRadius" );
new DrID:lTmpDrID=GetNearestEntity(UndWho,UndSelector, true, GetClassID( "cUnit" ), false);
if(lTmpDrID==DrID:0)
{
DebugMessage( "DoesSeeEnemy: No living unit in the queried selector!", DL_ERROR )
return false;
}
//ha a tav a legkozelebbi enemy es kozte <= FOWRange belso kore akkor true
return(DistanceAKe2e( UndWho, lTmpDrID )<=lTmpFloat);
}
stock DropPara2Ent(Team, setupID[], DrID:DP2E_Entity, flags)
{
new Float:DP2E_Vec3[vec3];
if(DP2E_Entity!=DrID:0)
{
GetPropertyVec3( DP2E_Entity, "LogicalPos_", DP2E_Vec3 );
}
else
{
return;
}
DropParatroopers(Team, setupID, DP2E_Vec3, flags);
}
//======================================================================================================
stock Float:FloatAbs( Float:Value )
{
if( Value < 0.0 )
return -Value;
return Value;
}
//======================================================================================================
stock Float:FloatClamp( Float:Value, Float:Min, Float:Max )
{
if( Max < Min )
DebugMessage( "Warning:akcommon.inc:FloatClamp: Max < Min!", DL_WARNING );
if( Value < Min )
Value = Min;
else if( Value > Max )
Value = Max;
return Value;
}
//======================================================================================================
stock Float:FloatRnd( Float:Min, Float:Max )
{
if( Max < Min )
DebugMessage( "Warning:akcommon.inc:FloatRnd: Max < Min!", DL_WARNING );
return Min + ( Max - Min ) * float( Rnd( 0, 32768 )) / 32768;
}
//======================================================================================================
stock FillWithCrew(DrID:FWFC_Ent, FWFC_Team=1, FWFC_LeaveEmpty=0)
{
// if(FWFC_Ent==DrID:0
// ||!(IsInstanceOf( FWFC_Ent, GetClassID( "cVehicle" ))
// || IsInstanceOf( FWFC_Ent, GetClassID( "cVehicle" ))))
// {
// return;
// }
new DrID:FWFC_MPoint = GetComponent(FWFC_Ent, "cMountPoint");
if(FWFC_MPoint==DrID:0)
{
DebugMessage( "FillWithCrew: The requested Entity is not mountable!", DL_WARNING );
return;
}
new FWFC_ciklus;
new FWFC_MP_Max=GetPropArrayLength(FWFC_MPoint, "MountPositions");
FWFC_MP_Max-=FWFC_LeaveEmpty;
new FWFC_MP_Act=GetPropArrayLength(FWFC_MPoint, "Mounted");
new DrID:FWFC_2BMounted;
new FWFC_Soldat[66];
new Float:FWFC_Loc[vec3];
GetPropertyVec3( FWFC_Ent, "LogicalPos_", FWFC_Loc )
if(FWFC_MP_Act>=FWFC_MP_Max)
{
DebugMessage( "FillWithCrew: The requested Entity already full!", DL_WARNING );
return;
}
for (FWFC_ciklus=FWFC_MP_Act;FWFC_ciklus<FWFC_MP_Max;FWFC_ciklus++)
{
switch(FWFC_Team)
{
case 1:
{
FWFC_Soldat="ax_rifleman";
}
default:
{
FWFC_Soldat="al_rifleman";
}
}
FWFC_2BMounted=CreateEntity( FWFC_Soldat, FWFC_Loc );
SetPropertyInt( FWFC_2BMounted, "Team", FWFC_Team );
CmdMount( FWFC_2BMounted, Q_OVERRIDE, FWFC_Ent,MTF_TELEPORT );
}
}
//======================================================================================================
stock FillSelectorWithCrew( Selector[], FWFC_Team=1, FWFC_LeaveEmpty=0 )
{
new Iterator:i = Iterate( Selector );
while( ItNext( i ))
FillWithCrew( ItEntity( i ), FWFC_Team, FWFC_LeaveEmpty );
ItStop( i );
}
//======================================================================================================
stock FixZ( Group[] )
{
new Iterator:i = Iterate( Group );
new DrID:Entity;
new Float:Coord[vec3];
while( ItNext( i ))
{
Entity = ItEntity( i );
GetPropertyVec3( Entity, "LogicalPos_", Coord );
Coord[vec3:z] = 0.0;
SetPropertyVec3( Entity, "Pos", Coord );
SetPropertyFloat( Entity, "RelativeZ", 0.0 );
SetPropertyVec3( Entity, "Pos", Coord );
SetPropertyFloat( Entity, "RelativeZ", 0.0 );
}
}
//======================================================================================================
stock FormationMoveToEnt(DasGroup[],DrID:DasTarget,eQueuing:DasQju = Q_OVERRIDE, eMoveFlag:DasFlag = MF_NONE)
{
/* //ha nem DIRECT MOVE-al kell neked akkor ezt hasznald:
CmdGroupMoveToEnt(DasGroup, DasTarget, DasQju, DasFlag | _:MF_KEEP_FORMATION);
*/ new Float:lTmpVec3[vec3];
GetPropertyVec3( DasTarget, "LogicalPos_", lTmpVec3 );
FormationMoveToPos(DasGroup,lTmpVec3,DasQju, DasFlag);
}
stock FormationMoveToPos(DasGroup[],Float:DasPositzion[vec3],eQueuing:DasQju = Q_OVERRIDE, eMoveFlag:DasFlag = MF_NONE)
{
/* ha nem DIRECT MOVE-al kell neked akkor ezt hasznald:
CmdGroupMove(DasGroup, DasQju, DasPositzion, DasFlag | _:MF_KEEP_FORMATION);
*/
new Float:FMTPMiddle[vec3];
new Float:FMTPActPos[vec3];
new Float:FMTPDestPos[vec3];
new Float:FMTPDiff[vec3];
new Iterator:FMTPiti=Iterate(DasGroup);
GetMiddleOfGroup(DasGroup, FMTPMiddle);
DiffVec3(FMTPMiddle,DasPositzion,FMTPDiff);
while(ItNext(FMTPiti))
{
if(IsInstanceOf( ItEntity(FMTPiti), GetClassID( "cUnit" )))
{
GetPropertyVec3( ItEntity(FMTPiti), "LogicalPos_", FMTPActPos );
AddVec3( FMTPActPos, FMTPDiff, FMTPDestPos );
if(!IsMounted( ItEntity(FMTPiti )))
{
CmdMove( ItEntity(FMTPiti), DasQju, FMTPDestPos, DasFlag );
}
}
}
ItStop(FMTPiti);
}
stock DrID:GetBaseComponentBase(DrID:EntityBase, GeneKibaszottLusta[])
{
new ComponentSzam=GetPropArrayLength(EntityBase, "ComponentBases");
new DrID:ImuleIsLusta;
new ciklus;
for(ciklus=0;ciklus<ComponentSzam;ciklus++)
{
ImuleIsLusta=GetArrayElement(EntityBase, "ComponentBases", ciklus);
if(IsInstanceOf(ImuleIsLusta, GetClassID( GeneKibaszottLusta )))
{
return ImuleIsLusta;
}
}
return DrID:0;
}
//======================================================================================================
stock DrID:GetFirstEntity( Selector[] )
{
new DrID:Entity = DrID:0;
new Iterator:i = Iterate( Selector );
if( ItNext(i))
Entity = ItEntity(i);
ItStop(i);
return Entity;
}
//======================================================================================================
stock DrID:GetFirstLivingUnit( Selector[] )
{
new DrID:Unit = DrID:0;
new Iterator:i = Iterate( Selector );
while( ItNext(i)) {
if( IsAlive( ItEntity(i))) {
Unit = ItEntity(i);
ItStop(i);
break;
}
}
return Unit;
}
//======================================================================================================
stock GetIncrementFloat( Float:Value1, Float:Value2, Float:Duration, Float:TimeSlice )
return (Value2 - Value1) * TimeSlice / Duration;
//======================================================================================================
stock GetIncrementRGBA( Float:Color1[rgba], Float:Color2[rgba], Float:Result[rgba], Float:Duration, Float:TimeSlice )
{
new Float:Ratio = TimeSlice / Duration;
Result[rgba:r] = Ratio * ( Color2[rgba:r] - Color1[rgba:r] );
Result[rgba:g] = Ratio * ( Color2[rgba:g] - Color1[rgba:g] );
Result[rgba:b] = Ratio * ( Color2[rgba:b] - Color1[rgba:b] );
Result[rgba:a] = Ratio * ( Color2[rgba:a] - Color1[rgba:a] );
}
//======================================================================================================
stock GetIncrementVec3( Float:Vec1[vec3], Float:Vec2[vec3], Float:Result[vec3], Float:Duration, Float:TimeSlice )
{
new Float:Ratio = TimeSlice / Duration;
Result[vec3:x] = Ratio * ( Vec2[vec3:x] - Vec1[vec3:x] );
Result[vec3:y] = Ratio * ( Vec2[vec3:y] - Vec1[vec3:y] );
Result[vec3:z] = Ratio * ( Vec2[vec3:z] - Vec1[vec3:z] );
}
//======================================================================================================
// Ket float kozott ara'nnyal kiszamitott floatot ad vissza. Ratio: 0.0 - 1.0
stock GetIntermediateFloat( Float:Value1, Float:Value2, Float:Ratio )
return ( Value1 + (Value2 - Value1) * Ratio );
//======================================================================================================
// Ket szin kozott ara'nnyal kiszamitott szint ad vissza: Ratio: 0.0 - 1.0
stock GetIntermediateRGBA( Float:Color1[rgba], Float:Color2[rgba], Float:Result[rgba], Float:Ratio )
{
Result[rgba:r] = Color1[rgba:r] + Ratio * ( Color2[rgba:r] - Color1[rgba:r] );
Result[rgba:g] = Color1[rgba:g] + Ratio * ( Color2[rgba:g] - Color1[rgba:g] );
Result[rgba:b] = Color1[rgba:b] + Ratio * ( Color2[rgba:b] - Color1[rgba:b] );
Result[rgba:a] = Color1[rgba:a] + Ratio * ( Color2[rgba:a] - Color1[rgba:a] );
}
//======================================================================================================
// Ket vektor kozott ara'nnyal kiszamitott vektort ad vissza: Ratio: 0.0 - 1.0
stock GetIntermediateVec3( Float:Vec1[vec3], Float:Vec2[vec3], Float:Result[vec3], Float:Ratio )
{
Result[vec3:x] = Vec1[vec3:x] + Ratio * ( Vec2[vec3:x] - Vec1[vec3:x] );
Result[vec3:y] = Vec1[vec3:y] + Ratio * ( Vec2[vec3:y] - Vec1[vec3:y] );
Result[vec3:z] = Vec1[vec3:z] + Ratio * ( Vec2[vec3:z] - Vec1[vec3:z] );
}
//======================================================================================================
stock Float:GetMaxSpeed( DrID:Unit, eMovementStyle:MovementStyle=MS_NONE ) // Untested
{
new DrID:Comp = GetComponent( Unit, "cUnitController" );
new DrID:BaseComp = GetComponent( GetBaseEntity( Unit ), "cUnitController" );
switch( MovementStyle )
{
case MS_NONE:
{
// A kovekezo ket sor teszt celra szolgal:
// new eMovementStyle:QueriedMS = eMovementStyle:GetPropertyInt( Comp, "MovementStyle" );
// new iQueriedMS = GetPropertyInt( Comp, "MovementStyle" );
switch( GetPropertyInt( Comp, "MovementStyle" ))
{
case MS_RUN:
return GetPropertyFloat( BaseComp, "MaxSpeedRun" );
case MS_WALK:
return GetPropertyFloat( BaseComp, "MaxSpeedWalk" );
case MS_CRAWL:
return GetPropertyFloat( BaseComp, "MaxSpeedCrawl" );
default:
{
DebugMessage( "akcommon.inc:GetMaxSpeed: No movementstyle specified and invalid movementstyle queried!", DL_ERROR );
return -1.0;
}
}
}
case MS_RUN:
return GetPropertyFloat( BaseComp, "MaxSpeedRun" );
case MS_WALK:
return GetPropertyFloat( BaseComp, "MaxSpeedWalk" );
case MS_CRAWL:
return GetPropertyFloat( BaseComp, "MaxSpeedCrawl" );
}
// Egyebkent hiba:
DebugMessage( "akcommon.inc:GetMaxSpeed:Invalid movementstyle queried!", DL_ERROR );
return -1.0;
}
//======================================================================================================
stock DrID:GetNearestEntity(DrID:FromWho, FromSelector[], bool:Alive = true, UnitType[100] = "cAKEntity", bool:CanBeMounted = true,Float:GNEMinRange=0.0,Float:GNEMaxRange=6666.66)
{
if(DrID:FromWho)
{
if(GetListLen(FromSelector)!=0)
{
new Float:LowestDistance = GNEMaxRange;
new DrID:NearestEntity = DrID:0;
new Iterator:i = Iterate(FromSelector, UnitType );
new bool:AliveFlag = true;
new Float:Dist;
new DrID:ZieAktEntity
while(ItNext(i))
{
Dist=DistanceAKe2e( FromWho, ItEntity(i) );
ZieAktEntity=ItEntity(i);
if(Alive)
AliveFlag = IsAlive( ZieAktEntity );
if(
Dist< LowestDistance
&& IsMountedIn(FromWho)!= ZieAktEntity
&& FromWho != ZieAktEntity
&& AliveFlag
&& Dist > GNEMinRange
)
{
if(CanBeMounted) //if the entity could be mounted then we're done
{
NearestEntity = ZieAktEntity;
LowestDistance = Dist;
}
else //if can't be a mounted unit then we've to check this
{
if(IsMountedIn(ZieAktEntity) == DrID:0) //so this unit isn't mounted
{
NearestEntity = ZieAktEntity;
LowestDistance = Dist;
}
}
}
}
ItStop(i);
if(NearestEntity)
return NearestEntity;
// else
// {
// DebugMessage( "akcommon.inc:GetNearestEntity:Empty DrID is the query's result!!!!!", DL_ERROR );
// }
}
// else
// {
// DebugMessage( "akcommon.inc:GetNearestEntity:Invalid Selector queried or no living member!!!!", DL_ERROR );
// }
}
// else
// {
// DebugMessage( "akcommon.inc:GetNearestEntity:Invalid Entity queried!!!!", DL_ERROR );
// }
return DrID:0;
}
//======================================================================================================
stock GetMiddleOfGroup(GMOGGroup[],Float:GMOGMiddle[vec3])
{
new Float:lSumVec3[vec3]={0.0,0.0,0.0};
new Float:lActVec3[vec3];
new lTotalMembs=0;
new Iterator:iti=Iterate(GMOGGroup,"cAKEntity");
new AkarmiString[255];
new PozicioString[255];
while(ItNext(iti))
{
if(ItEntity(iti)!=DrID:0)
{
GetPropertyString( ItEntity(iti), "StringID", 250, AkarmiString)
GetPropertyVec3( ItEntity(iti), "LogicalPos_", lActVec3 );
vec32str(PozicioString,lActVec3);
lTotalMembs++;
AddVec3( lSumVec3, lActVec3, lSumVec3 );
}
}
ItStop(iti);
if(lTotalMembs==0)
lTotalMembs++;
GMOGMiddle[vec3:x]=floatdiv(lSumVec3[vec3:x],float(lTotalMembs));
GMOGMiddle[vec3:y]=floatdiv(lSumVec3[vec3:y],float(lTotalMembs));
GMOGMiddle[vec3:z]=floatdiv(lSumVec3[vec3:z],float(lTotalMembs));
}
//======================================================================================================
stock DrID:GetSlowestUnitInSelector( Selector[], eMovementStyle:MovementStyle=MS_NONE ) // Untested
{
new DrID:SlowestUnit;
new Float:SlowestSpeed = 10000.0;
new Float:ActualSpeed;
// Count Entities:
new NoOfEntities = CountEntitiesInSelector( Selector );
// Special Cases:
if( NoOfEntities == 0)
return DrID:0;
// Iterations:
new Iterator:i = Iterate( Selector );
while( ItNext( i )) {
ActualSpeed = GetMaxSpeed( ItEntity( i ), MovementStyle );
if( ActualSpeed < SlowestSpeed ) {
SlowestUnit = ItEntity( i );
SlowestSpeed = ActualSpeed;
}
}
ItStop( i );
return SlowestUnit;
}
//======================================================================================================
stock Float:GetSlowestSpeedInGroup( Group[])
{
new Float:SpeedLimit = 10000.0;
new Iterator:i = Iterate( Group );
// new str[250];
while( ItNext(i) )
{
new Float:ActMaxSpeed;
ActMaxSpeed = GetPropertyFloat( GetComponent( ItEntity(i), "cUnitController"), "ActMaxSpeed" );
if( ActMaxSpeed < SpeedLimit )
SpeedLimit = ActMaxSpeed;
}
ItStop(i);
if( SpeedLimit == 10000.0 )
{
if( IsDebugLevelOK( DL_WARNING ))
{
new tmpStr[200];
ConcatString( tmpStr, 199, "GetSlowestSpeedInGroup: Return value = 0.0, because group is empty: ", Group );
DebugMessage( tmpStr, DL_WARNING );
}
return 0.0;
}
// else:
return SpeedLimit;
}
//======================================================================================================
stock DrID:GetWorld()
return GetEntity( "World" );
//======================================================================================================
stock bool:HasSelectorAnyAlive( Selector[], Limit = 1 ) // If selector has any OR! Limit piece of living entities
{
new NoOfLivingActive = 0;
new Iterator:i = Iterate( Selector );
while( ItNext(i)) {
if( IsAlive( ItEntity(i)) && IsEntityActive( ItEntity(i))) {
NoOfLivingActive++;
if( NoOfLivingActive >= Limit ) {
ItStop(i);
return true;
}
}
}
ItStop(i);
return false;
}
//======================================================================================================
stock bool:IsEvenNum(LeNumero)
{
return (((LeNumero/2)*2)==LeNumero);
}
//======================================================================================================
stock bool:IsAnyEntityMoving( Selector[] )
{
new bool:IsSomebodyMoving = false;
new Iterator:i = Iterate( Selector );
while( ItNext(i)) {
if( IsMoving( ItEntity(i))) {
IsSomebodyMoving = true;
ItStop(i);
break;
}
}
return IsSomebodyMoving;
}
//======================================================================================================
stock bool:IsPlayer(DrID:UndWho)
{
if(UndWho!=DrID:0)
return (GetPropertyInt( UndWho, "Team" )==gPlayerTeam)
return false;
}
//======================================================================================================
stock bool:IsEntityComp(DrID:Entity, Componentname[])
{
if(Entity != DrID:0)
{
if(GetComponent( Entity, Componentname) != DrID:0)
return true;
else
return false;
}
DebugMessage( "This DrID is not valid!", DL_ERROR );
return false;
}
//======================================================================================================
stock Float:GetActualHealth( DrID:Unit )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:GetActualHealth: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return Float:-1.0;
}
new DrID:BodyComp = GetPropertyObject( DRComp, "Body")
if(BodyComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have Body", DL_BEHAVIOR );
return Float:-1.0;
}
return Float:(GetPropertyFloat( BodyComp, "HP" ) );
}
//======================================================================================================
stock SetActualHealth( DrID:Unit, Float:Health )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:GetActualHealth: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return ;
}
new DrID:BodyComp = GetPropertyObject( DRComp, "Body")
if(BodyComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have Body", DL_BEHAVIOR );
return ;
}
SetPropertyFloat( BodyComp, "HP", Health );
}
stock bool:IsAttacking( DrID:Entity )
{
new bool:IsHeAttacking=false;
new DrID:WepMana=GetComponent( Entity, "cWeaponManager");
if(WepMana==DrID:0)
{
DebugMessage( "akcommon.inc:IsAttacking: No Weapon Manager Detected.", DL_ERROR );
return false;
}
else
{
DebugMessage( "akcommon.inc:IsAttacking: Weapon Manager Detected.", DL_BEHAVIOR );
}
new WepArraySize= GetPropArrayLength( WepMana, "Weapons");
if(WepArraySize==0)
{
DebugMessage( "akcommon.inc:IsAttacking: No Weapon under Weapon Manager!", DL_ERROR )
return false;
}
else
{
DebugMessage( "akcommon.inc:IsAttacking: Got Weapon under Weapon Manager!", DL_BEHAVIOR )
}
new DrID:AktElement;
new Float:lTmpVec3[vec3];
new ciklus;
for(ciklus=0;ciklus<WepArraySize;ciklus++)
{
AktElement=GetArrayElement(WepMana, "Weapons", ciklus);
if(AktElement!=DrID:0)
{
if(!(GetPropertyFloat( AktElement, "ReloadingCounter" )==0.0))
{
DebugMessage( "IsAttacking: ReloadingCounter was higher than 0.0", DL_MESSAGE )
}
else
{
DebugMessage( "IsAttacking: ReloadingCounter is 0.0", DL_BEHAVIOR )
}
GetPropertyVec3( AktElement, "TargetPos", lTmpVec3 );
if(!(CompareVec3(lTmpVec3,Float:{0.0,0.0,0.0})||CompareVec3(lTmpVec3,Float:{-1.0,-1.0,-1.0})))
{
DebugMessage( "IsAttacking: TargetPos was differ from 0,0,0 or -1,-1,-1", DL_MESSAGE )
}
else
{
DebugMessage( "IsAttacking: TargetPos is 0,0,0 or -1,-1,-1", DL_BEHAVIOR )
}
if(!
(
CompareVec3(lTmpVec3,Float:{0.0,0.0,0.0})
||
CompareVec3(lTmpVec3,Float:{-1.0,-1.0,-1.0})
)
||
!(
GetPropertyFloat( AktElement, "ReloadingCounter" )==0.0
)
)
{
IsHeAttacking=true;
}
// new lTmpStr[255]
// vec32str(lTmpStr, lTmpVec3)
// DebugMessage( lTmpStr, DL_MESSAGE );
// Float2Str( GetPropertyFloat( AktElement, "ReloadingCounter" ), lTmpStr, 255, "%7.3f" );
// DebugMessage( lTmpStr, DL_MESSAGE );
}
}
return IsHeAttacking;
}
//======================================================================================================
stock bool:IsDebugLevelOK( eDebugLevel:DebugLevel )
{
new eDebugLevel:tmpDL = gDL;
if( tmpDL >= eDebugLevel:10 )
tmpDL -= eDebugLevel:10;
if( !DebugLevel || !tmpDL ) // If either of them is 0. For the sake of security.
return false;
if( DebugLevel <= tmpDL )
return true;
return false;
}
//======================================================================================================
public IterateDebugLevels( DrID:Sender )
{
// A fuggveny erdekessege, hogy a palyan levo minden entitasban hozza kell adni az event handlert,
// hogy meghivodjon. Viszont a valtast csak egyszer kell kiirni a kepernyore.
// Leptetes:
if( gDL != DL_FORBID ) // csak akkor leptetunk, ha nem tilos
{
gDL++;
if( gDL < eDebugLevel:10 ) // mindenkeppen bekapcsoljuk a kepernyore irast
gDL += eDebugLevel:10;
}
if( gDL > gDLMax )
gDL = gDLMin;
// Kiiras:
new tmpMessage[200];
Int2Str( gDL, tmpMessage, 10 );
ConcatString( tmpMessage, 200, "#cred#>>>#d##cyellow#DebugLevel changed to ", tmpMessage );
switch( gDL - eDebugLevel:10 ) {
case DL_OFF: ConcatString( tmpMessage, 200, tmpMessage, " : No debug messages." );
case DL_CRITICAL: ConcatString( tmpMessage, 200, tmpMessage, " : Critical Errors. (Press CTRL-W to disable)" );
case DL_ERROR: ConcatString( tmpMessage, 200, tmpMessage, " : Errors. (Press CTRL-W to disable)" );
case DL_WARNING: ConcatString( tmpMessage, 200, tmpMessage, " : Warnings. (Press CTRL-W to disable)" );
case DL_MESSAGE: ConcatString( tmpMessage, 200, tmpMessage, " : Messages. (Press CTRL-W to disable)" );
case DL_BEHAVIOR: ConcatString( tmpMessage, 200, tmpMessage, " : Behavior messages. (Lots of text! Press CTRL-W to disable)" );
default: ConcatString( tmpMessage, 200, tmpMessage, " : Error in akcommon.inc:IterateDebugLevels." );
}
if( GetEntity( "self" ) == GetWorld() ) { // Csak a palyascriptre irjuk ki
ShowShortMessage( tmpMessage );
Log( tmpMessage, "proglog\\scriptlog" );
}
}
// Az alabbi beolvassa es visszaadja a local settingsbeli erteket, vagy visszaadja az overwrite-olt erteket
//======================================================================================================
stock eDebugLevel:GetDebugLevel()
{
return gDL;
}
//======================================================================================================
stock HideEntity(DrID:Unit)
{
if(Unit!=DrID:0)
{
SetPropertyBool( Unit, "Visible", false );
SetPropertyBool( Unit, "Invisible", true );
}
}
//======================================================================================================
stock bool:IsAlive( DrID:Unit, bool:CheckIfActive = false )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return false;
}
new DrID:BodyComp = GetPropertyObject( DRComp, "Body" )
if(BodyComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have Body", DL_BEHAVIOR );
return false;
}
// Check if active:
new bool:ActiveOK = true;
if( CheckIfActive && !GetPropertyBool( Unit, "Active" ))
ActiveOK = false;
return bool:( GetPropertyFloat( BodyComp, "HP" ) > 0.0 && ActiveOK );
}
//======================================================================================================
stock bool:IsAliveTurret( DrID:Unit )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
{
DRComp = GetComponent( Unit, "cDRVehicle");
}
else
{
DebugMessage( "akcommon.inc:IsAliveTurret: The Unit is not a Vehicle", DL_BEHAVIOR );
return false;
}
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAliveTurret: The Unit doesn't have cDRVehicle", DL_BEHAVIOR );
return false;
}
if(!GetPropertyBool( GetComponentBase(DRComp), "HasTurret" ))
{
DebugMessage( "akcommon.inc:IsAliveTurret: The Unit doesn't have a Turret", DL_BEHAVIOR );
return true; //returning true so repairing not necessary on this
}
return (GetPropertyFloat( DRComp, "TurretPercent" ) > 0.0);
}
//======================================================================================================
stock bool:IsAliveCaterpillar( DrID:Unit )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
{
DRComp = GetComponent( Unit, "cDRVehicle");
}
else
{
DebugMessage( "akcommon.inc:IsAliveCaterpillar: The Unit is not a Vehicle", DL_BEHAVIOR );
return false;
}
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAliveCaterpillar: The Unit doesn't have cDRVehicle", DL_BEHAVIOR );
return false;
}
if(!GetPropertyBool( GetComponentBase(DRComp), "HasCaterpillar" ))
{
DebugMessage( "akcommon.inc:IsAliveCaterpillar: The Unit doesn't have a Caterpillar", DL_BEHAVIOR );
return true; //probably the unit is not immobilized then -> repairing not necessary
}
return (GetPropertyFloat( DRComp, "CaterpillarPercent" ) > 0.0);
}
//======================================================================================================
stock bool:IsWreck( DrID:Unit )
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return false;
}
new DrID:WreckComp = GetPropertyObject( DRComp, "ActWreck")
if(WreckComp == DrID:0)
{
DebugMessage( "akcommon.inc:IsAlive: The Unit doesn't have ActWreck", DL_BEHAVIOR );
return false;
}
return !(GetPropertyFloat( WreckComp, "HP" ) > 0.0);
}
//======================================================================================================
stock bool:IsMounted( DrID:Unit, bool:returnMounting = false )
{
return (IsMountedIn(Unit, returnMounting) != DrID:0);
}
//======================================================================================================
stock DrID:IsMountedIn(DrID:Entity, bool:returnMounting = false)
{
if( IsInstanceOf( Entity, GetClassID( "cSoldier" )))
{
new DrID:hc = GetComponent(Entity, "cHumanController");
new bool:isMounted = GetPropertyBool(hc, "Mounted"); // Ez a prop mutatja, hogy be hova van tenylegesen bemountolva
if (!isMounted && !returnMounting)
return DrID:0;
return GetPropertyObject( Entity, "Mount" ); // Ez a prop mutatja, hogy hova van mountolva, vagy hova mountol eppen
}
else
{
DebugMessage( "IsMountedIn: The requested Entity is not a soldier!", DL_BEHAVIOR )
}
return DrID:0;
}
//======================================================================================================
stock bool:IsRegularInstanceOf( DrID:Entity, DrID:ClassID )
{
if( !IsInSelector( Entity, "Irregular" ))
return IsInstanceOf( Entity, ClassID )
return false;
}
//======================================================================================================
stock bool:IsTarget( DrID:Entity ) // Returns true, if param entity is the target of the event
{
if( GetMsgParamObject() != Entity )
return false;
return true;
}
//======================================================================================================
stock Percent( Base, Percent ) // Int-ben visszaad egy szazalekkal modositott erteket
return floatround( (Base*Percent)/100.0 );
//======================================================================================================
stock RndWeighted( ... ) // Sulyozott rnd-t szamol, visszateresi erteke, hogy hanyadik savba esik
// Visszateresi ertek 0..N-1, vagy -1 ha nem jott legalabb 2 parameter
{ // Check the number of arguments:
new n = numargs();
if( n < 2) {
DebugMessage( "akcommon.inc:RndWeighted: At least 2 arguments needed!", DL_WARNING );
return -1;
}
// Summarize values:
new sum, i;
for( i = 0; i < n; i++ )
sum += getarg(i);
// Randomize:
new TmpInt = Rnd( 0, sum - 1 );
// Select which zone is the number in:
while( TmpInt <= sum - 1 )
sum -= getarg( --i );
return i;
}
//======================================================================================================
stock Float:RadToDeg( Float:Value )
return (Value * 180 / PI);
//======================================================================================================
stock Regroup( selector[], eQueuing:Queuing = Q_OVERRIDE, flags = MF_NONE )
{
new Iterator:i = Iterate( selector );
if ( CountLivingInSelector( selector ) < 2 )
{
ItStop( i );
return;
}
ItNext(i);
new DrID:Unit = ItEntity(i);
new Float:TmpPos[vec3];
GetPropertyVec3( Unit, "LogicalPos_", TmpPos );
new Float:MinX = TmpPos[vec3:x];
new Float:MaxX = TmpPos[vec3:x];
new Float:MinY = TmpPos[vec3:y];
new Float:MaxY = TmpPos[vec3:y];
while( ItNext(i))
{
Unit = ItEntity(i);
GetPropertyVec3( Unit, "LogicalPos_", TmpPos );
if( TmpPos[vec3:x] < MinX )
{
MinX = TmpPos[vec3:x]
}
else if( TmpPos[vec3:x] > MaxX )
{
MaxX = TmpPos[vec3:x]
}
if( TmpPos[vec3:y] < MinY )
{
MinY = TmpPos[vec3:y]
}
else if( TmpPos[vec3:y] > MaxY )
{
MaxY = TmpPos[vec3:y]
}
}
ItStop( i );
TmpPos[vec3:x] = ( MinX + MaxX ) / 2.0;
TmpPos[vec3:y] = ( MinY + MaxY ) / 2.0;
TmpPos[vec3:z] = 0.0;
CmdGroupMove( selector, Queuing, TmpPos, flags);
}
//======================================================================================================
//.hack\\sign!
stock RefreshArea(DrID:ZieArea)
{
new Float:lTmpVec3[vec3];
GetPropertyVec3( ZieArea, "LogicalPos_", lTmpVec3 );
lTmpVec3[vec3:x]+=1.0;
SetPropertyVec3( ZieArea, "Pos", lTmpVec3 );
lTmpVec3[vec3:x]-=1.0;
SetPropertyVec3( ZieArea, "Pos", lTmpVec3 );
}
//======================================================================================================
stock ShowEntity(DrID:HiddenEntity)
{
if(HiddenEntity!=DrID:0)
{
SetPropertyBool( HiddenEntity, "Invisible", false );
if(IsPlayer(HiddenEntity))
SetPropertyBool( HiddenEntity, "Visible", true );
}
}
//======================================================================================================
stock SetSpeedInSelector( Selector[], Float:Speed ) // Untested
{
new Iterator:i = Iterate( Selector );
while( ItNext( i ))
SetPropertyFloat( GetComponent( ItEntity( i ), "cUnitController" ), "SpeedOverride", Speed );
ItStop( i );
}
//======================================================================================================
stock MakeUnSelectable(DrID:Entity)
{
SetPropertyBool( Entity, "Selectable", false );
// RemoveFromGroup( "Selection", Entity );
if(IsInSelector( Entity, "Selection" ))
RemoveFromSelector("Selection", Entity);
}
//======================================================================================================
stock MakeSelectable(DrID:Entity)
{
SetPropertyBool( Entity, "Selectable", true );
}
stock MakeInvulnerable(DrID:Unit)
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "MakeInvulnerable: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return false;
}
SetPropertyBool( DRComp, "Invulnerable", true);
return true;
}
stock MakeMountable(DrID:Who)
{
new DrID:egy = GetComponent(Who, "cMountPoint");
new DrID:ketto;
new i=0;
new j=GetPropArrayLength(egy, "MountPositions");
for (i=0;i<j;i++)
{
ketto = GetArrayElement (egy,"MountPositions",i);
SetPropertyBool( ketto, "Active", true );
}
}
stock MakeNOTMountable(DrID:Who)
{
new DrID:egy = GetComponent(Who, "cMountPoint");
new DrID:ketto;
new i=0;
new j=GetPropArrayLength(egy, "MountPositions");
for (i=0;i<j;i++)
{
ketto = GetArrayElement (egy,"MountPositions",i);
SetPropertyBool( ketto, "Active", false );
}
}
stock MakeVulnerable(DrID:Unit)
{
new DrID:DRComp = DrID:0;
if(IsInstanceOf( Unit, GetClassID( "cVehicle" )))
DRComp = GetComponent( Unit, "cDRVehicle");
else
if(IsInstanceOf( Unit, GetClassID( "cBuilding" )))
DRComp = GetComponent( Unit, "cDRBuilding");
else
DRComp = GetComponent( Unit, "cDRSimple");
if(DRComp == DrID:0)
{
DebugMessage( "MakeVulnerable: The Unit doesn't have cDRVehicle/cDRBuilding/cDRSimple", DL_BEHAVIOR );
return false;
}
SetPropertyBool( DRComp, "Invulnerable", false);
return true;
}
//======================================================================================================
stock MoveCameraToEnt( DrID:TargetEntity )
{
new Float:TargetPos[vec3];
GetPropertyVec3( TargetEntity , "LogicalPos_", TargetPos );
SetCameraTargetPos( TargetPos );
}
//======================================================================================================
stock MoveForward(DrID:ZieEntity, Float:ZieDistance, eQueuing:queuing = Q_ENQUEUE,eMoveFlag:flags = MF_NONE)
{
if(ZieEntity==DrID:0)
{
return;
}
new Float:MF_EntDir=GetEntityDir( ZieEntity ,DB_X_AXIS )-90.0;
new Float:MF_NewPos[vec3];
MF_NewPos[vec3:x]=0.0;
MF_NewPos[vec3:y]=ZieDistance;
MF_NewPos[vec3:z]=0.0;
new Float:MF_OldPos[vec3];
GetPropertyVec3(ZieEntity, "LogicalPos_", MF_OldPos );
RotateVec2(MF_NewPos,MF_EntDir);
AddVec3( MF_NewPos, MF_OldPos, MF_NewPos );
CmdMove( ZieEntity, queuing, MF_NewPos, flags );
}
stock TurnCW(DrID:ZieEntity, Float:ZieAngle, eQueuing:queuing = Q_ENQUEUE, eTurnFlags:flags = TF_NONE)
{
if(ZieEntity==DrID:0)
return;
new Float:TCW_Dir=GetEntityDir( ZieEntity,DB_X_AXIS )
TCW_Dir-=ZieAngle;
TCW_Dir=NormalizeDegree(TCW_Dir);
CmdTurnToDir( ZieEntity, queuing, TCW_Dir, DB_X_AXIS, flags );
}
stock Float:NormalizeDegree(Float:ND_Angle)
{
while(ND_Angle>180.0)
{
ND_Angle-=(360.0);
}
while(ND_Angle<-180.0)
{
ND_Angle+=(360.0);
}
return ND_Angle;
}
//======================================================================================================
stock RotateCameraToEnt( DrID:TargetEntity )
{
SetCameraTargetRotate( GetEntityDir( TargetEntity ));
}
//======================================================================================================
stock StrCpy( StrSource[], StrDest[], MaxLength = STR_PROP_MAX_LENGTH ) // Untested
{
new i;
for( i = 0; ( Str1[i] ) && ( i <= MaxLength - 1 ); i++ )
StrDest[i] = StrSource[i];
StrDest[i+1] = 0;
return true;
}
//======================================================================================================
stock Reinforcement( ID[], DrID:DeployAt, DrID:ArriveTo )
{
new Float:PosDeployAt[vec3];
new Float:PosArriveTo[vec3];
GetPropertyVec3( DeployAt, "LogicalPos_", PosDeployAt );
GetPropertyVec3( ArriveTo, "LogicalPos_", PosArriveTo );
TriggerReinforce( ID, PosDeployAt, PosArriveTo );
}
//======================================================================================================
stock Vec2toVec3( Float:Source[vec2], Float:Destination[vec3] )
{
Destination[vec3:x] = Source[vec2:x];
Destination[vec3:y] = Source[vec2:y];
Destination[vec3:z] = 0.0;
return true;
}
//======================================================================================================
stock Vec3toVec2( Float:Source[vec3], Float:Destination[vec2] )
{
Destination[vec2:x] = Source[vec3:x];
Destination[vec2:y] = Source[vec3:y];
return true;
}
//======================================================================================================
// usefull only to debug processes.
stock vec32str(DaString[255],Float:DaVec3[vec3])
{
new lTmpStr[250];
DaString="";
Float2Str( DaVec3[vec3:x], lTmpStr, 255, "%7.3f" );
ConcatString( DaString, 255, DaString, lTmpStr );
ConcatString( DaString, 255, DaString, " | " );
Float2Str( DaVec3[vec3:y], lTmpStr, 255, "%7.3f" );
ConcatString( DaString, 255, DaString, lTmpStr );
ConcatString( DaString, 255, DaString, " | " );
Float2Str( DaVec3[vec3:z], lTmpStr, 255, "%7.3f" );
ConcatString( DaString, 255, DaString, lTmpStr );
ConcatString( DaString, 255, DaString, " | " );
return true;
}
stock CmpVec3(Float:v1[vec3], Float:v2[vec3])
{
if (v1[vec3:x] != v2[vec3:x])
return false;
if (v1[vec3:y] != v2[vec3:y])
return false;
if (v1[vec3:z] != v2[vec3:z])
return false;
return true;
}
stock ShowTheStats()
{
static ShowTheStatsNum = 0;
ShowTheStatsNum++;
new lTmpStr[255];
new Float:CamActPos[vec3];
GetCameraActualPos( CamActPos );
new Float:CamActRot=GetCameraActualRotate();
new Float:CamActPit=GetCameraActualPitch();
new Float:CamActDis=GetCameraActualDistance();
Int2Str( ShowTheStatsNum, lTmpStr );
ConcatString( lTmpStr, 100, "No: ", lTmpStr );
DebugMessage( lTmpStr, DL_MESSAGE );
ShowShortMessage( lTmpStr );
vec32str( lTmpStr, CamActPos);
ConcatString( lTmpStr, 100, "Actual Position: ", lTmpStr );
DebugMessage( lTmpStr, DL_MESSAGE );
ShowShortMessage( lTmpStr );
Float2Str( CamActRot, lTmpStr, 10, "%7.3f" );
ConcatString( lTmpStr, 100, "Actual Rotation: ", lTmpStr );
DebugMessage( lTmpStr, DL_MESSAGE );
ShowShortMessage( lTmpStr );
Float2Str( CamActPit, lTmpStr, 10, "%7.3f" );
ConcatString( lTmpStr, 100, "Actual Pitch: ", lTmpStr );
DebugMessage( lTmpStr, DL_MESSAGE );
ShowShortMessage( lTmpStr );
Float2Str( CamActDis, lTmpStr, 10, "%7.3f" );
ConcatString( lTmpStr, 100, "Actual Distance: ", lTmpStr );
DebugMessage( lTmpStr, DL_MESSAGE );
ShowShortMessage( lTmpStr );
}
//====================================================
//Recon stuffazz
stock DrID:GetSupportObj(DasTeam)
{
new DrID:ReinfSys = GetPropertyObject( GetEntity( "World" ), "ReinforcementSystem" );
new DrID:AktElement;
new MaxElement = GetPropArrayLength( ReinfSys, "TeamDescriptors" );
new ciklus;
for(ciklus=0;ciklus<MaxElement;ciklus++)
{
AktElement=GetArrayElement(ReinfSys, "TeamDescriptors", ciklus);
if(AktElement!=DrID:0)
{
if(GetPropertyObject(AktElement, "Support")!=DrID:0)
{
if(GetPropertyInt( AktElement, "Team" )==DasTeam)
{
return GetPropertyObject(AktElement, "Support");
}
}
else
{
DebugMessage( "akcommon.inc:GetSupportObj: Requested Team doesn't have Support!!!", DL_ERROR );
return DrID:0;
}
}
}
DebugMessage( "akcommon.inc:GetSupportObj: Requested Team doesn't have ReinforcementSystem!!!", DL_ERROR );
return DrID:0;
}
stock GetNAirStrikes(DasTeam)
{
new DrID:lTmpDrID=GetSupportObj(DasTeam);
if(lTmpDrID)
return GetPropertyInt( lTmpDrID, "NAirStrikes");
return -1;
}
stock GetNAirRecons(DasTeam)
{
new DrID:lTmpDrID=GetSupportObj(DasTeam);
if(lTmpDrID)
return GetPropertyInt( lTmpDrID, "NRecons");
return -1;
}
stock GetNArtilleryAttack(DasTeam)
{
new DrID:lTmpDrID=GetSupportObj(DasTeam);
if(lTmpDrID)
return GetPropertyInt( lTmpDrID, "NArtilleryAttacks");
return -1;
}
stock GetNParatroopers(DasTeam)
{
new DrID:lTmpDrID=GetSupportObj(DasTeam);
if(lTmpDrID)
return GetPropertyInt( lTmpDrID, "NParatroopers");
return -1;
}
stock SetAirStrike(DasTeam,DasNum)
{
if(GetNAirStrikes(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NAirStrikes",DasNum);
}
stock SetAirRecon(DasTeam,DasNum)
{
if(GetNAirRecons(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NRecons",DasNum);
}
stock SetArtilleryAttack(DasTeam,DasNum)
{
if(GetNArtilleryAttack(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NArtilleryAttacks",DasNum);
}
stock SetParatroopers(DasTeam,DasNum)
{
if(GetNParatroopers(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NParatroopers",DasNum);
}
stock GiveAirStrike(DasTeam)
{
if(GetNAirStrikes(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NAirStrikes",GetNAirStrikes(DasTeam)+1);
}
stock GiveAirRecon(DasTeam)
{
if(GetNAirRecons(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NRecons",GetNAirRecons(DasTeam)+1);
}
stock GiveArtilleryAttack(DasTeam)
{
if(GetNArtilleryAttack(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NArtilleryAttacks",GetNArtilleryAttack(DasTeam)+1);
}
stock GiveParaTroopers(DasTeam)
{
if(GetNParatroopers(DasTeam)!=-1)
SetPropertyInt( GetSupportObj(DasTeam), "NParatroopers",GetNParatroopers(DasTeam)+1);
}
stock CountMPInSelector(DasSelector[],bool:MustBeAlive=true, IsInTeam=-1)
{
new lMPTotal=0;
new Iterator:iti=Iterate(DasSelector);
while(ItNext(iti))
{
if(!MustBeAlive||IsAlive(ItEntity(iti)))
{
if(IsInTeam==-1||GetPropertyInt( ItEntity(iti), "Team" )==IsInTeam)
{
lMPTotal+=GetPropertyInt(GetComponentBase(GetComponent(ItEntity(iti),"cManagement")), "Value" );
}
}
}
ItStop(iti);
return lMPTotal;
}
stock DestructEntityFake(DrID:entity)
{
SetPropertyBool( entity, "Survivor", false );
SetPropertyInt( entity, "Team", 0 );
HideEntity(entity);
DeActivateEntity( entity );
}
//-----------ANTI GOD MODE HACK by TIMBER--------------
stock bool:CheatDetector()
{
// insert this code just before >>EndMission( MS_ACCOMPLISHED );<<
//--GOD MODE DETECTION-START--
// if(CheatDetector())
// {
// return;
// }
//--GOD MODE DETECTION-END--
SetEnabledMessages(0);
new DrID:MegDogleszGeco=CreateEntity( "al_rifleman", Float:{0.0,0.0,0.0} );
SetPropertyInt( MegDogleszGeco, "Team", gPlayerTeam );
DamageEntity( MegDogleszGeco, 666.666, 49 );
if(IsAlive(MegDogleszGeco))
{
AddObjective( "Cheater", OT_PRIMARY, "Cheating is not payable!", "Cheating is bad! Don't do it", OS_IN_PROGRESS );
SetObjectiveState( "Cheater", OS_FAILED );
EndMission( MS_FAILED);
SetEnabledMessages(255);
return true;
}
SetEnabledMessages(255);
return false;
}
stock bool:CompareVec3(Float:First[vec3],Float:Second[vec3])
{
return bool:( (First[vec3:x]==Second[vec3:x]) && (First[vec3:y]==Second[vec3:y]) && (First[vec3:z]==Second[vec3:z]) );
}
stock SetBehav( Group[],
eMovementBehavior:SetMB = MB_UNMODIFIED,
eFiringBehavior:SetFB = FB_UNMODIFIED,
eUnmountBehav:SetUB = UB_UNMODIFIED,
eDestEmptyBehav:SetDB = DB_UNMODIFIED,
eMountBehav:SetMoB = MOB_UNMODIFIED,
eMountTargetPref:SetMTPB = MTP_UNDEFINED)
{
new Iterator:i = Iterate(Group);
while(ItNext(i))
{
SetBehav2Ent( ItEntity(i), SetMB, SetFB, SetUB, SetDB, SetMoB, SetMTPB)
}
ItStop(i);
}
stock SetBehav2Ent( DrID:Unit,
eMovementBehavior:SetMB = MB_UNMODIFIED,
eFiringBehavior:SetFB = FB_UNMODIFIED,
eUnmountBehav:SetUB = UB_UNMODIFIED,
eDestEmptyBehav:SetDB = DB_UNMODIFIED,
eMountBehav:SetMoB = MOB_UNMODIFIED,
eMountTargetPref:SetMTPB = MTP_UNDEFINED)
{
if(IsAlive(Unit))
{
if(SetMB != MB_UNMODIFIED)
CmdSetMB( Unit, Q_ENQUEUE, SetMB );
if(SetFB != FB_UNMODIFIED)
CmdSetFB( Unit, Q_ENQUEUE, SetFB );
if(SetUB != UB_UNMODIFIED)
SetPropertyInt( Unit, "UnmountBehavior", SetUB );
if(SetDB != DB_UNMODIFIED)
SetPropertyInt( Unit, "DestroyEmptyBehavior", SetDB );
if(SetMoB != MOB_UNMODIFIED)
SetPropertyInt( Unit, "MountBehavior", SetMoB );
if(SetMTPB != MTP_UNDEFINED)
SetPropertyInt( Unit, "MountTargetPreference", SetMTPB );
}
}
stock WreckDestructor(DrID:Entity, CompositeID[])
{
if(IsInSelector( Entity, CompositeID ))
if(IsInstanceOf( Entity, GetClassID( "cVehicle" ) ))
DamageEntity( Entity, 1000.0, 49 );
}
//============================================================================================================================
stock CamPosStore(bool:flag=true)
{
static Float:Camactpos[vec3];
static Float:Camactdist;
static Float:Camactrot;
static Float:Camactpitch;
if(flag)
{
GetCameraActualPos( Camactpos );
Camactdist = GetCameraActualDistance();
Camactrot = GetCameraActualRotate();
Camactpitch = GetCameraActualPitch();
}
else
{
ResetCameraSpeed();
SetCameraTargetPos( Camactpos );
SetCameraTargetDistance( Camactdist );
SetCameraTargetPitch( Camactpitch );
SetCameraTargetRotate( Camactrot );
}
}
stock CamPosRestore()
{
CamPosStore(false);
}
//============================================================================================================================
stock MountedPlaceNr(DrID:Entity = DrID:0)
{
new Establishment = 0
if (IsEntityComp( Entity, "cMountPoint"))
Establishment = GetPropArrayLength( GetComponent( Entity, "cMountPoint"), "Mounted")
else
Establishment = -1
return Establishment
}
//======================================================================================================
stock UnitCallEvent(DrID:UndWho, UndWhat[], eQueuing:queuing = Q_ENQUEUE, flags = CF_NONE)
{
CmdThrowEvent( UndWho, queuing, 666, flags );
AddAKEntityEvent( UndWhat, UndWho, CMD_EVENT );
}
stock KillEntity(DrID:UndWho)
{
DamageEntity( UndWho, Float:(GetActualHealth(UndWho)+1.0), 49 );
}
//======================================================================================================
stock DrID:CreateFOWBtoEntity( DrID:Entity, Base[]="fowbacon_180" )
{
new Float:pos[vec3];
GetPropertyVec3( Entity, "LogicalPos_", pos );
new DrID:Fow = CreateEntity( Base, pos );
SetPropertyInt( Fow, "Team", gPlayerTeam );
SetPropertyBool( Fow, "GadgetsVisible", false );
RefreshFOW();
return Fow;
}
stock ShowWeapon(DrID:Soldier, bool:WPisApply = true)
{
if(WPisApply == true)
{
if(IsInstanceOf( Soldier, GetClassID( "cSolider" )))
SetPropertyInt(GetComponent( Soldier ,"cHumanController"), "TextureStatus",0);
else
DebugMessage( "This entity is not soldier or dont exist!!", DL_ERROR );
}
else
{
if(IsInstanceOf( Soldier, GetClassID( "cSolider" )))
SetPropertyInt(GetComponent( Soldier ,"cHumanController"), "TextureStatus",1);
else
DebugMessage( "This entity is not soldier or dont exist!!", DL_ERROR );
}
}
//======================================================================================================
stock Test_ListEntitiesInSelector( Selector[] , const ClassType[] = "cAKEntity", bool:AliveOnly=false )
{
if( !IsDebugLevelOK( DL_MESSAGE ))
return;
new NoOfEntities = 0;
new tmpstr[200];
ConcatString( tmpstr, 199, "Listing the enitities in selector '", Selector );
ConcatString( tmpstr, 199, tmpstr, "'." );
DebugMessage( tmpstr, DL_MESSAGE );
new Iterator:i = Iterate( Selector , ClassType );
while( ItNext(i))
{
if(IsAlive(ItEntity(i))||!AliveOnly)
{
GetPropertyString( ItEntity( i ), "StringID", 199, tmpstr );
if(!GetPropertyBool( ItEntity(i), "Active" ))
{
ConcatString( tmpstr, 199, tmpstr, " (Inactive)" );
}
if(IsInSelector( ItEntity(i), "Irregular" ))
{
ConcatString( tmpstr, 199, tmpstr, " (Irregular)" );
}
DebugMessage( tmpstr, DL_MESSAGE );
NoOfEntities++;
}
}
ItStop(i);
ConcatString( tmpstr, 199, "Number of entities in selector '", Selector );
ConcatString( tmpstr, 199, tmpstr, "' = " );
new tmpstr2[200];
Int2Str( NoOfEntities, tmpstr2, 199 );
ConcatString( tmpstr, 199, tmpstr, tmpstr2 );
DebugMessage( tmpstr, DL_MESSAGE );
}
//============================================================================================================================
stock GroupRemover(DrID:Unit)
{
if(GetPropertyInt( Unit, "Team" ) == gPlayerTeam)
{
new GroupStr[200] = "";
new Char;
new i = 0;
new j = 0;
new tmpstr[100];
GetPropertyString( Unit, "Group", 198, GroupStr );
Char = GroupStr{0};
while(Char != '\0')
{
if(Char != ',')
{
tmpstr[j] = Char;
j++;
}
else
{
tmpstr[j] = '\0';
RemoveIfNotForbidden(tmpstr, Unit);
j = 0;
}
i++;
Char = GroupStr{i};
}
tmpstr[j] = '\0';
RemoveIfNotForbidden(tmpstr, Unit);
}
}
stock RemoveIfNotForbidden(group[], DrID:Unit)
{
new k;
for(k = 0; k != forbidden_grp_num; k++ )
{
if(CompareString( group, gForbiddenGroups[k]) == 0)
break;
}
if (k == forbidden_grp_num)
RemoveFromGroup( group, Unit );
}
//============================================================================================================================
// Requires an entity named 'scenarioflag' which is available only in Scenario Mode.
stock bool:IsScenario()
{
return (GetEntity( "scenarioflag" )!=DrID:0)
}
//============================================================================================================================
stock SetLvBehSentProp(ID, bool:Bool)
{
new MaxLength = GetPropArrayLength(GetEntity("World"), "LevelBehaviours");
new DrID:AktElement;
new i;
new tmpID;
for(i = 0; i<MaxLength; i++)
{
AktElement = GetArrayElement(GetEntity("World"), "LevelBehaviours", i);
if(AktElement != DrID:0)
{
tmpID = GetPropertyInt(AktElement, "Id" );
if(ID == tmpID)
SetPropertyBool( AktElement, "Sent", Bool);
}
}
}
//============================================================================================================================
stock ShipMode(DrID:SM_Unit,bool:SM_Mode=true)
{
if(SM_Unit==DrID:0)
return;
new DrID:SM_UnitComm = GetComponent( SM_Unit, "cUnitController" );
if(SM_UnitComm==DrID:0)
return;
SetPropertyBool( SM_UnitComm, "ShipMode", SM_Mode );
}