mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-21 11:21:52 +00:00
ported meatball crosshair
copied from http://www.quakewiki.net/archives/qdevels/quake2/12_1_98.html
This commit is contained in:
parent
b662cb9979
commit
1e6f016fca
5 changed files with 107 additions and 1 deletions
|
@ -201,6 +201,7 @@ set(Game-Source
|
||||||
${GAME_SRC_DIR}/g_turret.c
|
${GAME_SRC_DIR}/g_turret.c
|
||||||
${GAME_SRC_DIR}/g_utils.c
|
${GAME_SRC_DIR}/g_utils.c
|
||||||
${GAME_SRC_DIR}/g_weapon.c
|
${GAME_SRC_DIR}/g_weapon.c
|
||||||
|
${GAME_SRC_DIR}/laser.c
|
||||||
${GAME_SRC_DIR}/monster/berserker/berserker.c
|
${GAME_SRC_DIR}/monster/berserker/berserker.c
|
||||||
${GAME_SRC_DIR}/monster/boss2/boss2.c
|
${GAME_SRC_DIR}/monster/boss2/boss2.c
|
||||||
${GAME_SRC_DIR}/monster/boss3/boss3.c
|
${GAME_SRC_DIR}/monster/boss3/boss3.c
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -555,6 +555,7 @@ GAME_OBJS_ = \
|
||||||
src/game/g_turret.o \
|
src/game/g_turret.o \
|
||||||
src/game/g_utils.o \
|
src/game/g_utils.o \
|
||||||
src/game/g_weapon.o \
|
src/game/g_weapon.o \
|
||||||
|
src/game/laser.o \
|
||||||
src/game/monster/berserker/berserker.o \
|
src/game/monster/berserker/berserker.o \
|
||||||
src/game/monster/boss2/boss2.o \
|
src/game/monster/boss2/boss2.o \
|
||||||
src/game/monster/boss3/boss3.o \
|
src/game/monster/boss3/boss3.o \
|
||||||
|
|
|
@ -1364,10 +1364,14 @@ ClientCommand(edict_t *ent)
|
||||||
{
|
{
|
||||||
Cmd_Wave_f(ent);
|
Cmd_Wave_f(ent);
|
||||||
}
|
}
|
||||||
|
else if (Q_stricmp(cmd, "laser") == 0)
|
||||||
|
{
|
||||||
|
SP_LaserSight(ent);
|
||||||
|
}
|
||||||
else if (Q_stricmp(cmd, "playerlist") == 0)
|
else if (Q_stricmp(cmd, "playerlist") == 0)
|
||||||
{
|
{
|
||||||
Cmd_PlayerList_f(ent);
|
Cmd_PlayerList_f(ent);
|
||||||
}
|
}
|
||||||
else /* anything that doesn't match a command will be a chat */
|
else /* anything that doesn't match a command will be a chat */
|
||||||
{
|
{
|
||||||
Cmd_Say_f(ent, false, true);
|
Cmd_Say_f(ent, false, true);
|
||||||
|
|
|
@ -1073,4 +1073,9 @@ struct edict_s
|
||||||
monsterinfo_t monsterinfo;
|
monsterinfo_t monsterinfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* laser.c */
|
||||||
|
void LaserSightThink (edict_t *self);
|
||||||
|
void SP_LaserSight(edict_t *self);
|
||||||
|
void UpdateLaserSight(void);
|
||||||
|
|
||||||
#endif /* GAME_LOCAL_H */
|
#endif /* GAME_LOCAL_H */
|
||||||
|
|
95
src/game/laser.c
Normal file
95
src/game/laser.c
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
// laser sight patch, by Geza Beladi
|
||||||
|
|
||||||
|
#include "header/local.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------
|
||||||
|
SP_LaserSight
|
||||||
|
|
||||||
|
Create/remove the laser sight entity
|
||||||
|
-----------------------------------------*/
|
||||||
|
|
||||||
|
edict_t *lasersight;
|
||||||
|
|
||||||
|
#define lss lasersight
|
||||||
|
|
||||||
|
void SP_LaserSight(edict_t *self) {
|
||||||
|
|
||||||
|
vec3_t start,forward,right,end;
|
||||||
|
|
||||||
|
if ( lss ) {
|
||||||
|
G_FreeEdict(lss);
|
||||||
|
lss = NULL;
|
||||||
|
gi.bprintf(PRINT_HIGH, "lasersight off.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gi.bprintf(PRINT_HIGH, "lasersight on.");
|
||||||
|
|
||||||
|
AngleVectors (self->client->v_angle, forward, right, NULL);
|
||||||
|
|
||||||
|
VectorSet(end,100 , 0, 0);
|
||||||
|
G_ProjectSource(self->s.origin, end, forward, right, start);
|
||||||
|
|
||||||
|
lss = G_Spawn();
|
||||||
|
lss->owner = self;
|
||||||
|
lss->movetype = MOVETYPE_NOCLIP;
|
||||||
|
lss->solid = SOLID_NOT;
|
||||||
|
lss->classname = "lasersight";
|
||||||
|
// lss->s.modelindex = gi.modelindex ("put/your/own/model/here.md2");
|
||||||
|
lss->s.modelindex = gi.modelindex("models/objects/gibs/sm_meat/tris.md2");
|
||||||
|
lss->s.skinnum = 0;
|
||||||
|
|
||||||
|
lss->s.renderfx |= RF_FULLBRIGHT;
|
||||||
|
|
||||||
|
lss->think = LaserSightThink;
|
||||||
|
lss->nextthink = level.time + 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------
|
||||||
|
LaserSightThink
|
||||||
|
|
||||||
|
Updates the sights position, angle, and shape
|
||||||
|
is the lasersight entity
|
||||||
|
---------------------------------------------*/
|
||||||
|
|
||||||
|
void LaserSightThink(edict_t *self)
|
||||||
|
{
|
||||||
|
vec3_t start,end,endp,offset;
|
||||||
|
vec3_t forward,right,up;
|
||||||
|
trace_t tr;
|
||||||
|
|
||||||
|
AngleVectors(self->owner->client->v_angle, forward, right, up);
|
||||||
|
|
||||||
|
VectorSet(offset,24 , 6, self->owner->viewheight-7);
|
||||||
|
G_ProjectSource (self->owner->s.origin, offset, forward, right, start);
|
||||||
|
VectorMA(start,8192,forward,end);
|
||||||
|
|
||||||
|
tr = gi.trace(start,NULL,NULL, end,self->owner,CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_DEADMONSTER);
|
||||||
|
|
||||||
|
if(tr.fraction != 1) {
|
||||||
|
VectorMA(tr.endpos,-4,forward,endp);
|
||||||
|
VectorCopy(endp,tr.endpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client)){
|
||||||
|
if ((tr.ent->takedamage) && (tr.ent != self->owner)) {
|
||||||
|
self->s.skinnum = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
self->s.skinnum = 0;
|
||||||
|
|
||||||
|
vectoangles(tr.plane.normal,self->s.angles);
|
||||||
|
VectorCopy(tr.endpos,self->s.origin);
|
||||||
|
|
||||||
|
gi.linkentity(self);
|
||||||
|
self->nextthink = level.time + 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateLaserSight(void){
|
||||||
|
if(lasersight != NULL){
|
||||||
|
LaserSightThink(lasersight);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue