multi_manager in Quake

Discuss programming in the QuakeC language.
Post Reply
Max_Salivan
Posts: 96
Joined: Thu Dec 15, 2011 1:00 pm

multi_manager in Quake

Post by Max_Salivan »

Hello all.
I have a question)
How to make multi_manager,that can parse variables from it?
or how to make quake engines do register any unknown fields?
or maybe a tutorial how to add _fullspawndata in "your custom quake engine"?

and what the extension that sticks all property data into the .netname field ?
Sorry for my english :)
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: multi_manager in Quake

Post by toneddu2000 »

I don't know what a multimanager is but, probably I can answer to your question #2
or how to make quake engines do register any unknown fields?
On FTE you can use in qc registercvar command. It allows you to create cvars on the fly.Then you can bind cvar just created to a variable and use it during game running. You can also set cvars in default.cfg (or any other .cfg file) with the set or seta directive

No idea about the other questions,sorry
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: multi_manager in Quake

Post by frag.machine »

Max_Salivan wrote:Hello all.
I have a question)
How to make multi_manager,that can parse variables from it?
or how to make quake engines do register any unknown fields?
or maybe a tutorial how to add _fullspawndata in "your custom quake engine"?

and what the extension that sticks all property data into the .netname field ?
What problem do you intend to solve with this "multi_manager" thing ?

If you are talking about additional entity fields, you just need to declare them in QuakeC.

For example, let's say you want to create a field called "ammo_smoke_grenades" so the player can carry smoke grenades besides the regular rockets.
You can open defs.qc and just add to the very end of the file this:

Code: Select all

.float ammo_smoke_grenades;
Notice the dot (".") before the float reserved word. It tells the QuakeC compiler you are creating a new field for every entity. Without this the compiler would interpret this line as a global variable.

Now you can use the new entity attribute just like any other entity field.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Max_Salivan
Posts: 96
Joined: Thu Dec 15, 2011 1:00 pm

Re: multi_manager in Quake

Post by Max_Salivan »

i think,you doesnt know,how its works

Everyone know what map entity has key and value
so
We can create QuakeC variable for axample ".float something" and use it on map entity
its will be like
"key" "something"
"value" "0"

but multi_manager can have any key,and its registering in GoldSrc engine

what does its looks like
"classname" "multi_manager"
"targetname" "start_titles"
"train" "3"
"fade_in" "0"
"origin" "2816 2624 704"
}
"train,fade_in are targets,values are wait for targets
in multi_manager all keys are targets
you can do something like this in quake,but i want this function compatible with hl maps)
but this way is hackish
you must rewrite entity like this
"classname" "multi_manager"
"targetname" "start_titles"
"target1" "train"
"wait1" "3"
"target2" "fade_in"
"wait2" "0"
"origin" "2816 2624 704"
}
i think you got my message with this or not:)
in FTE, _fullspawndata is best feature for this,you can parse keys for multi_manager
i can show code,that can use 16 targets in original QC,if you are interested
Sorry for my english :)
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: multi_manager in Quake

Post by frag.machine »

Oh, it's a GoldSrc entity, okay. Not familiar with HL modding. :)
https://developer.valvesoftware.com/wik ... ce_Engine)

Code: Select all

Entity description

Lets you trigger multiple entities, potentially with a delay before fire for each targeted entity.

To trigger an entity with it, you must first turn off smart edit, then add keyvalue pairs for the targets. The "key" is the targetname of the entity you want to target. The "value" is the delay in seconds before the entity is triggered after the multi_manager itself has been triggered. The same targetname can be targeted multiple times at different delays, however the keyvalue will become targetname#1 and so on.

A maximum of 16 targets can exist for a single multi_manager.
Key Values

Targetname:

Name <target_source>
    The targetname that other entities refer to this entity by.

Targets:

Any other entity's targetname <float>
    The entity targetnames to be fired by this multi_manager. The key is the targetname of another entity, and the value is the delay in seconds. Up to 16 targets in the queue can exist.
    Note:These keyvalues must be added manually without smart edit.
So, if I got this correctly, multi_manager works in a similar way to a trigger_delay, but can have more up to 16 different targets, right ?

You can try something like this (WARNING: UNTESTED, may not work as expected or even work at all)

Code: Select all

void () multi_manager_use = 
{
	local string tgt;
	local entity et, etmp;
	local float i, len, stop;

	self.use = SUB_Null;	// don't allow to activate it again until finished
	if (self.target == string_null) { return; }
	len = strlen (self.target);
	i = 0;
	stop = FALSE;
	while (!stop) {
		if (i >= len) { stop = TRUE; }
		if (substr(self.target,i,1) == ',') { stop = TRUE; }
		i++;
	}

	tgt = substr(self.target,0,i-1);
	if (i < len)	{ self.target = substr (self.target, i, len - i); }
	else			{ self.target = string_null; }
	
	et = find (world, targetname, tgt); 
	while (et != world) {
		etmp = self;
		self = et;
		SUB_UseTargets ();
		self = etmp;
		et = find (et, targetname, tgt);
	}
	
	if (self.target != string_null) {
		self.nextthink = time + self.delay;
		self.think = multi_manager_use;
	} else {
		self.use = SUB_Null;
		self.nextthink = 0;
		self.target = self.noise;
		self.use = multi_manager_use;
	}
};

void () multi_manager = {
	if (!self.target)			{ objerror ("No target value for multi_manager"); }
	else if (!self.targetname	{ objerror ("No targetname value for multi_manager"); }
	else	{
		self.noise = self.target;	// so it can be refired
		self.use = multi_manager_use;
	}
};
You will need an engine supporting at least the FRIK_FILE extension (substr(), strlen(),etc). I suggest either Darkplaces or FTEQW.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: multi_manager in Quake

Post by Spike »

Code: Select all

float numargs = tokenizebyseparator("example1,example2,example3", ",");
for(float f=0; f < numargs; f++)
    SUB_UseTargets(argv(f));
would allow you to call the various triggers. you could use "target1,delay1,target2,delay2" pairs instead if you wanted.
obviously this won't allow you to run existing maps and it does require that extended builtin, but on the plus side it also means you don't get stuck wondering what's a targetname to trigger and what's just an extra field.

halflife doing something a certain way doesn't make it a good way to do it in other games.

ultimately if you want that fullspawndata stuff, you can just see how your engine allocates its storage for string fields and just store the entire entity's spawn data into the appropriate global the same way, leaving you free to parse it in qc however you want.
note that fte's GC mechanism allows it to reclaim unused such strings, but other engines will have to retain all that information for the entire map. You could even pass it in as a tempstring and require the mod do strzone in its spawnfunc if it wants a permanent copy, meaning in a 32bit vanilla engine its basically just pr_globals[PR_FindGlobal("__fullspawndata")->ofs]._int = pointertobuffer - pr_strings;
Max_Salivan
Posts: 96
Joined: Thu Dec 15, 2011 1:00 pm

Re: multi_manager in Quake

Post by Max_Salivan »

pr_globals[PR_FindGlobal("__fullspawndata")->ofs]._int = pointertobuffer - pr_strings;
this is really can help me,but i am not a true engine coder,its pseudocode?

so,how i can use it,there is no PR_FindGlobal in glquake, just ED_FindGlobal
Sorry for my english :)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: multi_manager in Quake

Post by Spike »

so use that then.

the code I typed was from memory. My memory sucks, but it should point you in the right direction.
Post Reply