mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-04-09 11:41:32 +00:00
game: extend animation group usage to object_big_fire
This commit is contained in:
parent
c63df9cab0
commit
f319bb0884
8 changed files with 124 additions and 82 deletions
|
@ -50,27 +50,40 @@ void AI_EnemyAdded(edict_t *ent)
|
|||
void AI_EnemyRemoved(edict_t *ent)
|
||||
{
|
||||
int i;
|
||||
int pos;
|
||||
int pos = -1;
|
||||
|
||||
// watch for 0 players
|
||||
if(num_AIEnemies < 1)
|
||||
/* watch for 0 players */
|
||||
if (num_AIEnemies < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// special case for only one player
|
||||
if(num_AIEnemies == 1)
|
||||
/* special case for only one player */
|
||||
if (num_AIEnemies == 1)
|
||||
{
|
||||
num_AIEnemies = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the player
|
||||
for(i=0;i<num_AIEnemies;i++)
|
||||
if(ent == AIEnemies[i])
|
||||
/* Find the player */
|
||||
for (i = 0; i < num_AIEnemies; i++)
|
||||
{
|
||||
if (ent == AIEnemies[i])
|
||||
{
|
||||
pos = i;
|
||||
}
|
||||
}
|
||||
|
||||
// decrement
|
||||
for( i=pos; i<num_AIEnemies-1; i++ )
|
||||
AIEnemies[i] = AIEnemies[i+1];
|
||||
if (pos < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* decrement */
|
||||
for (i = pos; i < num_AIEnemies - 1; i++)
|
||||
{
|
||||
AIEnemies[i] = AIEnemies[i + 1];
|
||||
}
|
||||
|
||||
num_AIEnemies--;
|
||||
}
|
||||
|
|
|
@ -38,36 +38,35 @@ edict_t *LINKS_PASSENT = NULL;
|
|||
//==========================================
|
||||
char *AI_LinkString( int linktype )
|
||||
{
|
||||
char *s;
|
||||
|
||||
if( linktype == LINK_MOVE )
|
||||
s = "LINK_MOVE";
|
||||
else if( linktype == LINK_STAIRS )
|
||||
s = "LINK_STAIRS";
|
||||
else if( linktype == LINK_FALL )
|
||||
s = "LINK_FALL";
|
||||
else if( linktype == LINK_CLIMB )
|
||||
s = "LINK_CLIMB";
|
||||
else if( linktype == LINK_TELEPORT )
|
||||
s = "LINK_TELEPORT";
|
||||
else if( linktype == LINK_PLATFORM )
|
||||
s = "LINK_PLATFORM";
|
||||
else if( linktype == LINK_JUMPPAD )
|
||||
s = "LINK_JUMPAD";
|
||||
else if( linktype == LINK_WATER )
|
||||
s = "LINK_WATER";
|
||||
else if( linktype == LINK_WATERJUMP )
|
||||
s = "LINK_WATERJUMP";
|
||||
else if( linktype == LINK_LADDER )
|
||||
s = "LINK_LADDER";
|
||||
else if( linktype == LINK_INVALID )
|
||||
s = "LINK_INVALID";
|
||||
else if( linktype == LINK_JUMP )
|
||||
s = "LINK_JUMP";
|
||||
else if( linktype )
|
||||
s = "UNKNOWN";
|
||||
|
||||
return s;
|
||||
switch (linktype)
|
||||
{
|
||||
case LINK_MOVE:
|
||||
return "LINK_MOVE";
|
||||
case LINK_STAIRS:
|
||||
return "LINK_STAIRS";
|
||||
case LINK_FALL:
|
||||
return "LINK_FALL";
|
||||
case LINK_CLIMB:
|
||||
return "LINK_CLIMB";
|
||||
case LINK_TELEPORT:
|
||||
return "LINK_TELEPORT";
|
||||
case LINK_PLATFORM:
|
||||
return "LINK_PLATFORM";
|
||||
case LINK_JUMPPAD:
|
||||
return "LINK_JUMPAD";
|
||||
case LINK_WATER:
|
||||
return "LINK_WATER";
|
||||
case LINK_WATERJUMP:
|
||||
return "LINK_WATERJUMP";
|
||||
case LINK_LADDER:
|
||||
return "LINK_LADDER";
|
||||
case LINK_INVALID:
|
||||
return "LINK_INVALID";
|
||||
case LINK_JUMP:
|
||||
return "LINK_JUMP";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================
|
||||
|
|
|
@ -646,43 +646,57 @@ qboolean AI_LoadPLKFile( char *mapname )
|
|||
// AI_IsPlatformLink
|
||||
// interpretation of this link type
|
||||
//==========================================
|
||||
int AI_IsPlatformLink( int n1, int n2 )
|
||||
static int
|
||||
AI_IsPlatformLink(int n1, int n2)
|
||||
{
|
||||
int i;
|
||||
if( nodes[n1].flags & NODEFLAGS_PLATFORM && nodes[n2].flags & NODEFLAGS_PLATFORM )
|
||||
if (n1 < 0 || n2 < 0)
|
||||
{
|
||||
return LINK_INVALID;
|
||||
}
|
||||
|
||||
if ((nodes[n1].flags & NODEFLAGS_PLATFORM) && (nodes[n2].flags & NODEFLAGS_PLATFORM))
|
||||
{
|
||||
//the link was added by it's dropping function or it's invalid
|
||||
return LINK_INVALID;
|
||||
}
|
||||
|
||||
//if first is plat but not second
|
||||
if( nodes[n1].flags & NODEFLAGS_PLATFORM && !(nodes[n2].flags & NODEFLAGS_PLATFORM) )
|
||||
/* if first is plat but not second */
|
||||
if ((nodes[n1].flags & NODEFLAGS_PLATFORM) && !(nodes[n2].flags & NODEFLAGS_PLATFORM))
|
||||
{
|
||||
edict_t *n1ent = NULL;
|
||||
int othernode;
|
||||
int othernode = -1, i;
|
||||
|
||||
// find ent
|
||||
for(i=0;i<nav.num_ents;i++) {
|
||||
if( nav.ents[i].node == n1 )
|
||||
for( i = 0; i < nav.num_ents; i++)
|
||||
{
|
||||
if (nav.ents[i].node == n1)
|
||||
{
|
||||
n1ent = nav.ents[i].ent;
|
||||
}
|
||||
}
|
||||
// find the other node from that ent
|
||||
for(i=0;i<nav.num_ents;i++){
|
||||
for(i = 0; i < nav.num_ents; i++)
|
||||
{
|
||||
if( nav.ents[i].node != n1 && nav.ents[i].ent == n1ent)
|
||||
{
|
||||
othernode = nav.ents[i].node;
|
||||
}
|
||||
}
|
||||
|
||||
if( othernode == -1 || !n1ent )
|
||||
if (othernode == -1 || !n1ent)
|
||||
{
|
||||
return LINK_INVALID;
|
||||
}
|
||||
|
||||
//find out if n1 is the upper or the lower plat node
|
||||
if( nodes[n1].origin[2] < nodes[othernode].origin[2] )
|
||||
if (nodes[n1].origin[2] < nodes[othernode].origin[2])
|
||||
{
|
||||
//n1 is plat lower: it can't link TO anything but upper plat node
|
||||
return LINK_INVALID;
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_t trace;
|
||||
float heightdiff;
|
||||
//n1 is plat upper: it can link to visibles at same height
|
||||
|
@ -693,8 +707,10 @@ int AI_IsPlatformLink( int n1, int n2 )
|
|||
if( heightdiff < 0 )
|
||||
heightdiff = -heightdiff;
|
||||
|
||||
if( heightdiff < AI_JUMPABLE_HEIGHT )
|
||||
if (heightdiff < AI_JUMPABLE_HEIGHT)
|
||||
{
|
||||
return LINK_MOVE;
|
||||
}
|
||||
|
||||
return LINK_INVALID;
|
||||
}
|
||||
|
@ -702,10 +718,10 @@ int AI_IsPlatformLink( int n1, int n2 )
|
|||
}
|
||||
|
||||
//only second is plat node
|
||||
if( !(nodes[n1].flags & NODEFLAGS_PLATFORM) && nodes[n2].flags & NODEFLAGS_PLATFORM )
|
||||
if (!(nodes[n1].flags & NODEFLAGS_PLATFORM) && (nodes[n2].flags & NODEFLAGS_PLATFORM))
|
||||
{
|
||||
edict_t *n2ent = NULL;
|
||||
int othernode;
|
||||
int othernode = -1, i;
|
||||
|
||||
// find ent
|
||||
for(i=0;i<nav.num_ents;i++) {
|
||||
|
|
|
@ -798,7 +798,43 @@ M_SetEffects(edict_t *ent)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
M_SetAnimGroupFrameValues(edict_t *self, const char *name,
|
||||
int *ofs_frames, int *num_frames)
|
||||
{
|
||||
const dmdxframegroup_t * frames;
|
||||
int num, i;
|
||||
|
||||
frames = gi.GetFrameGroups(self->s.modelindex, &num);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (!strcmp(frames[i].name, name))
|
||||
{
|
||||
*ofs_frames = frames[i].ofs;
|
||||
*num_frames = frames[i].num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
M_SetAnimGroupFrame(edict_t *self, const char *name)
|
||||
{
|
||||
int i, ofs_frames = 0, num_frames = 1;
|
||||
|
||||
M_SetAnimGroupFrameValues(self, name, &ofs_frames, &num_frames);
|
||||
|
||||
i = self->s.frame - ofs_frames;
|
||||
if (i < 0)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
i++;
|
||||
|
||||
self->s.frame = ofs_frames + i % num_frames;
|
||||
}
|
||||
|
||||
static void
|
||||
M_MoveFrame(edict_t *self)
|
||||
{
|
||||
mmove_t *move;
|
||||
|
|
|
@ -39,28 +39,7 @@
|
|||
void
|
||||
object_flame1_think(edict_t *self)
|
||||
{
|
||||
int num, i, ofs_frames = 0, num_frames = 1;
|
||||
const dmdxframegroup_t * frames;
|
||||
|
||||
frames = gi.GetFrameGroups(self->s.modelindex, &num);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (!strcmp(frames[i].name, "flame"))
|
||||
{
|
||||
ofs_frames = frames[i].ofs;
|
||||
num_frames = frames[i].num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i = self->s.frame - ofs_frames;
|
||||
if (i < 0)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
i++;
|
||||
|
||||
self->s.frame = ofs_frames + i % num_frames;
|
||||
M_SetAnimGroupFrame(self, "flame");
|
||||
self->nextthink = level.time + FRAMETIME;
|
||||
}
|
||||
|
||||
|
@ -100,7 +79,7 @@ SP_object_flame1(edict_t *self)
|
|||
void
|
||||
object_big_fire_think(edict_t *self)
|
||||
{
|
||||
self->s.frame = (self->s.frame + 1) % 60;
|
||||
M_SetAnimGroupFrame(self, "bigfire");
|
||||
self->nextthink = level.time + FRAMETIME;
|
||||
|
||||
/* add particles */
|
||||
|
|
|
@ -1020,6 +1020,7 @@ qboolean M_CheckBottom(edict_t *ent);
|
|||
qboolean M_walkmove(edict_t *ent, float yaw, float dist);
|
||||
void M_MoveToGoal(edict_t *ent, float dist);
|
||||
void M_ChangeYaw(edict_t *ent);
|
||||
void M_SetAnimGroupFrame(edict_t *self, const char *name);
|
||||
|
||||
/* g_phys.c */
|
||||
void G_RunEntity(edict_t *ent);
|
||||
|
|
|
@ -206,7 +206,6 @@ extern void M_FliesOff ( edict_t * self ) ;
|
|||
extern void M_FliesOn ( edict_t * self ) ;
|
||||
extern void M_FlyCheck ( edict_t * self ) ;
|
||||
extern void M_MonsterDodge ( edict_t * self , edict_t * attacker , float eta, trace_t *tr ) ;
|
||||
extern void M_MoveFrame ( edict_t * self ) ;
|
||||
extern void M_MoveToGoal ( edict_t * ent , float dist ) ;
|
||||
extern void M_ReactToDamage ( edict_t * targ , edict_t * attacker , edict_t * inflictor ) ;
|
||||
extern void M_SetEffects ( edict_t * ent ) ;
|
||||
|
|
|
@ -127,7 +127,6 @@
|
|||
{"M_FliesOn", (byte *)M_FliesOn},
|
||||
{"M_FlyCheck", (byte *)M_FlyCheck},
|
||||
{"M_MonsterDodge", (byte *)M_MonsterDodge},
|
||||
{"M_MoveFrame", (byte *)M_MoveFrame},
|
||||
{"M_MoveToGoal", (byte *)M_MoveToGoal},
|
||||
{"M_ReactToDamage", (byte *)M_ReactToDamage},
|
||||
{"M_SetEffects", (byte *)M_SetEffects},
|
||||
|
|
Loading…
Reference in a new issue