diff --git a/h2/src/init.qc b/h2/src/init.qc index 490c6ce..4fb0df7 100644 --- a/h2/src/init.qc +++ b/h2/src/init.qc @@ -1,3 +1,8 @@ +void Class_Rules(void) +{ + spawnfunc_H2Rules(); +} + void Precaches(void) { INIT_ITEM(H2Torch) diff --git a/h2/src/items/blastradius.qc b/h2/src/items/blastradius.qc index 40ece9e..4f29677 100644 --- a/h2/src/items/blastradius.qc +++ b/h2/src/items/blastradius.qc @@ -2,7 +2,6 @@ class H2BlastRadius:ncItem { void H2BlastRadius(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_blast.mdl" ); } void H2BlastRadius::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/cubeofforce.qc b/h2/src/items/cubeofforce.qc index a604931..2044c0a 100644 --- a/h2/src/items/cubeofforce.qc +++ b/h2/src/items/cubeofforce.qc @@ -2,7 +2,6 @@ class H2CubeOfForce:ncItem { void H2CubeOfForce(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_cube.mdl" ); } void H2CubeOfForce::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/flight.qc b/h2/src/items/flight.qc index fa895c3..71a0399 100644 --- a/h2/src/items/flight.qc +++ b/h2/src/items/flight.qc @@ -2,7 +2,6 @@ class H2Flight:ncItem { void H2Flight(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/ringft.mdl" ); } void H2Flight::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/glphy.qc b/h2/src/items/glphy.qc index 24f3ff9..42654a1 100644 --- a/h2/src/items/glphy.qc +++ b/h2/src/items/glphy.qc @@ -2,7 +2,6 @@ class H2Glyph:ncItem { void H2Glyph(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_glyph.mdl" ); } void H2Glyph::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/haste.qc b/h2/src/items/haste.qc index d1014cb..2c83271 100644 --- a/h2/src/items/haste.qc +++ b/h2/src/items/haste.qc @@ -2,7 +2,6 @@ class H2Haste:ncItem { void H2Haste(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_haste.mdl" ); } void H2Haste::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/healthboost.qc b/h2/src/items/healthboost.qc index ffb2076..70e85ab 100644 --- a/h2/src/items/healthboost.qc +++ b/h2/src/items/healthboost.qc @@ -2,7 +2,6 @@ class H2HealthBoost:ncItem { void H2HealthBoost(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_invinc.mdl" ); } void H2HealthBoost::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/invincibility.qc b/h2/src/items/invincibility.qc index 05cd3c2..01f9955 100644 --- a/h2/src/items/invincibility.qc +++ b/h2/src/items/invincibility.qc @@ -2,7 +2,6 @@ class H2Invincibility:ncItem { void H2Invincibility(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_invinc.mdl" ); } void H2Invincibility::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/invisibility.qc b/h2/src/items/invisibility.qc index c2fb3d1..1ea38ee 100644 --- a/h2/src/items/invisibility.qc +++ b/h2/src/items/invisibility.qc @@ -2,7 +2,6 @@ class H2Invisibility:ncItem { void H2Invisibility(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_invis.mdl" ); } void H2Invisibility::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/manaboost.qc b/h2/src/items/manaboost.qc index 318de35..62f8c60 100644 --- a/h2/src/items/manaboost.qc +++ b/h2/src/items/manaboost.qc @@ -2,7 +2,6 @@ class H2ManaBoost:ncItem { void H2ManaBoost(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_mboost.mdl" ); } void H2ManaBoost::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/polymorph.qc b/h2/src/items/polymorph.qc index 3ad9ac3..3fd34a4 100644 --- a/h2/src/items/polymorph.qc +++ b/h2/src/items/polymorph.qc @@ -2,7 +2,6 @@ class H2Polymorph:ncItem { void H2Polymorph(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_poly.mdl" ); } void H2Polymorph::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/summon.qc b/h2/src/items/summon.qc index 5f12c63..ad42ba7 100644 --- a/h2/src/items/summon.qc +++ b/h2/src/items/summon.qc @@ -2,7 +2,6 @@ class H2Summon:ncItem { void H2Summon(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_summon.mdl" ); } void H2Summon::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/superhboost.qc b/h2/src/items/superhboost.qc index 55d2cfa..31477a3 100644 --- a/h2/src/items/superhboost.qc +++ b/h2/src/items/superhboost.qc @@ -2,7 +2,6 @@ class H2SuperHBoost:ncItem { void H2SuperHBoost(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_shbost.mdl" ); } void H2SuperHBoost::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/teleport.qc b/h2/src/items/teleport.qc index 9dea3b0..257c05f 100644 --- a/h2/src/items/teleport.qc +++ b/h2/src/items/teleport.qc @@ -2,7 +2,6 @@ class H2Teleport:ncItem { void H2Teleport(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_telprt.mdl" ); } void H2Teleport::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/tomeofpower.qc b/h2/src/items/tomeofpower.qc index 36a4f06..2f51956 100644 --- a/h2/src/items/tomeofpower.qc +++ b/h2/src/items/tomeofpower.qc @@ -2,7 +2,6 @@ class H2TomeOfPower:ncItem { void H2TomeOfPower(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_tome.mdl" ); } void H2TomeOfPower::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/items/torch.qc b/h2/src/items/torch.qc index 53ad809..d73e5f4 100644 --- a/h2/src/items/torch.qc +++ b/h2/src/items/torch.qc @@ -2,7 +2,6 @@ class H2Torch:ncItem { void H2Torch(void); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnInventoryUse( ncEntity ); }; @@ -11,13 +10,8 @@ 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 ); + SetItemModel( "models/a_torch.mdl" ); } void H2Torch::OnInventoryUse( ncEntity carrier ) { diff --git a/h2/src/progs.src b/h2/src/progs.src index 4bd5668..5597d73 100644 --- a/h2/src/progs.src +++ b/h2/src/progs.src @@ -5,7 +5,6 @@ ../../src/include.src entities/obj_tree2.qc -entities/test_effects.qc items/blastradius.qc items/cubeofforce.qc @@ -23,5 +22,6 @@ items/teleport.qc items/tomeofpower.qc items/torch.qc +rules.qc init.qc #endlist \ No newline at end of file diff --git a/q1/src/items/quad.qc b/q1/src/items/quad.qc index f2009de..c48f94b 100644 --- a/q1/src/items/quad.qc +++ b/q1/src/items/quad.qc @@ -3,7 +3,6 @@ class Q1Quad:ncItem { void Q1Quad( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void OnPickup( ncEntity ); }; @@ -13,15 +12,10 @@ void Q1Quad::Q1Quad( void ) { } void Q1Quad::Precache( void ) { - ncEngine::Precache_Model( "progs/quad.mdl" ); + SetItemModel("progs/quaddama.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"); diff --git a/q1/src/weapons/axe.qc b/q1/src/weapons/axe.qc index 71361b2..e617a7d 100644 --- a/q1/src/weapons/axe.qc +++ b/q1/src/weapons/axe.qc @@ -3,7 +3,6 @@ class Q1Axe:ncItem { void Q1Axe( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -19,11 +18,6 @@ void Q1Axe::Precache( void ) { 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); diff --git a/q1/src/weapons/grenadelauncher.qc b/q1/src/weapons/grenadelauncher.qc index 2986bac..8eae969 100644 --- a/q1/src/weapons/grenadelauncher.qc +++ b/q1/src/weapons/grenadelauncher.qc @@ -3,7 +3,6 @@ class Q1GrenadeLauncher:ncItem { void Q1GrenadeLauncher( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -15,14 +14,9 @@ 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 ); + SetWeaponID( WEAPON_GRENADE_LAUNCHER ); + SetItemModel( "progs/g_rock.mdl" ); } void Q1GrenadeLauncher::Draw( ncEntity carrier ) { diff --git a/q1/src/weapons/lightning.qc b/q1/src/weapons/lightning.qc index 5bd06d0..18a3ac5 100644 --- a/q1/src/weapons/lightning.qc +++ b/q1/src/weapons/lightning.qc @@ -3,7 +3,6 @@ class Q1Lightning:ncItem { void Q1Lightning( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -15,14 +14,9 @@ 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 ); + SetItemModel( "progs/g_light.mdl" ); } void Q1Lightning::Draw( ncEntity carrier ) { diff --git a/q1/src/weapons/nailgun.qc b/q1/src/weapons/nailgun.qc index 6811633..e8a1ca3 100644 --- a/q1/src/weapons/nailgun.qc +++ b/q1/src/weapons/nailgun.qc @@ -3,7 +3,6 @@ class Q1Nailgun:ncItem { void Q1Nailgun( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -15,14 +14,9 @@ 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 ); + SetItemModel( "progs/g_nail.mdl" ); } void Q1Nailgun::Draw( ncEntity carrier ) { diff --git a/q1/src/weapons/rocketlauncher.qc b/q1/src/weapons/rocketlauncher.qc index 5d35665..d525a70 100644 --- a/q1/src/weapons/rocketlauncher.qc +++ b/q1/src/weapons/rocketlauncher.qc @@ -3,7 +3,6 @@ class Q1RocketLauncher:ncItem { void Q1RocketLauncher( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -15,14 +14,9 @@ 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 ); + SetItemModel( "progs/g_rock2.mdl" ); } void Q1RocketLauncher::Draw( ncEntity carrier ) { diff --git a/q1/src/weapons/shotgun.qc b/q1/src/weapons/shotgun.qc index 160c9ec..64b4bd5 100644 --- a/q1/src/weapons/shotgun.qc +++ b/q1/src/weapons/shotgun.qc @@ -3,7 +3,6 @@ class Q1Shotgun:ncItem { void Q1Shotgun( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -19,10 +18,6 @@ void Q1Shotgun::Precache( void ) { 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); diff --git a/q1/src/weapons/supernailgun.qc b/q1/src/weapons/supernailgun.qc index 8b4e441..b743e78 100644 --- a/q1/src/weapons/supernailgun.qc +++ b/q1/src/weapons/supernailgun.qc @@ -3,7 +3,6 @@ class Q1SuperNailgun:ncItem { void Q1SuperNailgun( void ); virtual void Precache( void ); - virtual void Spawn( void ); virtual void Draw( ncEntity ); virtual void PrimaryAttack( ncEntity ); @@ -15,14 +14,9 @@ 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 ); + SetItemModel( "progs/g_nail2.mdl" ); } void Q1SuperNailgun::Draw( ncEntity carrier ) { diff --git a/q1/src/weapons/supershotgun.qc b/q1/src/weapons/supershotgun.qc index 01dce12..2d26ee6 100644 --- a/q1/src/weapons/supershotgun.qc +++ b/q1/src/weapons/supershotgun.qc @@ -3,11 +3,9 @@ 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 ) { @@ -15,15 +13,9 @@ 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 ); + SetItemModel( "progs/g_shot.mdl" ); } void Q1SuperShotgun::Draw( ncEntity carrier ) { @@ -37,9 +29,4 @@ void Q1SuperShotgun::PrimaryAttack( ncEntity carrier ) { 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/entities/light.qc b/src/entities/light.qc index f2d57ea..4705c61 100644 --- a/src/entities/light.qc +++ b/src/entities/light.qc @@ -1,9 +1,31 @@ -class idLight:ncEntity { - void idLight( void ); +class ncLight:ncEntity { + void ncLight( void ); + + nonvirtual float LightLevelForEntity( ncEntity ); }; -void idLight::idLight( void ) { +void ncLight::ncLight( void ) { } -LINK_ENTITY_TO_CLASS(light, idLight) \ No newline at end of file +#ifndef TARGET_HEXEN2 +.float light_level; +#endif + +float ncLight::LightLevelForEntity( ncEntity target ) { + float maxDistance = 150; /* Q1/H2 = linear falloff */ + float currDistance = ncMath::VLen(GetOrigin() - target.GetOrigin()); + + if (currDistance > maxDistance) + return 0.0f; + + ncEngine::TraceLine(GetOrigin(), target.GetOrigin(), FALSE, this); + + if ( ( trace_ent == target ) || ( trace_fraction == 1.0f ) ) { + return maxDistance - currDistance; + } else { + return 0.0f; + } +} + +LINK_ENTITY_TO_CLASS(light, ncLight) \ No newline at end of file diff --git a/src/entry.qc b/src/entry.qc index 7596e18..4398b4e 100644 --- a/src/entry.qc +++ b/src/entry.qc @@ -115,6 +115,8 @@ void PlayerPreThink( void ) { if (self.health <= 0) return; + pl.CalculateLightLevel(); + #if 0 if (pl.GetDeadFlag() >= DEAD_DYING) { pl.DeadThink(); @@ -146,7 +148,7 @@ void PlayerPreThink( void ) { // camAngle[2] = ncMath::Sin(time) * 45.0f; float progress = pl.inCamera.GetCameraTime() / pl.inCamera.GetCameraLength(); -#if CAM_DEBUG +#if 0 pl.hud.SetExperience(progress * 999999); progress *= 100; pl.hud.SetHealth(progress); @@ -212,7 +214,7 @@ void PlayerPostThink( void ) { pl.SPrint(PRINT_LOW, " toggles crouch\n"); break; case 23: /* inventory use */ - pl.UseInventoryItem( pl.GetInventoryItem() ); + pl.UseInventoryItem( pl.GetInventoryItem() - 1 ); break; case 25: /* inventory next */ pl.NextInventoryItem(); @@ -221,7 +223,7 @@ void PlayerPostThink( void ) { pl.PreviousInventoryItem(); break; case 44: /* inventory drop */ - pl.DropInventoryItem( pl.GetInventoryItem() ); + pl.DropInventoryItem( pl.GetInventoryItem() - 1 ); break; case 100: case 101: diff --git a/src/system/ncEntity.qc b/src/system/ncEntity.qc index 7fccc14..ed6d206 100644 --- a/src/system/ncEntity.qc +++ b/src/system/ncEntity.qc @@ -9,6 +9,7 @@ void ncEntity::ncEntity( void ) { if (g_world_initialized == false) { Precache(); + _InternalPostPrecache(); } _InternalPreSpawn(); Spawn(); @@ -24,6 +25,9 @@ void ncEntity::_InternalPreSpawn( void ) { void ncEntity::_InternalPostSpawn( void ) { } +void ncEntity::_InternalPostPrecache( void ) { +} + void ncEntity::Spawn( void ) { } @@ -745,4 +749,25 @@ void ncEntity::PrimaryAttack( ncEntity carrier ) { void ncEntity::SetNextPrimaryAttack(float attackDelay) { next_primary_attack = time + attackDelay; +} + + + +/* wannabe thief */ +void ncEntity::CalculateLightLevel( void ) +{ +#ifndef TARGET_HEXEN2 + float lightValue = 0.0f; + + for ( ncEntity a = ( ncEntity) world; ( a = ( ncEntity )find( a, ::classname, "ncLight" ) ); ) { + ncLight targetLight = (ncLight)a; + lightValue += targetLight.LightLevelForEntity(this); + } + + if (lightValue > 255.0) { + lightValue = 255.0f; + } + + light_level = lightValue; +#endif } \ No newline at end of file diff --git a/src/system/ncEntity.qh b/src/system/ncEntity.qh index d5be39c..ac5f10a 100644 --- a/src/system/ncEntity.qh +++ b/src/system/ncEntity.qh @@ -272,7 +272,7 @@ public: nonvirtual float CheckBottom( void ); nonvirtual vector Aim( float speed ); nonvirtual void MakeStatic( void ); - nonvirtual void CenterPrint( string s ); + nonvirtual void CenterPrint( string ); nonvirtual bool DropToFloor( void ); nonvirtual void Remove( void ); nonvirtual float WalkMove( float yaw, float dist ); @@ -297,9 +297,13 @@ public: virtual void PrimaryAttack( ncEntity ); nonvirtual void SetNextPrimaryAttack( float ); + /** Recalculate the light level of the entity, run automatically on players during PreThink. */ + nonvirtual void CalculateLightLevel( void ); + private: virtual void _InternalPreSpawn( void ); virtual void _InternalPostSpawn( void ); + virtual void _InternalPostPrecache( void ); }; var bool g_world_initialized; diff --git a/src/system/ncFX.qc b/src/system/ncFX.qc index 9101926..4d285e2 100644 --- a/src/system/ncFX.qc +++ b/src/system/ncFX.qc @@ -8,6 +8,11 @@ void ncFX::LightStyle( float style, string value ) { lightstyle( style, value ); } +void ncFX:: CastScreenFlash( ncPlayer targetPlayer ) { + targetPlayer.StuffCmd( "bf\n" ); +} + + void ncFX::CastDamageScreen( ncPlayer targetPlayer, float armorValue, float bloodValue, vector damageOrigin ) { ncNet::WriteByte( FX_MSGTYPE, SVC_DAMAGE ); diff --git a/src/system/ncFX.qh b/src/system/ncFX.qh index f6d278c..5c3a245 100644 --- a/src/system/ncFX.qh +++ b/src/system/ncFX.qh @@ -12,6 +12,8 @@ class ncFX nonvirtual void Particle( vector o, vector d, float color, float count ); nonvirtual void LightStyle( float style, string value ); + /** causes the target player's screen to flash. */ + nonvirtual void CastScreenFlash( ncPlayer ); /** Causes the target player to receive a damage screen. */ nonvirtual void CastDamageScreen( ncPlayer, float, float, vector ); /** Causes the target entity to cast a muzzleflash. */ diff --git a/src/system/ncItem.qc b/src/system/ncItem.qc index 0ff2881..750f52c 100644 --- a/src/system/ncItem.qc +++ b/src/system/ncItem.qc @@ -2,8 +2,26 @@ .float item; void ncItem::ncItem(void) { - SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); SetTouchCallback(ItemTouched); + nc_pckupsnd = "weapons/pkup.wav"; +} + +void ncItem::Spawn( void ) { + SetModel( nc_model ); + SetSolid( SOLID_TRIGGER ); + SetSize( VEC_HULL_MIN, VEC_HULL_MAX ); +} + +void ncItem::SetItemModel( string modelPath ) { + nc_model = modelPath; +} + +void ncItem::SetPickupSound( string soundPath ) { + nc_pckupsnd = soundPath; +} + +string ncItem::GetPickupSound( void ) { + return nc_pckupsnd; } void ncItem::SetWeaponID(float a) { @@ -22,6 +40,19 @@ float ncItem::GetInventoryID(void) { return nc_itemid; } +string ncItem::GetItemName(void) { + if (nc_name) { + return nc_name; + } else { + string fallbackName; + if (nc_wepnid > 0) + fallbackName = ncEngine::FloatToString( nc_wepnid - 1 ); + else + fallbackName = ncEngine::FloatToString( nc_itemid - 1 ); + return fallbackName; + } +} + void ncItem::ItemTouched( ncEntity toucher ) { ncPlayer playerToucher; @@ -111,6 +142,21 @@ void ncItem::Release(ncEntity carrier) { } void ncItem::OnPickup(ncEntity carrier) { + carrier.SPrint( PRINT_LOW, carrier.netname ); + + if ( nc_wepnid > 0 ) { + carrier.SPrint( PRINT_LOW, " picked up weapon " ); + } else { + carrier.SPrint( PRINT_LOW, " picked up item " ); + } + + carrier.SPrint( PRINT_LOW, GetItemName() ); + carrier.SPrint( PRINT_LOW, "!\n" ); + + ncFX::CastScreenFlash( carrier ); + + if (nc_pckupsnd) + Sound( CHAN_ITEM, nc_pckupsnd, 1.0f, ATTN_NORM ); } @@ -119,4 +165,23 @@ void ncItem::OnInventoryUse( ncEntity carrier ) { carrier.SPrint(PRINT_LOW, " uses item "); carrier.SPrint(PRINT_LOW, ncEngine::FloatToString( inventory ) ); carrier.SPrint(PRINT_LOW, " which is unimplemented\n" ); +} + +ncItem ncItem::ItemForID( float itemNum ) { + ncEntity e; + while ( ( e = ncEngine::NextEnt( e ) ) ) { + if (e.nc_itemid == (itemNum + 1)) { + return (ncItem)e; + continue; + } + } + + return __NULL__; +} + +void ncItem::_InternalPostPrecache( void ) { + if (nc_pckupsnd) + ncEngine::Precache_Sound( nc_pckupsnd ); + if (nc_model) + ncEngine::Precache_Model( nc_model ); } \ No newline at end of file diff --git a/src/system/ncItem.qh b/src/system/ncItem.qh index 078d4d5..16443f3 100644 --- a/src/system/ncItem.qh +++ b/src/system/ncItem.qh @@ -1,4 +1,5 @@ class ncItem:ncEntity { +public: void ncItem(void); /* Sets the id of an Item. */ @@ -10,8 +11,16 @@ class ncItem:ncEntity { /** Returns the id of an Item. */ nonvirtual float GetInventoryID(void); + nonvirtual void SetItemModel(string); + nonvirtual void SetPickupSound(string); + nonvirtual string GetPickupSound(void); + nonvirtual void ItemTouched( ncEntity ); + nonvirtual string GetItemName( void ); + + virtual void Spawn( void ); + /** Overridable: Called when we switch to this weapon */ virtual void Draw(ncEntity); /** Overridable: On +attack execution. */ @@ -24,7 +33,15 @@ class ncItem:ncEntity { virtual void Release(ncEntity); virtual void OnPickup(ncEntity); virtual void OnInventoryUse( ncEntity ); + + nonvirtual ncItem ItemForID( float ); + +private: + virtual void _InternalPostPrecache( void ); }; .float nc_itemid; -.float nc_wepnid; \ No newline at end of file +.float nc_wepnid; +.string nc_model; +.string nc_name; +.string nc_pckupsnd; \ No newline at end of file diff --git a/src/system/ncPlayer.qc b/src/system/ncPlayer.qc index 2b95e70..e696b4a 100644 --- a/src/system/ncPlayer.qc +++ b/src/system/ncPlayer.qc @@ -103,6 +103,12 @@ void ncPlayer::StuffCmd( string s ) { stuffcmd( this, s ); } +void ncPlayer::LocalSound( string s ) { + stuffcmd( this, "play " ); + stuffcmd( this, s ); + stuffcmd( this, "\n" ); +} + .float item; bool ncPlayer::AddItem( float itemToAdd ) { ncItem theItem; @@ -174,13 +180,13 @@ bool ncPlayer::ImpulseCommand( float impulseValue ) { void ncPlayer::JumpPressed( void ) { SetVelocity(GetVelocity() + [0, 0, 250]); - SPrint(PRINT_HIGH, netname ); - SPrint(PRINT_HIGH, " pressed jump\n" ); + //SPrint(PRINT_HIGH, netname ); + //SPrint(PRINT_HIGH, " pressed jump\n" ); } void ncPlayer::JumpReleased( void ) { - SPrint(PRINT_HIGH, netname ); - SPrint(PRINT_HIGH, " released jump\n" ); + //SPrint(PRINT_HIGH, netname ); + //SPrint(PRINT_HIGH, " released jump\n" ); } float ncPlayer::GetInventoryItem( void ) { @@ -196,9 +202,12 @@ bool ncPlayer::DropInventoryItem( float itemNum ) { } bool ncPlayer::UseInventoryItem( float itemNum ) { - ncItem theItem; - ncEntity e; + + /* engine handles playing the sound in HeXen II */ +#ifndef TARGET_HEXEN2 + LocalSound( "misc/invuse.wav" ); +#endif /* check if we have it */ if (GetInventoryItemCount( itemNum ) <= 0 ) { @@ -212,12 +221,7 @@ bool ncPlayer::UseInventoryItem( float 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; - } - } + theItem = ncItem::ItemForID( itemNum ); if (!theItem) { //ncEngine::Error("Weapon of id "); @@ -331,6 +335,11 @@ void ncPlayer::NextInventoryItem( void ) { float firstSlot = -1; float nextSlot = -1; + /* engine handles playing the sound in HeXen II */ +#ifndef TARGET_HEXEN2 + LocalSound( "misc/invmove.wav" ); +#endif + for ( float f = 0; f < 15; f++ ) { float count = GetInventoryItemCount( f ); @@ -352,23 +361,28 @@ void ncPlayer::NextInventoryItem( void ) { if (nextSlot == -1) { /* do we have a first valid one? */ if (firstSlot != -1) { - inventory = firstSlot; + SelectInventoryItem( firstSlot ); return; } /* else... we just set it to 0, like Hexen 2 does (torch) */ - inventory = 0; + SelectInventoryItem( 0 ); return; } /* we're all good */ - inventory = nextSlot; + SelectInventoryItem( nextSlot ); } void ncPlayer::PreviousInventoryItem( void ) { float firstSlot = -1; float nextSlot = -1; + /* engine handles playing the sound in HeXen II */ +#ifndef TARGET_HEXEN2 + LocalSound( "misc/invmove.wav" ); +#endif + for ( float f = 14; f >= 0; f-- ) { float count = GetInventoryItemCount( f ); @@ -388,15 +402,28 @@ void ncPlayer::PreviousInventoryItem( void ) { if (nextSlot == -1) { /* do we have a first valid one? */ if (firstSlot != -1) { - inventory = firstSlot; + SelectInventoryItem( firstSlot ); return; } /* else... we just set it to 0, like Hexen 2 does (torch) */ - inventory = 0; + SelectInventoryItem( 0 ); return; } /* we're all good */ - inventory = nextSlot; + SelectInventoryItem( nextSlot ); +} + +void centerprint2(entity client, string s1, string s2) = #73; + +void ncPlayer::SelectInventoryItem( float itemNum ) +{ + if (GetInventoryItemCount( itemNum ) <= 0 ) { + return; + } + + ncItem theItem = ncItem::ItemForID( itemNum ); + centerprint2( this, "Selected: ", theItem.GetItemName() ); + inventory = itemNum; } \ No newline at end of file diff --git a/src/system/ncPlayer.qh b/src/system/ncPlayer.qh index 6bef2d3..b6c2be5 100644 --- a/src/system/ncPlayer.qh +++ b/src/system/ncPlayer.qh @@ -16,6 +16,7 @@ class ncPlayer:ncEntity { nonvirtual string GetInfoKey( string key ); nonvirtual void LogFrag( ncEntity victim ); nonvirtual void StuffCmd( string s ); + nonvirtual void LocalSound( string s ); virtual bool AddItem( float ); virtual bool SwitchToItem( float ); @@ -30,4 +31,5 @@ class ncPlayer:ncEntity { nonvirtual void NextInventoryItem( void ); nonvirtual void PreviousInventoryItem( void ); nonvirtual bool GetInventoryItemCount( float ); + nonvirtual void SelectInventoryItem( float ); }; \ No newline at end of file diff --git a/src/system/ncRules.qh b/src/system/ncRules.qh index 8460dd6..69b38a5 100644 --- a/src/system/ncRules.qh +++ b/src/system/ncRules.qh @@ -15,4 +15,4 @@ ncRules g_gameRules; #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 +#define INIT_ITEM(cname) { ##cname w_##cname = spawn(##cname); } \ No newline at end of file