Forum

visual equipment / setattachment / parent/child ents

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

visual equipment / setattachment / parent/child ents

Postby ceriux » Thu Oct 24, 2013 3:01 pm

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

};
Last edited by ceriux on Sun Nov 03, 2013 5:51 am, edited 3 times in total.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby frag.machine » Thu Oct 24, 2013 4:15 pm

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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: visual equipment / setattachment / parent/child ents

Postby ceriux » Thu Oct 24, 2013 4:31 pm

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.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby frag.machine » Thu Oct 24, 2013 4:33 pm

hrmm, I think it's about time to me to learn more about setattachment then. :)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: visual equipment / setattachment / parent/child ents

Postby ceriux » Thu Oct 24, 2013 4:44 pm

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 =)
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby Cobalt » Thu Oct 24, 2013 6:17 pm

Sounds interesting , post a vid sample if u can.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: visual equipment / setattachment / parent/child ents

Postby ceriux » Thu Oct 24, 2013 6:52 pm

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.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby drm_wayne » Fri Oct 25, 2013 3:10 pm

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;
   }


User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: visual equipment / setattachment / parent/child ents

Postby frag.machine » Fri Oct 25, 2013 7:38 pm

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 FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: visual equipment / setattachment / parent/child ents

Postby Spike » Fri Oct 25, 2013 7:54 pm

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.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: visual equipment / setattachment / parent/child ents

Postby drm_wayne » Sun Oct 27, 2013 5:09 pm

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.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: visual equipment / setattachment / parent/child ents

Postby frag.machine » Sun Oct 27, 2013 8:59 pm

Just a correction: the DP extension I was referring actually is DP_ENT_EXTERIORMODELTOCLIENT.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: visual equipment / setattachment / parent/child ents

Postby ceriux » Mon Oct 28, 2013 8:28 pm

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.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby ceriux » Thu Oct 31, 2013 12:15 pm

sorry for double post, mod has been finished, ill add information to the top of post.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: visual equipment / setattachment / parent/child ents

Postby Spirit » Fri Nov 01, 2013 6:44 pm

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
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest