death wip
This commit is contained in:
parent
16c5e2620e
commit
4bc6a26c74
44
src/pp/pp.c
44
src/pp/pp.c
@ -2,9 +2,9 @@ P_Ctx P = Zi;
|
|||||||
ThreadLocal P_ThreadLocalCtx P_tl = Zi;
|
ThreadLocal P_ThreadLocalCtx P_tl = Zi;
|
||||||
|
|
||||||
Readonly P_Ent P_NilEnt = {
|
Readonly P_Ent P_NilEnt = {
|
||||||
.prev_xf = CompXformIdentity,
|
|
||||||
.xf = CompXformIdentity,
|
.xf = CompXformIdentity,
|
||||||
.control.look = { 1, 0 },
|
.control.look = { 1, 0 },
|
||||||
|
.health = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
Readonly P_Frame P_NilFrame = {
|
Readonly P_Frame P_NilFrame = {
|
||||||
@ -1456,7 +1456,6 @@ void P_SpawnEntsFromList(P_Frame *frame, P_EntList ents)
|
|||||||
P_Ent *old_prev_in_bin = dst->prev_in_bin;
|
P_Ent *old_prev_in_bin = dst->prev_in_bin;
|
||||||
{
|
{
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
dst->prev_xf = NormXform(dst->prev_xf);
|
|
||||||
dst->xf = NormXform(dst->xf);
|
dst->xf = NormXform(dst->xf);
|
||||||
}
|
}
|
||||||
dst->next = old_next;
|
dst->next = old_next;
|
||||||
@ -1643,14 +1642,6 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
P_Ent *local_player = P_EntFromKey(frame, P_tl.local_player);
|
P_Ent *local_player = P_EntFromKey(frame, P_tl.local_player);
|
||||||
P_Ent *local_guy = P_EntFromKey(frame, local_player->guy);
|
P_Ent *local_guy = P_EntFromKey(frame, local_player->guy);
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
//- Update double-buffered entity data
|
|
||||||
|
|
||||||
for (P_Ent *ent = P_FirstEnt(frame); !P_IsEntNil(ent); ent = P_NextEnt(ent))
|
|
||||||
{
|
|
||||||
ent->prev_xf = ent->xf;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Spawn entities
|
//- Spawn entities
|
||||||
|
|
||||||
@ -2560,15 +2551,15 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
Vec2 ray_dir = SubVec2(ray_end, ray_start);
|
Vec2 ray_dir = SubVec2(ray_end, ray_start);
|
||||||
|
|
||||||
// TODO: Real raycast query
|
// TODO: Real raycast query
|
||||||
P_Ent *closest_victim = &P_NilEnt;
|
P_Ent *victim = &P_NilEnt;
|
||||||
P_RaycastResult victim_raycast = Zi;
|
P_RaycastResult victim_raycast = Zi;
|
||||||
{
|
{
|
||||||
f32 closest_len_sq = Inf;
|
f32 closest_len_sq = Inf;
|
||||||
for (P_Ent *victim = P_FirstEnt(frame); !P_IsEntNil(victim); victim = P_NextEnt(victim))
|
for (P_Ent *potential_victim = P_FirstEnt(frame); !P_IsEntNil(potential_victim); potential_victim = P_NextEnt(potential_victim))
|
||||||
{
|
{
|
||||||
if (victim->is_guy && !P_MatchKey(victim->key, bullet->bullet_firer))
|
if (potential_victim->is_guy && !P_MatchKey(potential_victim->key, bullet->bullet_firer))
|
||||||
{
|
{
|
||||||
P_Shape victim_world_shape = P_WorldShapeFromEnt(victim);
|
P_Shape victim_world_shape = P_WorldShapeFromEnt(potential_victim);
|
||||||
|
|
||||||
P_RaycastResult entrance_raycast = P_RaycastShape(victim_world_shape, ray_start, ray_dir);
|
P_RaycastResult entrance_raycast = P_RaycastShape(victim_world_shape, ray_start, ray_dir);
|
||||||
Vec2 entrance = entrance_raycast.p;
|
Vec2 entrance = entrance_raycast.p;
|
||||||
@ -2584,7 +2575,7 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
if (len_sq < closest_len_sq)
|
if (len_sq < closest_len_sq)
|
||||||
{
|
{
|
||||||
closest_len_sq = len_sq;
|
closest_len_sq = len_sq;
|
||||||
closest_victim = victim;
|
victim = potential_victim;
|
||||||
victim_raycast = entrance_raycast;
|
victim_raycast = entrance_raycast;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2593,13 +2584,16 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!P_IsEntNil(closest_victim))
|
if (!P_IsEntNil(victim))
|
||||||
{
|
{
|
||||||
bullet->has_hit = 1;
|
bullet->has_hit = 1;
|
||||||
bullet->hit_entry = victim_raycast.p;
|
bullet->hit_entry = victim_raycast.p;
|
||||||
bullet->hit_entry_normal = victim_raycast.normal;
|
bullet->hit_entry_normal = victim_raycast.normal;
|
||||||
// bullet->bullet_end = bullet->hit_entry;
|
// bullet->bullet_end = bullet->hit_entry;
|
||||||
bullet->exists = 0;
|
bullet->exists = 0;
|
||||||
|
|
||||||
|
// TODO: Remove this
|
||||||
|
victim->health -= 0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rng2 bounds = Zi;
|
Rng2 bounds = Zi;
|
||||||
@ -2615,6 +2609,24 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Kill guys
|
||||||
|
|
||||||
|
for (P_Ent *guy = P_FirstEnt(frame); !P_IsEntNil(guy); guy = P_NextEnt(guy))
|
||||||
|
{
|
||||||
|
if (guy->is_guy)
|
||||||
|
{
|
||||||
|
if (guy->health <= 0)
|
||||||
|
{
|
||||||
|
P_Ent *old_guy = P_EntFromKey(prev_frame, guy->key);
|
||||||
|
if (old_guy->health > 0)
|
||||||
|
{
|
||||||
|
guy->exists = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Debug draw
|
//- Debug draw
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,6 @@ Struct(P_Ent)
|
|||||||
b32 is_dummy;
|
b32 is_dummy;
|
||||||
f32 health;
|
f32 health;
|
||||||
|
|
||||||
Xform prev_xf;
|
|
||||||
Xform xf;
|
Xform xf;
|
||||||
|
|
||||||
// TODO: Remove this (weapon testing)
|
// TODO: Remove this (weapon testing)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user