Jump to content
The Dark Mod Forums

Recommended Posts

Posted

We want to have our AI using AF weapons, so they will need to have attachments to put them on. They'll also need one to carry around belt-pouches, keys, etc.

 

What does it take to add three AF attachments to each guard model? (2 belt, 1 back).

  • Replies 91
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Okay it seems pretty obvious from looking at the def file:

 

entityDef monster_zombie_maint_wrench 
{
// ...
"def_attach"					"prop_wrench"
"def_head"						"head_zombie2"
"head_joint"					"Shoulders"

"def_dropDeathItem"				"moveable_wrench"
"dropDeathItemJoint"			"Rhand"
}

This shows how to attach both a wrench and a head. The dropDeathItem makes them drop it on death. For stuff like a belt pouch or a sword in a frog, I guess we don't want this, it should remain attached on death. We might have to modify the code a bit so that it only drops the sword when drawn before death.

 

Looking at the SDK, you can have as many attachements as you want, def_attach1, def_attach2, etc. Also from the SDK, the place where you specify the joint to attach to is actually on the entity you're attaching, in the key "joint" This doesn't seem like a very good design, since a given object wouldn't be able to attach to multiple joints, like the sword needs to attach to the hand when drawn and the belt when sheathed, but whatever, we can change that later since it's just retrieving a string. Also, I don't see a scriptfunction or anim frame command to set the attachment point, we'll probably need to add that also. Should be fairly straightforward.

 

Anyway for now, this is how you would set up one item to attach to one joint:

In the item's def file,

"joint" "<name of joint on the model to attach to>"

Posted
In the item's def file,

 

Any idea where I would find prop_wrench's def file? Items.def seemed to make the most sense, but I can't find it there or anywhere else.

 

edit: Ah, found it. I'll post it here and look at it later.

 

model prop_wrench {

mesh models/md5/props/wrench.md5mesh

 

}

 

entityDef prop_wrench {

"inherit" "cin_base"

"model" "prop_wrench"

"joint" "RHANDCONNECTOR"

"origin" "0 0 0"

"angles" "0 0 0"

"remove" "1"

}

Posted

Hmm, it looks like you have to make a md5mesh of the object before you can attach it, is that correct? All of the carried objects I can find from D3 are defined as a md5mesh. That's kind of limiting.

Posted

No, I don't think you have to do that. You just need to create a separate def for it to define the orientation and joint axis. I used very similar code for attaching to weapons (since Id didn't provide for that initially), and it works fine with regular models. The only thing you need an md5 for is the thing you're attaching it to (the AI in this case), since you're attaching it relative to a joint on that md5.

 

We still need to write some code additions for this though, because currently you can't attach and detach things dynamically on a living AI, you only attach once at spawn and then they can drop it if they die. We would need to dynamically attach and detach things for goals like switching the attachment point for the sword from the hip to the hand when they draw it. So the system may change, don't get too attached(!) to the current system.

Posted

Still messing around with this...is there any way to get the name of a particular joint on a model? I can't open the files, and looking through the def files doesn't seem to help.

 

All I really need is a single joint name, so that I can test that it works. Doesn't particularly matter which one.

Posted

You can open up the md5 with a text editor and it will list the names of all the joints. That will just give the names though, not where they are, unless you can guesstimate based on the coordinates listed. :)

Posted

Oh, thanks, I forgot I could do that. :blush:

 

Luckily, the names are fairly intuitive. Ok, sounds like the best candidates are:

 

"LeftHips_Dummy"

"RightHips_Dummy"

"RightUpLeg"

"LeftUpLeg"

"LeftHand"

"LeftHandIndex1" (2,3)

 

Looks like there are a LOT of hand/finger joints at the moment, though I suppose that will change when we go mitten hands.

Posted

That is really just the hip joint, with an offset either left or right depending on what hip you want it on. Yeah eventually we will want some "left hip" and "right hip" variables for the authors to fill in, but for now all it means is you just have to enter the same number every time, eg. set the X offset to -30 for the left hip, or 30 for the right hip, something like that.

Posted

I tried doing it the same way D3 did, but replaced "mesh" with "model". But what I get in-game is this:

 

af1.jpg

 

This was the def entry for the torch:

 

model prop_torch {

model models/darkmod/props/lights/extinguishable/torch.lwo

 

}

 

entityDef prop_torch {

"inherit" "cin_base"

"model" "prop_torch"

"joint" "LeftHand"

"origin" "0 0 0"

"angles" "0 0 0"

"remove" "1"

}

 

It's basically cut and pasted from the D3 ones, though they all pointed to md5meshes, as opposed to models. If you really can use models, then I must be missing something.

Posted

Well, this is the code that gets called when attaching things:

 

ent->SetOrigin( origin + originOffset * renderEntity.axis );
idMat3 rotate = angleOffset.ToMat3();
idMat3 newAxis = rotate * axis;
ent->SetAxis( newAxis );
ent->BindToJoint( this, joint, true );

There's nothing to indicate that the ent being attached (ent) has to have an md5 mesh. It could be any entity. I used basically the same code on the bow attachment, and that works fine to attach anything, I attached a vase for testing and we've attached the arrow models for the animations.

 

I'm not sure what the problem is with your test though. I can't really see the screenshot (too dark), could you describe what happens? It looks like there are some key/values in there that are weird, like you seem to be inheriting the def of a cinematic item (cin_base), could be that's set up to only appear in cinematics. An attachment doesn't need any of that stuff, just the model and the data about the attachment point, e.g. :

 

entityDef attachment_broadhead
{
"inherit"	"ammo_broadhead_small"
"joint"		"arrowbone"

"frobable"	"0"
"angles"	"90 0 0"
"origin"	"34 0 0"
"noshadows"	"1"
}

 

I think you're inheriting from a weird class is what I'm trying to say. You could even put func_static in the "inherit" and set the model to the torch model.

 

Also, you didn't specifically say whether you put that prop_torch in the "def_attach" key of the AI you're attaching it to, but I'm assuming you did?

Posted
I can't really see the screenshot (too dark), could you describe what happens?

 

Basically there's a big black box around the model's left hand. So the attach seems to be working, it just doesn't like the model. I've tried different models but I get the same result.

 

Also, you didn't specifically say whether you put that prop_torch in the "def_attach" key of the AI you're attaching it to, but I'm assuming you did?

 

Yep, I did that. I'll try changing the cin bit and see what happens.

Posted

Cool. I had some trouble myself adjusting the angles to get an arbitrary orientation. I think they are relative to the joint axis, but sometimes the joint axis X and Y are not conveniently directed for applying certain rotations.

Posted

I've been looking for the command but can't find it...what's the best way to make the AI blind/deaf so I can have an easier look at them?

 

Also, the next think I'm going to try....don't we have a prefab torch set up already? Any guesses about how to attach a prefab? :)

Posted

To make them blind use "acuity_vis" "0" or look at the aitest3 map AI settings if that doesn't work.

 

We should be able to attach prefabs. Binding acts like a chain, so if one thing has a "child" bound to it, and you bind the parent to a joint, the whole chain should be bound to it. In this case the flame/light entity is bound to the torch, so if you bind the torch to the hand it should work.

Posted
In this case the flame/light entity is bound to the torch, so if you bind the torch to the hand it should work.

 

Where would I find the torch that is used? Or do we not have a prefab torch yet? I thought we did, but I kind of lost track of that discussion.

Posted

AFAIK, we don't have one, mostly because the light itself incorporates the flame, so it's really just a matter of creating (any) torch, and then giving it a light_extinguishable_moving. The current model might need scaling anyway, if I remember correctly. When you do create one by adding a light to a torch and binding it, it seems like it does it at exactly the location you place it in the map, so that's somewhat convenient.

Posted

Well, good news. It looks like we won't have to create any new joints for binding things to AI's belts. Here's a mansion guard that just got paid. :)

 

af2.jpg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • JackFarmer

      "The Year of the Rat." 
      😄

      Al Stewart must be proud of you!
      Happy testing!
      @MirceaKitsune
      · 1 reply
    • datiswous

      I posted about it before, but I think the default tdm logo video looks outdated. For a (i.m.o.) better looking version, you can download the pk4 attached to this post and plonk it in your tdm root folder. Every mission that starts with the tdm logo then starts with the better looking one. Try for example mission COS1 Pearls and Swine.
      tdm_logo_video.pk4
      · 2 replies
    • JackFarmer

      Kill the bots! (see the "Who is online" bar)
      · 3 replies
    • STiFU

      I finished DOOM - The Dark Ages the other day. It is a decent shooter, but not as great as its predecessors, especially because of the soundtrack.
      · 5 replies
×
×
  • Create New...