Forum

Entities creation/QuakeC and map connection

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Entities creation/QuakeC and map connection

Postby daemonicky » Thu Apr 28, 2011 10:50 am

IIUIC :
    each entity has attributes
      - Does it have to have attribues :?:
      - I want to make mod from scratch. What is a minimal set of attribues which Quake needs :?: Is it the one in progdefs.h :?:
    entities share attributes
      - engine gets attribute by fixed offsets (they are in a vector) rather than hashmap. How are user defined attributes stored :?:

    you create entity with classname X in a map
      - if map editor does not support arbitrary names use EntEd
    you create void function with name X in a Quake C
      - if you dont have one entity is not spawned
    when a map is loaded for all entities on a map quake calls all their X functions (based on their classnames)

    you make up some entity attributes Y in a map
    you add those parameters Y in a Quake C
      - into defs.qc (must be :?:)


Thanks. :)
User avatar
daemonicky
 
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Re: Entities creation/QuakeC and map connection

Postby behind_you » Mon May 02, 2011 8:56 am

from what you said (that from which i could comprehend):
entities don't have to have attributes.

daemonicky wrote:IIUIC :
you create entity with classname X in a map
    - if map editor does not support arbitrary names use EntEd
you create void function with name X in a Quake C
    - if you dont have one entity is not spawned
when a map is loaded for all entities on a map quake calls all their X functions


are these questions or statements?

my advice: please keep your topics organized, alright? reading that hurt my head.
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Spike » Mon May 02, 2011 1:14 pm

an ent is a block of fields
a union between an array and the fields defined before end_sys_fields in defs.qc.
the progs contains names/indexes of the fields, allowing the engine to lookup the index by field name.
fields can be defined anywhere at global scope in qc code. it doesn't have to be just in defs.qc. code cleanliness means they're *usually* defined in defs.qc, yes. but not always, you can define them whereever you want.

every entity type has the same exact fields. whether they are actually used is a different matter. the fields are always equally valid, as far as the engine/vm is aware.

loading ents from maps is a case of: spawn an ent. for each named field, look up the offset, store the value at that format ('angle' gets remapped to 'angles_y', field names with a leading underscore are considered comments and ignored), fields that don't exist result in a warning instead. find a function with the same name as the new .classname field. if found, call the function, if not found, delete the ent and print a warning.


editors don't have a clue which fields are used by any given entity type unless explicitly told. QuakeED parses the QC code itself, but other editors have some private field list which is chosen based on the classname chosen. Editors don't have a clue about custom fields in custom mods, and thus generally provide a way to add whatever custom fields you want.

note that functions are loaded in the same way that any other field is loaded, and matched by name. which means you can do some sneaky info_notnull entity hacks.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Entities creation/QuakeC and map connection

Postby daemonicky » Wed May 04, 2011 1:53 pm

Thank you both. And I apologize for messy post. :)

So, in order to make entity work I have to make function in quake C and match its classname in level editor?

What info_notnull hacks? Are they necessary?
User avatar
daemonicky
 
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Postby behind_you » Tue May 31, 2011 8:42 am

you're function:

void() iwanttoputagunhere;

in your map, make an entity called iwanttoputagunhere.


that's how you do it
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest