Adding Heads and Weapons to AI: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
mNo edit summary
Line 3: Line 3:
Are you a mapper looking for info on [[Swapping Heads on AI Models]] in your map?
Are you a mapper looking for info on [[Swapping Heads on AI Models]] in your map?


The following information is for adding newly modelled heads to an AI's def file.
The following information is for modifying AI def files to add newly modelled heads or weapons.


First let's add the head (tdm_ai_builder_guard.def). First you need a head mesh and animations (duh wacko.gif ) & add the head to the def file:
First let's add the head (tdm_ai_builder_guard.def). First you need a head mesh and animations (duh wacko.gif ) & add the head to the def file:

Revision as of 20:47, 26 May 2007

Originally written by ascottk on http://forums.thedarkmod.com/topic/4633

Are you a mapper looking for info on Swapping Heads on AI Models in your map?

The following information is for modifying AI def files to add newly modelled heads or weapons.

First let's add the head (tdm_ai_builder_guard.def). First you need a head mesh and animations (duh wacko.gif ) & add the head to the def file:

model head_builderguard {
   mesh                   models/md5/chars/builders/guard/builderguard_head.md5mesh
   channel eyelids        ( Ruplid Rlolid Luplid Llolid )
   anim idle              models/md5/chars/builders/guard/head_idle.md5anim
   anim stand             models/md5/chars/builders/guard/head_idle.md5anim
   anim blink             models/md5/chars/builders/guard/head_blink.md5anim
   anim dead              models/md5/chars/builders/guard/head_death.md5anim
}

Then you need add refer to that in the main entityDef (most tdm AI will attach the heads to "Head" on the main model):

entityDef atdm:ai_builder_guard
{
   "inherit"         "atdm:ai_humanoid"
   "ragdoll"         "guard_base"
   "model"           "builderguard"
   "def_head"        "head_builderguard"
   "head_joint"      "Head"
       . . .
}

That should be it for the head.

Now let's add the weapon (it needs to have a collision mesh). First you need to add two entityDefs per weapon (currently the entityDefs are in tdm_ai_weapons.def). Let's use the hammer as an example:

entityDef ai_weapon_hammer {
   "inherit"       "func_static"
   "model"         "models/weapons/hammer.lwo"
   "frobable"      "0"
   "joint"         "sword"
   "origin"        "2 0 0"
   "angles"        "0 -55 -165"
   "remove"        "1"
}

entityDef ai_weapon_hammer_drop {
   "inherit"       "moveable_base"
   "model"         "models/weapons/hammer.lwo"
   "frobable"      "1"
   "origin"        "2 0 0"

   "angles"        "0 -55 -165"
   "remove"        "1"
   "density"       "0.01"
   "mass"          "100"
   "bouncyness"    "0"

   "nonsolid"      "0"
   //"nodrop"      "0"
   "noimpact"      "0"
   "notpushable"   "0"
}

The first entityDef is for the weapon the AIs carry and "frobable" needs set to "0" or you'll be able to carry that weapon . . . with an AI attached to it. The "joint" is where the weapon will be attached to on the main mesh. In our case the joint will usually be "sword".

The second entityDef is for the weapon after it drops. Now you can pick up the weapon without an AI attached to it thus "frobable" = "1".

Now we need to attach those to the AI. Just add:

   "def_attach"                "ai_weapon_hammer"
   "def_dropDeathItem"         "ai_weapon_hammer_drop"
   "dropDeathItemJoint"        "RightHand"
   "dropDeathItemRotation"     "0 0 0"

into the main AI's entityDef.

def_attach = the weapon attachment def_dropDeathItem = the weapon after it drops off the AI dropDeathItemJoint = the joint the weapon will drop from after the AI is unconscious or dead dropDeathItemRotation = optional rotation of the weapon when it drops