From f3fb7c6614723bf3ea8ac973a8247820a6aa2417 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sun, 26 Nov 2023 22:24:08 -0800 Subject: [PATCH] Add camera system, inventory/weapon system with object oriented weapons... --- h2/src/entities/obj_pots.qc | 8 +- h2/src/entities/obj_tree.qc | 4 +- h2/src/entities/obj_tree2.qc | 35 +- h2/src/entities/test_effects.qc | 70 +++ h2/src/init.qc | 18 + h2/src/items/blastradius.qc | 29 + h2/src/items/cubeofforce.qc | 29 + h2/src/items/flight.qc | 29 + h2/src/items/glphy.qc | 29 + h2/src/items/haste.qc | 29 + h2/src/items/healthboost.qc | 29 + h2/src/items/invincibility.qc | 29 + h2/src/items/invisibility.qc | 29 + h2/src/items/manaboost.qc | 29 + h2/src/items/polymorph.qc | 29 + h2/src/items/summon.qc | 29 + h2/src/items/superhboost.qc | 29 + h2/src/items/teleport.qc | 29 + h2/src/items/tomeofpower.qc | 29 + h2/src/items/torch.qc | 29 + h2/src/progs.src | 21 +- q1/src/init.qc | 20 + q1/src/items/quad.qc | 30 + q1/src/player.qc | 51 ++ q1/src/progs.src | 16 +- q1/src/rules.qc | 19 + q1/src/weapon_supershotgun.qc | 29 - q1/src/weapons/axe.qc | 43 ++ q1/src/weapons/grenadelauncher.qc | 44 ++ q1/src/weapons/lightning.qc | 44 ++ q1/src/weapons/nailgun.qc | 44 ++ q1/src/weapons/rocketlauncher.qc | 44 ++ q1/src/weapons/shotgun.qc | 42 ++ q1/src/weapons/supernailgun.qc | 44 ++ q1/src/weapons/supershotgun.qc | 45 ++ src/builtins.qh | 2 +- src/defs.qh | 2 +- src/entities/camera_node.qc | 1 + src/entities/func_croucharea.qc | 2 +- src/entities/func_door.qc | 129 ++++ src/entities/func_illusionary.qc | 6 +- src/entities/func_wall.qc | 2 +- src/entities/info_null.qc | 2 +- src/entities/info_player_start.qc | 23 +- src/entities/light.qc | 2 +- src/entities/sources.src | 3 + src/entities/trigger_auto.qc | 19 + src/entities/trigger_changelevel.qc | 8 +- src/entities/trigger_teleport.qc | 8 +- src/entities/worldspawn.qc | 43 +- src/entry.qc | 344 ++++++++--- src/system/classes.qc | 13 +- src/system/headers.src | 20 +- src/system/idActor.qh | 5 - src/system/idEngine.qc | 315 ---------- src/system/idEngine.qh | 81 --- src/system/idEntity.qc | 593 ------------------- src/system/idFX.qc | 177 ------ src/system/idItem.qc | 25 - src/system/idItem.qh | 17 - src/system/idPlayer.qc | 35 -- src/system/idPlayer.qh | 9 - src/system/idRules.qc | 44 -- src/system/idRules.qh | 12 - src/system/{idActor.qc => ncActor.qc} | 4 +- src/system/ncActor.qh | 5 + src/system/ncCamera.qc | 220 +++++++ src/system/ncCamera.qh | 40 ++ src/system/ncEngine.qc | 139 +++++ src/system/ncEngine.qh | 41 ++ src/system/ncEntity.qc | 748 ++++++++++++++++++++++++ src/system/{idEntity.qh => ncEntity.qh} | 101 +++- src/system/ncFX.qc | 193 ++++++ src/system/{idFX.qh => ncFX.qh} | 17 +- src/system/ncHud.qc | 308 ++++++++++ src/system/ncHud.qh | 103 ++++ src/system/ncItem.qc | 122 ++++ src/system/ncItem.qh | 30 + src/system/ncMath.qc | 173 ++++++ src/system/ncMath.qh | 34 ++ src/system/{idMover.qc => ncMover.qc} | 75 ++- src/system/{idMover.qh => ncMover.qh} | 16 +- src/system/ncNet.qc | 37 ++ src/system/ncNet.qh | 17 + src/system/ncPlayer.qc | 402 +++++++++++++ src/system/ncPlayer.qh | 33 ++ src/system/ncRules.qc | 57 ++ src/system/ncRules.qh | 18 + src/system/sources.src | 20 +- 89 files changed, 4396 insertions(+), 1605 deletions(-) create mode 100644 h2/src/entities/test_effects.qc create mode 100644 h2/src/init.qc create mode 100644 h2/src/items/blastradius.qc create mode 100644 h2/src/items/cubeofforce.qc create mode 100644 h2/src/items/flight.qc create mode 100644 h2/src/items/glphy.qc create mode 100644 h2/src/items/haste.qc create mode 100644 h2/src/items/healthboost.qc create mode 100644 h2/src/items/invincibility.qc create mode 100644 h2/src/items/invisibility.qc create mode 100644 h2/src/items/manaboost.qc create mode 100644 h2/src/items/polymorph.qc create mode 100644 h2/src/items/summon.qc create mode 100644 h2/src/items/superhboost.qc create mode 100644 h2/src/items/teleport.qc create mode 100644 h2/src/items/tomeofpower.qc create mode 100644 h2/src/items/torch.qc create mode 100644 q1/src/init.qc create mode 100644 q1/src/items/quad.qc create mode 100644 q1/src/player.qc create mode 100644 q1/src/rules.qc delete mode 100644 q1/src/weapon_supershotgun.qc create mode 100644 q1/src/weapons/axe.qc create mode 100644 q1/src/weapons/grenadelauncher.qc create mode 100644 q1/src/weapons/lightning.qc create mode 100644 q1/src/weapons/nailgun.qc create mode 100644 q1/src/weapons/rocketlauncher.qc create mode 100644 q1/src/weapons/shotgun.qc create mode 100644 q1/src/weapons/supernailgun.qc create mode 100644 q1/src/weapons/supershotgun.qc create mode 100644 src/entities/camera_node.qc create mode 100644 src/entities/func_door.qc create mode 100644 src/entities/trigger_auto.qc delete mode 100644 src/system/idActor.qh delete mode 100644 src/system/idEngine.qc delete mode 100644 src/system/idEngine.qh delete mode 100644 src/system/idEntity.qc delete mode 100644 src/system/idFX.qc delete mode 100644 src/system/idItem.qc delete mode 100644 src/system/idItem.qh delete mode 100644 src/system/idPlayer.qc delete mode 100644 src/system/idPlayer.qh delete mode 100644 src/system/idRules.qc delete mode 100644 src/system/idRules.qh rename src/system/{idActor.qc => ncActor.qc} (63%) create mode 100644 src/system/ncActor.qh create mode 100644 src/system/ncCamera.qc create mode 100644 src/system/ncCamera.qh create mode 100644 src/system/ncEngine.qc create mode 100644 src/system/ncEngine.qh create mode 100644 src/system/ncEntity.qc rename src/system/{idEntity.qh => ncEntity.qh} (79%) create mode 100644 src/system/ncFX.qc rename src/system/{idFX.qh => ncFX.qh} (74%) create mode 100644 src/system/ncHud.qc create mode 100644 src/system/ncHud.qh create mode 100644 src/system/ncItem.qc create mode 100644 src/system/ncItem.qh create mode 100644 src/system/ncMath.qc create mode 100644 src/system/ncMath.qh rename src/system/{idMover.qc => ncMover.qc} (67%) rename src/system/{idMover.qh => ncMover.qh} (86%) create mode 100644 src/system/ncNet.qc create mode 100644 src/system/ncNet.qh create mode 100644 src/system/ncPlayer.qc create mode 100644 src/system/ncPlayer.qh create mode 100644 src/system/ncRules.qc create mode 100644 src/system/ncRules.qh diff --git a/h2/src/entities/obj_pots.qc b/h2/src/entities/obj_pots.qc index 1d3610d..bc4ba3a 100644 --- a/h2/src/entities/obj_pots.qc +++ b/h2/src/entities/obj_pots.qc @@ -1,4 +1,4 @@ -class H2ObjPot:idEntity { +class H2ObjPot:ncEntity { void H2ObjPot( void ); virtual void Spawn( void ); @@ -32,7 +32,7 @@ void obj_pot1::obj_pot1( void ) { } void obj_pot1::Precache( void ) { - gameEngine.Precache_Model( "models/pot1.mdl" ); + ncEngine::Precache_Model( "models/pot1.mdl" ); } void obj_pot1::Spawn( void ) { @@ -52,7 +52,7 @@ void obj_pot2::obj_pot2( void ) { } void obj_pot2::Precache( void ) { - gameEngine.Precache_Model( "models/pot2.mdl" ); + ncEngine::Precache_Model( "models/pot2.mdl" ); } void obj_pot2::Spawn( void ) { @@ -72,7 +72,7 @@ void obj_pot3::obj_pot3( void ) { } void obj_pot3::Precache( void ) { - gameEngine.Precache_Model( "models/pot3.mdl" ); + ncEngine::Precache_Model( "models/pot3.mdl" ); } void obj_pot3::Spawn( void ) { diff --git a/h2/src/entities/obj_tree.qc b/h2/src/entities/obj_tree.qc index b7568c7..2e0414a 100644 --- a/h2/src/entities/obj_tree.qc +++ b/h2/src/entities/obj_tree.qc @@ -1,4 +1,4 @@ -class obj_tree:idEntity { +class obj_tree:ncEntity { void obj_tree( void ); virtual void Precache( void ); @@ -13,5 +13,5 @@ void obj_tree::Spawn( void ) { } void obj_tree::Precache( void ) { - gameEngine.Precache_Model( "models/tree.mdl" ); + ncEngine::Precache_Model( "models/tree.mdl" ); } \ No newline at end of file diff --git a/h2/src/entities/obj_tree2.qc b/h2/src/entities/obj_tree2.qc index 37805c7..be38f82 100644 --- a/h2/src/entities/obj_tree2.qc +++ b/h2/src/entities/obj_tree2.qc @@ -1,4 +1,4 @@ -class obj_tree2:idEntity { +class obj_tree2:ncEntity { void obj_tree2( void ); virtual void Precache( void ); @@ -13,34 +13,5 @@ void obj_tree2::Spawn( void ) { } void obj_tree2::Precache( void ) { - gameEngine.Precache_Model( "models/tree2.mdl" ); -} - - -LINK_ENTITY_TO_CLASS(art_HealthBoost, idNull) -LINK_ENTITY_TO_CLASS(art_torch, idNull) -LINK_ENTITY_TO_CLASS(breakable_brush, idNull) -LINK_ENTITY_TO_CLASS(func_button, idNull) -LINK_ENTITY_TO_CLASS(func_door, idNull) -LINK_ENTITY_TO_CLASS(func_door_rotating, idNull) -LINK_ENTITY_TO_CLASS(func_train, idNull) -LINK_ENTITY_TO_CLASS(item_armor_amulet, idNull) -LINK_ENTITY_TO_CLASS(light_flame_large_yellow, idNull) -LINK_ENTITY_TO_CLASS(light_flame_small_yellow, idNull) -LINK_ENTITY_TO_CLASS(light_torch_castle, idNull) -LINK_ENTITY_TO_CLASS(monster_archer, idNull) -LINK_ENTITY_TO_CLASS(monster_ratnest, idNull) -LINK_ENTITY_TO_CLASS(monster_skull_wizard, idNull) -LINK_ENTITY_TO_CLASS(obj_barrel, idNull) -LINK_ENTITY_TO_CLASS(obj_corpse1, idNull) -LINK_ENTITY_TO_CLASS(obj_book_open, idNull) -LINK_ENTITY_TO_CLASS(obj_bush1, idNull) -LINK_ENTITY_TO_CLASS(obj_seaweed, idNull) -LINK_ENTITY_TO_CLASS(obj_statue_angel, idNull) -LINK_ENTITY_TO_CLASS(obj_tombstone1, idNull) -LINK_ENTITY_TO_CLASS(obj_tombstone2, idNull) -LINK_ENTITY_TO_CLASS(path_corner, idNull) -LINK_ENTITY_TO_CLASS(plaque, idNull) -LINK_ENTITY_TO_CLASS(player_sheep, idNull) -LINK_ENTITY_TO_CLASS(puzzle_piece, idNull) -LINK_ENTITY_TO_CLASS(trigger_once, idNull) \ No newline at end of file + ncEngine::Precache_Model( "models/tree2.mdl" ); +} \ No newline at end of file diff --git a/h2/src/entities/test_effects.qc b/h2/src/entities/test_effects.qc new file mode 100644 index 0000000..eebac72 --- /dev/null +++ b/h2/src/entities/test_effects.qc @@ -0,0 +1,70 @@ +.float targeteffect; + +class H2TestFX:ncEntity { + void H2TestFX( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + nonvirtual void UpdateEffect( void ); + virtual void Touch( ncEntity ); +}; + +void H2TestFX::H2TestFX( void ) { +} + +void H2TestFX::Spawn( void ) { + SetModel( "models/golem_s.mdl" ); + ScheduleThink(UpdateEffect, 1.0f); + SetSolid( SOLID_TRIGGER ); + SetSize( [-16, -16, -16], [16, 16, 16] ); + //touch = Touch; +} + +void H2TestFX::Precache( void ) { + ncEngine::Precache_Model( "models/golem_s.mdl" ); +} + +void H2TestFX::UpdateEffect( void ) { + effects = targeteffect; + SetNextThink(4.0f); +} + +void H2TestFX::Touch( ncEntity touchingEnt ) { + string printTest = ""; + + switch ( targeteffect ) { + case EF_BRIGHTFIELD: + printTest = "EF_BRIGHTFIELD"; + break; + case EF_MUZZLEFLASH: + printTest = "EF_MUZZLEFLASH"; + break; + case EF_BRIGHTLIGHT: + printTest = "EF_BRIGHTLIGHT"; + break; + case EF_TORCHLIGHT: + printTest = "EF_TORCHLIGHT"; + break; + case EF_DIMLIGHT: + printTest = "EF_DIMLIGHT"; + break; + case EF_DARKLIGHT: + printTest = "EF_DARKLIGHT"; + break; + case EF_DARKFIELD: + printTest = "EF_DARKFIELD"; + break; + case EF_LIGHT: + printTest = "EF_LIGHT"; + break; + case EF_NODRAW: + printTest = "EF_NODRAW"; + break; + } + + touchingEnt.CenterPrint( printTest ); +} + + +LINK_ENTITY_TO_CLASS(test_effects, H2TestFX) +LINK_ENTITY_TO_CLASS(test_effect, H2TestFX) \ No newline at end of file diff --git a/h2/src/init.qc b/h2/src/init.qc new file mode 100644 index 0000000..490c6ce --- /dev/null +++ b/h2/src/init.qc @@ -0,0 +1,18 @@ +void Precaches(void) +{ + INIT_ITEM(H2Torch) + INIT_ITEM(H2HealthBoost) + INIT_ITEM(H2SuperHBoost) + INIT_ITEM(H2ManaBoost) + INIT_ITEM(H2Teleport) + INIT_ITEM(H2TomeOfPower) + INIT_ITEM(H2Summon) + INIT_ITEM(H2Invisibility) + INIT_ITEM(H2Glyph) + INIT_ITEM(H2Haste) + INIT_ITEM(H2BlastRadius) + INIT_ITEM(H2Polymorph) + INIT_ITEM(H2Flight) + INIT_ITEM(H2CubeOfForce) + INIT_ITEM(H2Invincibility) +} \ No newline at end of file diff --git a/h2/src/items/blastradius.qc b/h2/src/items/blastradius.qc new file mode 100644 index 0000000..40ece9e --- /dev/null +++ b/h2/src/items/blastradius.qc @@ -0,0 +1,29 @@ +class H2BlastRadius:ncItem { + void H2BlastRadius(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2BlastRadius::H2BlastRadius( void ) { +} + +void H2BlastRadius::Precache( void ) { + ncEngine::Precache_Model( "models/a_blast.mdl" ); + SetInventoryID( 10 ); +} + +void H2BlastRadius::Spawn( void ) { + SetModel( "models/a_blast.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2BlastRadius::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used blast radius!\n"); +} + +LINK_ENTITY_TO_CLASS(art_blastradius, H2BlastRadius) + diff --git a/h2/src/items/cubeofforce.qc b/h2/src/items/cubeofforce.qc new file mode 100644 index 0000000..a604931 --- /dev/null +++ b/h2/src/items/cubeofforce.qc @@ -0,0 +1,29 @@ +class H2CubeOfForce:ncItem { + void H2CubeOfForce(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2CubeOfForce::H2CubeOfForce( void ) { +} + +void H2CubeOfForce::Precache( void ) { + ncEngine::Precache_Model( "models/a_cube.mdl" ); + SetInventoryID( 13 ); +} + +void H2CubeOfForce::Spawn( void ) { + SetModel( "models/a_cube.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2CubeOfForce::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used the cube of force!\n"); +} + +LINK_ENTITY_TO_CLASS(art_cubeofforce, H2CubeOfForce) + diff --git a/h2/src/items/flight.qc b/h2/src/items/flight.qc new file mode 100644 index 0000000..fa895c3 --- /dev/null +++ b/h2/src/items/flight.qc @@ -0,0 +1,29 @@ +class H2Flight:ncItem { + void H2Flight(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Flight::H2Flight( void ) { +} + +void H2Flight::Precache( void ) { + ncEngine::Precache_Model( "models/ringft.mdl" ); + SetInventoryID( 12 ); +} + +void H2Flight::Spawn( void ) { + SetModel( "models/ringft.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Flight::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used ring of flight!\n"); +} + +LINK_ENTITY_TO_CLASS(art_flight, H2Flight) + diff --git a/h2/src/items/glphy.qc b/h2/src/items/glphy.qc new file mode 100644 index 0000000..24f3ff9 --- /dev/null +++ b/h2/src/items/glphy.qc @@ -0,0 +1,29 @@ +class H2Glyph:ncItem { + void H2Glyph(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Glyph::H2Glyph( void ) { +} + +void H2Glyph::Precache( void ) { + ncEngine::Precache_Model( "models/a_glyph.mdl" ); + SetInventoryID( 8 ); +} + +void H2Glyph::Spawn( void ) { + SetModel( "models/a_glyph.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Glyph::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used a glyph!\n"); +} + +LINK_ENTITY_TO_CLASS(art_glyph, H2Glyph) + diff --git a/h2/src/items/haste.qc b/h2/src/items/haste.qc new file mode 100644 index 0000000..d1014cb --- /dev/null +++ b/h2/src/items/haste.qc @@ -0,0 +1,29 @@ +class H2Haste:ncItem { + void H2Haste(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Haste::H2Haste( void ) { +} + +void H2Haste::Precache( void ) { + ncEngine::Precache_Model( "models/a_haste.mdl" ); + SetInventoryID( 9 ); +} + +void H2Haste::Spawn( void ) { + SetModel( "models/a_haste.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Haste::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used haste!\n"); +} + +LINK_ENTITY_TO_CLASS(art_haste, H2Haste) + diff --git a/h2/src/items/healthboost.qc b/h2/src/items/healthboost.qc new file mode 100644 index 0000000..ffb2076 --- /dev/null +++ b/h2/src/items/healthboost.qc @@ -0,0 +1,29 @@ +class H2HealthBoost:ncItem { + void H2HealthBoost(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2HealthBoost::H2HealthBoost( void ) { +} + +void H2HealthBoost::Precache( void ) { + ncEngine::Precache_Model( "models/a_invinc.mdl" ); + SetInventoryID( 1 ); +} + +void H2HealthBoost::Spawn( void ) { + SetModel( "models/a_invinc.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2HealthBoost::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used invincibility!\n"); +} + +LINK_ENTITY_TO_CLASS(art_HealthBoost, H2HealthBoost) + diff --git a/h2/src/items/invincibility.qc b/h2/src/items/invincibility.qc new file mode 100644 index 0000000..05cd3c2 --- /dev/null +++ b/h2/src/items/invincibility.qc @@ -0,0 +1,29 @@ +class H2Invincibility:ncItem { + void H2Invincibility(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Invincibility::H2Invincibility( void ) { +} + +void H2Invincibility::Precache( void ) { + ncEngine::Precache_Model( "models/a_invinc.mdl" ); + SetInventoryID( 14 ); +} + +void H2Invincibility::Spawn( void ) { + SetModel( "models/a_invinc.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Invincibility::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used invisibility!\n"); +} + +LINK_ENTITY_TO_CLASS(art_invincibility, H2Invincibility) + diff --git a/h2/src/items/invisibility.qc b/h2/src/items/invisibility.qc new file mode 100644 index 0000000..c2fb3d1 --- /dev/null +++ b/h2/src/items/invisibility.qc @@ -0,0 +1,29 @@ +class H2Invisibility:ncItem { + void H2Invisibility(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Invisibility::H2Invisibility( void ) { +} + +void H2Invisibility::Precache( void ) { + ncEngine::Precache_Model( "models/a_invis.mdl" ); + SetInventoryID( 7 ); +} + +void H2Invisibility::Spawn( void ) { + SetModel( "models/a_invis.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Invisibility::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used invisibility!\n"); +} + +LINK_ENTITY_TO_CLASS(art_invisibility, H2Invisibility) + diff --git a/h2/src/items/manaboost.qc b/h2/src/items/manaboost.qc new file mode 100644 index 0000000..318de35 --- /dev/null +++ b/h2/src/items/manaboost.qc @@ -0,0 +1,29 @@ +class H2ManaBoost:ncItem { + void H2ManaBoost(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2ManaBoost::H2ManaBoost( void ) { +} + +void H2ManaBoost::Precache( void ) { + ncEngine::Precache_Model( "models/a_mboost.mdl" ); + SetInventoryID( 3 ); +} + +void H2ManaBoost::Spawn( void ) { + SetModel( "models/a_mboost.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2ManaBoost::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used a mana boost!\n"); +} + +LINK_ENTITY_TO_CLASS(art_manaboost, H2ManaBoost) + diff --git a/h2/src/items/polymorph.qc b/h2/src/items/polymorph.qc new file mode 100644 index 0000000..3ad9ac3 --- /dev/null +++ b/h2/src/items/polymorph.qc @@ -0,0 +1,29 @@ +class H2Polymorph:ncItem { + void H2Polymorph(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Polymorph::H2Polymorph( void ) { +} + +void H2Polymorph::Precache( void ) { + ncEngine::Precache_Model( "models/a_poly.mdl" ); + SetInventoryID( 11 ); +} + +void H2Polymorph::Spawn( void ) { + SetModel( "models/a_poly.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Polymorph::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " polymorphed!\n"); +} + +LINK_ENTITY_TO_CLASS(art_polymorph, H2Polymorph) + diff --git a/h2/src/items/summon.qc b/h2/src/items/summon.qc new file mode 100644 index 0000000..5f12c63 --- /dev/null +++ b/h2/src/items/summon.qc @@ -0,0 +1,29 @@ +class H2Summon:ncItem { + void H2Summon(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Summon::H2Summon( void ) { +} + +void H2Summon::Precache( void ) { + ncEngine::Precache_Model( "models/a_summon.mdl" ); + SetInventoryID( 6 ); +} + +void H2Summon::Spawn( void ) { + SetModel( "models/a_summon.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Summon::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " summoned!\n"); +} + +LINK_ENTITY_TO_CLASS(art_summon, H2Summon) + diff --git a/h2/src/items/superhboost.qc b/h2/src/items/superhboost.qc new file mode 100644 index 0000000..55d2cfa --- /dev/null +++ b/h2/src/items/superhboost.qc @@ -0,0 +1,29 @@ +class H2SuperHBoost:ncItem { + void H2SuperHBoost(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2SuperHBoost::H2SuperHBoost( void ) { +} + +void H2SuperHBoost::Precache( void ) { + ncEngine::Precache_Model( "models/a_shbost.mdl" ); + SetInventoryID( 2 ); +} + +void H2SuperHBoost::Spawn( void ) { + SetModel( "models/a_shbost.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2SuperHBoost::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used super health boost!\n"); +} + +LINK_ENTITY_TO_CLASS(art_SuperHBoost, H2SuperHBoost) + diff --git a/h2/src/items/teleport.qc b/h2/src/items/teleport.qc new file mode 100644 index 0000000..9dea3b0 --- /dev/null +++ b/h2/src/items/teleport.qc @@ -0,0 +1,29 @@ +class H2Teleport:ncItem { + void H2Teleport(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Teleport::H2Teleport( void ) { +} + +void H2Teleport::Precache( void ) { + ncEngine::Precache_Model( "models/a_telprt.mdl" ); + SetInventoryID( 4 ); +} + +void H2Teleport::Spawn( void ) { + SetModel( "models/a_telprt.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Teleport::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used a teleport!\n"); +} + +LINK_ENTITY_TO_CLASS(art_teleport, H2Teleport) + diff --git a/h2/src/items/tomeofpower.qc b/h2/src/items/tomeofpower.qc new file mode 100644 index 0000000..36a4f06 --- /dev/null +++ b/h2/src/items/tomeofpower.qc @@ -0,0 +1,29 @@ +class H2TomeOfPower:ncItem { + void H2TomeOfPower(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2TomeOfPower::H2TomeOfPower( void ) { +} + +void H2TomeOfPower::Precache( void ) { + ncEngine::Precache_Model( "models/a_tome.mdl" ); + SetInventoryID( 5 ); +} + +void H2TomeOfPower::Spawn( void ) { + SetModel( "models/a_tome.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2TomeOfPower::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " used Tome of Power!\n"); +} + +LINK_ENTITY_TO_CLASS(art_tomeofpower, H2TomeOfPower) + diff --git a/h2/src/items/torch.qc b/h2/src/items/torch.qc new file mode 100644 index 0000000..53ad809 --- /dev/null +++ b/h2/src/items/torch.qc @@ -0,0 +1,29 @@ +class H2Torch:ncItem { + void H2Torch(void); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnInventoryUse( ncEntity ); +}; + +void H2Torch::H2Torch( void ) { +} + +void H2Torch::Precache( void ) { + ncEngine::Precache_Model( "models/a_torch.mdl" ); + SetInventoryID( 0 ); +} + +void H2Torch::Spawn( void ) { + SetModel( "models/a_torch.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void H2Torch::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " lit a torch!\n"); +} + +LINK_ENTITY_TO_CLASS(art_torch, H2Torch) + diff --git a/h2/src/progs.src b/h2/src/progs.src index ffe8898..4bd5668 100644 --- a/h2/src/progs.src +++ b/h2/src/progs.src @@ -4,7 +4,24 @@ #includelist ../../src/include.src -entities/obj_tree.qc entities/obj_tree2.qc -entities/obj_pots.qc +entities/test_effects.qc + +items/blastradius.qc +items/cubeofforce.qc +items/flight.qc +items/glphy.qc +items/haste.qc +items/healthboost.qc +items/invincibility.qc +items/invisibility.qc +items/manaboost.qc +items/polymorph.qc +items/summon.qc +items/superhboost.qc +items/teleport.qc +items/tomeofpower.qc +items/torch.qc + +init.qc #endlist \ No newline at end of file diff --git a/q1/src/init.qc b/q1/src/init.qc new file mode 100644 index 0000000..862be45 --- /dev/null +++ b/q1/src/init.qc @@ -0,0 +1,20 @@ +void Class_Player(void) { + spawnfunc_Q1Player(); +} + +void Class_Rules(void) { + spawnfunc_Q1Rules(); +} + +void Precaches(void) +{ + INIT_ITEM( Q1Axe ) + INIT_ITEM( Q1Shotgun ) + INIT_ITEM( Q1SuperShotgun ) + INIT_ITEM( Q1Nailgun ) + INIT_ITEM( Q1SuperNailgun ) + INIT_ITEM( Q1GrenadeLauncher ) + INIT_ITEM( Q1RocketLauncher ) + INIT_ITEM( Q1Lightning ) + INIT_ITEM( Q1Quad ) +} \ No newline at end of file diff --git a/q1/src/items/quad.qc b/q1/src/items/quad.qc new file mode 100644 index 0000000..f2009de --- /dev/null +++ b/q1/src/items/quad.qc @@ -0,0 +1,30 @@ +class Q1Quad:ncItem { + + void Q1Quad( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void OnPickup( ncEntity ); +}; + +void Q1Quad::Q1Quad( void ) { + +} + +void Q1Quad::Precache( void ) { + ncEngine::Precache_Model( "progs/quad.mdl" ); + SetInventoryID( 0 ); +} + +void Q1Quad::Spawn( void ) { + //SetModel( "progs/g_axe.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1Quad::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up the quad!\n"); +} + +LINK_ENTITY_TO_CLASS(item_quaddamage, Q1Quad) \ No newline at end of file diff --git a/q1/src/player.qc b/q1/src/player.qc new file mode 100644 index 0000000..45b14ca --- /dev/null +++ b/q1/src/player.qc @@ -0,0 +1,51 @@ +class Q1Player:ncPlayer { + void Q1Player(void); + + virtual bool ImpulseCommand(float); +}; + +void Q1Player::Q1Player(void) { +} + +bool Q1Player::ImpulseCommand(float impulseValue) { + switch (impulseValue) { + case 1: + SwitchToItem(WEAPON_AXE); + break; + case 2: + SwitchToItem(WEAPON_SHOTGUN); + break; + case 3: + SwitchToItem(WEAPON_SUPER_SHOTGUN); + break; + case 4: + SwitchToItem(WEAPON_NAILGUN); + break; + case 5: + SwitchToItem(WEAPON_SUPER_NAILGUN); + break; + case 6: + SwitchToItem(WEAPON_GRENADE_LAUNCHER); + break; + case 7: + SwitchToItem(WEAPON_ROCKET_LAUNCHER); + break; + case 8: + SwitchToItem(WEAPON_LIGHTNING); + break; + case 9: + AddItem(WEAPON_AXE); + AddItem(WEAPON_SHOTGUN); + AddItem(WEAPON_SUPER_SHOTGUN); + AddItem(WEAPON_NAILGUN); + AddItem(WEAPON_SUPER_NAILGUN); + AddItem(WEAPON_GRENADE_LAUNCHER); + AddItem(WEAPON_ROCKET_LAUNCHER); + AddItem(WEAPON_LIGHTNING); + break; + default: + return super::ImpulseCommand(impulseValue); + } + + return true; +} \ No newline at end of file diff --git a/q1/src/progs.src b/q1/src/progs.src index ea72efe..2c1e35e 100644 --- a/q1/src/progs.src +++ b/q1/src/progs.src @@ -3,5 +3,19 @@ #includelist ../../src/include.src defs.qh -weapon_supershotgun.qc + +weapons/axe.qc +weapons/grenadelauncher.qc +weapons/lightning.qc +weapons/nailgun.qc +weapons/rocketlauncher.qc +weapons/shotgun.qc +weapons/supernailgun.qc +weapons/supershotgun.qc + +items/quad.qc + +rules.qc +player.qc +init.qc #endlist diff --git a/q1/src/rules.qc b/q1/src/rules.qc new file mode 100644 index 0000000..8c3645f --- /dev/null +++ b/q1/src/rules.qc @@ -0,0 +1,19 @@ +class Q1Rules:ncRules { + void Q1Rules(void); + + virtual void PlayerFinishesJoining( ncPlayer ); +}; + +void Q1Rules::Q1Rules(void) { + +} + +void Q1Rules::PlayerFinishesJoining( ncPlayer ourPlayer ) { + ourPlayer.hud.SetHealth(100); + + /* place them somewhere into the world */ + super::PlayerFinishesJoining( ourPlayer ); + + ourPlayer.AddItem( WEAPON_AXE ); + ourPlayer.AddItem( WEAPON_SHOTGUN ); +} \ No newline at end of file diff --git a/q1/src/weapon_supershotgun.qc b/q1/src/weapon_supershotgun.qc deleted file mode 100644 index 7ae2944..0000000 --- a/q1/src/weapon_supershotgun.qc +++ /dev/null @@ -1,29 +0,0 @@ -class Q1SuperShotgun:idItem { - - void Q1SuperShotgun( void ); - - virtual void Precache( void ); - virtual void Spawn( void ); - - virtual void PrimaryAttack( void ); -}; - -void Q1SuperShotgun::Q1SuperShotgun( void ) { - -} - -void Q1SuperShotgun::Precache( void ) { - gameEngine.Precache_Model( "progs/g_shot.mdl" ); -} - -void Q1SuperShotgun::Spawn( void ) { - SetModel( "progs/g_shot.mdl" ); - SetSolid( SOLID_TRIGGER ); - SetID( WEAPON_SUPER_SHOTGUN ); -} - -void Q1SuperShotgun::PrimaryAttack( void ) { - -} - -LINK_ENTITY_TO_CLASS(weapon_supershotgun, Q1SuperShotgun) \ No newline at end of file diff --git a/q1/src/weapons/axe.qc b/q1/src/weapons/axe.qc new file mode 100644 index 0000000..71361b2 --- /dev/null +++ b/q1/src/weapons/axe.qc @@ -0,0 +1,43 @@ +class Q1Axe:ncItem { + + void Q1Axe( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1Axe::Q1Axe( void ) { + +} + +void Q1Axe::Precache( void ) { + ncEngine::Precache_Model( "progs/v_axe.mdl" ); + SetWeaponID( WEAPON_AXE ); +} + +void Q1Axe::Spawn( void ) { + //SetModel( "progs/g_axe.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1Axe::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_axe.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1Axe::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Woosh\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1Axe::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up the axe!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_axe, Q1Axe) \ No newline at end of file diff --git a/q1/src/weapons/grenadelauncher.qc b/q1/src/weapons/grenadelauncher.qc new file mode 100644 index 0000000..2986bac --- /dev/null +++ b/q1/src/weapons/grenadelauncher.qc @@ -0,0 +1,44 @@ +class Q1GrenadeLauncher:ncItem { + + void Q1GrenadeLauncher( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1GrenadeLauncher::Q1GrenadeLauncher( void ) { + +} + +void Q1GrenadeLauncher::Precache( void ) { + ncEngine::Precache_Model( "progs/g_rock.mdl" ); + ncEngine::Precache_Model( "progs/v_rock.mdl" ); + SetWeaponID( WEAPON_ROCKET_LAUNCHER ); +} + +void Q1GrenadeLauncher::Spawn( void ) { + SetModel( "progs/g_rock.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1GrenadeLauncher::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_rock.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1GrenadeLauncher::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1GrenadeLauncher::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a grenade launcher!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_grenadelauncher, Q1GrenadeLauncher) \ No newline at end of file diff --git a/q1/src/weapons/lightning.qc b/q1/src/weapons/lightning.qc new file mode 100644 index 0000000..5bd06d0 --- /dev/null +++ b/q1/src/weapons/lightning.qc @@ -0,0 +1,44 @@ +class Q1Lightning:ncItem { + + void Q1Lightning( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1Lightning::Q1Lightning( void ) { + +} + +void Q1Lightning::Precache( void ) { + ncEngine::Precache_Model( "progs/g_light.mdl" ); + ncEngine::Precache_Model( "progs/v_light.mdl" ); + SetWeaponID( WEAPON_LIGHTNING ); +} + +void Q1Lightning::Spawn( void ) { + SetModel( "progs/g_light.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1Lightning::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_light.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1Lightning::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1Lightning::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a lightning gun!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_lightning, Q1Lightning) \ No newline at end of file diff --git a/q1/src/weapons/nailgun.qc b/q1/src/weapons/nailgun.qc new file mode 100644 index 0000000..6811633 --- /dev/null +++ b/q1/src/weapons/nailgun.qc @@ -0,0 +1,44 @@ +class Q1Nailgun:ncItem { + + void Q1Nailgun( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1Nailgun::Q1Nailgun( void ) { + +} + +void Q1Nailgun::Precache( void ) { + ncEngine::Precache_Model( "progs/g_nail.mdl" ); + ncEngine::Precache_Model( "progs/v_nail.mdl" ); + SetWeaponID( WEAPON_NAILGUN ); +} + +void Q1Nailgun::Spawn( void ) { + SetModel( "progs/g_nail.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1Nailgun::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_nail.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1Nailgun::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1Nailgun::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a nailgun!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_nailgun, Q1Nailgun) \ No newline at end of file diff --git a/q1/src/weapons/rocketlauncher.qc b/q1/src/weapons/rocketlauncher.qc new file mode 100644 index 0000000..5d35665 --- /dev/null +++ b/q1/src/weapons/rocketlauncher.qc @@ -0,0 +1,44 @@ +class Q1RocketLauncher:ncItem { + + void Q1RocketLauncher( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1RocketLauncher::Q1RocketLauncher( void ) { + +} + +void Q1RocketLauncher::Precache( void ) { + ncEngine::Precache_Model( "progs/g_rock2.mdl" ); + ncEngine::Precache_Model( "progs/v_rock2.mdl" ); + SetWeaponID( WEAPON_ROCKET_LAUNCHER ); +} + +void Q1RocketLauncher::Spawn( void ) { + SetModel( "progs/g_rock2.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1RocketLauncher::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_rock2.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1RocketLauncher::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1RocketLauncher::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a rocket launcher!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_rocketlauncher, Q1RocketLauncher) \ No newline at end of file diff --git a/q1/src/weapons/shotgun.qc b/q1/src/weapons/shotgun.qc new file mode 100644 index 0000000..160c9ec --- /dev/null +++ b/q1/src/weapons/shotgun.qc @@ -0,0 +1,42 @@ +class Q1Shotgun:ncItem { + + void Q1Shotgun( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1Shotgun::Q1Shotgun( void ) { + +} + +void Q1Shotgun::Precache( void ) { + ncEngine::Precache_Model( "progs/v_shot.mdl" ); + SetWeaponID( WEAPON_SHOTGUN ); +} + +void Q1Shotgun::Spawn( void ) { + SetSolid( SOLID_TRIGGER ); +} + +void Q1Shotgun::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_shot.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1Shotgun::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1Shotgun::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a shotgun!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_shotgun, Q1Shotgun) \ No newline at end of file diff --git a/q1/src/weapons/supernailgun.qc b/q1/src/weapons/supernailgun.qc new file mode 100644 index 0000000..8b4e441 --- /dev/null +++ b/q1/src/weapons/supernailgun.qc @@ -0,0 +1,44 @@ +class Q1SuperNailgun:ncItem { + + void Q1SuperNailgun( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1SuperNailgun::Q1SuperNailgun( void ) { + +} + +void Q1SuperNailgun::Precache( void ) { + ncEngine::Precache_Model( "progs/g_nail2.mdl" ); + ncEngine::Precache_Model( "progs/v_nail2.mdl" ); + SetWeaponID( WEAPON_SUPER_NAILGUN ); +} + +void Q1SuperNailgun::Spawn( void ) { + SetModel( "progs/g_nail2.mdl" ); + SetSolid( SOLID_TRIGGER ); +} + +void Q1SuperNailgun::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel("progs/v_nail2.mdl"); + carrier.hud.SetWeaponFrame(0); + carrier.hud.SetAmmo(AMMO_CURRENT, 20); +} + +void Q1SuperNailgun::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, "Pew\n"); + carrier.SetNextPrimaryAttack(0.5f); +} + +void Q1SuperNailgun::OnPickup( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " picked up a super nailgun!\n"); +} + +LINK_ENTITY_TO_CLASS(weapon_supernailgun, Q1SuperNailgun) \ No newline at end of file diff --git a/q1/src/weapons/supershotgun.qc b/q1/src/weapons/supershotgun.qc new file mode 100644 index 0000000..01dce12 --- /dev/null +++ b/q1/src/weapons/supershotgun.qc @@ -0,0 +1,45 @@ +class Q1SuperShotgun:ncItem { + + void Q1SuperShotgun( void ); + + virtual void Precache( void ); + virtual void Spawn( void ); + + virtual void Draw( ncEntity ); + virtual void PrimaryAttack( ncEntity ); + virtual void OnPickup( ncEntity ); +}; + +void Q1SuperShotgun::Q1SuperShotgun( void ) { + +} + +void Q1SuperShotgun::Precache( void ) { + ncEngine::Precache_Model( "progs/g_shot.mdl" ); + ncEngine::Precache_Model( "progs/v_shot2.mdl" ); + SetWeaponID( WEAPON_SUPER_SHOTGUN ); +} + +void Q1SuperShotgun::Spawn( void ) { + SetModel( "progs/g_shot.mdl" ); + SetSolid( SOLID_TRIGGER ); + SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); +} + +void Q1SuperShotgun::Draw( ncEntity carrier ) { + carrier.hud.SetWeaponModel( "progs/v_shot2.mdl" ); + carrier.hud.SetWeaponFrame( 0 ); + carrier.hud.SetAmmo( AMMO_CURRENT, 20 ); +} + +void Q1SuperShotgun::PrimaryAttack( ncEntity carrier ) { + carrier.SPrint( PRINT_LOW, "Pew\n" ); + carrier.SetNextPrimaryAttack( 0.5f ); +} + +void Q1SuperShotgun::OnPickup( ncEntity carrier ) { + carrier.SPrint( PRINT_LOW, carrier.netname ); + carrier.SPrint( PRINT_LOW, " picked up a super shotgun!\n" ); +} + +LINK_ENTITY_TO_CLASS( weapon_supershotgun, Q1SuperShotgun ) \ No newline at end of file diff --git a/src/builtins.qh b/src/builtins.qh index 0d64632..bbf338e 100644 --- a/src/builtins.qh +++ b/src/builtins.qh @@ -52,7 +52,7 @@ float tracearea(vector v1, vector v2, vector mins, vector maxs, float nomonsters /* #33 was removed */ #endif -float droptofloor(float yaw, float dist) = #34; +float droptofloor(void) = #34; void lightstyle(float style, string value) = #35; float rint(float v) = #36; float floor(float v) = #37; diff --git a/src/defs.qh b/src/defs.qh index 9f0327c..e2e7f51 100644 --- a/src/defs.qh +++ b/src/defs.qh @@ -176,7 +176,7 @@ float wp_deselect; #endif /* edict_t fields */ -/* they are much better documented in idEntity */ +/* they are much better documented in ncEntity */ .float modelindex; .vector absmin; .vector absmax; diff --git a/src/entities/camera_node.qc b/src/entities/camera_node.qc new file mode 100644 index 0000000..27ce4bf --- /dev/null +++ b/src/entities/camera_node.qc @@ -0,0 +1 @@ +LINK_ENTITY_TO_CLASS(camera_node, ncCamera) \ No newline at end of file diff --git a/src/entities/func_croucharea.qc b/src/entities/func_croucharea.qc index bfc802e..bd6116a 100644 --- a/src/entities/func_croucharea.qc +++ b/src/entities/func_croucharea.qc @@ -1,4 +1,4 @@ -class idFuncCroucharea:idEntity { +class idFuncCroucharea:ncEntity { void idFuncCroucharea( void ); }; diff --git a/src/entities/func_door.qc b/src/entities/func_door.qc new file mode 100644 index 0000000..35a19fd --- /dev/null +++ b/src/entities/func_door.qc @@ -0,0 +1,129 @@ + +enumflags { + FNC_DOOR_STARTOPEN, + FNC_DOOR_UNUSED1, /* Hexen II */ + FNC_DOOR_DONTLINK, + FNC_DOOR_UNUSED2, + FNC_DOOR_UNUSED3, + FNC_DOOR_TOGGLE +}; + +.entity door_partner; + +class ncFuncDoor:ncMover { + void ncFuncDoor( void ); + + virtual void Spawn( void ); + virtual void MoverFinishesMoving( void ); + + nonvirtual void DoorTrigger( ncEntity, triggerstate_t ); + nonvirtual void DoorBlocked( ncEntity ); + nonvirtual void DoorTouch( ncEntity ); + nonvirtual void DoorLink( void ); +}; + +void ncFuncDoor::ncFuncDoor( void ) { + ncEntity doorFind = ( ncEntity ) world; + + if ( door_partner ) { + return; + } + + if ( HasSpawnFlags( FNC_DOOR_DONTLINK ) ) { + owner = door_partner = this; + return; + } + + + while ( ( doorFind = ncEngine::NextEnt( doorFind ) ) ) { + if ( doorFind.classname != classname ) { + continue; + } + + if ( doorFind.WithinBounds( this ) ) { + ncEngine::BPrint( PRINT_HIGH, "Found door partner.\n" ); + } + } +} + +void ncFuncDoor::Spawn( void ) { + SetMovetype( MOVETYPE_PUSH ); + SetSolid( SOLID_BSP ); + SetModel( GetModel() ); /* relink with the above properties */ + ReleaseThink(); + + if ( HasSpawnFlags( FNC_DOOR_STARTOPEN ) ) { + SetMoverPosition1( GetDirectionalPosition( GetAngles(), GetLip() ) ); + SetMoverPosition2( GetOrigin() ); + SetOrigin( GetMoverPosition2() ); + } else { + SetMoverPosition1( GetOrigin() ); + SetMoverPosition2( GetDirectionalPosition( GetAngles(), GetLip() ) ); + } + + ClearAngles(); + + SetTriggerCallback( DoorTrigger ); + SetBlockedCallback( DoorBlocked ); + + if ( !GetTargetname() && HasSpawnFlags( FNC_DOOR_TOGGLE ) == false ) { + SetTouchCallback( DoorTouch ); + } + + ScheduleThink( DoorLink, 0.0f ); + + SPAWNDEFAULT( speed, 100 ) + SPAWNDEFAULT( wait, 3 ) + SPAWNDEFAULT( lip, 8 ) +} + +void ncFuncDoor::DoorLink( void ) { +} + +void ncFuncDoor::DoorBlocked( ncEntity eBlocker ) { + //if ( m_iDamage ) { + // Damage_Apply( eBlocker, this, m_iDamage, 0, DMG_CRUSH ); + //} + + //if ( !m_iForceClosed ) + if ( GetWaitTime() >= 0 ) { + MoveToReverse( GetSpeed() ); + } +} + +void ncFuncDoor::DoorTrigger( ncEntity act, triggerstate_t triggerstate ) +{ + if ( trigger_next > time ) { + return; + } + trigger_next = time + GetWaitTime(); + + if ( triggerstate == TRIGGERSTATE_OFF ) { + MoveToPosition( GetMoverPosition1(), speed ); + } else if ( triggerstate == TRIGGERSTATE_ON ) { + MoveToPosition( GetMoverPosition2(), speed ); + } else { + MoveToReverse( GetSpeed() ); + } +} + +void ncFuncDoor::DoorTouch( ncEntity eToucher ) { + if ( eToucher.IsPlayer() || eToucher.IsActor() ) { + if ( eToucher.IsAboveEntity( this ) == false ) { + Trigger( eToucher, 0 ); + } + } +} + +void ncFuncDoor::MoverFinishesMoving( void ) { + static void MoveBack( void ) { + MoveToPosition( GetMoverPosition1(), GetSpeed() ); + } + + /* will only return if TOGGLE is not set. */ + if ( HasSpawnFlags( FNC_DOOR_TOGGLE ) == false ) { + ScheduleThink( MoveBack, GetWaitTime() ); + } +} + +LINK_ENTITY_TO_CLASS( func_door, ncFuncDoor ) \ No newline at end of file diff --git a/src/entities/func_illusionary.qc b/src/entities/func_illusionary.qc index e75845a..ef1e7b1 100644 --- a/src/entities/func_illusionary.qc +++ b/src/entities/func_illusionary.qc @@ -1,4 +1,4 @@ -class idFuncIllusionary:idEntity { +class idFuncIllusionary:ncEntity { void idFuncIllusionary( void ); }; @@ -7,6 +7,10 @@ void idFuncIllusionary::idFuncIllusionary( void ) { SetMovetype(MOVETYPE_PUSH); SetSolid(SOLID_NOT); SetModel(GetModel()); /* relink with the above properties */ + + SetTranslucency(true); + + SetAbsoluteLightlevel(0.1); } 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 dd303ba..a6f3405 100644 --- a/src/entities/func_wall.qc +++ b/src/entities/func_wall.qc @@ -1,4 +1,4 @@ -class idFuncWall:idEntity { +class idFuncWall:ncEntity { void idFuncWall( void ); }; diff --git a/src/entities/info_null.qc b/src/entities/info_null.qc index d88ce43..d3dba71 100644 --- a/src/entities/info_null.qc +++ b/src/entities/info_null.qc @@ -1,4 +1,4 @@ -class idNull:idEntity { +class idNull:ncEntity { void idNull( void ); }; diff --git a/src/entities/info_player_start.qc b/src/entities/info_player_start.qc index d7a14c0..281a09e 100644 --- a/src/entities/info_player_start.qc +++ b/src/entities/info_player_start.qc @@ -1,28 +1,29 @@ -class idPlayerStart:idEntity { - void idPlayerStart( void ); +class ncPlayerStart:ncEntity { + void ncPlayerStart( void ); /** Moves a player to the first starting spawn point and returns the result. */ - nonvirtual idEntity MovePlayerToStart( idPlayer ); + nonvirtual ncEntity MovePlayerToStart( ncPlayer ); }; -void idPlayerStart::idPlayerStart( void ) { +void ncPlayerStart::ncPlayerStart( void ) { SetSolid( SOLID_NOT ); SetMovetype( MOVETYPE_NONE ); } -idEntity idPlayerStart::MovePlayerToStart( idPlayer player ) { - idEntity point = gameEngine.Find( ( idEntity ) world, ::classname, "idPlayerStart" ); +ncEntity ncPlayerStart::MovePlayerToStart( ncPlayer player ) { + ncEntity point = ncEngine::Find( ( ncEntity ) world, ::classname, "ncPlayerStart" ); if ( point ) { player.Transport( point.GetOrigin(), point.GetAngles(), false ); + point.TriggerTargets(player, 0); return point; } else { - gameEngine.Error( "Cannot find idPlayerStart on level." ); + ncEngine::Error( "Cannot find ncPlayerStart on level." ); return __NULL__; } } -LINK_ENTITY_TO_CLASS(info_player_start, idPlayerStart) -LINK_ENTITY_TO_CLASS(info_player_deathmatch, idPlayerStart) -LINK_ENTITY_TO_CLASS(info_player_coop, idPlayerStart) -LINK_ENTITY_TO_CLASS(info_player_start2, idPlayerStart) \ No newline at end of file +LINK_ENTITY_TO_CLASS(info_player_start, ncPlayerStart) +LINK_ENTITY_TO_CLASS(info_player_deathmatch, ncPlayerStart) +LINK_ENTITY_TO_CLASS(info_player_coop, ncPlayerStart) +LINK_ENTITY_TO_CLASS(info_player_start2, ncPlayerStart) \ No newline at end of file diff --git a/src/entities/light.qc b/src/entities/light.qc index 1792f24..f2d57ea 100644 --- a/src/entities/light.qc +++ b/src/entities/light.qc @@ -1,4 +1,4 @@ -class idLight:idEntity { +class idLight:ncEntity { void idLight( void ); }; diff --git a/src/entities/sources.src b/src/entities/sources.src index 6e74a1a..0894e44 100644 --- a/src/entities/sources.src +++ b/src/entities/sources.src @@ -1,10 +1,13 @@ #includelist func_wall.qc +func_door.qc func_illusionary.qc info_null.qc info_player_start.qc light.qc +trigger_auto.qc trigger_changelevel.qc trigger_teleport.qc +camera_node.qc worldspawn.qc #endlist diff --git a/src/entities/trigger_auto.qc b/src/entities/trigger_auto.qc new file mode 100644 index 0000000..4392551 --- /dev/null +++ b/src/entities/trigger_auto.qc @@ -0,0 +1,19 @@ +class idTriggerAuto:ncEntity { + void idTriggerAuto( void ); + + nonvirtual void AutoTrigger( void ); +}; + +void idTriggerAuto::idTriggerAuto( void ) { + ScheduleThink(AutoTrigger, 0.0); +} + +void idTriggerAuto::AutoTrigger( void ) { + ncEntity targetEntity = FindFirstTarget(); + + if (targetEntity) { + targetEntity.Trigger( this, 0 ); + } +} + +LINK_ENTITY_TO_CLASS(trigger_auto, idTriggerAuto) \ No newline at end of file diff --git a/src/entities/trigger_changelevel.qc b/src/entities/trigger_changelevel.qc index 61c6c77..2ec5353 100644 --- a/src/entities/trigger_changelevel.qc +++ b/src/entities/trigger_changelevel.qc @@ -1,11 +1,11 @@ /* we need to register and track this entity field. */ .string map; -class idTriggerChangelevel:idEntity { +class idTriggerChangelevel:ncEntity { void idTriggerChangelevel( void ); nonvirtual string GetNextLevel( void ); - nonvirtual void ChangelevelTouched( idEntity ); + nonvirtual void ChangelevelTouched( ncEntity ); }; void idTriggerChangelevel::idTriggerChangelevel( void ) { @@ -18,9 +18,9 @@ string idTriggerChangelevel::GetNextLevel( void ) return map; } -void idTriggerChangelevel::ChangelevelTouched( idEntity toucher ) { +void idTriggerChangelevel::ChangelevelTouched( ncEntity toucher ) { if ( toucher.IsPlayer() ) { - gameEngine.ChangeLevel( GetNextLevel() ); + ncEngine::ChangeLevel( GetNextLevel() ); } } diff --git a/src/entities/trigger_teleport.qc b/src/entities/trigger_teleport.qc index b994a4b..43998d0 100644 --- a/src/entities/trigger_teleport.qc +++ b/src/entities/trigger_teleport.qc @@ -1,7 +1,7 @@ -class idTriggerTeleport:idEntity { +class idTriggerTeleport:ncEntity { void idTriggerTeleport( void ); - nonvirtual void TeleporterTouched( idEntity ); + nonvirtual void TeleporterTouched( ncEntity ); }; void idTriggerTeleport::idTriggerTeleport( void ) { @@ -9,9 +9,9 @@ void idTriggerTeleport::idTriggerTeleport( void ) { SetTouchCallback(TeleporterTouched); } -void idTriggerTeleport::TeleporterTouched( idEntity toucher ) { +void idTriggerTeleport::TeleporterTouched( ncEntity toucher ) { if ( toucher.IsPlayer() ) { - idEntity destination = FindFirstTarget(); + ncEntity destination = FindFirstTarget(); if ( destination ) { toucher.Transport( destination.GetOrigin(), destination.GetAngles(), true ); diff --git a/src/entities/worldspawn.qc b/src/entities/worldspawn.qc index 34acba7..3010c03 100644 --- a/src/entities/worldspawn.qc +++ b/src/entities/worldspawn.qc @@ -1,3 +1,8 @@ + +/* overridable */ +__weak void Precaches(void) { +} + class idWorldspawn { void idWorldspawn( void ); @@ -7,30 +12,32 @@ class idWorldspawn { void idWorldspawn::idWorldspawn( void ) { #ifdef TARGET_HEXEN2 - gameEngine.Precache_Model( "models/paladin.mdl" ); - gameEngine.Precache_Model( "models/assassin.mdl" ); - gameEngine.Precache_Model( "models/necro.mdl" ); - gameEngine.Precache_Model( "models/crusader.mdl" ); - gameEngine.Precache_Model( "models/assassin.mdl" ); + ncEngine::Precache_Model( "models/paladin.mdl" ); + ncEngine::Precache_Model( "models/assassin.mdl" ); + ncEngine::Precache_Model( "models/necro.mdl" ); + ncEngine::Precache_Model( "models/crusader.mdl" ); + ncEngine::Precache_Model( "models/assassin.mdl" ); #else - gameEngine.Precache_Model( "progs/player.mdl" ); + ncEngine::Precache_Model( "progs/player.mdl" ); #endif InitLight(); + + Precaches(); } void idWorldspawn::InitLight( void ) { - gameEngine.LightStyle( 0, "m" ); - gameEngine.LightStyle( 1, "mmnmmommommnonmmonqnmmo" ); - gameEngine.LightStyle( 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" ); - gameEngine.LightStyle( 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" ); - gameEngine.LightStyle( 4, "mamamamamama" ); - gameEngine.LightStyle( 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj" ); - gameEngine.LightStyle( 6, "nmonqnmomnmomomno" ); - gameEngine.LightStyle( 7, "mmmaaaabcdefgmmmmaaaammmaamm" ); - gameEngine.LightStyle( 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" ); - gameEngine.LightStyle( 9, "aaaaaaaazzzzzzzz" ); - gameEngine.LightStyle( 10, "mmamammmmammamamaaamammma" ); - gameEngine.LightStyle( 11, "abcdefghijklmnopqrrqponmlkjihgfedcba" ); + ncFX::LightStyle( 0, "m" ); + ncFX::LightStyle( 1, "mmnmmommommnonmmonqnmmo" ); + ncFX::LightStyle( 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" ); + ncFX::LightStyle( 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" ); + ncFX::LightStyle( 4, "mamamamamama" ); + ncFX::LightStyle( 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj" ); + ncFX::LightStyle( 6, "nmonqnmomnmomomno" ); + ncFX::LightStyle( 7, "mmmaaaabcdefgmmmmaaaammmaamm" ); + ncFX::LightStyle( 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" ); + ncFX::LightStyle( 9, "aaaaaaaazzzzzzzz" ); + ncFX::LightStyle( 10, "mmamammmmammamamaaamammma" ); + ncFX::LightStyle( 11, "abcdefghijklmnopqrrqponmlkjihgfedcba" ); } LINK_ENTITY_TO_CLASS(worldspawn, idWorldspawn) \ No newline at end of file diff --git a/src/entry.qc b/src/entry.qc index dc9254b..7596e18 100644 --- a/src/entry.qc +++ b/src/entry.qc @@ -2,73 +2,89 @@ void main( void ) { /* all the files that DOSQuake needs to boot. */ - gameEngine.Precache_File( "progs.dat"); - gameEngine.Precache_File( "gfx.wad" ); - gameEngine.Precache_File( "quake.rc" ); - gameEngine.Precache_File( "default.cfg" ); - gameEngine.Precache_File( "gfx/palette.lmp" ); - gameEngine.Precache_File( "gfx/colormap.lmp" ); - gameEngine.Precache_File( "gfx/complete.lmp" ); - gameEngine.Precache_File( "gfx/inter.lmp" ); - gameEngine.Precache_File( "gfx/ranking.lmp" ); - gameEngine.Precache_File( "gfx/vidmodes.lmp" ); - gameEngine.Precache_File( "gfx/finale.lmp" ); - gameEngine.Precache_File( "gfx/conback.lmp" ); - gameEngine.Precache_File( "gfx/qplaque.lmp" ); - gameEngine.Precache_File( "gfx/menudot1.lmp" ); - gameEngine.Precache_File( "gfx/menudot2.lmp" ); - gameEngine.Precache_File( "gfx/menudot3.lmp" ); - gameEngine.Precache_File( "gfx/menudot4.lmp" ); - gameEngine.Precache_File( "gfx/menudot5.lmp" ); - gameEngine.Precache_File( "gfx/menudot6.lmp" ); - gameEngine.Precache_File( "gfx/menuplyr.lmp" ); - gameEngine.Precache_File( "gfx/bigbox.lmp" ); - gameEngine.Precache_File( "gfx/dim_modm.lmp" ); - gameEngine.Precache_File( "gfx/dim_drct.lmp" ); - gameEngine.Precache_File( "gfx/dim_ipx.lmp" ); - gameEngine.Precache_File( "gfx/dim_tcp.lmp" ); - gameEngine.Precache_File( "gfx/dim_mult.lmp" ); - gameEngine.Precache_File( "gfx/mainmenu.lmp" ); - gameEngine.Precache_File( "gfx/box_tl.lmp" ); - gameEngine.Precache_File( "gfx/box_tm.lmp" ); - gameEngine.Precache_File( "gfx/box_tr.lmp" ); - gameEngine.Precache_File( "gfx/box_ml.lmp" ); - gameEngine.Precache_File( "gfx/box_mm.lmp" ); - gameEngine.Precache_File( "gfx/box_mm2.lmp" ); - gameEngine.Precache_File( "gfx/box_mr.lmp" ); - gameEngine.Precache_File( "gfx/box_bl.lmp" ); - gameEngine.Precache_File( "gfx/box_bm.lmp" ); - gameEngine.Precache_File( "gfx/box_br.lmp" ); - gameEngine.Precache_File( "gfx/sp_menu.lmp" ); - gameEngine.Precache_File( "gfx/ttl_sgl.lmp" ); - gameEngine.Precache_File( "gfx/ttl_main.lmp" ); - gameEngine.Precache_File( "gfx/ttl_cstm.lmp" ); - gameEngine.Precache_File( "gfx/mp_menu.lmp" ); - gameEngine.Precache_File( "gfx/netmen1.lmp" ); - gameEngine.Precache_File( "gfx/netmen2.lmp" ); - gameEngine.Precache_File( "gfx/netmen3.lmp" ); - gameEngine.Precache_File( "gfx/netmen4.lmp" ); - gameEngine.Precache_File( "gfx/netmen5.lmp" ); - gameEngine.Precache_File( "gfx/sell.lmp" ); - gameEngine.Precache_File( "gfx/help0.lmp" ); - gameEngine.Precache_File( "gfx/help1.lmp" ); - gameEngine.Precache_File( "gfx/help2.lmp" ); - gameEngine.Precache_File( "gfx/help3.lmp" ); - gameEngine.Precache_File( "gfx/help4.lmp" ); - gameEngine.Precache_File( "gfx/help5.lmp" ); - gameEngine.Precache_File( "gfx/pause.lmp" ); - gameEngine.Precache_File( "gfx/loading.lmp" ); - gameEngine.Precache_File( "gfx/p_option.lmp" ); - gameEngine.Precache_File( "gfx/p_load.lmp" ); - gameEngine.Precache_File( "gfx/p_save.lmp" ); - gameEngine.Precache_File( "gfx/p_multi.lmp" ); - gameEngine.Precache_Sound( "misc/menu1.wav" ); - gameEngine.Precache_Sound( "misc/menu2.wav" ); - gameEngine.Precache_Sound( "misc/menu3.wav" ); - gameEngine.Precache_Sound( "ambience/water1.wav" ); - gameEngine.Precache_Sound( "ambience/wind2.wav" ); - gameEngine.Precache_File( "maps/start.bsp" ); - gameEngine.Precache_File2( "gfx/pop.lmp" ); +#ifdef TARGET_HEXEN2 + ncEngine::Precache_File( "maps/demo1.bsp" ); + ncEngine::Precache_File( "raven/menu1.wav" ); + ncEngine::Precache_File( "raven/menu2.wav" ); + ncEngine::Precache_File( "raven/menu3.wav" ); + ncEngine::Precache_File( "misc/barmovup.wav" ); + ncEngine::Precache_File( "misc/barmovdn.wav" ); + ncEngine::Precache_File( "misc/invmove.wav" ); + ncEngine::Precache_File( "misc/invuse.wav" ); +#else + #ifndef TARGET_QUAKEWORLD + ncEngine::Precache_File( "progs.dat"); + #else + ncEngine::Precache_File( "qwprogs.dat"); + #endif + + ncEngine::Precache_File( "quake.rc" ); + ncEngine::Precache_File( "gfx/palette.lmp" ); + ncEngine::Precache_File( "gfx/colormap.lmp" ); + ncEngine::Precache_File( "gfx/complete.lmp" ); + ncEngine::Precache_File( "gfx/inter.lmp" ); + ncEngine::Precache_File( "gfx/ranking.lmp" ); + ncEngine::Precache_File( "gfx/vidmodes.lmp" ); + ncEngine::Precache_File( "gfx/finale.lmp" ); + ncEngine::Precache_File( "gfx/conback.lmp" ); + ncEngine::Precache_File( "gfx/qplaque.lmp" ); + ncEngine::Precache_File( "gfx/menudot1.lmp" ); + ncEngine::Precache_File( "gfx/menudot2.lmp" ); + ncEngine::Precache_File( "gfx/menudot3.lmp" ); + ncEngine::Precache_File( "gfx/menudot4.lmp" ); + ncEngine::Precache_File( "gfx/menudot5.lmp" ); + ncEngine::Precache_File( "gfx/menudot6.lmp" ); + ncEngine::Precache_File( "gfx/menuplyr.lmp" ); + ncEngine::Precache_File( "gfx/bigbox.lmp" ); + ncEngine::Precache_File( "gfx/dim_modm.lmp" ); + ncEngine::Precache_File( "gfx/dim_drct.lmp" ); + ncEngine::Precache_File( "gfx/dim_ipx.lmp" ); + ncEngine::Precache_File( "gfx/dim_tcp.lmp" ); + ncEngine::Precache_File( "gfx/dim_mult.lmp" ); + ncEngine::Precache_File( "gfx/mainmenu.lmp" ); + ncEngine::Precache_File( "gfx/box_tl.lmp" ); + ncEngine::Precache_File( "gfx/box_tm.lmp" ); + ncEngine::Precache_File( "gfx/box_tr.lmp" ); + ncEngine::Precache_File( "gfx/box_ml.lmp" ); + ncEngine::Precache_File( "gfx/box_mm.lmp" ); + ncEngine::Precache_File( "gfx/box_mm2.lmp" ); + ncEngine::Precache_File( "gfx/box_mr.lmp" ); + ncEngine::Precache_File( "gfx/box_bl.lmp" ); + ncEngine::Precache_File( "gfx/box_bm.lmp" ); + ncEngine::Precache_File( "gfx/box_br.lmp" ); + ncEngine::Precache_File( "gfx/sp_menu.lmp" ); + ncEngine::Precache_File( "gfx/ttl_sgl.lmp" ); + ncEngine::Precache_File( "gfx/ttl_main.lmp" ); + ncEngine::Precache_File( "gfx/ttl_cstm.lmp" ); + ncEngine::Precache_File( "gfx/mp_menu.lmp" ); + ncEngine::Precache_File( "gfx/netmen1.lmp" ); + ncEngine::Precache_File( "gfx/netmen2.lmp" ); + ncEngine::Precache_File( "gfx/netmen3.lmp" ); + ncEngine::Precache_File( "gfx/netmen4.lmp" ); + ncEngine::Precache_File( "gfx/netmen5.lmp" ); + ncEngine::Precache_File( "gfx/sell.lmp" ); + ncEngine::Precache_File( "gfx/help0.lmp" ); + ncEngine::Precache_File( "gfx/help1.lmp" ); + ncEngine::Precache_File( "gfx/help2.lmp" ); + ncEngine::Precache_File( "gfx/help3.lmp" ); + ncEngine::Precache_File( "gfx/help4.lmp" ); + ncEngine::Precache_File( "gfx/help5.lmp" ); + ncEngine::Precache_File( "gfx/pause.lmp" ); + ncEngine::Precache_File( "gfx/loading.lmp" ); + ncEngine::Precache_File( "gfx/p_option.lmp" ); + ncEngine::Precache_File( "gfx/p_load.lmp" ); + ncEngine::Precache_File( "gfx/p_save.lmp" ); + ncEngine::Precache_File( "gfx/p_multi.lmp" ); + ncEngine::Precache_Sound( "misc/menu1.wav" ); + ncEngine::Precache_Sound( "misc/menu2.wav" ); + ncEngine::Precache_Sound( "misc/menu3.wav" ); + ncEngine::Precache_Sound( "ambience/water1.wav" ); + ncEngine::Precache_Sound( "ambience/wind2.wav" ); + ncEngine::Precache_File( "maps/start.bsp" ); +#endif + ncEngine::Precache_File2( "gfx/pop.lmp" ); + ncEngine::Precache_File( "gfx.wad" ); + ncEngine::Precache_File( "default.cfg" ); } void StartFrame( void ) { @@ -77,67 +93,213 @@ void StartFrame( void ) { /* if our rules class doesn't yet exist - create it! */ if ( !g_gameRules ) { - g_gameRules = gameEngine.Spawn(); + g_gameRules = (ncRules)ncEngine::Spawn(); self = g_gameRules; Class_Rules(); self = world; } + + ncEntity e = ( ncEntity ) world; + + while ( ( e = ncEngine::NextEnt( e ) ) ) { + if (e.isIdEntity == true) + if (e.IsPlayer() == false) + e.PreThink(); + } } void PlayerPreThink( void ) { - idPlayer pl = ( idPlayer ) self; + ncPlayer pl = ( ncPlayer ) self; + /* FIXME: only needed because NQ executes PlayerPreThink before we're ncPlayer */ + if (self.health <= 0) + return; + +#if 0 if (pl.GetDeadFlag() >= DEAD_DYING) { pl.DeadThink(); return; } else { pl.PreThink(); } +#endif + + if (pl.button2) { + if (pl.HasFlag(FL_JUMPRELEASED) && pl.HasFlag(FL_ONGROUND)) { + pl.RemoveFlags(FL_JUMPRELEASED | FL_ONGROUND); + pl.JumpPressed(); + } + } else { + bool alreadyReleased = pl.HasFlag(FL_JUMPRELEASED) ? false : true; + pl.AddFlags(FL_JUMPRELEASED); + + if (alreadyReleased) { + pl.JumpReleased(); + } + } + + if (pl.inCamera) { + vector camPos = pl.inCamera.GetCameraOrigin(); + vector camAngle = pl.inCamera.GetCameraAngles(); + float camFOV = pl.inCamera.GetCameraFOV(); + camAngle[0] *= -1; + // camAngle[2] = ncMath::Sin(time) * 45.0f; + float progress = pl.inCamera.GetCameraTime() / pl.inCamera.GetCameraLength(); + +#if CAM_DEBUG + pl.hud.SetExperience(progress * 999999); + progress *= 100; + pl.hud.SetHealth(progress); + pl.hud.SetBottomBar(progress); + pl.hud.SetAmmo(AMMO_LEFT, progress); + pl.hud.SetAmmo(AMMO_MAX, progress); + pl.hud.SetBarItem(BARITEM_4, progress); + pl.hud.SetArmor(ARMOR_PART_1, progress); + pl.hud.SetLevel(progress); + pl.hud.SetIntelligence(progress); + pl.hud.SetWisdom(progress); + pl.hud.SetStrength(progress); + pl.hud.SetDexterity(progress); +#endif #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); - } + msg_entity = pl; + ncEngine::WriteByte( MSG_ONE, SVC_SETANGLE ); + ncEngine::WriteAngle( MSG_ONE, camAngle[0] ); + ncEngine::WriteAngle( MSG_ONE, camAngle[1] ); + ncEngine::WriteAngle( MSG_ONE, camAngle[2] ); + //ncEngine::MultiCast( pl.GetOrigin(), MULTICAST_ONE ); #endif + pl.v_angle = camAngle; + pl.angles = camAngle; + pl.fixangle = true; + pl.SetOrigin(camPos); + pl.SetMovetype(MOVETYPE_NONE); + pl.SetFOV( camFOV ); + + if (pl.inCamera.GetCameraTime() >= pl.inCamera.GetCameraLength()) { + ncEntity nextCamera = pl.inCamera.GetNextCamera(); + + if (nextCamera) { + nextCamera.Trigger(pl, 0); + } else { + pl.inCamera = __NULL__; + } + } + } } void PlayerPostThink( void ) { - idPlayer pl = ( idPlayer ) self; + ncPlayer pl = ( ncPlayer ) self; if (pl.GetDeadFlag() < DEAD_DEAD) { pl.PostThink(); } + + if (pl.button0) { + if (pl.weapon) { + pl.PrimaryAttack(pl); + } + } + + if (pl.impulse) { + float theImpulse = pl.impulse; + pl.impulse = 0; + if (pl.ImpulseCommand(theImpulse) == false) { + switch (theImpulse) { + case 22: /* crouch toggle */ + pl.SPrint(PRINT_LOW, pl.netname ); + pl.SPrint(PRINT_LOW, " toggles crouch\n"); + break; + case 23: /* inventory use */ + pl.UseInventoryItem( pl.GetInventoryItem() ); + break; + case 25: /* inventory next */ + pl.NextInventoryItem(); + break; + case 26: /* inventory previous */ + pl.PreviousInventoryItem(); + break; + case 44: /* inventory drop */ + pl.DropInventoryItem( pl.GetInventoryItem() ); + break; + case 100: + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + pl.UseInventoryItem(theImpulse - 100); + break; + } + } + } } void ClientKill( void ) { - g_gameRules.ApplyDamage( ( idEntity ) self, ( idEntity ) self, 200, 0, 0); + g_gameRules.ApplyDamage( ( ncEntity ) self, ( ncEntity ) self, 200, 0, 0); } void ClientConnect( void ) { Class_Player(); - g_gameRules.PlayerConnects( ( idPlayer ) self ); + g_gameRules.PlayerConnects( ( ncPlayer ) self ); } void PutClientInServer( void ) { - g_gameRules.PlayerFinishesJoining( ( idPlayer ) self ); + g_gameRules.PlayerFinishesJoining( ( ncPlayer ) self ); + +#if 0 + /* MATH FUNCTION TEST */ + for (float f = 0.0f; f < 10; f += 0.1f) { + float result = ncMath::Sin(f); + ncEngine::DPrint("Sin: "); + ncEngine::DPrint(ncEngine::FloatToString(f)); + ncEngine::DPrint(" "); + ncEngine::DPrint(ncEngine::FloatToString(result)); + ncEngine::DPrint("\n"); + } + ncEngine::DPrint("\n"); + for (float f = 1.0f; f < 100; f += 1.0f) { + float result = ncMath::Sqrt(f); + ncEngine::DPrint("Sqrt: "); + ncEngine::DPrint(ncEngine::FloatToString(f)); + ncEngine::DPrint(" "); + ncEngine::DPrint(ncEngine::FloatToString(result)); + ncEngine::DPrint("\n"); + } + ncEngine::DPrint("\n"); + for (float f = 0.0f; f < 10; f += 0.1f) { + float result = ncMath::Acos(f); + ncEngine::DPrint("Acos: "); + ncEngine::DPrint(ncEngine::FloatToString(f)); + ncEngine::DPrint(" "); + ncEngine::DPrint(ncEngine::FloatToString(result)); + ncEngine::DPrint("\n"); + } + for (float f = 0.0f; f < 10; f += 0.1f) { + float result = ncMath::Cos(f); + ncEngine::DPrint("Cos: "); + ncEngine::DPrint(ncEngine::FloatToString(f)); + ncEngine::DPrint(" "); + ncEngine::DPrint(ncEngine::FloatToString(result)); + ncEngine::DPrint("\n"); + } + ncEngine::DPrint("\n"); +#endif } void ClientDisconnect( void ) { - g_gameRules.PlayerDisconnects( ( idPlayer ) self ); + g_gameRules.PlayerDisconnects( ( ncPlayer ) self ); } void SetNewParms( void ) { diff --git a/src/system/classes.qc b/src/system/classes.qc index 6341a2c..4545556 100644 --- a/src/system/classes.qc +++ b/src/system/classes.qc @@ -1,19 +1,22 @@ __weak void Class_Player(void) { - spawnfunc_idPlayer(); + spawnfunc_ncPlayer(); } __weak void Class_Actor(void) { - spawnfunc_idActor(); + spawnfunc_nsActor(); } __weak void Class_Rules(void) { - spawnfunc_idRules(); + spawnfunc_ncRules(); } __weak void Class_Engine(void) { - spawnfunc_idEngine(); + spawnfunc_ncEngine(); } __weak void Class_Entity(void) { - spawnfunc_idEntity(); + spawnfunc_ncEntity(); +} + +__weak void Precaches(void) { } diff --git a/src/system/headers.src b/src/system/headers.src index da0a0d2..2d1c700 100644 --- a/src/system/headers.src +++ b/src/system/headers.src @@ -1,11 +1,15 @@ #includelist -idEntity.qh -idEngine.qh -idActor.qh -idPlayer.qh -idRules.qh -idItem.qh -idMover.qh -idFX.qh +ncEntity.qh +ncEngine.qh +ncMath.qh +ncActor.qh +ncItem.qh +ncPlayer.qh +ncRules.qh +ncMover.qh +ncFX.qh +ncCamera.qh +ncHud.qh +ncNet.qh classes.qh #endlist diff --git a/src/system/idActor.qh b/src/system/idActor.qh deleted file mode 100644 index 25967d0..0000000 --- a/src/system/idActor.qh +++ /dev/null @@ -1,5 +0,0 @@ -class idActor : idEntity { - void idActor( void ); - - virtual void _InternalPostSpawn( void ); -}; \ No newline at end of file diff --git a/src/system/idEngine.qc b/src/system/idEngine.qc deleted file mode 100644 index 28eaa31..0000000 --- a/src/system/idEngine.qc +++ /dev/null @@ -1,315 +0,0 @@ -/* we include this here so the rest of the codebase won't be able to call them */ -#include "../builtins.qh" - -void idEngine::MakeVectors( vector ang ) { - return makevectors( ang ); -} - -void idEngine::SetOrigin( idEntity e, vector o ) { - setorigin( e, o ); -} - -void idEngine::SetModel( idEntity e, string m ) { - setmodel( e, m ); -} - -void idEngine::SetSize( idEntity e, vector min, vector max ) { - setsize( e, min, max ); -} - -void idEngine::Break( void ) { - break (); -} - -float idEngine::Random( void ) { - return random(); -} - -void idEngine::Sound( idEntity e, float chan, string samp, float vol, float atten ) { - sound( e, chan, samp, vol, atten ); -} - -vector idEngine::Normalize( vector v ) { - return normalize( v ); -} - -void idEngine::Error( string e ) { - error( e ); -} - -void idEngine::ObjError( string e ) { - objerror( e ); -} - -float idEngine::VLen( vector v ) { - return vlen( v ); -} - -float idEngine::VecToYaw( vector v ) { - return vectoyaw( v ); -} - -idEntity idEngine::Spawn( void ) { - return spawn(); -} - -void idEngine::Remove( idEntity e ) { - remove( e ); -} - -void idEngine::TraceLine( vector v1, vector v2, float nomonsters, idEntity forent ) { - traceline( v1, v2, nomonsters, forent ); -} - -idEntity idEngine::CheckClient( void ) { - return checkclient(); -} - -idEntity idEngine::Find( idEntity start, .string fld, string match ) { - return find( start, ::fld, match ); -} - -string idEngine::Precache_Sound( string s ) { - return precache_sound( s ); -} - -string idEngine::Precache_Model( string s ) { - return precache_model( s ); -} - -void idEngine::StuffCmd( idEntity client, string s ) { - stuffcmd( client, s ); -} - -idEntity idEngine::FindRadius( vector org, float rad ) { - return findradius( org, rad ); -} - -void idEngine::BPrint( print_t level, string s ) { -#ifdef TARGET_QUAKEWORLD - bprint( level, s ); -#else - bprint( s ); -#endif -} - -void idEngine::SPrint( idEntity client, print_t level, string s ) { -#ifdef TARGET_QUAKEWORLD - sprint( client, level, s ); -#else - sprint( client, s ); -#endif -} - -void idEngine::DPrint( string s ) { - dprint( s ); -} - -string idEngine::FloatToString( float f ) { - return ftos( f ); -} - -string idEngine::VectorToString( vector v ) { - return vtos( v ); -} - -void idEngine::CoreDump( void ) { - coredump(); -} - -void idEngine::TraceOn( void ) { - traceon(); -} - -void idEngine::TraceOff( void ) { - traceoff(); -} - -void idEngine::EPrint( idEntity e ) { - eprint( e ); -} - -float idEngine::WalkMove( float yaw, float dist ) { - return walkmove( yaw, dist ); -} - -float idEngine::DropToFloor( float yaw, float dist ) { - return droptofloor( yaw, dist ); -} - -void idEngine::LightStyle( float style, string value ) { - lightstyle( style, value ); -} - -float idEngine::RInt( float v ) { - return rint( v ); -} - -float idEngine::Floor( float v ) { - return floor( v ); -} - -float idEngine::Ceil( float v ) { - return ceil( v ); -} - -float idEngine::CheckBottom( idEntity e ) { - return checkbottom( e ); -} - -float idEngine::PointContents( vector v ) { - return pointcontents( v ); -} - -float idEngine::AbsoluteFloat( float f ) { - return fabs( f ); -} - -vector idEngine::Aim( idEntity e, float speed ) { - return aim( e, speed ); -} - -float idEngine::CVar( string s ) { - return cvar( s ); -} - -void idEngine::LocalCmd( string s ) { - localcmd( s ); -} - -idEntity idEngine::NextEnt( idEntity e ) { - return nextent( e ); -} - -void idEngine::Particle( vector o, vector d, float color, float count ) { -#ifndef TARGET_QUAKEWORLD - particle( o, d, color, count ); -#endif -} - -void idEngine::ChangeYaw( void ) { -#ifndef TARGET_QUAKEWORLD - changeyaw(); -#endif -} - -vector idEngine::VecToAngles( vector v ) { - return vectoangles( v ); -} - -void idEngine::WriteByte( float to, float f ) { - writeByte( to, f ); -} - -void idEngine::WriteChar( float to, float f ) { - writeChar( to, f ); -} - -void idEngine::WriteShort( float to, float f ) { - writeShort( to, f ); -} - -void idEngine::WriteLong( float to, float f ) { - writeLong( to, f ); -} - -void idEngine::WriteCoord( float to, float f ) { - writeCoord( to, f ); -} - -void idEngine::WriteAngle( float to, float f ) { - writeAngle( to, f ); -} - -void idEngine::WriteString( float to, string s ) { - writeString( to, s ); -} - -void idEngine::WriteEntity( float to, idEntity s ) { - writeEntity( to, s ); -} - -void idEngine::MoveToGoal( float step ) { - movetogoal( step ); -} - -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 ); -} - -void idEngine::ChangeLevel( string s ) { -#ifdef TARGET_HEXEN2 - changelevel( s, "" ); -#else - changelevel( s ); -#endif -} - -void idEngine::CVarSet( string variable, string val ) { - cvar_set( variable, val ); -} - -void idEngine::CenterPrint( idEntity client, string s ) { - centerprint( client, s ); -} - -void idEngine::AmbientSound( vector pos, string samp, float vol, float atten ) { - ambientsound( pos, samp, vol, atten ); -} - -void idEngine::SetSpawnParms( idEntity e ) { - setspawnparms( e ); -} - -void idEngine::LogFrag( idEntity killer, idEntity victim ) { -#ifdef TARGET_QUAKEWORLD - logfrag(killer, victim); -#endif -} - -string idEngine::InfoKey( idEntity e, string key ) { -#ifdef TARGET_QUAKEWORLD - return infokey(e, key); -#else - return ""; -#endif -} - -float idEngine::StringToFloat( string s ) { -#ifdef TARGET_QUAKEWORLD - return stof(s); -#else - return 0.0f; -#endif -} - -void idEngine::MultiCast( vector where, multicast_t set ) { -#ifdef TARGET_QUAKEWORLD - multicast(where, set); -#endif -} - -float idEngine::NumForEdict( idEntity targetEnt ) { - /* this requires denormals, may not work on custom engines */ - return (float)(__variant)targetEnt / (float)(__variant)nextent(world); -} - -idEntity idEngine::EdictForNum( float targetNum ) { - idEntity e = ( idEntity ) world; - - while ( ( e = NextEnt( e ) ) ) { - if ( NumForEdict( e ) == targetNum ) - return (e); - } - - Error( "idEngine::EdictForNum: edict not found\n" ); - return __NULL__; -} diff --git a/src/system/idEngine.qh b/src/system/idEngine.qh deleted file mode 100644 index 7d43a97..0000000 --- a/src/system/idEngine.qh +++ /dev/null @@ -1,81 +0,0 @@ -class idEngine { - nonvirtual void MakeVectors( vector ang ); - nonvirtual void SetOrigin( idEntity e, vector o ); - nonvirtual void SetModel( idEntity e, string m ); - nonvirtual void SetSize( idEntity e, vector min, vector max ); - nonvirtual void Break( void ); - nonvirtual float Random( void ); - nonvirtual void Sound( idEntity e, float chan, string samp, float vol, float atten ); - nonvirtual vector Normalize( vector v ); - nonvirtual void Error( string e ); - nonvirtual void ObjError( string e ); - nonvirtual float VLen( vector v ); - nonvirtual float VecToYaw( vector v ); - nonvirtual idEntity Spawn( void ); - nonvirtual void Remove( idEntity e ); - nonvirtual void TraceLine( vector v1, vector v2, float nomonsters, idEntity forent ); - nonvirtual idEntity CheckClient( void ); - nonvirtual idEntity Find( idEntity start,.string fld, string match ); - nonvirtual string Precache_Sound( string s ); - nonvirtual string Precache_Model( string s ); - nonvirtual void StuffCmd( idEntity client, string s ); - nonvirtual idEntity FindRadius( vector org, float rad ); - nonvirtual void BPrint( print_t level, string s ); - nonvirtual void SPrint( idEntity client, print_t level, string s ); - nonvirtual void DPrint( string s ); - nonvirtual string FloatToString( float f ); - nonvirtual string VectorToString( vector v ); - nonvirtual void CoreDump( void ); - nonvirtual void TraceOn( void ); - nonvirtual void TraceOff( void ); - nonvirtual void EPrint( idEntity e ); - nonvirtual float WalkMove( float yaw, float dist ); - nonvirtual float DropToFloor( float yaw, float dist ); - nonvirtual void LightStyle( float style, string value ); - nonvirtual float RInt( float v ); - nonvirtual float Floor( float v ); - nonvirtual float Ceil( float v ); - nonvirtual float CheckBottom( idEntity e ); - nonvirtual float PointContents( vector v ); - nonvirtual float AbsoluteFloat( float f ); - nonvirtual vector Aim( idEntity e, float speed ); - nonvirtual float CVar( string s ); - nonvirtual void LocalCmd( string s ); - nonvirtual idEntity NextEnt( idEntity e ); - nonvirtual void Particle( vector o, vector d, float color, float count ); - nonvirtual void ChangeYaw( void ); - nonvirtual vector VecToAngles( vector v ); - nonvirtual void WriteByte( float to, float f ); - nonvirtual void WriteChar( float to, float f ); - nonvirtual void WriteShort( float to, float f ); - nonvirtual void WriteLong( float to, float f ); - nonvirtual void WriteCoord( float to, float f ); - nonvirtual void WriteAngle( float to, float f ); - nonvirtual void WriteString( float to, string s ); - 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 ); - nonvirtual void CenterPrint( idEntity client, string s ); - nonvirtual void AmbientSound( vector pos, string samp, float vol, float atten ); - nonvirtual void SetSpawnParms( idEntity e ); - - /* natively implemented by QuakeWorld */ - nonvirtual void LogFrag( idEntity killer, idEntity victim ); - nonvirtual string InfoKey( idEntity e, string key ); - nonvirtual float StringToFloat( string s ); - nonvirtual void MultiCast( vector where, float set ); - - /* custom builtins that we can do within QC */ - virtual float NumForEdict( idEntity targetEnt ); - virtual idEntity EdictForNum( float targetNum ); -}; - -idEngine gameEngine; - -#define LINK_ENTITY_TO_CLASS(cname,classa) void cname(void) { spawnfunc_##classa(); } - -.void( idEntity ) TouchCallback; \ No newline at end of file diff --git a/src/system/idEntity.qc b/src/system/idEntity.qc deleted file mode 100644 index f2a36fe..0000000 --- a/src/system/idEntity.qc +++ /dev/null @@ -1,593 +0,0 @@ - -void idEntity::idEntity( void ) { - health = 0; - max_health = 100; - - if (g_world_initialized == false) { - Precache(); - } - _InternalPreSpawn(); - Spawn(); - _InternalPostSpawn(); -} - -void idEntity::Precache( void ) { -} - -void idEntity::_InternalPreSpawn( void ) { -} - -void idEntity::_InternalPostSpawn( void ) { -} - -void idEntity::Spawn( void ) { -} - -void idEntity::Death( void ) { -} - -void idEntity::Pain( void ) { -} - -/* set functions */ -void idEntity::SetModelindex( float value ) { - modelindex = value; -} - -void idEntity::SetMovetype( movetype_t value ) { - movetype = value; -} - -void idEntity::SetSolid( solid_t value ) { - solid = value; -} - -void idEntity::SetOrigin( vector value ) { - gameEngine.SetOrigin( this, value ); -} - -void idEntity::SetVelocity( vector value ) { - velocity = value; -} - -void idEntity::SetAngles( vector value ) { - angles = value; -} - -void idEntity::SetAngularVelocity( vector value ) { - avelocity = value; -} - -void idEntity::SetPunchangle( vector value ) { -#ifndef TARGET_QUAKEWORLD - punchangle = value; -#endif -} - -void idEntity::SetModel( string value ) { - gameEngine.SetModel( this, value ); -} - -void idEntity::SetFrame( float value ) { - frame = value; -} - -void idEntity::SetSkin( float value ) { - skin = value; -} - -void idEntity::AddEffect( effects_t value ) { - effects |= value; -} - -void idEntity::RemoveEffect( effects_t value ) { - effects &= ~value; -} - -void idEntity::ClearEffects( void ) { - effects = 0; -} - -void idEntity::SetSize( vector min, vector max ) { - gameEngine.SetSize( this, min, max ); -} - -void idEntity::SetHealth( float value ) { - health = value; - - if ( health > max_health ) - health = max_health; -} - -void idEntity::AddFrags( float value ) { - frags += value; -} - -void idEntity::RemoveFrags( float value ) { - frags -= value; -} - -void idEntity::ClearFrags( void ) { - frags = 0; -} - -void idEntity::SetWeapon( float value ) { - weapon = value; -} - -void idEntity::SetWeaponmodel( string value ) { - weaponmodel = value; -} - -void idEntity::SetWeaponframe( float value ) { - weaponframe = value; -} - -void idEntity::SetCurrentAmmo( float value ) { -#ifndef TARGET_HEXEN2 - currentammo = value; -#endif -} - -void idEntity::SetAmmoType1( float value ) { -#ifndef TARGET_HEXEN2 - ammo_shells = value; -#endif -} - -void idEntity::SetAmmoType2( float value ) { -#ifndef TARGET_HEXEN2 - ammo_nails = value; -#endif -} - -void idEntity::SetAmmoType3( float value ) { -#ifndef TARGET_HEXEN2 - ammo_rockets = value; -#endif -} - -void idEntity::SetAmmoType4( float value ) { -#ifndef TARGET_HEXEN2 - ammo_cells = value; -#endif -} - -void idEntity::SetTakedamage( damage_t value ) { - takedamage = value; -} - -void idEntity::SetDeadFlag( dead_t value ) { - deadflag = value; -} - -void idEntity::SetViewOffset( vector value ) { - view_ofs = value; -} - -void idEntity::ForceUpdateClientAngle( void ) { - fixangle = 1; -} - -void idEntity::AddFlags( flags_t value ) { - flags |= value; -} - -void idEntity::RemoveFlags( flags_t value ) { - flags &= ~value; -} - -void idEntity::ClearFlags( void ) { - flags = 0; -} - -void idEntity::SetColormap( float value ) { - colormap = value; -} - -void idEntity::SetDisplayname( string value ) { - netname = value; -} - -void idEntity::SetMaxHealth( float value ) { - max_health = value; -} - -void idEntity::SetArmorType( float value ) { - armortype = value; -} - -void idEntity::SetArmor( float value ) { - armorvalue = value; -} - -void idEntity::SetAimEntity( entity value ) { -#ifndef TARGET_HEXEN2 - aiment = value; -#endif -} - -void idEntity::SetGoalEntity( entity value ) { - goalentity = value; -} - -void idEntity::SetTarget( string value ) { - target = value; -} - -void idEntity::SetTargetname( string value ) { - targetname = value; -} - -void idEntity::SetOwner( entity value ) { - owner = value; -} - -void idEntity::SetMovementDirection( vector value ) { - movedir = value; -} - -void idEntity::SetTriggerMessage( string value ) { -#ifndef TARGET_HEXEN2 - message = value; -#endif -} - -void idEntity::SetSoundStyle( float value ) { -#ifndef TARGET_HEXEN2 - sounds = value; -#endif -} - -void idEntity::SetNoiseValue1( string value ) { - noise = value; -} - -void idEntity::SetNoiseValue2( string value ) { - noise1 = value; -} - -void idEntity::SetNoiseValue3( string value ) { - noise2 = value; -} - -void idEntity::SetNoiseValue4( string value ) { - noise3 = value; -} - -void idEntity::SetTouchCallback( void( idEntity ) callback ) { - /* give this entity a touch, this is for the engine only */ - touch = _TouchWrapper; - /* this is the touch function we'll be calling whenever the entity really gets touched */ - TouchCallback = callback; -} - -void idEntity::_TouchWrapper( void ) { - TouchCallback( ( idEntity) other ); -} - - -/* get functions */ -float idEntity::GetModelindex( void ) { - return modelindex; -} - -movetype_t idEntity::GetMovetype( void ) { - return ( movetype_t ) movetype; -} - -solid_t idEntity::GetSolid( void ) { - return ( solid_t ) solid; -} - -vector idEntity::GetOrigin( void ) { - return origin; -} - -vector idEntity::GetVelocity( void ) { - return velocity; -} - -vector idEntity::GetAngles( void ) { - return angles; -} - -vector idEntity::GetAngularVelocity( void ) { - return avelocity; -} - -vector idEntity::GetPunchangle( void ) { -#ifndef TARGET_QUAKEWORLD - return punchangle; -#else - return [0.0, 0.0, 0.0]; -#endif -} - -string idEntity::GetModel( void ) { - return model; -} - -float idEntity::GetFrame( void ) { - return frame; -} - -float idEntity::GetSkin( void ) { - return skin; -} - -bool idEntity::HasEffect( effects_t value ) { - return ( effects & value ) ? 1 : 0; -} - -vector idEntity::GetSize( void ) { - return size; -} - -float idEntity::GetHealth( void ) { - return health; -} - -float idEntity::GetFrags( void ) { - return frags; -} - -float idEntity::GetWeapon( void ) { - return weapon; -} - -string idEntity::GetWeaponmodel( void ) { - return weaponmodel; -} - -float idEntity::GetWeaponframe( void ) { - return weaponframe; -} - -float idEntity::GetCurrentAmmo( void ) { -#ifndef TARGET_HEXEN2 - return currentammo; -#endif -} - -float idEntity::GetAmmoType1( void ) { -#ifndef TARGET_HEXEN2 - return ammo_shells; -#endif -} - -float idEntity::GetAmmoType2( void ) { -#ifndef TARGET_HEXEN2 - return ammo_nails; -#endif -} - -float idEntity::GetAmmoType3( void ) { -#ifndef TARGET_HEXEN2 - return ammo_rockets; -#endif -} - -float idEntity::GetAmmoType4( void ) { -#ifndef TARGET_HEXEN2 - return ammo_cells; -#endif -} - -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; -} - -bool idEntity::HasFlag( flags_t value ) { - return ( flags & value ) ? 1 : 0; -} - -float idEntity::GetColormap( void ) { - return colormap; -} - -string idEntity::GetDisplayname( void ) { - return netname; -} - -float idEntity::GetMaxHealth( void ) { - return max_health; -} - -float idEntity::GetArmorType( void ) { - return armortype; -} - -float idEntity::GetArmor( void ) { - return armorvalue; -} - -entity idEntity::GetAimEntity( void ) { -#ifndef TARGET_HEXEN2 - return aiment; -#endif -} - -entity idEntity::GetGoalEntity( void ) { - return goalentity; -} - -string idEntity::GetTarget( void ) { - return target; -} - -string idEntity::GetTargetname( void ) { - return targetname; -} - -entity idEntity::GetOwner( void ) { - return owner; -} - -vector idEntity::GetMovementDirection( void ) { - return movedir; -} - -string idEntity::GetTriggerMessage( void ) { -#ifndef TARGET_HEXEN2 - return message; -#endif -} - -float idEntity::GetSoundStyle( void ) { -#ifndef TARGET_HEXEN2 - return sounds; -#endif -} - -string idEntity::GetNoiseValue1( void ) { - return noise; -} - -string idEntity::GetNoiseValue2( void ) { - return noise1; -} - -string idEntity::GetNoiseValue3( void ) { - return noise2; -} - -string idEntity::GetNoiseValue4( void ) { - return noise3; -} - -string idEntity::GetInfoKey( string key ) { - return gameEngine.InfoKey(this, key); -} - -bool idEntity::IsPlayer( void ) { - return HasFlag(FL_CLIENT); -} - -bool idEntity::IsActor( void ) { - return HasFlag(FL_MONSTER); -} - -bool idEntity::IsWorld( void ) { - if (this == world) - return TRUE; - else - return FALSE; -} - - -/* misc helper methods */ -void idEntity::InitTrigger( void ) { - SetSolid(SOLID_TRIGGER); - SetModel(GetModel()); - SetMovetype(MOVETYPE_NONE); - SetModelindex(0); -} - -void idEntity::Transport( vector newPosition, vector newAngle, bool retainVelocity ) { - - if (retainVelocity == true) { - float flSpeed = gameEngine.VLen(this.GetVelocity()); - gameEngine.MakeVectors(newAngle); - SetVelocity(v_forward * flSpeed); - } else { - SetVelocity([0,0,0]); - } - - SetOrigin(newPosition); - SetAngles(newAngle); - ForceUpdateClientAngle(); -} - -idEntity idEntity::FindFirstTarget( void ) { - return gameEngine.Find( (idEntity) world, ::targetname, target); -} - -void idEntity::ClearVelocity( void ) { - velocity = g_vec_null; - avelocity = g_vec_null; -} - -float idEntity::GetTime(void) -{ - return (movetype == MOVETYPE_PUSH) ? ltime : time; -} - -void idEntity::ReleaseThink( void ) { - think = __NULL__; - nextthink = 0.0f; -} - -void idEntity::SetThink( void ( void ) func ) { - think = func; -} - -void idEntity::SetNextThink( float fl ) { - float flTime = GetTime() + fl; - - /* HACK: to make sure things happen post-spawn */ - if ( flTime == 0.0f ) - flTime = 0.1f; - - if ( flTime >= 0 ) - nextthink = flTime; -} - -void idEntity::ScheduleThink( void ( void ) func, float fl ) { - SetThink( func ); - SetNextThink( fl ); -} - -/* this is where Hexen 2 specific methods begin. They will be mostly stubbed */ -void idEntity::SetScale( float modelScale ) { -#ifdef TARGET_HEXEN2 - scale = modelScale; -#endif -} - -float idEntity::GetScale( void ) { -#ifdef TARGET_HEXEN2 - return scale; -#else - return 1.0f; -#endif -} - -void idEntity::SetScaleOrigin( scaleOrigin_t scaleOrg ) { -#ifdef TARGET_HEXEN2 - drawflags &= ~SCALE_ORIGIN_MASKOUT; - - switch ( scaleOrg ) { - case SCALEORIGIN_CENTER: - drawflags |= SCALE_ORIGIN_CENTER; - break; - case SCALEORIGIN_BOTTOM: - drawflags |= SCALE_ORIGIN_BOTTOM; - break; - case SCALEORIGIN_TOP: - drawflags |= SCALE_ORIGIN_TOP; - break; - } -#endif -} - -scaleOrigin_t idEntity::GetScaleOrigin( void ) { -#ifdef TARGET_HEXEN2 - if (drawflags & SCALE_ORIGIN_BOTTOM) - return SCALEORIGIN_BOTTOM; - else if (drawflags & SCALE_ORIGIN_TOP) - return SCALEORIGIN_TOP; - else - return SCALEORIGIN_CENTER; -#else - return SCALEORIGIN_CENTER; -#endif -} \ No newline at end of file diff --git a/src/system/idFX.qc b/src/system/idFX.qc deleted file mode 100644 index 9eb74a7..0000000 --- a/src/system/idFX.qc +++ /dev/null @@ -1,177 +0,0 @@ -#ifdef TARGET_QUAKEWORLD - #define FX_MSGTYPE MSG_MULTICAST -#else - #define FX_MSGTYPE MSG_BROADCAST -#endif - -void idFX::CastMuzzleFlash( idEntity targetEntity ) { - /* the entity is already emitting a light of sorts. */ - if (targetEntity.effects > 1) - return; - - targetEntity.effects = EF_MUZZLEFLASH; -} - -void idFX::CastSpike( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_SPIKE ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.MultiCast(targetPos, MULTICAST_PHS); -} - -void idFX::CastSuperSpike( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_SUPERSPIKE ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PHS ); -} - -void idFX::CastGunShot( vector targetPos, float shotCount ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_GUNSHOT ); -#ifdef TARGET_QUAKEWORLD - gameEngine.WriteByte( FX_MSGTYPE, shotCount ); -#endif - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PVS ); -} - -void idFX::CastExplosion( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_EXPLOSION ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PHS ); -} - -void idFX::CastTarExplosion( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_TAREXPLOSION ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PHS ); -} - -void idFX::CastLightning( idEntity boltOwner, vector startPos, vector endPos, lightningStyle_t lightningStyle ) { - gameEngine.WriteByte (FX_MSGTYPE, SVC_TEMP_ENTITY); - - switch ( lightningStyle ) { - case FXLIGHTNING_TYPE1: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING1); - break; - case FXLIGHTNING_TYPE2: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING2); - break; - case FXLIGHTNING_TYPE3: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING3); - break; - default: - float r = gameEngine.RInt(gameEngine.Random() * 2.0); - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING1); - } - - gameEngine.WriteEntity(FX_MSGTYPE, boltOwner); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[0] ); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[1] ); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[2] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[0] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[1] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[2] ); - gameEngine.MultiCast( startPos, MULTICAST_PHS ); -} - -void idFX::CastWizardSpike( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_WIZSPIKE ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.MultiCast(targetPos, MULTICAST_PHS); -} - -void idFX::CastKnightSpike( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_KNIGHTSPIKE ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.MultiCast(targetPos, MULTICAST_PHS); -} - -void idFX::CastLavaSplash( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_LAVASPLASH ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PVS ); -} - -void idFX::CastTeleport( vector targetPos ) { - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_TELEPORT ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PVS ); -} - -void idFX::CastBlood( vector targetPos ) { -#ifdef TARGET_QUAKEWORLD - gameEngine.WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); - gameEngine.WriteByte( FX_MSGTYPE, TE_BLOOD ); - gameEngine.WriteByte( FX_MSGTYPE, 1 ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[0] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[1] ); - gameEngine.WriteCoord( FX_MSGTYPE, targetPos[2] ); - gameEngine.MultiCast( targetPos, MULTICAST_PVS ); -#else - gameEngine.Particle( targetPos, [0, 0, 0], 73, 1 ); -#endif -} - -void idFX::CastLightningBlood( idEntity boltOwner, vector startPos, vector endPos, lightningStyle_t lightningStyle ) { - gameEngine.WriteByte (FX_MSGTYPE, SVC_TEMP_ENTITY); - - /* QW exclusive effect, substitute the other games with a separate blood impact */ -#ifdef TARGET_QUAKEWORLD - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNINGBLOOD); -#else - switch ( lightningStyle ) { - case FXLIGHTNING_TYPE1: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING1); - break; - case FXLIGHTNING_TYPE2: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING2); - break; - case FXLIGHTNING_TYPE3: - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING3); - break; - default: - float r = gameEngine.RInt(gameEngine.Random() * 2.0); - gameEngine.WriteByte(FX_MSGTYPE, TE_LIGHTNING1); - } -#endif - - gameEngine.WriteEntity(FX_MSGTYPE, boltOwner); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[0] ); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[1] ); - gameEngine.WriteCoord(FX_MSGTYPE, startPos[2] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[0] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[1] ); - gameEngine.WriteCoord(FX_MSGTYPE, endPos[2] ); - gameEngine.MultiCast( startPos, MULTICAST_PHS ); - - /* substitute for NQ/H2 */ -#ifndef TARGET_QUAKEWORLD - CastBlood(endPos); -#endif -} \ No newline at end of file diff --git a/src/system/idItem.qc b/src/system/idItem.qc deleted file mode 100644 index 4479e4d..0000000 --- a/src/system/idItem.qc +++ /dev/null @@ -1,25 +0,0 @@ - -.float item; - -void idItem::idItem(void) { -} - -void idItem::SetID(float a) { - item = a; -} - -float idItem::GetID(void) { - return item; -} - -void idItem::PrimaryAttack(void) { -} - -void idItem::SecondaryAttack(void) { -} - -void idItem::Reload(void) { -} - -void idItem::Release(void) { -} diff --git a/src/system/idItem.qh b/src/system/idItem.qh deleted file mode 100644 index 5151541..0000000 --- a/src/system/idItem.qh +++ /dev/null @@ -1,17 +0,0 @@ -class idItem:idEntity { - void idItem(void); - - /* Sets the id of an Item. */ - nonvirtual void SetID(float); - /** Returns the id of an Item. */ - nonvirtual float GetID(void); - - /** Overridable: On +attack execution. */ - virtual void PrimaryAttack(void); - /** Overridable: On +attack2 execution. */ - virtual void SecondaryAttack(void); - /** Overridlable: On +reload execution. */ - virtual void Reload(void); - /** Overridable: When no buttons are held. */ - virtual void Release(void); -}; \ No newline at end of file diff --git a/src/system/idPlayer.qc b/src/system/idPlayer.qc deleted file mode 100644 index 43ce0a2..0000000 --- a/src/system/idPlayer.qc +++ /dev/null @@ -1,35 +0,0 @@ -void idPlayer::idPlayer( void ) { -} - -void idPlayer::PreThink( void ) { -} - -void idPlayer::PostThink( void ) { -} - -void idPlayer::DeadThink( void ) { -} - -void idPlayer::ResetPlayer( void ) { - ClearFlags(); - ClearEffects(); - ClearFrags(); - -#ifdef TARGET_HEXEN2 - SetModel( "models/paladin.mdl" ); -#else - SetModel( "progs/player.mdl" ); -#endif - SetMovetype( MOVETYPE_WALK ); - SetSolid( SOLID_SLIDEBOX ); - SetViewOffset( [0, 0, 24] ); - AddFlags( FL_CLIENT ); - SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); - SetHealth( 100 ); - 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 deleted file mode 100644 index ef4da44..0000000 --- a/src/system/idPlayer.qh +++ /dev/null @@ -1,9 +0,0 @@ -class idPlayer:idEntity { - void idPlayer( void ); - - 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 deleted file mode 100644 index a30865f..0000000 --- a/src/system/idRules.qc +++ /dev/null @@ -1,44 +0,0 @@ -void idRules::idRules( void ) { -} - -void idRules::PlayerConnects( idPlayer pl ) { - gameEngine.BPrint( PRINT_HIGH, "Player connected.\n" ); -} - -void idRules::PlayerDisconnects( idPlayer pl ) { - gameEngine.BPrint( PRINT_HIGH, "Player disconnected.\n" ); -} - -void idRules::PlayerFinishesJoining( idPlayer player ) { - gameEngine.BPrint( PRINT_HIGH, "Player joined the game fully.\n" ); - - /* reset them fully */ - player.ResetPlayer(); - - /* place them to the nearest spawn point */ - { - idPlayerStart spawn = world; - - spawn.MovePlayerToStart( 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 deleted file mode 100644 index 6636ec1..0000000 --- a/src/system/idRules.qh +++ /dev/null @@ -1,12 +0,0 @@ -class idRules { - void idRules( void ); - - 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; diff --git a/src/system/idActor.qc b/src/system/ncActor.qc similarity index 63% rename from src/system/idActor.qc rename to src/system/ncActor.qc index 6d01aa3..7dfff3a 100644 --- a/src/system/idActor.qc +++ b/src/system/ncActor.qc @@ -1,8 +1,8 @@ -void idActor::idActor ( void ) { +void nsActor::nsActor ( void ) { } -void idActor::_InternalPostSpawn ( void ) { +void nsActor::_InternalPostSpawn ( void ) { /* monsters are auto-aim by default */ SetTakedamage( DAMAGE_AIM ); SetSolid( SOLID_SLIDEBOX ); diff --git a/src/system/ncActor.qh b/src/system/ncActor.qh new file mode 100644 index 0000000..c99ce5e --- /dev/null +++ b/src/system/ncActor.qh @@ -0,0 +1,5 @@ +class nsActor : ncEntity { + void nsActor( void ); + + virtual void _InternalPostSpawn( void ); +}; \ No newline at end of file diff --git a/src/system/ncCamera.qc b/src/system/ncCamera.qc new file mode 100644 index 0000000..64325c1 --- /dev/null +++ b/src/system/ncCamera.qc @@ -0,0 +1,220 @@ + +.float wait; +.string next; + +.camInterpolation_t lerp_angle; +.camInterpolation_t lerp_origin; + +.camAcceleration_t accel_angle; +.camAcceleration_t accel_origin; + +void ncCamera::ncCamera( void ) { + + SetTriggerCallback(CamTrigger); + + if (wait <= 0) + wait = 4.0f; + + if (fov <= 0) + fov = 90; + + if (lerp_origin <= 0) + lerp_origin = CAMINTERPOLATION_LINEAR; + if (lerp_angle <= 0) + lerp_angle = CAMINTERPOLATION_LINEAR; + + if (accel_angle <= 0) + accel_angle = CAMACCELERATION_LINEAR; + if (accel_origin <= 0) + accel_origin = CAMACCELERATION_LINEAR; +} + +float ncCamera::GetCameraLength( void ) { + return wait; +} + +void ncCamera::ResetCamera( void ) { + health = 0.0f; +} + +float ncCamera::GetCameraTime( void ) { + return health; +} + +void ncCamera::PreThink( void ) { + health += frametime; +} + +void ncCamera::CamTrigger( ncEntity activatorEntity, triggerstate_t triggerFlag ) { + ResetCamera(); + activatorEntity.inCamera = this; /* assign us to be their camera */ + + //ncPlayer pl = (ncPlayer)activatorEntity; + //ncFX::CastDamageScreen( pl, 0, 5, GetOrigin() ); +} + +float ncCamera::GetCameraAcceleration( camAcceleration_t accel_type ) { + float cameraTime = GetCameraTime() / GetCameraLength(); + float testTime; + + switch (accel_type) { + case CAMACCELERATION_SINE: + testTime = ncMath::Lerp(-MATH_HALF_PI, MATH_HALF_PI, cameraTime); + cameraTime = ncMath::Sin(testTime); + cameraTime *= 0.5; + cameraTime += 0.5f; + break; + case CAMACCELERATION_COS: + testTime = ncMath::Lerp(-MATH_HALF_PI, MATH_HALF_PI, cameraTime); + cameraTime = ncMath::Cos(testTime - MATH_PI) + (MATH_PI / 3); + break; + case CAMACCELERATION_LINEAR: + default: + break; + } + + cameraTime = ncMath::Clamp(0.0, 1.0, cameraTime); + return cameraTime; +} + +vector ncCamera::GetCameraAngles( void ) { + ncEntity nextCam = GetNextCamera(); + vector position1 = angles; + vector position2 = nextCam.GetAngles(); + vector position3; + vector position4; + vector newAngle; + float cameraTime = GetCameraAcceleration(accel_angle); + + ncMath::MakeVectors(position1); + position1 = v_forward; + ncMath::MakeVectors(position2); + position2 = v_forward; + + switch (lerp_angle) { + case CAMINTERPOLATION_LINEAR: + newAngle[0] = ncMath::Lerp(position1[0], position2[0], cameraTime); + newAngle[1] = ncMath::Lerp(position1[1], position2[1], cameraTime); + newAngle[2] = ncMath::Lerp(position1[2], position2[2], cameraTime); + break; + case CAMINTERPOLATION_QUADRATIC: + /* skew things just a little */ + position3[0] = ncMath::Lerp(position1[0], position2[0], 0.25f); + position3[1] = ncMath::Lerp(position1[1], position2[1], 0.5f); + position3[2] = ncMath::Lerp(position1[2], position2[2], 0.75f); + + newAngle[0] = ncMath::LerpQ(position1[0], position3[0], position2[0], cameraTime); + newAngle[1] = ncMath::LerpQ(position1[1], position3[1], position2[1], cameraTime); + newAngle[2] = ncMath::LerpQ(position1[2], position3[2], position2[2], cameraTime); + break; + case CAMINTERPOLATION_CUBIC: + position3[0] = ncMath::Lerp(position1[0], position2[0], 0.4f); + position3[1] = ncMath::Lerp(position1[1], position2[1], 0.4f); + position3[2] = ncMath::Lerp(position1[2], position2[2], 0.4f); + + position4[0] = ncMath::Lerp(position1[0], position2[0], 0.6f); + position4[1] = ncMath::Lerp(position1[1], position2[1], 0.6f); + position4[2] = ncMath::Lerp(position1[2], position2[2], 0.6f); + + newAngle[0] = ncMath::LerpC(position1[0], position3[0], position4[0], position2[0], cameraTime); + newAngle[1] = ncMath::LerpC(position1[1], position3[1], position4[1], position2[1], cameraTime); + newAngle[2] = ncMath::LerpC(position1[2], position3[2], position4[2], position2[2], cameraTime); + break; + } + + newAngle = ncMath::VecToAngles(newAngle); + +#if 1 + newAngle[0] = ncMath::Rint(newAngle[0]); + newAngle[1] = ncMath::Rint(newAngle[1]); + newAngle[2] = ncMath::Rint(newAngle[2]); +#endif + return newAngle; +} + +vector ncCamera::GetCameraOrigin( void ) { + ncEntity nextCam = GetNextCamera(); + vector position1 = GetOrigin(); + vector position2 = nextCam.GetOrigin(); + vector position3; + vector position4; + vector pushDiff; + vector newOrigin; + float pushLength; + float cameraDist = ncMath::VLen(position1 - position2); + float cameraTime = GetCameraAcceleration(accel_origin); + + switch (lerp_origin) { + case CAMINTERPOLATION_LINEAR: + newOrigin[0] = ncMath::Lerp(position1[0], position2[0], cameraTime); + newOrigin[1] = ncMath::Lerp(position1[1], position2[1], cameraTime); + newOrigin[2] = ncMath::Lerp(position1[2], position2[2], cameraTime); + break; + case CAMINTERPOLATION_QUADRATIC: + position3[0] = ncMath::Lerp(position1[0], position2[0], 0.5f); + position3[1] = ncMath::Lerp(position1[1], position2[1], 0.5f); + position3[2] = ncMath::Lerp(position1[2], position2[2], 0.5f); + + ncMath::MakeVectors(position3); + pushLength = ncMath::Sqrt(cameraDist); + pushDiff = v_forward * -pushLength; + position3 += pushDiff; + + newOrigin[0] = ncMath::LerpQ(position1[0], position3[0], position2[0], cameraTime); + newOrigin[1] = ncMath::LerpQ(position1[1], position3[1], position2[1], cameraTime); + newOrigin[2] = ncMath::LerpQ(position1[2], position3[2], position2[2], cameraTime); + break; + case CAMINTERPOLATION_CUBIC: + position3[0] = ncMath::Lerp(position1[0], position2[0], 0.25f); + position3[1] = ncMath::Lerp(position1[1], position2[1], 0.25f); + position3[2] = ncMath::Lerp(position1[2], position2[2], 0.25f); + + position4[0] = ncMath::Lerp(position1[0], position2[0], 0.75f); + position4[1] = ncMath::Lerp(position1[1], position2[1], 0.75f); + position4[2] = ncMath::Lerp(position1[2], position2[2], 0.75f); + + pushDiff[0] = ncMath::Lerp(position1[0], position2[0], 0.5f); + pushDiff[1] = ncMath::Lerp(position1[1], position2[1], 0.5f); + pushDiff[2] = ncMath::Lerp(position1[2], position2[2], 0.5f); + + ncMath::MakeVectors(pushDiff); + pushLength = ncMath::Sqrt(cameraDist); + pushDiff = v_forward * -pushLength; + position3 += pushDiff; + position4 += pushDiff; + + newOrigin[0] = ncMath::LerpC(position1[0], position3[0], position4[0], position2[0], cameraTime); + newOrigin[1] = ncMath::LerpC(position1[1], position3[1], position4[1], position2[1], cameraTime); + newOrigin[2] = ncMath::LerpC(position1[2], position3[2], position4[2], position2[2], cameraTime); + break; + } + +#if 1 + newOrigin[0] = ncMath::Rint(newOrigin[0]); + newOrigin[1] = ncMath::Rint(newOrigin[1]); + newOrigin[2] = ncMath::Rint(newOrigin[2]); +#endif + return newOrigin; +} + +float ncCamera::GetCameraFOV( void ) { + ncEntity nextCam = GetNextCamera(); + float fov1 = fov; + float fov2 = nextCam.fov; + float cameraTime = GetCameraAcceleration(accel_angle); + + return ncMath::Lerp(fov1, fov2, cameraTime); +} + +ncCamera ncCamera::GetNextCamera( void ) { + return ncEngine::Find( (ncEntity) world, ::targetname, next); +} + +ncCamera ncCamera::GetLastCamera( void ) { + return ncEngine::Find( (ncEntity) world, ::next, targetname); +} + +ncCamera ncCamera::GetVeryNextCamera( void ) { + ncCamera nextCamera = GetNextCamera(); + return ncEngine::Find( (ncEntity) world, ::targetname, nextCamera.next); +} \ No newline at end of file diff --git a/src/system/ncCamera.qh b/src/system/ncCamera.qh new file mode 100644 index 0000000..9b4c564 --- /dev/null +++ b/src/system/ncCamera.qh @@ -0,0 +1,40 @@ + + +typedef enum +{ + CAMINTERPOLATION_LINEAR, /**< linear interpolation */ + CAMINTERPOLATION_QUADRATIC, /**< quadratic, between 3 points */ + CAMINTERPOLATION_CUBIC, /**< cubic, between 4 points */ +} camInterpolation_t; + +typedef enum +{ + CAMACCELERATION_LINEAR, /**< linear progression */ + CAMACCELERATION_SINE, /**< slow - fast - slow accel */ + CAMACCELERATION_COS, /**< fast - slow - fast accel */ +} camAcceleration_t; + +class ncCamera:ncEntity { + void ncCamera( void ); + + virtual void CamTrigger( ncEntity, triggerstate_t ); + + nonvirtual float GetCameraTime( void ); + nonvirtual float GetCameraLength( void ); + + nonvirtual float GetCameraFOV( void ); + nonvirtual vector GetCameraOrigin( void ); + nonvirtual vector GetCameraAngles( void ); + nonvirtual ncCamera GetNextCamera( void ); + + nonvirtual ncCamera GetLastCamera( void ); + nonvirtual ncCamera GetVeryNextCamera( void ); + + nonvirtual float GetCameraAcceleration(camAcceleration_t); + + nonvirtual void ResetCamera( void ); + virtual void PreThink( void ); + +}; + +.ncCamera inCamera; \ No newline at end of file diff --git a/src/system/ncEngine.qc b/src/system/ncEngine.qc new file mode 100644 index 0000000..c9e1d47 --- /dev/null +++ b/src/system/ncEngine.qc @@ -0,0 +1,139 @@ +/* we include this here so the rest of the codebase won't be able to call them */ +#include "../builtins.qh" + +void ncEngine::Break( void ) { + break (); +} + +void ncEngine::Error( string e ) { + error( e ); +} + +void ncEngine::ObjError( string e ) { + objerror( e ); +} + +ncEntity ncEngine::Spawn( void ) { + return spawn(); +} + +void ncEngine::TraceLine( vector v1, vector v2, float nomonsters, ncEntity forent ) { + traceline( v1, v2, nomonsters, forent ); +} + +ncEntity ncEngine::Find( ncEntity start, .string fld, string match ) { + return find( start, ::fld, match ); +} + +string ncEngine::Precache_Sound( string s ) { + return precache_sound( s ); +} + +string ncEngine::Precache_Model( string s ) { + return precache_model( s ); +} +ncEntity ncEngine::FindRadius( vector org, float rad ) { + return findradius( org, rad ); +} + +void ncEngine::BPrint( print_t level, string s ) { +#ifdef TARGET_QUAKEWORLD + bprint( level, s ); +#else + bprint( s ); +#endif +} + +void ncEngine::DPrint( string s ) { + dprint( s ); +} + +string ncEngine::FloatToString( float f ) { + return ftos( f ); +} + +string ncEngine::VectorToString( vector v ) { + return vtos( v ); +} + +void ncEngine::CoreDump( void ) { + coredump(); +} + +void ncEngine::TraceOn( void ) { + traceon(); +} + +void ncEngine::TraceOff( void ) { + traceoff(); +} + +float ncEngine::PointContents( vector v ) { + return pointcontents( v ); +} + + +float ncEngine::CVar( string s ) { + return cvar( s ); +} + +void ncEngine::LocalCmd( string s ) { + localcmd( s ); +} + +ncEntity ncEngine::NextEnt( ncEntity e ) { + return nextent( e ); +} + +string ncEngine::Precache_File( string s ) { + return precache_file( s ); +} + +string ncEngine::Precache_File2( string s ) { + return precache_file2( s ); +} + +void ncEngine::ChangeLevel( string s ) { +#ifdef TARGET_HEXEN2 + changelevel( s, "" ); +#else + changelevel( s ); +#endif +} + +void ncEngine::CVarSet( string variable, string val ) { + cvar_set( variable, val ); +} + +void ncEngine::AmbientSound( vector pos, string samp, float vol, float atten ) { + ambientsound( pos, samp, vol, atten ); +} + +void ncEngine::SetSpawnParms( ncEntity e ) { + setspawnparms( e ); +} + +float ncEngine::StringToFloat( string s ) { +#ifdef TARGET_QUAKEWORLD + return stof(s); +#else + return 0.0f; +#endif +} + +float ncEngine::NumForEdict( ncEntity targetEnt ) { + /* this requires denormals, may not work on custom engines */ + return (float)(__variant)targetEnt / (float)(__variant)nextent(world); +} + +ncEntity ncEngine::EdictForNum( float targetNum ) { + ncEntity e = ( ncEntity ) world; + + while ( ( e = NextEnt( e ) ) ) { + if ( NumForEdict( e ) == targetNum ) + return (e); + } + + Error( "ncEngine::EdictForNum: edict not found\n" ); + return __NULL__; +} diff --git a/src/system/ncEngine.qh b/src/system/ncEngine.qh new file mode 100644 index 0000000..9738d9a --- /dev/null +++ b/src/system/ncEngine.qh @@ -0,0 +1,41 @@ +class ncEngine { + nonvirtual void Break( void ); + nonvirtual void Error( string e ); + nonvirtual void ObjError( string e ); + nonvirtual ncEntity Spawn( void ); + nonvirtual void TraceLine( vector v1, vector v2, float nomonsters, ncEntity forent ); + nonvirtual ncEntity Find( ncEntity start,.string fld, string match ); + nonvirtual string Precache_Sound( string s ); + nonvirtual string Precache_Model( string s ); + nonvirtual ncEntity FindRadius( vector org, float rad ); + nonvirtual void BPrint( print_t level, string s ); + nonvirtual void DPrint( string s ); + nonvirtual string FloatToString( float f ); + nonvirtual string VectorToString( vector v ); + nonvirtual void CoreDump( void ); + nonvirtual void TraceOn( void ); + nonvirtual void TraceOff( void ); + nonvirtual float PointContents( vector v ); + nonvirtual float CVar( string s ); + nonvirtual void LocalCmd( string s ); + nonvirtual ncEntity NextEnt( ncEntity e ); + nonvirtual string Precache_File( string s ); + nonvirtual string Precache_File2( string s ); + nonvirtual void ChangeLevel( string s ); + nonvirtual void CVarSet( string var, string val ); + nonvirtual void AmbientSound( vector pos, string samp, float vol, float atten ); + nonvirtual void SetSpawnParms( ncEntity e ); + + /* natively implemented by QuakeWorld */ + nonvirtual float StringToFloat( string s ); + + /* custom builtins that we can do within QC */ + virtual float NumForEdict( ncEntity targetEnt ); + virtual ncEntity EdictForNum( float targetNum ); +}; + +#define LINK_ENTITY_TO_CLASS(cname,classa) void cname(void) { spawnfunc_##classa(); } + +.void( ncEntity ) TouchCallback; +.void( ncEntity ) BlockedCallback; +.void( ncEntity, triggerstate_t ) TriggerCallback; \ No newline at end of file diff --git a/src/system/ncEntity.qc b/src/system/ncEntity.qc new file mode 100644 index 0000000..7fccc14 --- /dev/null +++ b/src/system/ncEntity.qc @@ -0,0 +1,748 @@ +.float real_health; +.float real_max_health; +.float real_armorvalue; + +void ncEntity::ncEntity( void ) { + isIdEntity = true; + real_health = 0; + real_max_health = 100; + + if (g_world_initialized == false) { + Precache(); + } + _InternalPreSpawn(); + Spawn(); + _InternalPostSpawn(); +} + +void ncEntity::Precache( void ) { +} + +void ncEntity::_InternalPreSpawn( void ) { +} + +void ncEntity::_InternalPostSpawn( void ) { +} + +void ncEntity::Spawn( void ) { +} + +void ncEntity::Death( void ) { +} + +void ncEntity::Pain( void ) { +} + +void ncEntity::PreThink( void ) { +} + +void ncEntity::Trigger( ncEntity activatorEntity, triggerstate_t triggerType ) { + TriggerCallback(activatorEntity, triggerType); +} + +/* set functions */ +void ncEntity::SetModelindex( float value ) { + modelindex = value; +} + +void ncEntity::SetMovetype( movetype_t value ) { + movetype = value; +} + +void ncEntity::SetSolid( solid_t value ) { + solid = value; +} + +void ncEntity::SetOrigin( vector value ) { + setorigin( this, value ); +} + +void ncEntity::SetVelocity( vector value ) { + velocity = value; +} + +void ncEntity::SetAngles( vector value ) { + angles = value; +} + +void ncEntity::ClearAngles( void ) { + avelocity = [0,0,0]; + angles = [0,0,0]; +} + +void ncEntity::SetAngularVelocity( vector value ) { + avelocity = value; +} + +void ncEntity::SetPunchangle( vector value ) { +#ifndef TARGET_QUAKEWORLD + punchangle = value; +#endif +} + +void ncEntity::SetModel( string value ) { + setmodel( this, value ); +} + +void ncEntity::SetFrame( float value ) { + frame = value; +} + +void ncEntity::SetSkin( float value ) { + skin = value; +} + +void ncEntity::AddEffect( effects_t value ) { + effects |= value; +} + +void ncEntity::RemoveEffect( effects_t value ) { + effects &= ~value; +} + +void ncEntity::ClearEffects( void ) { + effects = 0; +} + +void ncEntity::SetSize( vector min, vector max ) { + setsize( this, min, max ); +} + +void ncEntity::SetHealth( float value ) { + real_health = value; + + if ( real_health > real_max_health ) + real_health = real_max_health; +} + +void ncEntity::AddFrags( float value ) { + frags += value; +} + +void ncEntity::RemoveFrags( float value ) { + frags -= value; +} + +void ncEntity::ClearFrags( void ) { + frags = 0; +} + +void ncEntity::SetTakedamage( damage_t value ) { + takedamage = value; +} + +void ncEntity::SetDeadFlag( dead_t value ) { + deadflag = value; +} + +void ncEntity::SetViewOffset( vector value ) { + view_ofs = value; +} + +void ncEntity::ForceUpdateClientAngle( void ) { + fixangle = 1; +} + +void ncEntity::AddFlags( flags_t value ) { + flags |= value; +} + +void ncEntity::RemoveFlags( flags_t value ) { + flags &= ~value; +} + +void ncEntity::ClearFlags( void ) { + flags = 0; +} + +void ncEntity::SetColormap( float value ) { + colormap = value; +} + +void ncEntity::SetDisplayname( string value ) { + netname = value; +} + +void ncEntity::SetMaxHealth( float value ) { + real_max_health = value; +} + +void ncEntity::SetArmorType( float value ) { + armortype = value; +} + +void ncEntity::SetArmor( float value ) { + real_armorvalue = value; +} + +void ncEntity::SetAimEntity( entity value ) { +#ifndef TARGET_HEXEN2 + aiment = value; +#endif +} + +void ncEntity::SetGoalEntity( entity value ) { + goalentity = value; +} + +void ncEntity::SetTarget( string value ) { + target = value; +} + +void ncEntity::SetTargetname( string value ) { + targetname = value; +} + +void ncEntity::SetOwner( entity value ) { + owner = value; +} + +void ncEntity::SetMovementDirection( vector value ) { + movedir = value; +} + +void ncEntity::SetTriggerMessage( string value ) { +#ifndef TARGET_HEXEN2 + message = value; +#endif +} + +void ncEntity::SetSoundStyle( float value ) { +#ifndef TARGET_HEXEN2 + sounds = value; +#endif +} + +void ncEntity::SetNoiseValue1( string value ) { + noise = value; +} + +void ncEntity::SetNoiseValue2( string value ) { + noise1 = value; +} + +void ncEntity::SetNoiseValue3( string value ) { + noise2 = value; +} + +void ncEntity::SetNoiseValue4( string value ) { + noise3 = value; +} + +void ncEntity::SetTouchCallback( void( ncEntity ) callback ) { + /* give this entity a touch, this is for the engine only */ + touch = _TouchWrapper; + /* this is the touch function we'll be calling whenever the entity really gets touched */ + TouchCallback = callback; +} + +void ncEntity::_TouchWrapper( void ) { + TouchCallback( ( ncEntity) other ); +} + +void ncEntity::SetBlockedCallback( void( ncEntity ) callback ) { + blocked = _BlockedWrapper; + BlockedCallback = callback; +} + +void ncEntity:: _BlockedWrapper( void ) { + BlockedCallback( ( ncEntity) other ); +} + +void ncEntity::SetTriggerCallback( void( ncEntity, triggerstate_t ) callback ) { + TriggerCallback = callback; +} + +/* get functions */ +float ncEntity::GetModelindex( void ) { + return modelindex; +} + +movetype_t ncEntity::GetMovetype( void ) { + return ( movetype_t ) movetype; +} + +solid_t ncEntity::GetSolid( void ) { + return ( solid_t ) solid; +} + +vector ncEntity::GetOrigin( void ) { + return origin; +} + +vector ncEntity::GetVelocity( void ) { + return velocity; +} + +vector ncEntity::GetAngles( void ) { + return angles; +} + +vector ncEntity::GetAngularVelocity( void ) { + return avelocity; +} + +vector ncEntity::GetPunchangle( void ) { +#ifndef TARGET_QUAKEWORLD + return punchangle; +#else + return [0.0, 0.0, 0.0]; +#endif +} + +string ncEntity::GetModel( void ) { + return model; +} + +float ncEntity::GetFrame( void ) { + return frame; +} + +float ncEntity::GetSkin( void ) { + return skin; +} + +bool ncEntity::HasEffect( effects_t value ) { + return ( effects & value ) ? 1 : 0; +} + +vector ncEntity::GetSize( void ) { + return size; +} + +float ncEntity::GetHealth( void ) { + return real_health; +} + +float ncEntity::GetFrags( void ) { + return frags; +} + +float ncEntity::GetWeapon( void ) { + return weapon; +} + +string ncEntity::GetWeaponmodel( void ) { + return weaponmodel; +} + +float ncEntity::GetWeaponframe( void ) { + return weaponframe; +} + +float ncEntity::GetCurrentAmmo( void ) { +#ifndef TARGET_HEXEN2 + return currentammo; +#endif +} + +float ncEntity::GetAmmoType1( void ) { +#ifndef TARGET_HEXEN2 + return ammo_shells; +#endif +} + +float ncEntity::GetAmmoType2( void ) { +#ifndef TARGET_HEXEN2 + return ammo_nails; +#endif +} + +float ncEntity::GetAmmoType3( void ) { +#ifndef TARGET_HEXEN2 + return ammo_rockets; +#endif +} + +float ncEntity::GetAmmoType4( void ) { +#ifndef TARGET_HEXEN2 + return ammo_cells; +#endif +} + +bool ncEntity::CanTakeDamage( void ) { + return ( takedamage != DAMAGE_NO ) ? TRUE : FALSE; +} + +dead_t ncEntity::GetDeadFlag( void ) { + return (dead_t)deadflag; +} + +vector ncEntity::GetViewOffset( void ) { + return view_ofs; +} + +bool ncEntity::HasFlag( flags_t value ) { + return ( flags & value ) ? 1 : 0; +} + +float ncEntity::GetColormap( void ) { + return colormap; +} + +string ncEntity::GetDisplayname( void ) { + return netname; +} + +float ncEntity::GetMaxHealth( void ) { + return real_max_health; +} + +float ncEntity::GetArmorType( void ) { + return armortype; +} + +float ncEntity::GetArmor( void ) { + return real_armorvalue; +} + +entity ncEntity::GetAimEntity( void ) { +#ifndef TARGET_HEXEN2 + return aiment; +#endif +} + +entity ncEntity::GetGoalEntity( void ) { + return goalentity; +} + +string ncEntity::GetTarget( void ) { + return target; +} + +string ncEntity::GetTargetname( void ) { + return targetname; +} + +entity ncEntity::GetOwner( void ) { + return owner; +} + +vector ncEntity::GetMovementDirection( void ) { + return movedir; +} + +string ncEntity::GetTriggerMessage( void ) { +#ifndef TARGET_HEXEN2 + return message; +#endif +} + +float ncEntity::GetSoundStyle( void ) { +#ifndef TARGET_HEXEN2 + return sounds; +#endif +} + +string ncEntity::GetNoiseValue1( void ) { + return noise; +} + +string ncEntity::GetNoiseValue2( void ) { + return noise1; +} + +string ncEntity::GetNoiseValue3( void ) { + return noise2; +} + +string ncEntity::GetNoiseValue4( void ) { + return noise3; +} + +bool ncEntity::IsPlayer( void ) { + return HasFlag(FL_CLIENT); +} + +bool ncEntity::IsActor( void ) { + return HasFlag(FL_MONSTER); +} + +bool ncEntity::IsWorld( void ) { + if (this == world) + return TRUE; + else + return FALSE; +} + +bool ncEntity::IsBelowEntity( ncEntity testEnt ) { + if (absmax[2] <= testEnt.absmin[2] ) { + return true; + } + + return false; +} + +bool ncEntity::IsAboveEntity( ncEntity testEnt ) { + if ( absmin[2] >= testEnt.absmax[2] ) { + return true; + } + + return false; +} + +bool ncEntity::HasSpawnFlags( float flags ) { + return ( spawnflags & flags ) ? true : false; +} + +/* misc helper methods */ +void ncEntity::InitTrigger( void ) { + SetSolid(SOLID_TRIGGER); + SetModel(GetModel()); + SetMovetype(MOVETYPE_NONE); + SetModelindex(0); +} + +void ncEntity::Transport( vector newPosition, vector newAngle, bool retainVelocity ) { + + if (retainVelocity == true) { + float flSpeed = ncMath::VLen(this.GetVelocity()); + ncMath::MakeVectors(newAngle); + SetVelocity(v_forward * flSpeed); + } else { + SetVelocity([0,0,0]); + } + + SetOrigin(newPosition); + SetAngles(newAngle); + ForceUpdateClientAngle(); +} + +ncEntity ncEntity::FindFirstTarget( void ) { + ncEntity result; + result = ncEngine::Find( (ncEntity) world, ::targetname, target); + return (result == world) ? __NULL__ : result; +} + +void ncEntity::ClearVelocity( void ) { + velocity = g_vec_null; + avelocity = g_vec_null; +} + +float ncEntity::GetTime(void) +{ + return (movetype == MOVETYPE_PUSH) ? ltime : time; +} + +void ncEntity::ReleaseThink( void ) { + think = __NULL__; + nextthink = 0.0f; +} + +void ncEntity::SetThink( void ( void ) func ) { + think = func; +} + +void ncEntity::SetNextThink( float fl ) { + float flTime = GetTime() + fl; + + /* HACK: to make sure things happen post-spawn */ + if ( flTime == 0.0f ) + flTime = 0.1f; + + if ( flTime >= 0 ) + nextthink = flTime; +} + +void ncEntity::ScheduleThink( void ( void ) func, float fl ) { + SetThink( func ); + SetNextThink( fl ); +} + +/* this is where Hexen 2 specific methods begin. They will be mostly stubbed */ +void ncEntity::SetScale( float modelScale ) { +#ifdef TARGET_HEXEN2 + scale = modelScale; +#endif +} + +float ncEntity::GetScale( void ) { +#ifdef TARGET_HEXEN2 + return scale; +#else + return 1.0f; +#endif +} + +void ncEntity::SetScaleOrigin( scaleOrigin_t scaleOrg ) { +#ifdef TARGET_HEXEN2 + drawflags &= ~SCALE_ORIGIN_MASKOUT; + + switch ( scaleOrg ) { + case SCALEORIGIN_CENTER: + drawflags |= SCALE_ORIGIN_CENTER; + break; + case SCALEORIGIN_BOTTOM: + drawflags |= SCALE_ORIGIN_BOTTOM; + break; + case SCALEORIGIN_TOP: + drawflags |= SCALE_ORIGIN_TOP; + break; + } +#endif +} + +scaleOrigin_t ncEntity::GetScaleOrigin( void ) { +#ifdef TARGET_HEXEN2 + if (drawflags & SCALE_ORIGIN_BOTTOM) + return SCALEORIGIN_BOTTOM; + else if (drawflags & SCALE_ORIGIN_TOP) + return SCALEORIGIN_TOP; + else + return SCALEORIGIN_CENTER; +#else + return SCALEORIGIN_CENTER; +#endif +} + +void ncEntity::SetAbsoluteLightlevel( float lightLevel ) { +#ifdef TARGET_HEXEN2 + if (lightLevel == -1.0) { + drawflags &= MLS_ABSLIGHT; + abslight = 0.0; + } + + drawflags |= MLS_ABSLIGHT; + abslight = lightLevel; +#endif +} + +float ncEntity::GetAbsoluteLightlevel( void ) { +#ifdef TARGET_HEXEN2 + if (drawflags & MLS_ABSLIGHT) + return abslight; +#endif + + return -1.0; +} + +void ncEntity::SetTranslucency( bool value ) { +#ifdef TARGET_HEXEN2 + if (value) + drawflags |= DRF_TRANSLUCENT; + else + drawflags &= DRF_TRANSLUCENT; +#endif +} + +bool ncEntity::IsTranslucent( void ) { +#ifdef TARGET_HEXEN2 + return ( drawflags & DRF_TRANSLUCENT ) ? true : false; +#else + return false; +#endif +} + +void ncEntity::Sound( float chan, string samp, float vol, float atten ) { + sound( this, chan, samp, vol, atten ); +} + +void ncEntity::StopSound( float channel ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_STOPSOUND ); + ncNet::WriteShort( FX_MSGTYPE, channel ); + ncNet::MultiCast( GetOrigin(), MULTICAST_PHS_R ); +} + +void ncEntity::SPrint( print_t level, string s ) { +#ifdef TARGET_QUAKEWORLD + sprint( this, level, s ); +#else + sprint( this, s ); +#endif +} + +void ncEntity::EPrint( void ) { + eprint( this ); +} + +float ncEntity::CheckBottom( void ) { + return checkbottom( this ); +} + +vector ncEntity::Aim( float speed ) { + return aim( this, speed ); +} + +void ncEntity::MakeStatic( void ) { + makestatic( this ); +} + +void ncEntity::CenterPrint( string s ) { + centerprint( this, s ); +} + +bool ncEntity::DropToFloor( void ) { + return droptofloor() ? true : false; +} + +void ncEntity::Remove( void ) { + remove( this ); +} + +float ncEntity::WalkMove( float yaw, float dist ) { + return walkmove( yaw, dist ); +} + +void ncEntity::ChangeYaw( void ) { +#ifndef TARGET_QUAKEWORLD + changeyaw(); +#endif +} + +void ncEntity::MoveToGoal( float step ) { + movetogoal( step ); +} + +ncEntity ncEntity::CheckClient( void ) { + return checkclient(); +} + +bool ncEntity::WithinBounds( ncEntity check ) { + if not ( check.absmin[0] >= absmin[0] && check.absmax[0] <= absmax[0] ) + return ( false ); + if not ( check.absmin[1] >= absmin[1] && check.absmax[1] <= absmax[1] ) + return ( false ); + if not ( check.absmin[2] >= absmin[2] && check.absmax[2] <= absmax[2] ) + return ( false ); + + return ( true ); +} + +void ncEntity::TriggerTargets( ncEntity activator, triggerstate_t triggertype ) +{ + string targetIdent = GetTarget(); + + /* trigger all targets */ + if (targetIdent) { + for ( ncEntity a = ( ncEntity) world; ( a = ( ncEntity )find( a, ::targetname, targetIdent ) ); ) { + + if ( a.Trigger ) { + a.Trigger(activator, triggertype); + } + } + } + + /* kill all killtargets */ + if (killtarget) { + for ( ncEntity a = ( ncEntity) world; ( a = ( ncEntity )find( a, ::targetname, killtarget ) ); ) { + remove(a); + } + } +} + +/* weapon logic */ +.ncItem currentweapon; +.float next_primary_attack; +void ncEntity::PrimaryAttack( ncEntity carrier ) { + + if (next_primary_attack > time) { + return; + } + + currentweapon.PrimaryAttack(carrier); +} + +void ncEntity::SetNextPrimaryAttack(float attackDelay) +{ + next_primary_attack = time + attackDelay; +} \ No newline at end of file diff --git a/src/system/idEntity.qh b/src/system/ncEntity.qh similarity index 79% rename from src/system/idEntity.qh rename to src/system/ncEntity.qh index 6c2d3bb..d5be39c 100644 --- a/src/system/idEntity.qh +++ b/src/system/ncEntity.qh @@ -5,9 +5,27 @@ typedef enum SCALEORIGIN_TOP } scaleOrigin_t; -class idEntity { +.void( void ) Precache; +.void( void ) Spawn; +.void( void ) Death; +.void( void ) Pain; +.void( void ) PreThink; + + +typedef enum +{ + TRIGGERSTATE_AUTO, /**< default trigger state, toggle */ + TRIGGERSTATE_OFF, /**< trigger entity into 'off' mode, often means closed. */ + TRIGGERSTATE_ON, /**<< trigger entit into 'on' mode, often means open. */ +} triggerstate_t; + +.float trigger_next; +.triggerstate_t triggerstate; +.string killtarget; + +class ncEntity { public: - void idEntity( void ); + void ncEntity( void ); /* core engine tracked fields */ @@ -23,6 +41,8 @@ public: nonvirtual void SetVelocity( vector ); /** Sets the angles the direction is facing via euler angles. */ nonvirtual void SetAngles( vector ); + /** Clears the angle and angularvelocity attributes. */ + nonvirtual void ClearAngles( void ); /** Sets the angular velocity of the entity at units-per-second per axis. */ nonvirtual void SetAngularVelocity( vector ); /** Sets the punchangle of the entity (players only) */ @@ -64,22 +84,7 @@ public: nonvirtual void RemoveFrags( float ); /** Removes all frags. Should be called when they enter the game anew. */ nonvirtual void ClearFrags( void ); - /** Sets the active weapon of the entity. */ - nonvirtual void SetWeapon( float ); - /** Sets the active weapon model of the entity. */ - nonvirtual void SetWeaponmodel( string ); - /** Sets the active weapon model frame group of the entity. */ - nonvirtual void SetWeaponframe( float ); - /** Sets what the currently selected ammo on the heads up display. */ - nonvirtual void SetCurrentAmmo( float ); - /** Sets the value for ammo type 1. */ - nonvirtual void SetAmmoType1( float ); - /** Sets the value for ammo type 2. */ - nonvirtual void SetAmmoType2( float ); - /** Sets the value for ammo type 3. */ - nonvirtual void SetAmmoType3( float ); - /** Sets the value for ammo type 4. */ - nonvirtual void SetAmmoType4( float ); + /** TODO: This needs to be changed. */ nonvirtual void SetTakedamage( damage_t ); /** Sets the dead_t state */ @@ -125,9 +130,14 @@ public: nonvirtual void SetNoiseValue3( string ); nonvirtual void SetNoiseValue4( string ); - nonvirtual void SetTouchCallback( void( idEntity ) callback ); + nonvirtual void SetTouchCallback( void( ncEntity ) callback ); nonvirtual void _TouchWrapper( void ); + nonvirtual void SetBlockedCallback( void( ncEntity ) callback ); + nonvirtual void _BlockedWrapper( void ); + + nonvirtual void SetTriggerCallback( void( ncEntity, triggerstate_t ) callback ); + /** Returns the model id of the entity. */ nonvirtual float GetModelindex( void ); /** Returns the movetype of the entity. */ @@ -212,7 +222,6 @@ public: nonvirtual string GetNoiseValue2( void ); nonvirtual string GetNoiseValue3( void ); nonvirtual string GetNoiseValue4( void ); - nonvirtual string GetInfoKey( string ); /** Sets the model scale of the entity, normalized value. 1.0 being normal size. */ nonvirtual void SetScale( float ); @@ -222,24 +231,58 @@ public: nonvirtual void SetScaleOrigin( scaleOrigin_t ); /** Returns the origin at which the model scales. See scaleOrigin_t for types. */ nonvirtual scaleOrigin_t GetScaleOrigin( void ); + /** Sets the absolute light level of the entity. Pass -1 to return to normal lighting. */ + nonvirtual void SetAbsoluteLightlevel( float ); + /** Returns the current absolute light level of the entity. Returns -1 when dynamic/normal lighting is being used on the entity. */ + nonvirtual float GetAbsoluteLightlevel( void ); - /** Returns true/false whether this idEntity is a player. */ + /** Sets whether the entity is translucent or not. */ + nonvirtual void SetTranslucency( bool ); + nonvirtual bool IsTranslucent( void ); + + /** Returns true/false whether this ncEntity is a player. */ nonvirtual bool IsPlayer( void ); - /** Returns true/false whether this idEntity is an actor. */ + /** Returns true/false whether this ncEntity is an actor. */ nonvirtual bool IsActor( void ); - /** Returns true/false whether this idEntity is part of the world. */ + /** Returns true/false whether this ncEntity is part of the world. */ nonvirtual bool IsWorld( void ); + /** Returns true/false whether this ncEntity started with certain spawn flags. */ + nonvirtual bool HasSpawnFlags( float ); + + nonvirtual bool IsBelowEntity( ncEntity ); + nonvirtual bool IsAboveEntity( ncEntity ); + + nonvirtual bool WithinBounds( ncEntity check ); /** Will turn the entity into an invisible trigger. */ nonvirtual void InitTrigger( void ); /** Will transport the entity to a given position, facing a specific angle while retaining the original velocity if desired. */ nonvirtual void Transport( vector, vector, bool ); /** Will return an entity handle of the first entity it finds that was named after SetTarget() 'ing it. */ - nonvirtual idEntity FindFirstTarget( void ); + nonvirtual ncEntity FindFirstTarget( void ); + nonvirtual void Trigger( ncEntity, triggerstate_t ); nonvirtual float GetTime( void ); nonvirtual void ClearVelocity( void ); + nonvirtual void Sound( float chan, string samp, float vol, float atten ); + nonvirtual void StopSound( float chan ); + nonvirtual void SPrint( print_t level, string s ); + nonvirtual void EPrint( void ); + nonvirtual float CheckBottom( void ); + nonvirtual vector Aim( float speed ); + nonvirtual void MakeStatic( void ); + nonvirtual void CenterPrint( string s ); + nonvirtual bool DropToFloor( void ); + nonvirtual void Remove( void ); + nonvirtual float WalkMove( float yaw, float dist ); + nonvirtual void ChangeYaw( void ); + nonvirtual void MoveToGoal( float step ); + nonvirtual ncEntity CheckClient( void ); + + /** Trigger all targets with their `targetname` set as the entity it's `target`. */ + nonvirtual void TriggerTargets( ncEntity, triggerstate_t ); + /** Overridable: When the entity has initialized, it will execute this method. */ virtual void Spawn( void ); /** Overridable: When the entity spawns on level-load, execute this method. */ @@ -249,9 +292,17 @@ public: /** Overridable: Called when the entity felt pain. Only valid when the entity has health and can take damage. See SetTakedamage() and SetHealth(), as well as SetMaxHealth(). */ virtual void Pain( void ); + virtual void PreThink( void ); + + virtual void PrimaryAttack( ncEntity ); + nonvirtual void SetNextPrimaryAttack( float ); + private: virtual void _InternalPreSpawn( void ); virtual void _InternalPostSpawn( void ); }; -var bool g_world_initialized; \ No newline at end of file +var bool g_world_initialized; +.bool isIdEntity; + +#define SPAWNDEFAULT(x,y) if (x == 0) { x = y; } \ No newline at end of file diff --git a/src/system/ncFX.qc b/src/system/ncFX.qc new file mode 100644 index 0000000..9101926 --- /dev/null +++ b/src/system/ncFX.qc @@ -0,0 +1,193 @@ +void ncFX::Particle( vector o, vector d, float color, float count ) { +#ifndef TARGET_QUAKEWORLD + particle( o, d, color, count ); +#endif +} + +void ncFX::LightStyle( float style, string value ) { + lightstyle( style, value ); +} + +void ncFX::CastDamageScreen( ncPlayer targetPlayer, float armorValue, float bloodValue, vector damageOrigin ) { + + ncNet::WriteByte( FX_MSGTYPE, SVC_DAMAGE ); + ncNet::WriteByte( FX_MSGTYPE, armorValue ); + ncNet::WriteByte( FX_MSGTYPE, bloodValue ); + + for ( float i = 0; i < 3; i++ ) { + ncNet::WriteCoord( FX_MSGTYPE, damageOrigin[i] ); + } +} + +void ncFX::CastMuzzleFlash( ncEntity targetEntity ) { + /* the entity is already emitting a light of sorts. */ + if (targetEntity.effects > 1) { + return; + } + + targetEntity.effects = EF_MUZZLEFLASH; +} + +void ncFX::CastSpike( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_SPIKE ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::MultiCast(targetPos, MULTICAST_PHS); +} + +void ncFX::CastSuperSpike( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_SUPERSPIKE ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PHS ); +} + +void ncFX::CastGunShot( vector targetPos, float shotCount ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_GUNSHOT ); +#ifdef TARGET_QUAKEWORLD + ncNet::WriteByte( FX_MSGTYPE, shotCount ); +#endif + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PVS ); +} + +void ncFX::CastExplosion( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_EXPLOSION ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PHS ); +} + +void ncFX::CastTarExplosion( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_TAREXPLOSION ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PHS ); +} + +void ncFX::CastLightning( ncEntity boltOwner, vector startPos, vector endPos, lightningStyle_t lightningStyle ) { + ncNet::WriteByte (FX_MSGTYPE, SVC_TEMP_ENTITY); + + switch ( lightningStyle ) { + case FXLIGHTNING_TYPE1: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING1); + break; + case FXLIGHTNING_TYPE2: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING2); + break; + case FXLIGHTNING_TYPE3: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING3); + break; + default: + float r = ncMath::Rint(ncMath::Random() * 2.0); + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING1); + } + + ncNet::WriteEntity(FX_MSGTYPE, boltOwner); + ncNet::WriteCoord(FX_MSGTYPE, startPos[0] ); + ncNet::WriteCoord(FX_MSGTYPE, startPos[1] ); + ncNet::WriteCoord(FX_MSGTYPE, startPos[2] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[0] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[1] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[2] ); + ncNet::MultiCast( startPos, MULTICAST_PHS ); +} + +void ncFX::CastWizardSpike( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_WIZSPIKE ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::MultiCast(targetPos, MULTICAST_PHS); +} + +void ncFX::CastKnightSpike( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_KNIGHTSPIKE ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::MultiCast(targetPos, MULTICAST_PHS); +} + +void ncFX::CastLavaSplash( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_LAVASPLASH ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PVS ); +} + +void ncFX::CastTeleport( vector targetPos ) { + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_TELEPORT ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PVS ); +} + +void ncFX::CastBlood( vector targetPos ) { +#ifdef TARGET_QUAKEWORLD + ncNet::WriteByte( FX_MSGTYPE, SVC_TEMP_ENTITY ); + ncNet::WriteByte( FX_MSGTYPE, TE_BLOOD ); + ncNet::WriteByte( FX_MSGTYPE, 1 ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[0] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[1] ); + ncNet::WriteCoord( FX_MSGTYPE, targetPos[2] ); + ncNet::MultiCast( targetPos, MULTICAST_PVS ); +#else + Particle( targetPos, [0, 0, 0], 73, 1 ); +#endif +} + +void ncFX::CastLightningBlood( ncEntity boltOwner, vector startPos, vector endPos, lightningStyle_t lightningStyle ) { + ncNet::WriteByte (FX_MSGTYPE, SVC_TEMP_ENTITY); + + /* QW exclusive effect, substitute the other games with a separate blood impact */ +#ifdef TARGET_QUAKEWORLD + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNINGBLOOD); +#else + switch ( lightningStyle ) { + case FXLIGHTNING_TYPE1: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING1); + break; + case FXLIGHTNING_TYPE2: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING2); + break; + case FXLIGHTNING_TYPE3: + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING3); + break; + default: + float r = ncMath::Rint(ncMath::Random() * 2.0); + ncNet::WriteByte(FX_MSGTYPE, TE_LIGHTNING1); + } +#endif + + ncNet::WriteEntity(FX_MSGTYPE, boltOwner); + ncNet::WriteCoord(FX_MSGTYPE, startPos[0] ); + ncNet::WriteCoord(FX_MSGTYPE, startPos[1] ); + ncNet::WriteCoord(FX_MSGTYPE, startPos[2] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[0] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[1] ); + ncNet::WriteCoord(FX_MSGTYPE, endPos[2] ); + ncNet::MultiCast( startPos, MULTICAST_PHS ); + + /* substitute for NQ/H2 */ +#ifndef TARGET_QUAKEWORLD + CastBlood(endPos); +#endif +} \ No newline at end of file diff --git a/src/system/idFX.qh b/src/system/ncFX.qh similarity index 74% rename from src/system/idFX.qh rename to src/system/ncFX.qh index 9da4d10..f6d278c 100644 --- a/src/system/idFX.qh +++ b/src/system/ncFX.qh @@ -6,11 +6,16 @@ typedef enum FXLIGHTNING_TYPE3 } lightningStyle_t; -/** The idFX class contains helper functions for effects included in NQ/QW/H2. Keep in mind that a lot of these assume that your palette is organized similarily to how they are in their respective games. So if you use a custom palette, you may want to avoid using this namespace. */ -class idFX +/** The ncFX class contains helper functions for effects included in NQ/QW/H2. Keep in mind that a lot of these assume that your palette is organized similarily to how they are in their respective games. So if you use a custom palette, you may want to avoid using this namespace. */ +class ncFX { + nonvirtual void Particle( vector o, vector d, float color, float count ); + nonvirtual void LightStyle( float style, string value ); + + /** Causes the target player to receive a damage screen. */ + nonvirtual void CastDamageScreen( ncPlayer, float, float, vector ); /** Causes the target entity to cast a muzzleflash. */ - nonvirtual void CastMuzzleFlash( idEntity ); + nonvirtual void CastMuzzleFlash( ncEntity ); /** Create a spike impact at the specified position. */ nonvirtual void CastSpike( vector ); /** Create a super-spike impact at the specified position. */ @@ -22,7 +27,7 @@ class idFX /** Create a tar explosion at the specified position. */ nonvirtual void CastTarExplosion( vector ); /** Create a lightning strike between to positions. */ - nonvirtual void CastLightning( idEntity, vector, vector, lightningStyle_t ); + nonvirtual void CastLightning( ncEntity, vector, vector, lightningStyle_t ); /** Create a wizard spike impact at the specified position. */ nonvirtual void CastWizardSpike( vector ); /** Create a knight spike impact at the specified position. */ @@ -34,7 +39,7 @@ class idFX /** Create a blood splash specified position. */ nonvirtual void CastBlood( vector ); /** Create a lightning bolt between two points + blood splash at the specified position. */ - nonvirtual void CastLightningBlood( idEntity, vector, vector, lightningStyle_t ); + nonvirtual void CastLightningBlood( ncEntity, vector, vector, lightningStyle_t ); }; -noref idFX gameFX; \ No newline at end of file +noref ncFX gameFX; \ No newline at end of file diff --git a/src/system/ncHud.qc b/src/system/ncHud.qc new file mode 100644 index 0000000..1dcb34d --- /dev/null +++ b/src/system/ncHud.qc @@ -0,0 +1,308 @@ + +noref .float activeweapon; + +#ifdef TARGET_HEXEN2 +noref .float armor; +noref .float currentammo; +noref .float ammo_shells; +noref .float ammo_nails; +noref .float ammo_rockets; +noref .float ammo_cells; +#else +noref .float max_mana; +noref .float armor_amulet; +noref .float armor_bracer; +noref .float armor_breastplate; +noref .float armor_helmet; +noref .float ring_flight; +noref .float ring_water; +noref .float ring_turning; +noref .float ring_regeneration; +noref .float level; +noref .float intelligence; +noref .float wisdom; +noref .float strength; +noref .float dexterity; +noref .float bluemana; +noref .float greenmana; +noref .float experience; + +noref .float cnt_torch; +noref .float cnt_h_boost; +noref .float cnt_sh_boost; +noref .float cnt_mana_boost; +noref .float cnt_teleport; +noref .float cnt_tome; +noref .float cnt_summon; +noref .float cnt_invisibility; +noref .float cnt_glyph; +noref .float cnt_haste; +noref .float cnt_blast; +noref .float cnt_polymorph; +noref .float cnt_flight; +noref .float cnt_cubeofforce; +noref .float cnt_invincibility; + +noref .string puzzle_inv1; +noref .string puzzle_inv2; +noref .string puzzle_inv3; +noref .string puzzle_inv4; +noref .string puzzle_inv5; +noref .string puzzle_inv6; +noref .string puzzle_inv7; +noref .string puzzle_inv8; +#endif + +void ncHud::SetHealth( float newValue ) { + owner.health = newValue; +} + +void ncHud::SetMaxHealth( float newValue ) { + /* a bit of a hack */ + owner.max_health = newValue; +} + +void ncHud::SetBottomBar( float newValue ) { + newValue *= 0.01; + newValue = ncMath::Clamp(0.0, 1.0, newValue); + owner.max_health = owner.health / newValue; +} + +void ncHud::SetArmor( armorType_t type, float newValue ) { + switch ( type ) { + case ARMOR_PART_1: + owner.armor_helmet = newValue; + break; + case ARMOR_PART_2: + owner.armor_amulet = newValue; + break; + case ARMOR_PART_3: + owner.armor_breastplate = newValue; + break; + case ARMOR_PART_4: + owner.armor_bracer = newValue; + break; + default: + owner.armorvalue = newValue; + } +} + +void ncHud::SetWeaponModel( string newValue ) { + owner.weaponmodel = newValue; +} + +void ncHud::SetWeaponFrame( float newValue ) { + owner.weaponframe = newValue; +} + +void ncHud::SetActiveWeapon( float newValue ) { + owner.activeweapon = newValue; +} + + +void ncHud::SetAmmo( ammoType_t type, float newValue ) { + switch ( type ) { + case AMMO_1: + owner.ammo_shells = newValue; + break; + case AMMO_2: + owner.ammo_nails = newValue; + break; + case AMMO_3: + owner.ammo_rockets = newValue; + break; + case AMMO_4: + owner.ammo_cells = newValue; + break; + case AMMO_LEFT: + owner.bluemana = newValue; + break; + case AMMO_RIGHT: + owner.greenmana = newValue; + break; + case AMMO_MAX: + owner.max_mana = newValue; + break; + default: + owner.currentammo = newValue; + } +} + +void ncHud::SetBarItem( barItemType_t type, float newValue ) { + switch ( type ) { + case BARITEM_1: + owner.ring_flight = newValue; + break; + case BARITEM_2: + owner.ring_water = newValue; + break; + case BARITEM_3: + owner.ring_turning = newValue; + break; + case BARITEM_4: + owner.ring_regeneration = newValue; + break; + } +} + +void ncHud::SetLevel( float newValue ) { + owner.level = newValue; +} + +void ncHud::SetIntelligence( float newValue ) { + owner.intelligence = newValue; +} + +void ncHud::SetWisdom( float newValue ) { + owner.wisdom = newValue; +} + +void ncHud::SetStrength( float newValue ) { + owner.strength = newValue; +} + +void ncHud::SetDexterity( float newValue ) { + owner.dexterity = newValue; +} + +void ncHud::SetExperience( float newValue ) { + owner.experience = newValue; +} + +void ncHud::SetItemCount( itemSlot_t slotType, float newValue ) { + switch ( slotType ) { + case ITEM_SLOT1: + owner.cnt_torch = newValue; + break; + case ITEM_SLOT2: + owner.cnt_h_boost = newValue; + break; + case ITEM_SLOT3: + owner.cnt_sh_boost = newValue; + break; + case ITEM_SLOT4: + owner.cnt_mana_boost = newValue; + break; + case ITEM_SLOT5: + owner.cnt_teleport = newValue; + break; + case ITEM_SLOT6: + owner.cnt_tome = newValue; + break; + case ITEM_SLOT7: + owner.cnt_summon = newValue; + break; + case ITEM_SLOT8: + owner.cnt_invisibility = newValue; + break; + case ITEM_SLOT9: + owner.cnt_glyph = newValue; + break; + case ITEM_SLOT10: + owner.cnt_haste = newValue; + break; + case ITEM_SLOT11: + owner.cnt_blast = newValue; + break; + case ITEM_SLOT12: + owner.cnt_polymorph = newValue; + break; + case ITEM_SLOT13: + owner.cnt_flight = newValue; + break; + case ITEM_SLOT14: + owner.cnt_cubeofforce = newValue; + break; + case ITEM_SLOT15: + owner.cnt_invincibility = newValue; + break; + } +} + +float ncHud::GetItemCount( itemSlot_t slotType ) { + switch ( slotType ) { + case ITEM_SLOT1: + return owner.cnt_torch; + case ITEM_SLOT2: + return owner.cnt_h_boost; + case ITEM_SLOT3: + return owner.cnt_sh_boost; + case ITEM_SLOT4: + return owner.cnt_mana_boost; + case ITEM_SLOT5: + return owner.cnt_teleport; + case ITEM_SLOT6: + return owner.cnt_tome; + case ITEM_SLOT7: + return owner.cnt_summon; + case ITEM_SLOT8: + return owner.cnt_invisibility; + case ITEM_SLOT9: + return owner.cnt_glyph; + case ITEM_SLOT10: + return owner.cnt_haste; + case ITEM_SLOT11: + return owner.cnt_blast; + case ITEM_SLOT12: + return owner.cnt_polymorph; + case ITEM_SLOT13: + return owner.cnt_flight; + case ITEM_SLOT14: + return owner.cnt_cubeofforce; + case ITEM_SLOT15: + return owner.cnt_invincibility; + default: + return -1.0f; + } +} + +void ncHud::SetPuzzleSlot( puzzleSlot_t slotType, string newValue ) { + switch ( slotType ) { + case PUZZLE_SLOT1: + owner.puzzle_inv1 = newValue; + break; + case PUZZLE_SLOT2: + owner.puzzle_inv2 = newValue; + break; + case PUZZLE_SLOT3: + owner.puzzle_inv3 = newValue; + break; + case PUZZLE_SLOT4: + owner.puzzle_inv4 = newValue; + break; + case PUZZLE_SLOT5: + owner.puzzle_inv5 = newValue; + break; + case PUZZLE_SLOT6: + owner.puzzle_inv6 = newValue; + break; + case PUZZLE_SLOT7: + owner.puzzle_inv7 = newValue; + break; + case PUZZLE_SLOT8: + owner.puzzle_inv8 = newValue; + break; + } +} + +string ncHud::GetPuzzleSlot( puzzleSlot_t slotType ) { + switch ( slotType ) { + case PUZZLE_SLOT1: + return owner.puzzle_inv1; + case PUZZLE_SLOT2: + return owner.puzzle_inv2; + case PUZZLE_SLOT3: + return owner.puzzle_inv3; + case PUZZLE_SLOT4: + return owner.puzzle_inv4; + case PUZZLE_SLOT5: + return owner.puzzle_inv5; + case PUZZLE_SLOT6: + return owner.puzzle_inv6; + case PUZZLE_SLOT7: + return owner.puzzle_inv7; + case PUZZLE_SLOT8: + default: + return __NULL__; + } +} \ No newline at end of file diff --git a/src/system/ncHud.qh b/src/system/ncHud.qh new file mode 100644 index 0000000..b07af8b --- /dev/null +++ b/src/system/ncHud.qh @@ -0,0 +1,103 @@ +typedef enum +{ + ITEM_SLOT1, + ITEM_SLOT2, + ITEM_SLOT3, + ITEM_SLOT4, + ITEM_SLOT5, + ITEM_SLOT6, + ITEM_SLOT7, + ITEM_SLOT8, + ITEM_SLOT9, + ITEM_SLOT10, + ITEM_SLOT11, + ITEM_SLOT12, + ITEM_SLOT13, + ITEM_SLOT14, + ITEM_SLOT15 +} itemSlot_t; + +typedef enum +{ + AMMO_1, + AMMO_2, + AMMO_3, + AMMO_4, + AMMO_LEFT, + AMMO_RIGHT, + AMMO_MAX, + AMMO_CURRENT +} ammoType_t; + +typedef enum +{ + ARMOR_ALL, + ARMOR_PART_1, /**< gfx/armor1.lmp */ + ARMOR_PART_2, /**< gfx/armor2.lmp */ + ARMOR_PART_3, /**< gfx/armor3.lmp */ + ARMOR_PART_4, /**< gfx/armor4.lmp */ +} armorType_t; + +typedef enum +{ + BARITEM_1, /**< gfx/ring_f.lmp */ + BARITEM_2, /**< gfx/ring_w.lmp */ + BARITEM_3, /**< gfx/ring_t.lmp */ + BARITEM_4, /**< gfx/ring_r.lmp */ +} barItemType_t; + +typedef enum +{ + PUZZLE_SLOT1, + PUZZLE_SLOT2, + PUZZLE_SLOT3, + PUZZLE_SLOT4, + PUZZLE_SLOT5, + PUZZLE_SLOT6, + PUZZLE_SLOT7, + PUZZLE_SLOT8, +} puzzleSlot_t; + +/** This class talks to the players' heads-up-display */ +class ncHud { + /** Sets the health value on the HUD. */ + nonvirtual void SetHealth( float ); + /** Sets the value of armor to a given type. */ + nonvirtual void SetArmor( armorType_t, float ); + /** Sets the weapon model on the HUD. */ + nonvirtual void SetWeaponModel( string ); + /** Sets the frame used by the weapon model on the HUD. */ + nonvirtual void SetWeaponFrame( float ); + /** Sets the currently active weapon. Used only in Quake. */ + nonvirtual void SetActiveWeapon( float ); + /** Sets the value for various types of ammo. */ + nonvirtual void SetAmmo( ammoType_t, float ); + /** Sets the value of a bar item to a given type. */ + nonvirtual void SetBarItem( barItemType_t, float ); + /** sets the max health, affecting the bottom bar. Only visible in Hexen II. */ + nonvirtual void SetMaxHealth( float ); + /** sets the bottom bar on the HUD. Only visible in Hexen II. */ + nonvirtual void SetBottomBar( float ); + /** Sets the level on the HUD. Only visible in Hexen II. */ + nonvirtual void SetLevel( float ); + /** Sets the intelligence skill on the HUD. Only visible in Hexen II. */ + nonvirtual void SetIntelligence( float ); + /** Sets the wisdom skill on the HUD. Only visible in Hexen II. */ + nonvirtual void SetWisdom( float ); + /** Sets the strength skill on the HUD. Only visible in Hexen II. */ + nonvirtual void SetStrength( float ); + /** Sets the dexterity skill on the HUD. Only visible in Hexen II. */ + nonvirtual void SetDexterity( float ); + /** Sets the experience points on the HUD. Only visible in Hexen II. */ + nonvirtual void SetExperience( float ); + /** Sets the count of a given item slot. Only visible in Hexen II. */ + nonvirtual void SetItemCount( itemSlot_t, float ); + /** Returns the count of items in a given slot. */ + nonvirtual float GetItemCount( itemSlot_t ); + /** Sets the puzzle image into a given slot. Only visible in Hexen II. */ + nonvirtual void SetPuzzleSlot( puzzleSlot_t, string ); + /** Returns the puzzle image of a given slot.*/ + nonvirtual string GetPuzzleSlot( puzzleSlot_t ); +}; + +.ncHud hud; \ No newline at end of file diff --git a/src/system/ncItem.qc b/src/system/ncItem.qc new file mode 100644 index 0000000..0ff2881 --- /dev/null +++ b/src/system/ncItem.qc @@ -0,0 +1,122 @@ + +.float item; + +void ncItem::ncItem(void) { + SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); + SetTouchCallback(ItemTouched); +} + +void ncItem::SetWeaponID(float a) { + nc_wepnid = a + 1; +} + +float ncItem::GetWeaponID(void) { + return nc_wepnid; +} + +void ncItem::SetInventoryID(float a) { + nc_itemid = a + 1; +} + +float ncItem::GetInventoryID(void) { + return nc_itemid; +} + + +void ncItem::ItemTouched( ncEntity toucher ) { + ncPlayer playerToucher; + + if (toucher.flags & (FL_CLIENT) == false) { + return; + } + + playerToucher = (ncPlayer)toucher; + + if ( nc_wepnid > 0 ) { + if (playerToucher.AddItem(nc_wepnid - 1) == true) { + modelindex = 0; + solid = SOLID_NOT; + } + } else if ( nc_itemid > 0) { + float itemNum = nc_itemid - 1; + switch ( itemNum ) { + case 0: + playerToucher.cnt_torch++; + break; + case 1: + playerToucher.cnt_h_boost++; + break; + case 2: + playerToucher.cnt_sh_boost++; + break; + case 3: + playerToucher.cnt_mana_boost++; + break; + case 4: + playerToucher.cnt_teleport++; + break; + case 5: + playerToucher.cnt_tome++; + break; + case 6: + playerToucher.cnt_summon++; + break; + case 7: + playerToucher.cnt_invisibility++; + break; + case 8: + playerToucher.cnt_glyph++; + break; + case 9: + playerToucher.cnt_haste++; + break; + case 10: + playerToucher.cnt_blast++; + break; + case 11: + playerToucher.cnt_polymorph++; + break; + case 12: + playerToucher.cnt_flight++; + break; + case 13: + playerToucher.cnt_cubeofforce++; + break; + case 14: + playerToucher.cnt_invincibility++; + break; + } + + OnPickup(playerToucher); + modelindex = 0; + solid = SOLID_NOT; + } + //remove(this); +} + +/* overridable methods */ +void ncItem::Draw(ncEntity carrier) { +} + +void ncItem::PrimaryAttack(ncEntity carrier) { +} + +void ncItem::SecondaryAttack(ncEntity carrier) { +} + +void ncItem::Reload(ncEntity carrier) { +} + +void ncItem::Release(ncEntity carrier) { +} + +void ncItem::OnPickup(ncEntity carrier) { +} + + +void ncItem::OnInventoryUse( ncEntity carrier ) { + carrier.SPrint(PRINT_LOW, carrier.netname ); + carrier.SPrint(PRINT_LOW, " uses item "); + carrier.SPrint(PRINT_LOW, ncEngine::FloatToString( inventory ) ); + carrier.SPrint(PRINT_LOW, " which is unimplemented\n" ); +} \ No newline at end of file diff --git a/src/system/ncItem.qh b/src/system/ncItem.qh new file mode 100644 index 0000000..078d4d5 --- /dev/null +++ b/src/system/ncItem.qh @@ -0,0 +1,30 @@ +class ncItem:ncEntity { + void ncItem(void); + + /* Sets the id of an Item. */ + nonvirtual void SetWeaponID(float); + /** Returns the id of an Item. */ + nonvirtual float GetWeaponID(void); + /* Sets the id of an Item. */ + nonvirtual void SetInventoryID(float); + /** Returns the id of an Item. */ + nonvirtual float GetInventoryID(void); + + nonvirtual void ItemTouched( ncEntity ); + + /** Overridable: Called when we switch to this weapon */ + virtual void Draw(ncEntity); + /** Overridable: On +attack execution. */ + virtual void PrimaryAttack(ncEntity); + /** Overridable: On +attack2 execution. */ + virtual void SecondaryAttack(ncEntity); + /** Overridlable: On +reload execution. */ + virtual void Reload(ncEntity); + /** Overridable: When no buttons are held. */ + virtual void Release(ncEntity); + virtual void OnPickup(ncEntity); + virtual void OnInventoryUse( ncEntity ); +}; + +.float nc_itemid; +.float nc_wepnid; \ No newline at end of file diff --git a/src/system/ncMath.qc b/src/system/ncMath.qc new file mode 100644 index 0000000..4063500 --- /dev/null +++ b/src/system/ncMath.qc @@ -0,0 +1,173 @@ + +void ncMath::MakeVectors( vector ang ) { + return makevectors( ang ); +} + +float ncMath::Random( void ) { + return random(); +} + +vector ncMath::Normalize( vector v ) { + return normalize( v ); +} + +float ncMath::VLen( vector v ) { + return vlen( v ); +} + +float ncMath::VecToYaw( vector v ) { + return vectoyaw( v ); +} + +float ncMath::Rint( float v ) { + return rint( v ); +} + +float ncMath::Floor( float v ) { + return floor( v ); +} + +float ncMath::Ceil( float v ) { + return ceil( v ); +} + +vector ncMath::VecToAngles( vector v ) { + return vectoangles( v ); +} + +float ncMath::Fabs( float f ) { + return fabs( f ); +} + +float ncMath::Lerp( float fA, float fB, float fPercent) { + return (fA * (1 - fPercent)) + (fB * fPercent); +} + +float ncMath::LerpQ( float fA, float fB, float fC, float fPercent) { + float x = Lerp(fA, fB, fPercent); + float y = Lerp(fB, fC, fPercent); + return Lerp(x, y, fPercent); +} + +float ncMath::LerpC( float fA, float fB, float fC, float fD, float fPercent) { + float x = LerpQ(fA, fB, fC, fPercent); + float y = LerpQ(fB, fC, fD, fPercent); + return Lerp(x, y, fPercent); +} + +float ncMath::LerpAngle( float fStart, float fEnd, float fAmount ) { + float shortest_angle = ((((fEnd - fStart) % 360.0f) + 540.0f) % 360.0f) - 180.0f; + return shortest_angle * fAmount; +} + +float ncMath::Sin( float x ) { + static float lastX, lastR; + + /* return cached result */ + if (x == lastX) { + //ncEngine::BPrint(PRINT_HIGH, "Returning cached result!\n"); + return lastR; + } + +#if 0 + /* bounds, we will however lose precision after a short while */ + while (x < -MATH_PI) { + x += MATH_PI; + } + while (x > MATH_PI) { + x -= MATH_PI; + } + + const float B = 1.273239544735163; + const float C = -0.40528473456935; + const float P = 0.225; + float y = B * x + C * x * ncMath::Fabs(x); + y = P * (y * ncMath::Fabs(y) - y) + y; +#else + /* Bhāskara I */ + float y, t; + x /= MATH_DOUBLE_PI; + x -= Rint(x); + + if (x <= 0.5) { + t = 2 * x * (2 * x - 1); + y = (MATH_PI * t) / ((MATH_PI - 4) * t - 1); + } else { + t = 2 * (1 - x) * (1 - 2 * x); + y = -(MATH_PI * t) / ((MATH_PI - 4) * t - 1); + } +#endif + + /* ensure only valid values are returned. */ + y = Clamp(-1.0, 1.0, y); + + lastX = x; + lastR = y; + return y; +} + +float ncMath::Cos( float x ) { + static float lastX, lastR; + float result; + + /* return cached result */ + if (x == lastX) { + return lastR; + } + + result = ncMath::Sin( x + MATH_HALF_PI ); + lastR = result; + lastX = x; + return result; +} + +float ncMath::Acos( float x ) { + static float lastX, lastR; + float result; + + /* return cached result */ + if (x == lastX) { + return lastR; + } + + result = (MATH_ACOS_CURVE_A * x * x - MATH_ACOS_CURVE_B) * x + MATH_HALF_PI; + lastR = result; + lastX = x; + return result; +} + +float ncMath::Sqrt( float x ) { + if ( x == 0 || x == 1 ) { + return x; + } else { + float result; + float start = 0; + float end = x; + + while ( start <= end ) { + float mid = Rint( ( start + end ) / 2 ); + + if ( mid * mid == x ) { + return mid; + } else if ( mid * mid < x ) { + start = mid + 1; + result = mid; + } else { + end = mid - 1; + } + } + + return result; + } +} + +float ncMath::Clamp( float min, float max, float x ) { + if ( x < min ) { + return min; + } + if ( x > max ) { + return max; + } + return x; + +} \ No newline at end of file diff --git a/src/system/ncMath.qh b/src/system/ncMath.qh new file mode 100644 index 0000000..b6e8b39 --- /dev/null +++ b/src/system/ncMath.qh @@ -0,0 +1,34 @@ +class ncMath { + nonvirtual void MakeVectors( vector ang ); + nonvirtual float Random( void ); + nonvirtual vector Normalize( vector v ); + nonvirtual float VLen( vector v ); + nonvirtual float VecToYaw( vector v ); + nonvirtual float Rint( float v ); + nonvirtual float Floor( float v ); + nonvirtual float Ceil( float v ); + nonvirtual vector VecToAngles( vector v ); + nonvirtual float Fabs( float f ); + nonvirtual float Lerp( float, float, float ); + nonvirtual float LerpQ( float, float, float, float ); + nonvirtual float LerpC( float, float, float, float, float ); + nonvirtual float LerpAngle( float, float, float ); + nonvirtual float Sin( float ); + nonvirtual float Cos( float ); + nonvirtual float Acos( float ); + nonvirtual float Sqrt( float ); + nonvirtual float Clamp( float, float, float ); +}; + +const float MATH_PI = 3.141592653589793; +const float MATH_HALF_PI = 1.570796326794897; +const float MATH_DOUBLE_PI = 6.283185307179586; +const float MATH_SIN_CURVE_A = 0.0415896; +const float MATH_SIN_CURVE_B = 0.00129810625032; +const float MATH_ACOS_CURVE_A = -0.698131700797732; +const float MATH_ACOS_CURVE_B = 0.872664625997165; + +/** If a is bigger than b, return b. */ +#define min(a, b) ((a)>(b)?(b):(a)) +/** If a is bigger than b, return a. */ +#define max(a, b) ((a)>(b)?(a):(b)) \ No newline at end of file diff --git a/src/system/idMover.qc b/src/system/ncMover.qc similarity index 67% rename from src/system/idMover.qc rename to src/system/ncMover.qc index 4dba0de..245cb99 100644 --- a/src/system/idMover.qc +++ b/src/system/ncMover.qc @@ -1,8 +1,8 @@ -void idMover::idMover( void ) { +void ncMover::ncMover( void ) { } -vector idMover::GetDirectionalPosition(vector vecAngle, float flLip) { +vector ncMover::GetDirectionalPosition(vector vecAngle, float flLip) { vector vecMoveDir = g_vec_null; vector vecPos = g_vec_null; @@ -13,73 +13,86 @@ vector idMover::GetDirectionalPosition(vector vecAngle, float flLip) { vecMoveDir = [0,0,-1]; } else { /* manually specified angle */ - gameEngine.MakeVectors(vecAngle); + ncMath::MakeVectors(vecAngle); vecMoveDir = v_forward; } - vecPos = (GetOrigin() + vecMoveDir * (gameEngine.AbsoluteFloat(vecMoveDir * size) - flLip)); + float movementWidth = ncMath::Fabs(vecMoveDir * size); + vecPos = (GetOrigin() + vecMoveDir * (movementWidth - flLip)); return vecPos; } -vector idMover::GetDirectionalRotation(vector normalizedAngle, float travelDistance) { +vector ncMover::GetDirectionalRotation(vector normalizedAngle, float travelDistance) { vector vecMoveDir = normalizedAngle; return (GetAngles() + vecMoveDir * travelDistance); } -void idMover::SetMoverState(moverState_t val) { +void ncMover::SetMoverState(moverState_t val) { m_moverState = val; } -moverState_t idMover::GetMoverState(void) { +moverState_t ncMover::GetMoverState(void) { return m_moverState; } -void idMover::SetMoverType(moverType_t val) { +void ncMover::SetMoverType(moverType_t val) { m_moverType = val; } -moverType_t idMover::GetMoverType(void) { +moverType_t ncMover::GetMoverType(void) { return m_moverType; } -void idMover::SetMoverPosition1(vector val) { +void ncMover::SetMoverPosition1(vector val) { m_vecPos1 = val; } -vector idMover::GetMoverPosition1(void) { +vector ncMover::GetMoverPosition1(void) { return m_vecPos1; } -void idMover::SetMoverPosition2(vector val) { +void ncMover::SetMoverPosition2(vector val) { m_vecPos2 = val; } -vector idMover::GetMoverPosition2(void) { +vector ncMover::GetMoverPosition2(void) { return m_vecPos2; } -void idMover::SetMoverRotation1(vector val) { +void ncMover::SetMoverRotation1(vector val) { m_vecPos3 = val; } -vector idMover::GetMoverRotation1(void) { +vector ncMover::GetMoverRotation1(void) { return m_vecPos3; } -void idMover::SetMoverRotation2(vector val) { +void ncMover::SetMoverRotation2(vector val) { m_vecPos4 = val; } -vector idMover::GetMoverRotation2(void) { +vector ncMover::GetMoverRotation2(void) { return m_vecPos4; } -void idMover::MoveToPosition(vector vecDest, float flSpeed) { +float ncMover::GetLip( void ) { + return lip; +} + +float ncMover::GetSpeed( void ) { + return speed; +} + +float ncMover::GetWaitTime( void ) { + return wait; +} + +void ncMover::MoveToPosition(vector vecDest, float flSpeed) { MoveAndRotateToPosition(vecDest, GetAngles(), flSpeed); } -void idMover::MoveAndRotateToPosition(vector vecDest, vector vecAngle, float flSpeed) { +void ncMover::MoveAndRotateToPosition(vector vecDest, vector vecAngle, float flSpeed) { vector vecDifference; vector vecAngleDifference; float flTravel; @@ -110,7 +123,7 @@ void idMover::MoveAndRotateToPosition(vector vecDest, vector vecAngle, float flS /* abort if no speed is defined whatsoever */ if (!flSpeed) { - gameEngine.ObjError("idMover::MoveToPosition: No speed defined!"); + ncEngine::ObjError("ncMover::MoveToPosition: No speed defined!"); return; } @@ -120,12 +133,12 @@ void idMover::MoveAndRotateToPosition(vector vecDest, vector vecAngle, float flS /* calculate travel distance and time */ vecDifference = (vecDest - GetOrigin()); vecAngleDifference = (vecAngle - GetAngles()); - flTravel = gameEngine.VLen(vecDifference); + flTravel = ncMath::VLen(vecDifference); fTravelTime = (flTravel / flSpeed); /* if we won't move far enough, we may rotate? */ if (!flTravel) { - flTravel = gameEngine.VLen(vecAngleDifference); + flTravel = ncMath::VLen(vecAngleDifference); fTravelTime = (flTravel / flSpeed); } @@ -150,7 +163,7 @@ void idMover::MoveAndRotateToPosition(vector vecDest, vector vecAngle, float flS SetAngularVelocity((vecAngleDifference * (1.0 / fTravelTime))); } -void idMover::MoveToReverse(float flSpeed) { +void ncMover::MoveToReverse(float flSpeed) { if ((GetMoverState() == MOVER_POS2) || (GetMoverState() == MOVER_1TO2)){ MoveToPosition(GetMoverPosition1(), flSpeed); } else { @@ -158,11 +171,11 @@ void idMover::MoveToReverse(float flSpeed) { } } -void idMover::RotateToPosition(vector vecAngle, float flSpeed) { +void ncMover::RotateToPosition(vector vecAngle, float flSpeed) { MoveAndRotateToPosition(GetOrigin(), vecAngle, flSpeed); } -void idMover::RotateToReverse(float flSpeed) { +void ncMover::RotateToReverse(float flSpeed) { if ((GetMoverState() == MOVER_POS2) || (GetMoverState() == MOVER_1TO2)){ RotateToPosition(GetMoverRotation1(), flSpeed); } else { @@ -170,7 +183,7 @@ void idMover::RotateToReverse(float flSpeed) { } } -bool idMover::IsMoving(void) { +bool ncMover::IsMoving(void) { switch (GetMoverState()) { case MOVER_POS1: case MOVER_POS2: @@ -181,7 +194,7 @@ bool idMover::IsMoving(void) { } } -void idMover::_ArrivedAtRotPosition1(void) { +void ncMover::_ArrivedAtRotPosition1(void) { SetOrigin(m_vecPos1); SetAngles(m_vecPos3); ClearVelocity(); @@ -190,7 +203,7 @@ void idMover::_ArrivedAtRotPosition1(void) { MoverFinishesMoving(); } -void idMover::_ArrivedAtRotPosition2(void) { +void ncMover::_ArrivedAtRotPosition2(void) { SetOrigin(m_vecPos2); SetAngles(m_vecPos4); ClearVelocity(); @@ -199,12 +212,12 @@ void idMover::_ArrivedAtRotPosition2(void) { MoverFinishesMoving(); } -void idMover::_BeginMoving(void) { +void ncMover::_BeginMoving(void) { } -void idMover::MoverStartsMoving(void) { +void ncMover::MoverStartsMoving(void) { } -void idMover::MoverFinishesMoving(void) { +void ncMover::MoverFinishesMoving(void) { } \ No newline at end of file diff --git a/src/system/idMover.qh b/src/system/ncMover.qh similarity index 86% rename from src/system/idMover.qh rename to src/system/ncMover.qh index 1d3ec65..bb72d97 100644 --- a/src/system/idMover.qh +++ b/src/system/ncMover.qh @@ -14,10 +14,15 @@ typedef enum MOVERTYPE_ACCELERATED, /**< Moved in an accelerated fashion. */ } moverType_t; -class idMover:idEntity +/* fields used by ncMover */ +.float wait; +.float lip; +.float speed; + +class ncMover:ncEntity { public: - void idMover(void); + void ncMover(void); /** Returns a directional position from the current one. */ nonvirtual vector GetDirectionalPosition(vector, float); @@ -68,6 +73,13 @@ public: /** Returns if the NSMoverEntity is currently moving. */ nonvirtual bool IsMoving(void); + /** Returns the 'lip', the amount the brush sticks out/overlaps in units. */ + nonvirtual float GetLip(void); + /** Returns the speed the brush moves at in units per second. */ + nonvirtual float GetSpeed(void); + /** Returns the time in seconds until the mover returns to its default position. */ + nonvirtual float GetWaitTime(void); + /** Overridable: Called when the mover starts moving from its position to another. */ virtual void MoverStartsMoving(void); /** Overridable: Called when the mover completes its movement to a destination. */ diff --git a/src/system/ncNet.qc b/src/system/ncNet.qc new file mode 100644 index 0000000..ef4f183 --- /dev/null +++ b/src/system/ncNet.qc @@ -0,0 +1,37 @@ +void ncNet::WriteByte( float to, float f ) { + writeByte( to, f ); +} + +void ncNet::WriteChar( float to, float f ) { + writeChar( to, f ); +} + +void ncNet::WriteShort( float to, float f ) { + writeShort( to, f ); +} + +void ncNet::WriteLong( float to, float f ) { + writeLong( to, f ); +} + +void ncNet::WriteCoord( float to, float f ) { + writeCoord( to, f ); +} + +void ncNet::WriteAngle( float to, float f ) { + writeAngle( to, f ); +} + +void ncNet::WriteString( float to, string s ) { + writeString( to, s ); +} + +void ncNet::WriteEntity( float to, ncEntity s ) { + writeEntity( to, s ); +} + +void ncNet::MultiCast( vector where, multicast_t set ) { +#ifdef TARGET_QUAKEWORLD + multicast(where, set); +#endif +} \ No newline at end of file diff --git a/src/system/ncNet.qh b/src/system/ncNet.qh new file mode 100644 index 0000000..3447d1a --- /dev/null +++ b/src/system/ncNet.qh @@ -0,0 +1,17 @@ +class ncNet { + nonvirtual void WriteByte( float to, float f ); + nonvirtual void WriteChar( float to, float f ); + nonvirtual void WriteShort( float to, float f ); + nonvirtual void WriteLong( float to, float f ); + nonvirtual void WriteCoord( float to, float f ); + nonvirtual void WriteAngle( float to, float f ); + nonvirtual void WriteString( float to, string s ); + nonvirtual void WriteEntity( float to, ncEntity s ); + nonvirtual void MultiCast( vector where, float set ); +}; + +#ifdef TARGET_QUAKEWORLD + #define FX_MSGTYPE MSG_MULTICAST +#else + #define FX_MSGTYPE MSG_BROADCAST +#endif \ No newline at end of file diff --git a/src/system/ncPlayer.qc b/src/system/ncPlayer.qc new file mode 100644 index 0000000..2b95e70 --- /dev/null +++ b/src/system/ncPlayer.qc @@ -0,0 +1,402 @@ + +.float fov; + +/* hexen 2 cross-compat */ +#ifndef TARGET_HEXEN2 +.float inventory; +.float cnt_torch; +.float cnt_h_boost; +.float cnt_sh_boost; +.float cnt_mana_boost; +.float cnt_teleport; +.float cnt_tome; +.float cnt_summon; +.float cnt_invisibility; +.float cnt_glyph; +.float cnt_haste; +.float cnt_blast; +.float cnt_polymorph; +.float cnt_flight; +.float cnt_cubeofforce; +.float cnt_invincibility; +#endif + +void ncPlayer::ncPlayer( void ) { + hud = spawn(ncHud); + hud.owner = this; +} + +void ncPlayer::PreThink( void ) { +} + +void ncPlayer::PostThink( void ) { +} + +void ncPlayer::DeadThink( void ) { +} + +void ncPlayer::ResetPlayer( void ) { + ClearFlags(); + ClearEffects(); + ClearFrags(); + +#ifdef TARGET_HEXEN2 + SetModel( "models/paladin.mdl" ); +#else + SetModel( "progs/player.mdl" ); +#endif + SetMovetype( MOVETYPE_WALK ); + SetSolid( SOLID_SLIDEBOX ); + SetViewOffset( [0, 0, 24] ); + AddFlags( FL_CLIENT ); + SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); + SetHealth( 100 ); + SetArmorType( 0 ); + SetArmor( 0 ); +} + +void ncPlayer::Death( void ) { + SetViewOffset( [0, 0, -8] ); +} + +void ncPlayer::SetFOV( float targetFOV ) { + fov = targetFOV; + + StuffCmd( "fov " ); + StuffCmd( ncEngine::FloatToString( fov ) ); + StuffCmd( "\n" ); +} + +float ncPlayer::GetFOV( void ) { + return fov; +} + +void ncPlayer::FlashScreen( void ) { + StuffCmd( "bf\n" ); +} + +void ncPlayer::SetInfoKey( string key, string value ) { +#ifdef TARGET_QUAKEWORLD + StuffCmd( "setinfo \"" ); + StuffCmd( key ); + StuffCmd( "\" \"" ); + StuffCmd( value ); + StuffCmd( "\"\n" ); +#endif +} + +string ncPlayer::GetInfoKey( string key ) { +#ifdef TARGET_QUAKEWORLD + return infokey(this, key); +#else + return ""; +#endif +} + +void ncPlayer::LogFrag( ncEntity victim ) { +#ifdef TARGET_QUAKEWORLD + logfrag(this, victim); +#endif +} + +void ncPlayer::StuffCmd( string s ) { + stuffcmd( this, s ); +} + +.float item; +bool ncPlayer::AddItem( float itemToAdd ) { + ncItem theItem; + ncEntity e; + + /* check if we already have it */ + if (items & itemToAdd) { + return false; + } + + /* figure out which class we belong to in the world */ + while ( ( e = ncEngine::NextEnt( e ) ) ) { + if (e.nc_wepnid == itemToAdd + 1) { + theItem = (ncItem)e; + continue; + } + } + + if (!theItem) { + //ncEngine::Error("Weapon of id "); + ncEngine::Error(ncEngine::FloatToString(itemToAdd)); + //ncEngine::Error("is not precached\n"); + return false; + } + + /* add it */ + items |= itemToAdd; + theItem.OnPickup(this); + + if (weapon == 0) { + /* switch to it */ + weapon = itemToAdd; + currentweapon = theItem; + theItem.Draw(this); + } + + return true; +} + +bool ncPlayer::SwitchToItem(float itemID) { + + ncItem theItem; + ncEntity e; + + /* check if we already have it */ + if (!(items & itemID)) { + return false; + } + + /* figure out which class we belong to in the world */ + while ( ( e = ncEngine::NextEnt( e ) ) ) { + if (e.nc_wepnid == itemID + 1) { + theItem = (ncItem)e; + continue; + } + } + + + /* switch to it */ + weapon = itemID; + currentweapon = theItem; + theItem.Draw(this); + return true; +} + +bool ncPlayer::ImpulseCommand( float impulseValue ) { + return false; +} + +void ncPlayer::JumpPressed( void ) { + SetVelocity(GetVelocity() + [0, 0, 250]); + SPrint(PRINT_HIGH, netname ); + SPrint(PRINT_HIGH, " pressed jump\n" ); +} + +void ncPlayer::JumpReleased( void ) { + SPrint(PRINT_HIGH, netname ); + SPrint(PRINT_HIGH, " released jump\n" ); +} + +float ncPlayer::GetInventoryItem( void ) { + return inventory; +} + +bool ncPlayer::DropInventoryItem( float itemNum ) { + SPrint(PRINT_LOW, netname ); + SPrint(PRINT_LOW, " drops item "); + SPrint(PRINT_LOW, ncEngine::FloatToString( itemNum ) ); + SPrint(PRINT_LOW, "\n" ); + return false; +} + +bool ncPlayer::UseInventoryItem( float itemNum ) { + + ncItem theItem; + ncEntity e; + + /* check if we have it */ + if (GetInventoryItemCount( itemNum ) <= 0 ) { + SPrint(PRINT_LOW, "No item.\n" ); + return false; + } + + //SPrint(PRINT_LOW, netname ); + //SPrint(PRINT_LOW, " uses item "); + //SPrint(PRINT_LOW, ncEngine::FloatToString( itemNum ) ); + //SPrint(PRINT_LOW, "\n" ); + + /* figure out which class we belong to in the world */ + while ( ( e = ncEngine::NextEnt( e ) ) ) { + if (e.nc_itemid == (itemNum + 1)) { + theItem = (ncItem)e; + continue; + } + } + + if (!theItem) { + //ncEngine::Error("Weapon of id "); + ncEngine::Error(ncEngine::FloatToString(itemNum)); + //ncEngine::Error("is not precached\n"); + return false; + } + + theItem.OnInventoryUse( this ); + + switch ( itemNum ) { + case 0: + cnt_torch--; + break; + case 1: + cnt_h_boost--; + break; + case 2: + cnt_sh_boost--; + break; + case 3: + cnt_mana_boost--; + break; + case 4: + cnt_teleport--; + break; + case 5: + cnt_tome--; + break; + case 6: + cnt_summon--; + break; + case 7: + cnt_invisibility--; + break; + case 8: + cnt_glyph--; + break; + case 9: + cnt_haste--; + break; + case 10: + cnt_blast--; + break; + case 11: + cnt_polymorph--; + break; + case 12: + cnt_flight--; + break; + case 13: + cnt_cubeofforce--; + break; + case 14: + cnt_invincibility--; + break; + } + + /* the engine handles it in H2 for us */ +#ifndef TARGET_HEXEN2 + /* ran out? switch to the next item */ + if (GetInventoryItemCount( itemNum ) <= 0 ) { + NextInventoryItem(); + } +#endif + + return true; +} + +float ncPlayer::GetInventoryItemCount( float slotNum ) { + switch ( slotNum ) { + case 0: + return cnt_torch; + case 1: + return cnt_h_boost; + case 2: + return cnt_sh_boost; + case 3: + return cnt_mana_boost; + case 4: + return cnt_teleport; + case 5: + return cnt_tome; + case 6: + return cnt_summon; + case 7: + return cnt_invisibility; + case 8: + return cnt_glyph; + case 9: + return cnt_haste; + case 10: + return cnt_blast; + case 11: + return cnt_polymorph; + case 12: + return cnt_flight; + case 13: + return cnt_cubeofforce; + case 14: + return cnt_invincibility; + default: + return -1; + } +} + +//void(string s, ...) print = #339; +//string(string fmt, ...) sprintf = #627; + +void ncPlayer::NextInventoryItem( void ) { + float firstSlot = -1; + float nextSlot = -1; + + for ( float f = 0; f < 15; f++ ) { + float count = GetInventoryItemCount( f ); + + //print(sprintf("%d: count: %d\n", f, count)); + + /* first valid slot */ + if (firstSlot == -1 && count > 0) { + firstSlot = f; + } + + /* next valid slot after the current one */ + if (f > inventory && count > 0) { + nextSlot = f; + break; + } + } + + /* no good one to the right of us? skip to the first valid one*/ + if (nextSlot == -1) { + /* do we have a first valid one? */ + if (firstSlot != -1) { + inventory = firstSlot; + return; + } + + /* else... we just set it to 0, like Hexen 2 does (torch) */ + inventory = 0; + return; + } + + /* we're all good */ + inventory = nextSlot; +} + +void ncPlayer::PreviousInventoryItem( void ) { + float firstSlot = -1; + float nextSlot = -1; + + for ( float f = 14; f >= 0; f-- ) { + float count = GetInventoryItemCount( f ); + + /* first valid slot */ + if (firstSlot == -1 && count > 0) { + firstSlot = f; + } + + /* next valid slot after the current one */ + if (f < inventory && count > 0) { + nextSlot = f; + break; + } + } + + /* no good one to the left of us? skip to the first valid one*/ + if (nextSlot == -1) { + /* do we have a first valid one? */ + if (firstSlot != -1) { + inventory = firstSlot; + return; + } + + /* else... we just set it to 0, like Hexen 2 does (torch) */ + inventory = 0; + return; + } + + /* we're all good */ + inventory = nextSlot; +} \ No newline at end of file diff --git a/src/system/ncPlayer.qh b/src/system/ncPlayer.qh new file mode 100644 index 0000000..6bef2d3 --- /dev/null +++ b/src/system/ncPlayer.qh @@ -0,0 +1,33 @@ +class ncPlayer:ncEntity { + void ncPlayer( void ); + + /* overrides */ + virtual void Death( void ); + virtual void PreThink( void ); + + nonvirtual void PostThink( void ); + nonvirtual void DeadThink( void ); + nonvirtual void ResetPlayer( void ); + nonvirtual void SetFOV( float ); + nonvirtual float GetFOV( void ); + nonvirtual void FlashScreen( void ); + + nonvirtual void SetInfoKey( string key, string value ); + nonvirtual string GetInfoKey( string key ); + nonvirtual void LogFrag( ncEntity victim ); + nonvirtual void StuffCmd( string s ); + + virtual bool AddItem( float ); + virtual bool SwitchToItem( float ); + virtual bool ImpulseCommand( float ); + virtual void JumpPressed( void ); + virtual void JumpReleased( void ); + + /* inventory handling */ + nonvirtual bool UseInventoryItem( float ); + nonvirtual float GetInventoryItem( void ); + nonvirtual bool DropInventoryItem( float ); + nonvirtual void NextInventoryItem( void ); + nonvirtual void PreviousInventoryItem( void ); + nonvirtual bool GetInventoryItemCount( float ); +}; \ No newline at end of file diff --git a/src/system/ncRules.qc b/src/system/ncRules.qc new file mode 100644 index 0000000..bca2879 --- /dev/null +++ b/src/system/ncRules.qc @@ -0,0 +1,57 @@ +void ncRules::ncRules( void ) { +} + +void ncRules::PlayerConnects( ncPlayer pl ) { + ncEngine::BPrint( PRINT_HIGH, "Player connected.\n" ); +} + +void ncRules::PlayerDisconnects( ncPlayer pl ) { + ncEngine::BPrint( PRINT_HIGH, "Player disconnected.\n" ); +} + +void ncRules::PlayerFinishesJoining( ncPlayer player ) { + ncEngine::BPrint( PRINT_HIGH, "Player joined the game fully.\n" ); + + /* reset them fully */ + player.ResetPlayer(); + + /* place them to the nearest spawn point */ + { + ncPlayerStart spawn = world; + + spawn.MovePlayerToStart( player ); + } + +#if 0 + /* start the intro camera */ + { + ncCamera start = (ncCamera)ncEngine::Find((ncEntity)world, ::classname, "ncCamera"); + + if (start) { + start.Trigger(player, 0); + ncEngine::BPrint( PRINT_HIGH, "Camera found.\n" ); + } else { + ncEngine::BPrint( PRINT_HIGH, "Camera not found.\n" ); + } + } +#endif +} + +void ncRules::ApplyDamage( ncEntity target, + ncEntity 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/ncRules.qh b/src/system/ncRules.qh new file mode 100644 index 0000000..8460dd6 --- /dev/null +++ b/src/system/ncRules.qh @@ -0,0 +1,18 @@ +class ncRules { + void ncRules( void ); + + virtual void PlayerConnects( ncPlayer ); + virtual void PlayerDisconnects( ncPlayer ); + virtual void PlayerFinishesJoining( ncPlayer ); + + /* damage specific */ + virtual void ApplyDamage( ncEntity, ncEntity, float, float, float ); +}; + +ncRules g_gameRules; + +#define INIT_WEAPON(wid, cname) { ##cname w_##cname = spawn(##cname); w_##cname.nc_wepnid = wid; w_##cname.Precache(); } + +#define INIT_INVENTORY(wid, cname) { ##cname w_##cname = spawn(##cname); w_##cname.nc_itemid = wid + 1; w_##cname.Precache(); } + +#define INIT_ITEM(cname) { ##cname w_##cname = spawn(##cname); w_##cname.Precache(); } \ No newline at end of file diff --git a/src/system/sources.src b/src/system/sources.src index 44a9a75..8243bf8 100644 --- a/src/system/sources.src +++ b/src/system/sources.src @@ -1,11 +1,15 @@ #includelist -idEntity.qc -idActor.qc -idPlayer.qc -idRules.qc -idItem.qc -idMover.qc -idFX.qc -idEngine.qc +ncEngine.qc +ncEntity.qc +ncActor.qc +ncPlayer.qc +ncRules.qc +ncItem.qc +ncMover.qc +ncFX.qc +ncCamera.qc +ncMath.qc +ncHud.qc +ncNet.qc classes.qc #endlist