Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

darkplaces help with attach entities

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
RooT Joined: 07 Sep 2005 Posts: 40 |

Posted: Fri Oct 21, 2005 3:55 am Post subject: darkplaces help with attach entities |

ive been reading through the darkplaces.qc trying to understand the quake3 attack entity script, and what ive gathered is that it allows seemless movement of one entity with another, such as say a weapon in the players hand (not first person tho) . Lets just say I wanted to make a hat or something, that you can have attached to players head. how do i set the attachment point for the hat? i think its tag_index but im not quite sure what it wants me to do with it
if someone could explain this a little for me i would much appreciate it. thanks!
-root
_________________
My mod site!
Mod Status:
Turret Defense: 30%
UPS: 45%

Back to top |

Supa Joined: 26 Oct 2004 Posts: 122 |

Posted: Fri Oct 21, 2005 5:56 pm Post subject: |

To just attach an entity to an object, you need to call:

Code:
setattachment(entity (the entity you want to attach), entity (the entity you want to attach it to), string (name of the tag to attach the entity to, ie 'tag_foo'); For example: setattachment(foo, self, "tag_torso");

Of course, you'll need a tag to attach it to or the attacher entity will just attach to the center of the attachee.
Once an entity is attached to another, .tag_entity will return which entity it's attached to and .tag_index will return the index of the tag (tag_index of 2 would be the second tag, for instance). One last note, once an entity is attached to something it ignores collision, so you can't do things like hand held shields easily (You *can* do them, it's just harder).
[Edit: I managed to confuse even myself so I added an example to better explain what I was trying to say.]

Back to top |

RooT Joined: 07 Sep 2005 Posts: 40 |

Posted: Fri Oct 21, 2005 8:52 pm Post subject: ahh |

i think i get it thanks man, hope to turn out something useful with all that work you put in for me thanks again -root _________________ My mod site! Mod Status:
Turret Defense: 30%
UPS: 45%

Back to top |

jimmmy Joined: 07 Nov 2005 Posts: 5 Location: Australia |

Posted: Mon Nov 07, 2005 9:59 am Post subject: |

Supa wrote:
One last note, once an entity is attached to something it ignores collision, so you can't do things like hand held shields easily (You *can* do them, it's just harder).

What's the best way to do attachments but still have collisions?
Use MOVETYPE_FOLLOW? Or attach the entity and have an invisible 'bounding box' using' MOVETYPE_FOLLOW or something similar?
Thanks.

Back to top |

Supa Joined: 26 Oct 2004 Posts: 122 |

Posted: Fri Nov 11, 2005 9:44 am Post subject: |

jimmmy wrote:
What's the best way to do attachments but still have collisions? Use MOVETYPE_FOLLOW? Or attach the entity and have an invisible 'bounding box' using' MOVETYPE_FOLLOW or something similar?

Both the MOVETYPE_FOLLOW (You'd actaully need MOVETYPE_NONE) and the bounding box (Again, MOVETYPE_NONE) method will work (The bounding box method will result in another entity per player though *and* the bounding box needs to be a reasonable duplicate of the shield model). Use DP_QC_GETTAGINFO to get the forward vectors of the shield tag and align the entity to match. Note that you're going to need to update the position and angles of the 'shield' every frame.
Note that if you use this method you will need to modify how your weaponset works or you'll get things hitting the bounding box of the shield when they shouldn't. (Much like firing a little over a grunts head and still hitting the grunt) For traceline weapons you just need to use MOVE_HITMODEL when you call traceline, please check dpextensions.qc for details on this. For projectiles you'll need to trace out from the front of the projectile a little each frame, again using MOVE_HITMODEL. I haven't actually tried using this with projectiles though, so I could be wrong.
'Hope this helps and let me know how it works, okay? =)

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Sat Nov 12, 2005 1:13 am Post subject: |

ACtually if you want to have it work with projectiles as well, set the shield's solid to SOLID_BSP. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

jimmmy Joined: 07 Nov 2005 Posts: 5 Location: Australia |

Posted: Tue Nov 22, 2005 3:24 am Post subject: |

Thanks for that help, however I don't seem to have my implementation quite right and aren't sure exactly what I'm doing wrong. I'm not familiar enough with quake c. I'm using noctrun's md3 example code (http://mitglied.lycos.de/noctrun/q1md3/ ) as a base and fiddling around with md3 models using that (I'm experimenting before I waste any of my art orientated friend's time), my plan was to remove its usage of attach so that each body section can handle collisions with traces via MOVE_HITMODEL for simple location damage type stuff.
So far this is what I have:

Code:
void(entity body) AttachBodyParts = { local float torsoTagIndex; torsoTagIndex = gettagindex(body, "tag_torso"); gettaginfo(body, torsoTagIndex);
setorigin (body.torso, v_forward);
body.torso.angles = v_forward;
}
void() UpdatePeopleModels =
{
local entity people;
people = find(world, classname, "monster_army");
while (people)
{
AttachBodyParts(people);
people = find(people, classname, "monster_army");
// loop to next monster in sequence (the start parameter is now person)
}
}

UpdatePeopleModels is temporary while I get the basic code working, afterwards I'll do something more efficient. I'm just testing it out with the ranger replacement for the grunt / soldier.
I call AttachBodyParts from the setup function (setq3model in noctrun's code) and UpdatePeopleModels every frame like you said.

Code:
void(entity person, string mdl_legs, string mdl_torso, string mdl_head) setq3model = { if (person == world) { return;
}
//don't add new torso/head while respawning in multiplayer
if (person.md3partsspawned == FALSE)
{
person.torso = spawn();
person.head = spawn();
person.md3partsspawned = TRUE;
}
setmodel(person, mdl_legs);
setmodel(person.torso, mdl_torso);
setmodel(person.head, mdl_head);
person.head.exteriormodeltoclient = person;
person.torso.exteriormodeltoclient = person;
AttachBodyParts(person);
// setattachment(person.torso, person, "tag_torso");
// setattachment(person.head, person.torso, "tag_head");
person.torso.think = md3_player_animate_torso;
person.torso.nextthink = time + 0.1;
};

So I've commented out the setattachment bits of code and replaced them with AttachBodyParts (which doesn't do the head yet). But it doesn't seem to be working and my attempts at trying other methods and figuring out why have been rather unsuccessful.
Thanks for your help so far and any you can give me with this next bit.

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group