Page 1 of 2

visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 3:01 pm
by ceriux
Visual Equipment mod release:

download
readme

mods mainly for coop and ffa use because the armor makes it to where you cannot see your custom colors.


-------------------------------------------------
okay so iv been attempting to get visual gear/weapons into quake. essentially what i did was edit the original player model i split the head from the body and weapons. the only part of the players model that it is still tied to the original player ent is the head model.

i spawn a new ent (pbody) and give it , it's own model. i then give the ent a think and next think which points to my body_think function. the body_think function tells pbody, that its frames are the same as its parents frames. the parent being the player/owner of pbody.

here's the thing i join the game with chase_active on i see the body set its frames to the idle frames then it crashes DP.

iv been trying to get help on IRC with this for the past 3 days. but no one there seems to know whats wrong. id really appreciate it if anyone could please point out what iv done/doing wrong. ill post the code here and a link to a pastebin.

--- body(); is only called once in client connect. i don't spam it in playerprethink or playerpostthink.

http://pastebin.com/zjU7kC4E

Code: Select all

// visual attachment stuff  (currently crashes)


void() body_think = 
{
	
	self.think = self.frame = self.parent.frame; // bodies frame is "parents" frame
	
	self.nextthink = time + 0.1; // think every 0.1 ticks

};

void() body =

{ 
	
	self.pbody = spawn ();  // spawn the body
	self.pbody.parent = self ;  // the bodies owner is the player
	
	
	
	setmodel (self.pbody, "progs/body.mdl"); // he will get the player body model
	setattachment (self.pbody, self.pbody.parent, ""); // attach the body model to "parent"
	
	self.pbody.think = body_think; // make the body think
	self.pbody.nextthink = time + 0.1; // it thinks every 0.1 ticks
};

EDIT : Right after i made this thread figured it out! im sorry, thread can be deleted. but ill post the fix and maybe the thread can be useful to someone else later on!



THE FIX:

Code: Select all

void() body_think = 
{
	self.frame = self.parent.frame; // bodies frame is "parents" frame
	self.think = body_think;
	
	self.nextthink = time + 0.01; // think every 0.01 ticks

};

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 4:15 pm
by frag.machine
I've made a multi part player model using MOVETYPE_FOLLOW instead of setattachment (see earlier version). It's tricky to make the body react in a synchronous way, but feasible.

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 4:31 pm
by ceriux
i started using movetype_follow. i was told by LH that its not as good as setattachment, so i changed my code to use it.

it syncs pretty well as far as i can tell.

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 4:33 pm
by frag.machine
hrmm, I think it's about time to me to learn more about setattachment then. :)

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 4:44 pm
by ceriux
the code above could be used for weapons as well as a body =) right now im still using the quake guy. =) also works in multipalyer =)

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 6:17 pm
by Cobalt
Sounds interesting , post a vid sample if u can.

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 24, 2013 6:52 pm
by ceriux
sure as soon as i can. the current code posted above only draws the original body. but its easy enough to add in support for showing armors with a few lines (already added green armor.) id like to get some weapons added in before i make a video.

once i get all this added in, i might release the visual parts of my mod as a standalone so others can use it.

Re: visual equipment / setattachment / parent/child ents

Posted: Fri Oct 25, 2013 3:10 pm
by drm_wayne
This is what i use to attach stuff to the player (weapons, legs etc...), works great in DQuake, Darkplaces but in FTEQW the legs are not really
synced xD
I use custom scratch qc so some stuff might look weird...

Legs ingame:

Image

Legs QC:

Code: Select all


void() legs_update =
	{
	float chasecam;
	chasecam = cvar("chase_active");
	if (chasecam == 1)	
	setmodel (self, string_null);
	else
	setmodel (self, "progs/players/p_legs.md2");	

	if (self.owner.deadflag != DEAD_NO)
            SUB_Remove();
		if (self.owner.incam == TRUE) // Intermission, we dont need to see our legs here
            SUB_Remove();
	makevectors(self.owner.v_angle);
	self.think = legs_update;
	self.nextthink = time + 0.01;
	
	self.angles_y = self.owner.angles_y;
	self.origin = self.owner.origin + v_up*-20;
	self.frame = self.owner.frame;
	}
		
void() player_legs = //Called at PutClientInServer
	{
	local entity legs
	makevectors(self.v_angle);
	legs = spawn();
	setmodel (legs, "progs/players/p_legs.md2");
	legs.solid = #SOLID_NOT;
	legs.movetype = #MOVETYPE_NOCLIP;
	legs.owner = self;
	legs.angles_y = self.angles_y;
	legs.origin = self.origin;
	legs.velocity = self.velocity;
	legs.drawonlytoclient = self;
	legs.frame = self.frame;
	legs.think = legs_update;
	legs.nextthink = time + 0.01;
	}



Re: visual equipment / setattachment / parent/child ents

Posted: Fri Oct 25, 2013 7:38 pm
by frag.machine
float chasecam;
chasecam = cvar("chase_active");
if (chasecam == 1)
setmodel (self, string_null);
else
setmodel (self, "progs/players/p_legs.md2");
In DP there's a extension exactly to deal with this situation: IIRC is DP_VISIBLETOCLIENT. I'm using this and makes the code much simpler and elegant.

Re: visual equipment / setattachment / parent/child ents

Posted: Fri Oct 25, 2013 7:54 pm
by Spike
fte defaults to prediction enabled.
cl_nopred to turn it off, or sv_nqplayerphysics to force it off for all clients (yay! authentic nq physics!).
you would see the same thing with DP and its cl_movement 1 setting.
setattachment works clientside so is meant to function properly regardless of prediction, instead of only when its disabled.

Re: visual equipment / setattachment / parent/child ents

Posted: Sun Oct 27, 2013 5:09 pm
by drm_wayne
frag.machine wrote:
float chasecam;
chasecam = cvar("chase_active");
if (chasecam == 1)
setmodel (self, string_null);
else
setmodel (self, "progs/players/p_legs.md2");
In DP there's a extension exactly to deal with this situation: IIRC is DP_VISIBLETOCLIENT. I'm using this and makes the code much simpler and elegant.
I know, the qc i posted above is mainly designed for my customized PSP Engine, i already added some DP features like drawonlytoclient and nodrawtoclient.

Re: visual equipment / setattachment / parent/child ents

Posted: Sun Oct 27, 2013 8:59 pm
by frag.machine
Just a correction: the DP extension I was referring actually is DP_ENT_EXTERIORMODELTOCLIENT.

Re: visual equipment / setattachment / parent/child ents

Posted: Mon Oct 28, 2013 8:28 pm
by ceriux
update, im still working on this. got all the armor coded in, but the weapons are crashing the game so i have to figure that out first.

edit: so there wasnt any problem with my code, some how one of the models became corrupt and thats fixed. which essentially means there are 2 things left to do. there's a bug with the exit level cam where you see the body still, and theres a bug with ring of invisibility where you have a body walking around with a floating pair of eyes (kinda funny looking). after that all is finished! then i can release.

Re: visual equipment / setattachment / parent/child ents

Posted: Thu Oct 31, 2013 12:15 pm
by ceriux
sorry for double post, mod has been finished, ill add information to the top of post.

Re: visual equipment / setattachment / parent/child ents

Posted: Fri Nov 01, 2013 6:44 pm
by Spirit
Hey, it would be great if you could add a readme to the archive. Check out some readmes from idgames2 as good examples: https://www.quaddicted.com/files/idgame ... nversions/ :wink:

For Quake file hosting there is http://quaketastic.com/ : quaketastic - ZigguratVertigoBlewTronynsSocksOff