Adding Heads and Weapons to AI: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Original_Reference|ascottk|4633}}


<math>Springheel:  For mappers who want to swap heads on their AI, you don't need to change anything in the def files (nor should you) to attach a different head.
For attaching non-weapons and other items to AI see [[Attaching Props to AI]]


Just add the spawnarg:


"def_head" "tdm_head_young" (or whatever head you want)
==Changing (attaching) weapons to AI==


to the AI in question from the editor. Not every head looks good on every AI.  If you want to see what heads have been specifically set up to work on an AI, open the AI's .def file and look for the list of heads (see below).  Any heads not listed probably don't work.  The numerical values to the right offset the head so it fits properly on the AI's neck.
This section possibly needs expanding but here is some basic info:


"tdm_head_young" "-0.6 0 -8.5"
def_attach1 <weapon name> is sufficient now to attach working weapons to AI.
"tdm_head_young02" "-1 0 -9.5"
"tdm_head_pretty_old" "-0.8 0 -9"
"tdm_head_pretty_old02" "-1 0 -9.3"
"tdm_head_old_evileye" "-1 0 -9.5"
"tdm_head_bald" "-1 0 -9.2"
"tdm_head_bald02" "-1 0 -9"
"tdm_head_bald_big" "-1 0 -9.2"
</math>


Adding newly modelled heads:
Example:


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:
To make a builder use a sword instead of a hammer weapon:


model head_builderguard {
def_attach atdm:moveable_longsword
    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
By default that is carried on the back. I think there is a spawnarg to carry it at the belt (TO DO)
    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):
So, if you wanted say, a builder to use a bow then try this (I've not tested this):


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


That should be it for the head.
Optionally also add...


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:
def_attach2 atdm:prop_quiver_full


entityDef ai_weapon_hammer {
def_attach3 atdm:prop_quiver_arrow
    "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".
You might, for instance, find the above is optimally position on the back of the builder. TODO add offset spawnargs to modify position


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:
== Changing (attaching) heads on AI ==


    "def_attach"                "ai_weapon_hammer"
def_head <head name> is sufficient now to attach heads. But Dark Radiant now has a visual head browser so the easiest way is to enter the property def_head with some random characters as value, select it, then select the select head button at the bottom of the Entity Inspector panel.
    "def_dropDeathItem"        "ai_weapon_hammer_drop"
    "dropDeathItemJoint"        "RightHand"
    "dropDeathItemRotation"    "0 0 0"


into the main AI's entityDef.
Details are at:


def_attach = the weapon attachment
[[Swapping Heads on AI Models]]<BR>
def_dropDeathItem = the weapon after it drops off the AI
[[Heads Available for 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


[[Category:Tutorial]]
 
[[Category:Models]]
== Removing inherited Attachments from AI ==
[[Category:AI]]
It's possible to remove inherited AI attachments like weapons in DarkRadiant by overriding the inherited spawnargs. To do this, select the entity in DarkRadiant, select "Show inherited properties" and browse to the offending attachment (for instance "def_attach1") and set its value to the minus sign "-". (Note: It's not possible to store empty spawnargs (this would be a deletion in DarkRadiant), the "empty" value has been set to the minus "-" - this is just a convention, the SDK will ignore the minus signs. Other values will throw an error).
"def_attach1"  "-"
This will override the inherited spawnarg and in fact remove the attachment from the AI without throwing a console error on map load.
 
{{tutorial-ai}}
[[Category:Cleanup]]

Latest revision as of 22:16, 26 August 2010

For attaching non-weapons and other items to AI see Attaching Props to AI


Changing (attaching) weapons to AI

This section possibly needs expanding but here is some basic info:

def_attach1 <weapon name> is sufficient now to attach working weapons to AI.

Example:

To make a builder use a sword instead of a hammer weapon:

def_attach atdm:moveable_longsword

By default that is carried on the back. I think there is a spawnarg to carry it at the belt (TO DO)

So, if you wanted say, a builder to use a bow then try this (I've not tested this):

def_attach1 atdm:moveable_longbow

Optionally also add...

def_attach2 atdm:prop_quiver_full

def_attach3 atdm:prop_quiver_arrow

You might, for instance, find the above is optimally position on the back of the builder. TODO add offset spawnargs to modify position


Changing (attaching) heads on AI

def_head <head name> is sufficient now to attach heads. But Dark Radiant now has a visual head browser so the easiest way is to enter the property def_head with some random characters as value, select it, then select the select head button at the bottom of the Entity Inspector panel.

Details are at:

Swapping Heads on AI Models
Heads Available for AI


Removing inherited Attachments from AI

It's possible to remove inherited AI attachments like weapons in DarkRadiant by overriding the inherited spawnargs. To do this, select the entity in DarkRadiant, select "Show inherited properties" and browse to the offending attachment (for instance "def_attach1") and set its value to the minus sign "-". (Note: It's not possible to store empty spawnargs (this would be a deletion in DarkRadiant), the "empty" value has been set to the minus "-" - this is just a convention, the SDK will ignore the minus signs. Other values will throw an error).

"def_attach1"   "-"

This will override the inherited spawnarg and in fact remove the attachment from the AI without throwing a console error on map load.