00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "../../../../client.h"
00026 #include "../../../cl_localentity.h"
00027 #include "../../../cl_ugv.h"
00028 #include "../../../cl_actor.h"
00029 #include "../../../cl_hud.h"
00030 #include "../../../../cl_game.h"
00031 #include "../../../cl_particle.h"
00032 #include "e_event_actorappear.h"
00033 #include "../../../../../common/grid.h"
00034
00035 int CL_ActorAppearTime (const eventRegister_t *self, struct dbuffer *msg, const int dt)
00036 {
00037 #if 0
00038 nextTime += 600;
00039 #else
00040 return cl.time + 600;
00041 #endif
00042 }
00043
00047 static void CL_DrawLineOfSight (const le_t *watcher, const le_t *target)
00048 {
00049 ptl_t *ptl;
00050 vec3_t eyes;
00051
00052 if (!watcher || !target)
00053 return;
00054
00055
00056 VectorCopy(watcher->origin, eyes);
00057 if (LE_IsCrouched(watcher))
00058 eyes[2] += EYE_HT_CROUCH;
00059 else
00060 eyes[2] += EYE_HT_STAND;
00061
00062 ptl = CL_ParticleSpawn("fadeTracer", 0, eyes, target->origin, NULL);
00063
00064 if (LE_IsCivilian(target))
00065 VectorSet(ptl->color, 0.2, 0.2, 1);
00066 }
00067
00074 void CL_ActorAppear (const eventRegister_t *self, struct dbuffer *msg)
00075 {
00076 le_t *le, *leResponsible;
00077 int entnum, entnumResponsible, modelnum1, modelnum2;
00078 int teamDefID = -1;
00079
00080
00081 entnum = NET_ReadShort(msg);
00082 entnumResponsible = NET_ReadShort(msg);
00083 le = LE_Get(entnum);
00084 leResponsible = LE_Get(entnumResponsible);
00085
00086 if (entnumResponsible != SKIP_LOCAL_ENTITY && !leResponsible)
00087 LE_NotFoundError(entnumResponsible);
00088
00089
00090 if (!le)
00091 le = LE_Add(entnum);
00092
00093
00094
00095 LE_Lock(le);
00096
00097
00098 le->invis = qfalse;
00099
00100
00101 NET_ReadFormat(msg, self->formatString,
00102 &le->team, &teamDefID, &le->gender, &le->pnum, &le->pos,
00103 &le->dir, &le->right, &le->left,
00104 &modelnum1, &modelnum2, &le->skinnum,
00105 &le->state, &le->fieldSize,
00106 &le->maxTU, &le->maxMorale, &le->maxHP);
00107
00108 if (teamDefID < 0 || teamDefID > csi.numTeamDefs)
00109 Com_Printf("CL_ActorAppear: Invalid teamDef index\n");
00110 else
00111 le->teamDef = &csi.teamDef[teamDefID];
00112
00113 switch (le->fieldSize) {
00114 case ACTOR_SIZE_NORMAL:
00115 le->addFunc = CL_AddActor;
00116 le->type = ET_ACTOR;
00117 break;
00118 case ACTOR_SIZE_2x2:
00119 le->addFunc = CL_AddUGV;
00120 le->type = ET_ACTOR2x2;
00121 break;
00122 default:
00123 Com_Error(ERR_DROP, "Unknown fieldSize for le in CL_ActorAppear (EV_ACTOR_APPEAR)");
00124 }
00125 le->modelnum1 = modelnum1;
00126 le->modelnum2 = modelnum2;
00127 le->model1 = cl.model_draw[modelnum1];
00128 le->model2 = cl.model_draw[modelnum2];
00129 Grid_PosToVec(cl.mapData->map, le->fieldSize, le->pos, le->origin);
00130 le->angles[YAW] = directionAngles[le->dir];
00131
00132 le->contents = CONTENTS_ACTOR;
00133 VectorCopy(player_mins, le->mins);
00134 if (LE_IsDead(le))
00135 VectorCopy(player_dead_maxs, le->maxs);
00136 else
00137 VectorCopy(player_maxs, le->maxs);
00138
00139 LE_SetThink(le, LET_StartIdle);
00140
00141
00142 if (LE_IsLivingActor(le) && le->team != cls.team && le->team != TEAM_CIVILIAN)
00143 cl.numAliensSpotted++;
00144
00145 if (LE_IsLivingActor(le)) {
00146
00147 if (cl.actTeam != cls.team)
00148 LE_CenterView(le);
00149
00150
00151 if (le->team != cls.team) {
00152 if (leResponsible)
00153 CL_DrawLineOfSight(leResponsible, le);
00154
00155
00156 if (le->team != TEAM_CIVILIAN) {
00157 if (GAME_TeamIsKnown(le->teamDef)) {
00158 char tmpbuf[128];
00159 Com_sprintf(tmpbuf, sizeof(tmpbuf), _("Enemy spotted: %s!"), _(le->teamDef->name));
00160 HUD_DisplayMessage(tmpbuf);
00161 } else
00162 HUD_DisplayMessage(_("Enemy spotted!\n"));
00163 } else
00164 HUD_DisplayMessage(_("Civilian spotted!\n"));
00165
00166
00167 CL_ActorConditionalMoveCalc(leResponsible ? leResponsible : selActor);
00168 }
00169 }
00170
00171
00172 CL_ActorAddToTeamList(le);
00173 LE_Unlock(le);
00174 }