UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_battlescape.cpp File Reference
#include "../client.h"
#include "cl_battlescape.h"
#include "cl_actor.h"
Include dependency graph for cl_battlescape.cpp:

Go to the source code of this file.

Macros

#define LOOKUP_EPSILON   0.0001f

Functions

le_tCL_BattlescapeSearchAtGridPos (const pos3_t pos, bool includingStunned, const le_t *actor)
 Searches a local entity at the given position.
bool CL_BattlescapeRunning (void)
 Check whether we already have actors spawned on the battlefield.
bool CL_OnBattlescape (void)
 Check whether we are in a tactical mission as server or as client. But this only means that we are able to render the map - not that the game is running (the team can still be missing - see CL_BattlescapeRunning).
static float CL_LookupErrorFunction (float z)
 calculate approximate erf, the error function http://en.wikipedia.org/wiki/Error_function uses lookup table and linear interpolation approximation good to around 0.001. easily good enough for the job.
static bool CL_TestLine (const vec3_t start, const vec3_t stop, const int levelmask)
int CL_GetHitProbability (const le_t *actor)
 Calculates chance to hit if the actor has a fire mode activated.
bool CL_OutsideMap (const vec3_t position, const float delta)
 Checks whether give position is still inside the map borders.
int CL_CountVisibleEnemies (void)
 Counts visible enemies on the battlescape.
char * CL_GetConfigString (int index)
int CL_GetConfigStringInteger (int index)
char * CL_SetConfigString (int index, dbuffer *msg)

Variables

clientBattleScape_t cl
static const float lookup [30]
 table for lookup_erf lookup[]= {erf(0), erf(0.1), ...}
static const float lookupdiff [30]
 table for lookup_erf lookup[]= {10*(erf(0.1)-erf(0.0)), 10*(erf(0.2)-erf(0.1)), ...}
static const float mapZBorder = -(UNIT_HEIGHT * 5)

Macro Definition Documentation

◆ LOOKUP_EPSILON

#define LOOKUP_EPSILON   0.0001f

Definition at line 109 of file cl_battlescape.cpp.

Referenced by CL_GetHitProbability(), and CL_LookupErrorFunction().

Function Documentation

◆ CL_BattlescapeRunning()

bool CL_BattlescapeRunning ( void )

◆ CL_BattlescapeSearchAtGridPos()

le_t * CL_BattlescapeSearchAtGridPos ( const pos3_t pos,
bool includingStunned,
const le_t * actor )

Searches a local entity at the given position.

Parameters
[in]posThe grid position to search a local entity at
[in]includingStunnedAlso search for stunned actors if true.
[in]actorThe current selected actor

Definition at line 37 of file cl_battlescape.cpp.

References ACTOR_SIZE_2x2, ACTOR_SIZE_NORMAL, le_t::clientAction, Com_Error(), ERR_DROP, le_t::fieldSize, LE_GetNextInUse(), LE_IsLivingAndVisibleActor(), LE_IsStunned, le_t::pos, VectorCompare, and VectorSet.

Referenced by CL_ActorMouseTrace(), CL_TargetingGrenade(), and CL_TargetingStraight().

◆ CL_CountVisibleEnemies()

int CL_CountVisibleEnemies ( void )

Counts visible enemies on the battlescape.

Returns
The amount of visible enemies (from all the other teams)

Definition at line 319 of file cl_battlescape.cpp.

References cls, count, LE_GetNextInUse(), LE_IsLivingAndVisibleActor(), le_t::team, and TEAM_CIVILIAN.

Referenced by CL_ActorAppear(), CL_ActorDie(), and CL_EntPerish().

◆ CL_GetConfigString()

◆ CL_GetConfigStringInteger()

int CL_GetConfigStringInteger ( int index)

◆ CL_GetHitProbability()

int CL_GetHitProbability ( const le_t * actor)

Calculates chance to hit if the actor has a fire mode activated.

Parameters
[in]actorThe local entity of the actor to calculate the hit probability for.
Todo
The hit probability should work somewhat differently for splash damage weapons. Since splash damage weapons can deal damage even when they don't directly hit an actor, the hit probability should be defined as the predicted percentage of the maximum splash damage of the firemode, assuming the projectile explodes at the desired location. This means that a percentage should be displayed for EVERY actor in the predicted blast radius. This will likely require specialized code.
Todo
use LE_FindRadius

Definition at line 176 of file cl_battlescape.cpp.

References ABILITY_ACCURACY, le_t::actorMode, CL_ActorGetChr(), CL_ActorInjuryModifier(), CL_LookupErrorFunction(), CL_TestLine(), Com_Error(), fireDef_t::crouch, ERR_DROP, le_t::fd, FIRESH_IsMedikit, GET_ACC, IS_MODE_FIRE_PENDING, LE_GetFromPos(), LE_IsCrouched, LE_IsInvisible, LE_IsSelected, LOOKUP_EPSILON, MODIFIER_ACCURACY, le_t::mousePendPos, mousePos, le_t::origin, PLAYER_CROUCHING_HEIGHT, PLAYER_STANDING_HEIGHT, PLAYER_WIDTH, character_t::score, SKILL_BALANCE, chrScoreGlobal_t::skills, fireDef_t::spread, TL_FLAG_NONE, torad, UNIT_HEIGHT, VectorCopy, WEAPON_BALANCE, and fireDef_t::weaponSkill.

Referenced by HUD_UpdateActorFireMode().

◆ CL_LookupErrorFunction()

float CL_LookupErrorFunction ( float z)
static

calculate approximate erf, the error function http://en.wikipedia.org/wiki/Error_function uses lookup table and linear interpolation approximation good to around 0.001. easily good enough for the job.

Parameters
[in]zthe number to calculate the erf of.
Returns
for positive arg, returns approximate erf. for -ve arg returns 0.0f.

Definition at line 144 of file cl_battlescape.cpp.

References int(), lookup, LOOKUP_EPSILON, and lookupdiff.

Referenced by CL_GetHitProbability().

◆ CL_OnBattlescape()

bool CL_OnBattlescape ( void )

Check whether we are in a tactical mission as server or as client. But this only means that we are able to render the map - not that the game is running (the team can still be missing - see CL_BattlescapeRunning).

Note
handles multiplayer and singleplayer
See also
CL_BattlescapeRunning
Returns
true when we are in battlefield

Definition at line 95 of file cl_battlescape.cpp.

References ca_connected, cls, and Com_ServerState().

Referenced by cgame_import_t::bool(), CL_ActionDown_f(), CL_LevelDown_f(), CL_LevelUp_f(), CL_SpawnSoldiers_f(), GAME_GetImportData(), HUD_ActorSelectionChangeListener(), HUD_LeftHandChangeListener(), HUD_RightHandChangeListener(), HUD_TUChangeListener(), Irc_Client_Invite_f(), Key_Event(), M_Change_f(), M_PlayRandomByCategory(), S_Frame(), and SCR_UpdateScreen().

◆ CL_OutsideMap()

bool CL_OutsideMap ( const vec3_t position,
const float delta )

Checks whether give position is still inside the map borders.

Parameters
[in]positionThe position to check (world coordinate)
[in]deltaThe delta from the map boundaries. Positive values to make the position being earlier out of the map, negative values to let the position be later out of the map
Returns
true if the given position is out of the map boundaries, false otherwise.

Definition at line 296 of file cl_battlescape.cpp.

References cl, and mapZBorder.

Referenced by CL_ActorDoShootTime(), CL_ActorMouseTrace(), CL_ActorShootHidden(), and LET_Projectile().

◆ CL_SetConfigString()

char * CL_SetConfigString ( int index,
dbuffer * msg )

◆ CL_TestLine()

bool CL_TestLine ( const vec3_t start,
const vec3_t stop,
const int levelmask )
inlinestatic

Definition at line 161 of file cl_battlescape.cpp.

References cl, and TR_TestLine().

Referenced by CL_GetHitProbability().

Variable Documentation

◆ cl

Definition at line 29 of file cl_battlescape.cpp.

Referenced by CL_ActorAdd(), CL_ActorAddToTeamList(), CL_ActorAppear(), CL_ActorConditionalMoveCalc(), CL_ActorConfirmAction(), CL_ActorConfirmAction_f(), CL_ActorDie(), CL_ActorDieTime(), CL_ActorDoMove(), CL_ActorEndShootTime(), CL_ActorGetChr(), CL_ActorGetFromCharacter(), CL_ActorGetNumber(), CL_ActorMaximumMove(), CL_ActorMouseTrace(), CL_ActorMoveLength(), CL_ActorMoveMode(), CL_ActorRemoveFromTeamList(), CL_ActorSelect(), CL_ActorSelectList(), CL_ActorSelectNext(), CL_ActorSelectPrev(), CL_ActorStandCrouch_f(), CL_ActorStats(), CL_ActorTraceMove(), CL_AddActor(), CL_AddBrushModel(), CL_AddMapParticle(), CL_AddPathingBox(), CL_AddTargetingBox(), CL_AddUGV(), CL_AreBattlescapeEventsBlocked(), CL_BattlescapeMouseDragging(), CL_BattlescapeRadarGenerateAll(), CL_BattlescapeRadarMapInFrameBuffer(), CL_BattlescapeRunning(), CL_BlockBattlescapeEvents(), CL_CameraMove(), CL_CameraRoute(), CL_CameraZoomIn(), CL_CameraZoomOut(), CL_CamSetAngles_f(), CL_CamSetZoom_f(), CL_CanMultiplayerStart(), CL_CenterCameraIntoMap_f(), CL_CheckCameraRoute(), CL_ClampCamToMap(), CL_ClearState(), CL_ClipMoveToLEs(), CL_CompleteRecalcRouting(), CL_CvarWorldLevel(), CL_DisplayFloorArrows(), CL_DisplayObstructionArrows(), CL_DoEndRound(), CL_EntAppear(), CL_EntAppearTime(), CL_EntPerish(), CL_Explode(), CL_ExplodeTime(), CL_Frame(), CL_GetConfigString(), CL_GetEventTime(), CL_GetWorldCoordsUnderMouse(), CL_GridRecalcRouting(), CL_HullForEntity(), CL_InvAddTime(), CL_InvDelTime(), CL_LevelUp_f(), CL_LogEvent(), CL_MoveView(), CL_NextAlien_f(), CL_NextAlienVisibleFromActor_f(), CL_OutsideMap(), CL_ParseClientinfo(), CL_ParseConfigString(), CL_ParseEvent(), CL_ParseServerData(), CL_ParticleAppearTime(), CL_ParticleRun2(), CL_ParticleSpawn(), CL_ParticleSpawnEventTime(), CL_PlayerGetName(), CL_PrevAlien_f(), CL_RequestNextDownload(), CL_Reset(), CL_RunMapParticles(), CL_SetConfigString(), CL_SoundEvent(), CL_SpawnParseEntitystring(), CL_SpawnSoldiers_f(), CL_StartGame(), CL_StartMatch_f(), CL_TargetingGrenade(), CL_TargetingStraight(), CL_TestLine(), CL_Trace(), CL_ViewCalcFieldOfViewX(), CL_ViewCenterAtGridPosition(), CL_ViewLoadMedia(), CL_ViewRender(), CL_ViewUpdateRenderData(), uiRadarNode::draw(), GAME_InitializeBattlescape(), GAME_SetMode(), GAME_SpawnSoldiers(), GAME_StartBattlescape(), GAME_StartMatch(), HUD_ActorSelectionChangeListener(), HUD_MapDebugCursor(), HUD_Update(), client_static_t::isOurRound(), LE_ActorGetStepTime(), LE_Add(), LE_AddEdictHighlight(), LE_AddGrenade(), LE_AddProjectile(), LE_AddToScene(), LE_CenterView(), LE_Cleanup(), LE_GenerateInlineModelList(), LE_GetClipModel(), LE_GetDrawModel(), LE_GetNext(), LE_PlaceItem(), LET_BrushModel(), LET_PathMove(), LET_Projectile(), LET_RotateDoor(), LET_SlideDoor(), LM_AddModel(), LM_AddToSceneOrder(), LM_Find(), LM_GetByID(), LM_Register(), LM_Think(), uiRadarNode::onCapturedMouseMove(), PTL_Trace(), R_RenderFrame(), S_Frame(), S_SpatializeChannel(), SEQ_Execute(), SEQ_InitContext(), SEQ_Render3D(), SEQ_SetCamera(), SP_worldspawn(), SV_Begin_f(), SV_BroadcastPrintf(), SV_BroadcastPrintf(), SV_CheckSpawnSoldiers(), SV_CheckStartMatch(), SV_CheckTimeouts(), SV_ClientPrintf(), SV_ClientPrintf(), SV_CountPlayers(), SV_Disconnect_f(), SV_DropClient(), SV_ExecuteClientMessage(), SV_ExecuteUserCommand(), SV_FinalMessage(), SV_GetPlayerClientStructure(), SV_Kick_f(), SV_Map(), SV_Multicast(), SV_New_f(), SV_PingPlayers(), SV_PlayerPrintf(), SV_ReadPacket(), SV_ShowServerinfo_f(), SV_StartGame_f(), SV_StartMatch_f(), SV_Status_f(), SV_UserInfo_f(), SV_UserinfoChanged(), SVC_DirectConnect(), SVC_Info(), SVC_Status(), SVC_TeamInfo(), UI_BuildRadarImageList(), UI_InitRadar(), and Weather::update().

◆ lookup

const float lookup[30]
static
Initial value:
= {
0.0f, 0.1125f, 0.2227f, 0.3286f, 0.4284f, 0.5205f, 0.6039f,
0.6778f, 0.7421f, 0.7969f, 0.8427f, 0.8802f, 0.9103f, 0.9340f,
0.9523f, 0.9661f, 0.9763f, 0.9838f, 0.9891f, 0.9928f, 0.9953f,
0.9970f, 0.9981f, 0.9989f, 0.9993f, 0.9996f, 0.9998f, 0.9999f,
0.9999f, 1.0000f
}

table for lookup_erf lookup[]= {erf(0), erf(0.1), ...}

Definition at line 115 of file cl_battlescape.cpp.

Referenced by CL_LookupErrorFunction().

◆ lookupdiff

const float lookupdiff[30]
static
Initial value:
= {
1.1246f, 1.1024f, 1.0592f, 0.9977f, 0.9211f, 0.8336f, 0.7395f,
0.6430f, 0.5481f, 0.4579f, 0.3750f, 0.3011f, 0.2369f, 0.1828f,
0.1382f, 0.1024f, 0.0744f, 0.0530f, 0.0370f, 0.0253f, 0.0170f,
0.0112f, 0.0072f, 0.0045f, 0.0028f, 0.0017f, 0.0010f, 0.0006f,
0.0003f, 0.0002f
}

table for lookup_erf lookup[]= {10*(erf(0.1)-erf(0.0)), 10*(erf(0.2)-erf(0.1)), ...}

Definition at line 127 of file cl_battlescape.cpp.

Referenced by CL_LookupErrorFunction().

◆ mapZBorder

const float mapZBorder = -(UNIT_HEIGHT * 5)
static

Definition at line 286 of file cl_battlescape.cpp.

Referenced by CL_OutsideMap().