diff --git a/src/entities/func_croucharea.qc b/src/entities/func_croucharea.qc new file mode 100644 index 0000000..bfc802e --- /dev/null +++ b/src/entities/func_croucharea.qc @@ -0,0 +1,12 @@ +class idFuncCroucharea:idEntity { + void idFuncCroucharea( void ); +}; + +void idFuncCroucharea::idFuncCroucharea( void ) { + SetAngles( [0, 0, 0] ); + SetMovetype(MOVETYPE_PUSH); + SetSolid(SOLID_BSP); + SetModel(GetModel()); /* relink with the above properties */ +} + +LINK_ENTITY_TO_CLASS(func_croucharea, idFuncCroucharea) \ No newline at end of file diff --git a/src/entities/func_illusionary.qc b/src/entities/func_illusionary.qc new file mode 100644 index 0000000..e75845a --- /dev/null +++ b/src/entities/func_illusionary.qc @@ -0,0 +1,12 @@ +class idFuncIllusionary:idEntity { + void idFuncIllusionary( void ); +}; + +void idFuncIllusionary::idFuncIllusionary( void ) { + SetAngles( [0, 0, 0] ); + SetMovetype(MOVETYPE_PUSH); + SetSolid(SOLID_NOT); + SetModel(GetModel()); /* relink with the above properties */ +} + +LINK_ENTITY_TO_CLASS(func_illusionary, idFuncIllusionary) \ No newline at end of file diff --git a/src/entities/func_wall.qc b/src/entities/func_wall.qc index c66bffd..dd303ba 100644 --- a/src/entities/func_wall.qc +++ b/src/entities/func_wall.qc @@ -2,7 +2,7 @@ class idFuncWall:idEntity { void idFuncWall( void ); }; -void idFuncWall:: idFuncWall( void ) { +void idFuncWall::idFuncWall( void ) { SetAngles( [0, 0, 0] ); SetMovetype(MOVETYPE_PUSH); SetSolid(SOLID_BSP); diff --git a/src/entities/info_player_start.qc b/src/entities/info_player_start.qc index 00498e2..c63084b 100644 --- a/src/entities/info_player_start.qc +++ b/src/entities/info_player_start.qc @@ -11,7 +11,7 @@ void idPlayerStart::idPlayerStart( void ) { } idEntity idPlayerStart::MovePlayerToStart( idPlayer player ) { - idEntity point = g_idEngine.Find( world, ::classname, "idPlayerStart" ); + idEntity point = g_idEngine.Find( ( idEntity ) world, ::classname, "idPlayerStart" ); if ( point ) { player.Transport( point.GetOrigin(), point.GetAngles() ); diff --git a/src/entities/light.qc b/src/entities/light.qc index e69de29..1792f24 100644 --- a/src/entities/light.qc +++ b/src/entities/light.qc @@ -0,0 +1,9 @@ +class idLight:idEntity { + void idLight( void ); +}; + +void idLight::idLight( void ) { + +} + +LINK_ENTITY_TO_CLASS(light, idLight) \ No newline at end of file diff --git a/src/entities/sources.src b/src/entities/sources.src index db4f809..6e74a1a 100644 --- a/src/entities/sources.src +++ b/src/entities/sources.src @@ -1,5 +1,6 @@ #includelist func_wall.qc +func_illusionary.qc info_null.qc info_player_start.qc light.qc diff --git a/src/entry.qc b/src/entry.qc index 200d30d..3962452 100644 --- a/src/entry.qc +++ b/src/entry.qc @@ -1,6 +1,75 @@ /* all standard game entry functions live here */ void main( void ) { + /* all the files that DOSQuake needs to boot. */ + g_idEngine.Precache_File( "progs.dat"); + g_idEngine.Precache_File( "gfx.wad" ); + g_idEngine.Precache_File( "quake.rc" ); + g_idEngine.Precache_File( "default.cfg" ); + g_idEngine.Precache_File( "gfx/palette.lmp" ); + g_idEngine.Precache_File( "gfx/colormap.lmp" ); + g_idEngine.Precache_File( "gfx/complete.lmp" ); + g_idEngine.Precache_File( "gfx/inter.lmp" ); + g_idEngine.Precache_File( "gfx/ranking.lmp" ); + g_idEngine.Precache_File( "gfx/vidmodes.lmp" ); + g_idEngine.Precache_File( "gfx/finale.lmp" ); + g_idEngine.Precache_File( "gfx/conback.lmp" ); + g_idEngine.Precache_File( "gfx/qplaque.lmp" ); + g_idEngine.Precache_File( "gfx/menudot1.lmp" ); + g_idEngine.Precache_File( "gfx/menudot2.lmp" ); + g_idEngine.Precache_File( "gfx/menudot3.lmp" ); + g_idEngine.Precache_File( "gfx/menudot4.lmp" ); + g_idEngine.Precache_File( "gfx/menudot5.lmp" ); + g_idEngine.Precache_File( "gfx/menudot6.lmp" ); + g_idEngine.Precache_File( "gfx/menuplyr.lmp" ); + g_idEngine.Precache_File( "gfx/bigbox.lmp" ); + g_idEngine.Precache_File( "gfx/dim_modm.lmp" ); + g_idEngine.Precache_File( "gfx/dim_drct.lmp" ); + g_idEngine.Precache_File( "gfx/dim_ipx.lmp" ); + g_idEngine.Precache_File( "gfx/dim_tcp.lmp" ); + g_idEngine.Precache_File( "gfx/dim_mult.lmp" ); + g_idEngine.Precache_File( "gfx/mainmenu.lmp" ); + g_idEngine.Precache_File( "gfx/box_tl.lmp" ); + g_idEngine.Precache_File( "gfx/box_tm.lmp" ); + g_idEngine.Precache_File( "gfx/box_tr.lmp" ); + g_idEngine.Precache_File( "gfx/box_ml.lmp" ); + g_idEngine.Precache_File( "gfx/box_mm.lmp" ); + g_idEngine.Precache_File( "gfx/box_mm2.lmp" ); + g_idEngine.Precache_File( "gfx/box_mr.lmp" ); + g_idEngine.Precache_File( "gfx/box_bl.lmp" ); + g_idEngine.Precache_File( "gfx/box_bm.lmp" ); + g_idEngine.Precache_File( "gfx/box_br.lmp" ); + g_idEngine.Precache_File( "gfx/sp_menu.lmp" ); + g_idEngine.Precache_File( "gfx/ttl_sgl.lmp" ); + g_idEngine.Precache_File( "gfx/ttl_main.lmp" ); + g_idEngine.Precache_File( "gfx/ttl_cstm.lmp" ); + g_idEngine.Precache_File( "gfx/mp_menu.lmp" ); + g_idEngine.Precache_File( "gfx/netmen1.lmp" ); + g_idEngine.Precache_File( "gfx/netmen2.lmp" ); + g_idEngine.Precache_File( "gfx/netmen3.lmp" ); + g_idEngine.Precache_File( "gfx/netmen4.lmp" ); + g_idEngine.Precache_File( "gfx/netmen5.lmp" ); + g_idEngine.Precache_File( "gfx/sell.lmp" ); + g_idEngine.Precache_File( "gfx/help0.lmp" ); + g_idEngine.Precache_File( "gfx/help1.lmp" ); + g_idEngine.Precache_File( "gfx/help2.lmp" ); + g_idEngine.Precache_File( "gfx/help3.lmp" ); + g_idEngine.Precache_File( "gfx/help4.lmp" ); + g_idEngine.Precache_File( "gfx/help5.lmp" ); + g_idEngine.Precache_File( "gfx/pause.lmp" ); + g_idEngine.Precache_File( "gfx/loading.lmp" ); + g_idEngine.Precache_File( "gfx/p_option.lmp" ); + g_idEngine.Precache_File( "gfx/p_load.lmp" ); + g_idEngine.Precache_File( "gfx/p_save.lmp" ); + g_idEngine.Precache_File( "gfx/p_multi.lmp" ); + g_idEngine.Precache_Sound( "misc/menu1.wav" ); + g_idEngine.Precache_Sound( "misc/menu2.wav" ); + g_idEngine.Precache_Sound( "misc/menu3.wav" ); + g_idEngine.Precache_Sound( "ambience/water1.wav" ); + g_idEngine.Precache_Sound( "ambience/wind2.wav" ); + g_idEngine.Precache_File( "maps/start.bsp" ); + g_idEngine.Precache_File( "maps/scale_test.bsp" ); + g_idEngine.Precache_File2( "gfx/pop.lmp" ); } void StartFrame( void ) { @@ -16,16 +85,44 @@ void StartFrame( void ) { void PlayerPreThink( void ) { idPlayer pl = ( idPlayer ) self; - pl.PreThink(); + if (pl.GetDeadFlag() >= DEAD_DYING) { + pl.DeadThink(); + return; + } else { + pl.PreThink(); + } + +#if 0 + if (pl.button2) { + if (pl.HasFlag(FL_JUMPRELEASED) && pl.HasFlag(FL_ONGROUND)) { + pl.RemoveFlags(FL_JUMPRELEASED | FL_ONGROUND); + pl.SetVelocity(pl.GetVelocity() + [0, 0, 200]); + } + } else { + pl.AddFlags(FL_JUMPRELEASED); + } +#else + if (pl.button2) { + if (pl.HasFlag(FL_JUMPRELEASED) && pl.HasFlag(FL_ONGROUND)) { + pl.RemoveFlags(FL_JUMPRELEASED | FL_ONGROUND); + pl.SetVelocity(pl.GetVelocity() + [0, 0, 200]); + } + } else { + pl.AddFlags(FL_JUMPRELEASED); + } +#endif } void PlayerPostThink( void ) { idPlayer pl = ( idPlayer ) self; - pl.PostThink(); + if (pl.GetDeadFlag() < DEAD_DEAD) { + pl.PostThink(); + } } void ClientKill( void ) { + g_gameRules.ApplyDamage( ( idEntity) self, ( idEntity ) self, 200, 0, 0); } void ClientConnect( void ) { diff --git a/src/system/idEngine.qc b/src/system/idEngine.qc index dbbbfb2..e2effb7 100644 --- a/src/system/idEngine.qc +++ b/src/system/idEngine.qc @@ -302,6 +302,10 @@ string idEngine::Precache_File( string s ) { return precache_file( s ); } +string idEngine::Precache_File2( string s ) { + return precache_file2( s ); +} + void idEngine::MakeStatic( idEntity e ) { makestatic( e ); } diff --git a/src/system/idEngine.qh b/src/system/idEngine.qh index a8b5bae..9ab3aad 100644 --- a/src/system/idEngine.qh +++ b/src/system/idEngine.qh @@ -55,6 +55,7 @@ class idEngine { nonvirtual void WriteEntity( float to, idEntity s ); nonvirtual void MoveToGoal( float step ); nonvirtual string Precache_File( string s ); + nonvirtual string Precache_File2( string s ); nonvirtual void MakeStatic( idEntity e ); nonvirtual void ChangeLevel( string s ); nonvirtual void CVarSet( string var, string val ); diff --git a/src/system/idEntity.qc b/src/system/idEntity.qc index a67a3bc..3e069d3 100644 --- a/src/system/idEntity.qc +++ b/src/system/idEntity.qc @@ -123,6 +123,10 @@ void idEntity::SetTakedamage( damage_t value ) { takedamage = value; } +void idEntity::SetDeadFlag( dead_t value ) { + deadflag = value; +} + void idEntity::SetViewOffset( vector value ) { view_ofs = value; } @@ -219,7 +223,7 @@ void idEntity::SetTouchCallback( void( idEntity ) callback ) { } void idEntity::_TouchWrapper( void ) { - TouchCallback(other); + TouchCallback( ( idEntity) other ); } @@ -316,10 +320,14 @@ float idEntity::GetAmmoType4( void ) { return ammo_cells; } -float idEntity::CanTakeDamage( void ) { +bool idEntity::CanTakeDamage( void ) { return ( takedamage != DAMAGE_NO ) ? TRUE : FALSE; } +dead_t idEntity::GetDeadFlag( void ) { + return (dead_t)deadflag; +} + vector idEntity::GetViewOffset( void ) { return view_ofs; } @@ -431,5 +439,13 @@ void idEntity::Transport( vector new_pos, vector new_ang ) { } idEntity idEntity::FindFirstTarget( void ) { - return g_idEngine.Find(world, ::targetname, target); + return g_idEngine.Find( (idEntity) world, ::targetname, target); +} + +void idEntity::Death( void ) { + +} + +void idEntity::Pain( void ) { + } \ No newline at end of file diff --git a/src/system/idEntity.qh b/src/system/idEntity.qh index 0c037eb..909a0f0 100644 --- a/src/system/idEntity.qh +++ b/src/system/idEntity.qh @@ -61,6 +61,8 @@ class idEntity { nonvirtual void SetAmmoType4( float ); /** TODO: This needs to be changed. */ nonvirtual void SetTakedamage( damage_t ); + /** Sets the dead_t state */ + nonvirtual void SetDeadFlag( dead_t ); /** Sets the eye position of the entity. As an offset relative to its origin. */ nonvirtual void SetViewOffset( vector ); /** When called, will force the client to update its camera angles on the client-side. */ @@ -152,7 +154,9 @@ class idEntity { /** Returns the amount of ammo type 4. */ nonvirtual float GetAmmoType4( void ); /** Returns whether or not this entity can take damage. */ - nonvirtual float CanTakeDamage( void ); + nonvirtual bool CanTakeDamage( void ); + /** Returns which state of dying we're in. */ + nonvirtual dead_t GetDeadFlag( void ); /** Returns the eye position of the entity relative to its origin. */ nonvirtual vector GetViewOffset( void ); /** Returns either TRUE or FALSE if the entity has a given flag. */ @@ -195,4 +199,7 @@ class idEntity { nonvirtual void InitTrigger( void ); nonvirtual void Transport( vector, vector ); nonvirtual idEntity FindFirstTarget( void ); + + virtual void Death( void ); + virtual void Pain( void ); }; diff --git a/src/system/idPlayer.qc b/src/system/idPlayer.qc index 1e0ef04..19c8b71 100644 --- a/src/system/idPlayer.qc +++ b/src/system/idPlayer.qc @@ -7,6 +7,9 @@ void idPlayer::PreThink( void ) { void idPlayer::PostThink( void ) { } +void idPlayer::DeadThink( void ) { +} + void idPlayer::ResetPlayer( void ) { ClearFlags(); ClearEffects(); @@ -21,3 +24,7 @@ void idPlayer::ResetPlayer( void ) { SetArmorType( 0 ); SetArmor( 0 ); } + +void idPlayer::Death( void ) { + SetViewOffset( [0, 0, -8] ); +} \ No newline at end of file diff --git a/src/system/idPlayer.qh b/src/system/idPlayer.qh index acdf3c1..ef4da44 100644 --- a/src/system/idPlayer.qh +++ b/src/system/idPlayer.qh @@ -3,6 +3,7 @@ class idPlayer:idEntity { nonvirtual void PreThink( void ); nonvirtual void PostThink( void ); - + nonvirtual void DeadThink( void ); nonvirtual void ResetPlayer( void ); + virtual void Death( void ); }; diff --git a/src/system/idRules.qc b/src/system/idRules.qc index 6601ecd..7f111ce 100644 --- a/src/system/idRules.qc +++ b/src/system/idRules.qc @@ -23,3 +23,22 @@ void idRules::PlayerFinishesJoining( idPlayer player ) { } } + +void idRules::ApplyDamage( idEntity target, + idEntity attacker, + float damage, + float weapon, + float flags) +{ + /* deduct whatever damage we can */ + target.health -= damage; + + /* death or pain */ + if (target.health <= 0) { + target.SetMovetype(MOVETYPE_TOSS); + target.SetDeadFlag(DEAD_DYING); + target.Death(); + } else { + target.Pain(); + } +} \ No newline at end of file diff --git a/src/system/idRules.qh b/src/system/idRules.qh index f95474c..6636ec1 100644 --- a/src/system/idRules.qh +++ b/src/system/idRules.qh @@ -4,6 +4,9 @@ class idRules { nonvirtual void PlayerConnects( idPlayer ); nonvirtual void PlayerDisconnects( idPlayer ); nonvirtual void PlayerFinishesJoining( idPlayer ); + + /* damage specific */ + nonvirtual void ApplyDamage( idEntity, idEntity, float, float, float ); }; idRules g_gameRules;