.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  
Map entities and Quake C (Groups : qc : Forum : vault() : Map entities and Quake C) Locked
Thread Options
numbersix
numbersix quake-c coder++
May 30 2014 Anchor

You may have been wondering how map authors use quake-c.

Raw maps are composed of 2 sections:

1. Brush data
2. Entity data

Entity data looks like this:

{
"classname" "item_shells"
"spawnflags" "1"
"origin" "48 -43 196"
"target" "trap1"
}

A sequence of string pairs consisting of string or numeric data.
The first is always a string representing an entity data field defined in quake-c with:
.float {field name}
.string {field name}
.vector {field name}
The second is the data for the specified entity parameter.
Order is not important for this data.

When the map is compiled, entity data is included in the "{mapname}.bsp".

When the engine loads the map it processes entity data last.
First an entity is created for each in game item (lights, for instance, do not consume in game entities.)
Second the fields specified above are loaded into any matching entity fields, such as: origin, spawnflags, classname, angle, target, etc.
Third the spawn function specified by "classname" is called in quake-c:

void() item_shells =
{
self.touch = ammo_touch;

if (self.spawnflags & WEAPON_BIG2)
{
precache_model ("maps/b_shell1.bsp");
setmodel (self, "maps/b_shell1.bsp");
self.aflag = 40;
}
else
{
precache_model ("maps/b_shell0.bsp");
setmodel (self, "maps/b_shell0.bsp");
self.aflag = 20;
}
self.weapon = 1;
self.netname = "shells";
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};

Notes:
You can only supply string or numeric data in the map entity second field.
Some fields, such as model, think functions, etc. can NOT be specified in map data.
Numeric or string codes can be used to tell quake-c what to do in these cases.

As seen in the shells example, one bit in spawnflags is used to control setting various fields in the code with regards to a large or small box of shells.
It would be trivial to allow map entity specs to over-ride in game specs, such as ammo counts in this shells example:

if (self.count > 0) self.aflag = self.count;

Add this prior to the closing "};".

The map author could now use "count" to specify shell boxes with 1 to any ammo count.
If not set, the default of 20 (or 40 for large) is used.

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.