.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
Quake C v2.0 (Groups : qc : Forum : discuss() : Quake C v2.0) Locked
Thread Options
numbersix
numbersix quake-c coder++
Jan 16 2016 Anchor

After a short deliberation I have decided to re-christen qc++ v1.07 as (drum roll...)

quake c v2.0


Soon, this code base will have very little in common with v1.06.
Consequently it will only run on darkplaces or a port like maphack.

Now for a new achievement in quake c - with the existing override code I needed to make Q one work.
(which is about 10 lines needed for this bit, maybe 30 total)
6 new lines of code in 2 functions (3 in prespawn and 3 in startitem)

   if (!self.classvn) self.classvn = self.classname; // NOTE: order here, should this happen before any initial reassign ?s
   if (!isfunction(self.classname))
   {
       if (self.flags & FL_ITEM) self.classname = "StartItem";
   }

   if (self.classname == "StartItem")
   {
       self.classname = self.classvn;
       setmodel(self, self.model); // pre load doesnt set this
   }

Completely eliminates the need for any item spawn code - ANY item, even new stuff.
You just have to write the script that drives it similar to this example:

set    __d_weapon_shotgun                        1        "d shotgun wep testing"
set    __d_weapon_shotgun_flags                256        "item code - start as item"
set    __d_weapon_shotgun_touch                "weapon_touch"        ""
set    __d_weapon_shotgun_currentammo        8        "def ammo"
set    __d_weapon_shotgun_items                1        "IT_SHOTGUN"
set    __d_weapon_shotgun_lip                    101        "AMMO_SHELLS"
set    __d_weapon_shotgun_volume                50        "D_MAX_SHELLS"
set    __d_weapon_shotgun_attack_finished    1        ""

The same thing can be done for monsters.
Now the existing code will need some tweaks to use that - health and armor, minor tweaks - other items, more.
Any new weapons will need the fire functions of course.

Re-writing the existing code to be more generic and use that style
(and what I developed in the mark II code base to manage new weapons and items)
could prob eliminate 40% of the original quake c.

All of this:

items.qc :    void() item_health =
items.qc :    void() item_armor1 =
items.qc :    void() item_armor2 =
items.qc :    void() item_armorInv =
items.qc :    void() weapon_supershotgun =
items.qc :    void() weapon_nailgun =
items.qc :    void() weapon_supernailgun =
items.qc :    void() weapon_grenadelauncher =
items.qc :    void() weapon_rocketlauncher =
items.qc :    void() weapon_lightning =
items.qc :    void() item_shells =
items.qc :    void() item_spikes =
items.qc :    void() item_rockets =
items.qc :    void() item_cells =
items.qc :    void() item_weapon =
items.qc :    void() item_key1 =
items.qc :    void() item_key2 =
items.qc :    void() item_sigil =
items.qc :    void() item_artifact_invulnerability =
items.qc :    void() item_artifact_envirosuit =
items.qc :    void() item_artifact_invisibility =
items.qc :    void() item_artifact_super_damage = 

Gone. They will not be needed.
Code is already tested and functional.

Archon mod had 217 map codes for new items that doesnt include the nodules, power runes, crates, cubes, etc.
This will make it easier to support new items and port elements between mods.

On top of this admin / item control will be much easier.
Want super shotguns to be rocket launchers - edit a cfg, done.
Want the ring of invisibilty removed from your deathmatch server - done, like hitting the easy button.

There is always a catch of course.
This is only possible with darkplaces extensions - a good number of them.
Someone has to write the cfg files.
And, blow away config files and all you have is the defaults.
(But I bet I'll likely write this new code so all v1.06 stuff will still work.)

As the chaos mod mark III code base takes shape, it could get pretty wild.
Stay tuned.

Jan 16 2016 Anchor

Sounds interesting.


I have seen these refered to as "Quaked" entities in the old days. Essentially any item thats part of the map is what that means.

I know in the worldspawn function if you do nextent (world) up to however many maxplayers is set to , it wont go past that maxplayers number, as those player slots are now set up. Technicly no other ents are spawned as of yet, till _X_ number of frames....which is where things get tricky because depending on CPU speed and what engine and ticrate / frametime is running, means not all "Quaked" ents are not spawned yet.

So if your idea means less QC to go through, then I would guess this means all the ents are set up faster?

Edited by: Teknoskillz

numbersix
numbersix quake-c coder++
Jan 17 2016 Anchor

"QUAKED" was a series of comments in the source code:

/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
The next attack from the player will
do 4x damage. Lasts 30 seconds.
*/

Those often get put in some kind of file for editors to reference, like "entities.def" for radiant.
Newer editors use some kind of XML type .fgd file. Not to my liking.
This has very little to do with spawning ents. You can use _any_ function call as a classname:

// entity 115
{
"weapon" "16"
"ammo_cells" "23"
"ammo_rockets" "19"
"ammo_nails" "17"
"ammo_shells" "13"
"classname" "DropBackpack"
"origin" "-56 -312 56"
}

That is my editor trick to spawn a backpack with the indicated stuff.
Some of the map editing forums have lists of this kind of thing: map hacks
(Isnt that a coincidental name?)

When the engine loads the map, it processes the worldspawn and its brushes
Then it loads the rest of the ents. From a qc point of view that happens instantly, before worldspawn (or during) is called.
Any classnames wtih invalid function calls are removed. I change that in the prespawn to allow cfg of new ents with
no new spawn func.

And technically my new method has just as much qc to run. Possibly more.
Instead of an entire series of spawn funcs, SV_OnEntityPreSpawnFunction is called for every entity.
It will setup any ent it finds cfg data for in various formats. That means it runs checks on awhole bunch of possibilities.

This still happens blazingly fast.

The big slow down in my testing seems to be precache. Because it loads all kinds of stuff plus the models and sounds called
by map spawns. Since darkplaces dynamically precaches, I turned all the precache into // comments.
Map load went a lot faster after that. Except for the HD pack - thats a bit slow. That might be excessive precache though.

--

\|/
-*- Support free code: Patreon.com
/|\

Sep 15 2016 Anchor

those are spawn functions. the engine reads the entities when it loads the map and finds those functions.

why reinvent the wheel.

your wasting time doing things that seem interesting yet useless. hope you dont lose wind bewfore u finalize your project. and

i think you will graduate from highschool before you do finish, so stop wasting your time on quake. it is dead


numbersix
numbersix quake-c coder++
Sep 16 2016 Anchor

>why reinvent the wheel.

Because I got tired of maintaining a code base of spawn functions for an ever increasing pile of items.

>your wasting time

A Wizards (or a coders) time is never wasted! Perhaps frittered away foolishly. But even that, if enjoyable, is not a waste.
And this should be "You are wasting time"

>hope you dont lose wind

You worry about your problems - I'll take care of my own, thanks.

And I graduated before doom was released.

--

\|/
-*- Support free code: Patreon.com
/|\

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.