.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  
darkplaces builtin - ent_load (Groups : qc : Forum : hard_code() : darkplaces builtin - ent_load) Locked
Thread Options
numbersix
numbersix quake-c coder++
Jul 12 2015 Anchor

Per my last post, I have created a new builtin function for darkplaces: "ent_load"
(where are the editor text color controls? this editor just keeps getting worse!)

static void ent_load(const char *fname)

Thusly:

in svvm_cmds.c, modify
(I picked NULL, // #101)

VM_ent_load, // #101 void(string s) ent_load -Cataboligne - load ents on to map from: *bsp, *ent files

in prvm_cmds.h add

void VM_ent_load(void);

in prvm_cmds.c - the actual code:
(TAB is "___" - this editor refuses to do tabs, nbsp, etc.)

/*
=================
VM_ent_load__________________(Cataboligne - 7.10.15)

loads any map entities found in the supplied filenme
=================
*/
static void ent_load(const char *fname)
{
___char *entities;

___if ((entities = (char *)FS_LoadFile(va("%s", fname), tempmempool, true, NULL)))
___{
______Con_Printf("Loaded entities %s\n", fname);
______PRVM_ED_LoadFromFile (entities);
______Mem_Free(entities);
___}
}

void VM_ent_load (void)
{
___char string[VM_STRINGTEMP_LENGTH];

___VM_VarString(0, string, sizeof(string));
___ent_load(string);
}

Then compile, copy / install darkplaces_glx binary.

In quake-c:

void(string s) ent_load = #101;

This works as expected. Calling builtin 101 passes the string parameter to the VM function

I'm still testing but I expect I'll have to add a vector offset to use this with map-hack.
I was surprised at how easy this was.

>add a vector

I was right about this. A quick test shows the map chunk loads in the right location, but the entities center around '0, 0, 0'

Edited by: numbersix

Dec 5 2015 Anchor

Hmm, sounds impressive. Lord Havoc ought to see this.


If I undertand it right, from a qc perspective you are basicly spawning what they use to call "quaked" entities , aka, map entities such as

void () func_wall =
{

};


If so, then sure, you will need to specify origin arguments, or better yet why not copy them from a global field such as the entity "other" for example or create a new global entity, IE: entity dyn_mapent; just for this new built in.

Then any fields that entity has get passed to your new spawned ent.

numbersix
numbersix quake-c coder++
Dec 6 2015 Anchor

I may have already told him. Occasionally I ask him some questions. I get the feeling he might be pretty busy.

As far as actual purpose - it has to spawn _any_ entity that can be found on a map. Doors and other map model entities are the current challenge. They dont load external models, getting their model data from map brushes stored in the entity definition itself. Which the world load stores in a special array.

And I already have an origin solution - a special global entity called the "maphack" master specifies a position that is added to the inital load, which by design all center on '0 0 0'.

Rotating doors, buttons, plats, and other map brush model ents is also a big pain. On top of having to handle door internal triggers and other triggers and the need for a dynamic targeting system - so a button or trigger doesnt fire off every single copy of a door.

I'm currently looking at modifing ent_load to load map brush model entities when {mapname}.bsp is passed to it. Darkplaces also adds an entity replacement system with {mapname}.ent. But that can not handle brush data. I want to use the .ent files too - in the tradition of roguelikes, as you proceed in quake hack, different ents will load in a chunk. More powerful weapons and monsters.

This thing looks great in my imagination. If only I can make it work that way. A minecraft world...for quake.

--

\|/
-*- 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.