Jump to content
The Dark Mod Forums

Applying Af Attachments


Springheel

Recommended Posts

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).

Link to comment
Share on other sites

  • Replies 91
  • Created
  • Last Reply

Top Posters In This Topic

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>"

Link to comment
Share on other sites

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"

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Thanks Ish, I've got it working. Now I'm just playing around with the origin coordinates.

Link to comment
Share on other sites

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? :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...