Attaching Props to AI: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(3 intermediate revisions by the same user not shown)
Line 17: Line 17:
Each AI has a set of pre-determined coordinates (attachment points).  The mapper can attach things to these points by using the following spawnargs in an AI's entity window:
Each AI has a set of pre-determined coordinates (attachment points).  The mapper can attach things to these points by using the following spawnargs in an AI's entity window:


  "def_attach5"  "[entity name]"
  def_attach5       [entity name]
  "pos_attach5"  "[attachment point name]"
  pos_attach5       [attachment point name]


The number is arbitrary.  As long as both lines have the same number, you could use 999.  Best to stay away from numbers 1-5, however, as some AI come with default props (pauldrons, weapons, etc), and you could overwrite them.   
The number is arbitrary.  As long as both lines have the same number, you could use 999.  Best to stay away from numbers 1-5, however, as some AI come with default props (pauldrons, weapons, etc), and you could overwrite them.   
Line 52: Line 52:


=== List of Attachable Objects ===
=== List of Attachable Objects ===
The following are prop entities already created for def_attaching.  You can cut and paste these into the entity window in DR.  You may need to change the number to something unique.
The following are prop entities already created for def_attaching.  After you select one and copy its spawnargs into the AI's entity window in DR, you may need to change the ''attach'' number to something unique.


For information on making new attachment points, or positioning new entities, see [[Attachment Positions]].
For information on making new attachment points, or positioning new entities, see [[Attachment Positions]].


==== Lights ====
==== Hand Objects - Lights ====


  "def_attach5"  "atdm:prop_torch_on"        // a regular, lit torch
  def_attach5       atdm:prop_torch_on         ''// a regular, lit torch''
  "pos_attach5"  "hand_l"
  pos_attach5       hand_l


  "def_attach5"  "atdm:prop_torch_gothic_on"    // a lit torch with a cage
  def_attach5       atdm:prop_torch_gothic_on ''// a lit torch with a cage''
  "pos_attach5"  "hand_l"
  pos_attach5       hand_l


  "def_attach5"  "atdm:prop_lantern_on"       // a brass oil lantern
  def_attach5       atdm:prop_lantern_on      ''// a brass oil lantern''
  "pos_attach5"  "hand_l"
  pos_attach5       hand_l


  "def_attach5"  "atdm:prop_lantern02_on"      // an alternate metal oil lantern
  def_attach5       atdm:prop_lantern02_on     ''// an alternate metal oil lantern''
  "pos_attach5" "hand_l"
  pos_attach5       hand_l
 
==== Hand Objects - Other Than Lights ====
 
def_attach5        atdm:prop_halberd        ''// a long halberd; decorative only--dropped when AI alerted''
pos_attach5        hand_l
 
def_attach5        atdm:prop_winebottle      ''// AI holds bottle and occasionally drinks from it''
  pos_attach5        hand_l
 
def_attach5        atdm:prop_cards          ''// AI holds hand of cards and occasionally draws another one.  For use when sitting.''
pos_attach5        hand_l


==== Belt Objects ====
==== Belt Objects ====


  "def_attach6"  "atdm:prop_lootbag// used for loot
  def_attach6       atdm:prop_lootbag         ''// used for loot''
  "pos_attach6" "belt_back_right"
  pos_attach6       belt_back_right
 
  def_attach6        atdm:prop_belt_pouch      ''// used for decoration''
pos_attach6        belt_back_right


  "def_attach6"  "atdm:prop_belt_pouch" // used for decoration
  def_attach6       atdm:prop_potion_healing ''// for pick-pocketing; AI will not use it.''
  "pos_attach6"  "belt_back_right"
  pos_attach6       belt_back_right


  "def_attach6"  "atdm:prop_key_gold"
  def_attach6       atdm:prop_smithyhammer    ''// a simple work hammer, decorative only at the moment''
  "pos_attach6"  "belt_back_right"
  pos_attach6       hip_sheath_l


"def_attach6"  "atdm:prop_key_silver"
==== Belt Objects - Keys ====
"pos_attach6"  "belt_back_right"
''Example of key attachment by bikerdude''


  "def_attach6"  "atdm:prop_key_padlock"
  def_attach6               atdm:prop_silverkey
  "pos_attach6" "belt_back_right"
  pos_attach6               belt_back_right
  name_attach6              gate_key
set inv_name on gate_key  gate key          ''// name shown in inventory''
set name on gate_key      gate_key


"def_attach6"  "atdm:prop_key_simple"
More info can be found on the following thread - http://forums.thedarkmod.com/topic/13084-ai-attach-keys/
"pos_attach6"  "belt_back_right"


  "def_attach6"  "atdm:prop_key_fancy01"
Other attachable key styles include:
  "pos_attach6"  "belt_back_right"
atdm:prop_key_gold
atdm:prop_key_silver
atdm:prop_key_simple
  atdm:prop_key_fancy01
  atdm:prop_key_padlock


"def_attach6"  "atdm:prop_potion_healing"      // for pick-pocketing; AI will not use it.
=== Changing the Behavior of Def-Attached Props ===
"pos_attach6"  "belt_back_right"
''by Geep''


"def_attach6"  "atdm:prop_smithyhammer"  // a simple work hammer, decorative only atm
As with the Keys example above, you have to name the prop:
  "pos_attach6"  "hip_sheath_l"
  name_attach[number]  [my_prop_name]  ''where [number] is the def_attach number and my_prop_name contains no spaces''


== Example, attaching a key to an AI == (bikerdude)
Then reference that name:
set [spawnarg] on [my_prop_name]  [value]


"def_attach6" "atdm:prop_silverkey"
This can be done not just for props you attach, but for those pre-provisioned with an AI. For example, consider an archer whose quiver comes with 1 frobable arrow. Suppose you wish to override the default frob behavior. If you examine the archer with the Entity Inspector (including inherited items), you will find that there's an arrow on def_attach3, but it is unnamed. Fix that:
  "pos_attach6" "belt_back_right"
  name_attach3      quiver_arrow
"name_attach6" "gate_key"
Then, to replace the default frob action with a function FrobbedQuiverArrow you defined in <fm>.script:
"set inv_name on gate_key" "gate key"
  set frob_action_script on quiver_arrow    FrobbedQuiverArrow
  "set name on gate_key" "gate_key"


More info can be found on the following thread - http://forums.thedarkmod.com/topic/13084-ai-attach-keys/
''Suggested by Destined''


==== Other ====
If you want to instead use Stimulus/Response to affect behavior, note that props that are def_attached are not visible as selectable objects in DR. So the usual direct method of using the S/R Editor is not possible.


"def_attach5"  "atdm:prop_halberd"  // a long halberd; decorative only--dropped when AI alerted
Instead, create all the S/R spawnargs manually. The easiest way to do that is create a dummy entity and, with it selected, set up the response effects you want with the S/R Editor. Once you have generated all the spawnargs you need, apply each to your AI as:
  "pos_attach5"   "hand_l"
  set [S/R spawnarg] on [my_prop_name]  [S/R value]   ''where [my_prop_name] might be "quiver_arrow" from above''


"def_attach5"  "atdm:prop_winebottle" // AI holds bottle and occasionally drinks from it
If there is any problem when overriding a behavior for an existing prop, a safe bet is to write a new definition. Thus, in our arrow example, copy the definition of atdm:prop_quiver_arrow to a new definition file, rename the definition to a unique name (e.g. "atdm:prop_quiver_arrow_special"). Again, use a dummy entity to create the S/R spawnargs. Then add those spawnargs to the definition, and change the spawnarg def_attach_3 on the AI to the new name.
"pos_attach5"  "hand_l"


"def_attach5"  "atdm:prop_cards"  // AI holds hand of cards and occasionally draws another one.  For use when sitting.
This latter alternative is especially useful if you want this response on multiple AI: just set up the S/R spawnargs once, then easily give the special arrow to various AI by changing the def_attach_3 spawnarg.
"pos_attach5"  "hand_l"


== Binding ==
== Binding ==


'''Benefits:''' You can bind any object to an AI, so it is a great deal more flexible.  You can also see and position the object in DR.
'''Benefits:''' You can bind any object to an AI, so it is a great deal more flexible.  You can also see and position the object in DR.


'''Weaknesses:''' Bound objects cannot affect AI animations.  You must adjust each object individually.
'''Weaknesses:''' Bound objects cannot affect AI animations.  You must adjust each object individually.


See [[BindToJoint]] for more info.
See [[BindToJoint]] and [[Attaching Items]] for more info on using bind.
 
 
See [[Attaching Items]] for more info on using bind.


{{tutorial-ai}}
{{tutorial-ai}}

Revision as of 21:24, 23 March 2020

Attaching things to AI is an important way to make your AI unique.

There are two ways to attach things (hereafter referred to as 'props') to AI. Each has its strengths and weaknesses.


To attach working weapons and heads see Adding Heads and Weapons to AI


Using Def_Attach

Benefits: The mapper can easily attach pre-existing prop entities; no fiddling with positions or rotations. More importantly, def_attached entities often adjusts AI animations appropriately (eg, def_attaching a torch automatically makes the AI use the 'torch' animations).


Weaknesses: It is time-consuming to make prop entities that don't already exist. Def_attached objects will not be visible in DR.


Each AI has a set of pre-determined coordinates (attachment points). The mapper can attach things to these points by using the following spawnargs in an AI's entity window:

def_attach5       [entity name]
pos_attach5       [attachment point name]

The number is arbitrary. As long as both lines have the same number, you could use 999. Best to stay away from numbers 1-5, however, as some AI come with default props (pauldrons, weapons, etc), and you could overwrite them.

[entity name] is the entity that you want to attach, like "atdm:prop_torch_gothic_on". You can find a list of preset attachable objects in prop_items.def and prop_wearable_items.def. Or see the quick list below.

[attachment point name] is the name of the predefined point you want to attach the object to, like "hand_l". See the list of preset attachment points below.


This image indicates some common attachment points. You can cut and paste the names below:

attachment_points.jpg

1. "hip_sheath_l"

This is designed for sheathed weapons on the hip.

2. "hand_l"

The left hand, used for torches, bottles, etc. You can attach a weapon to this hand but AI will not attack with it.

3. "belt_back_right"

This is on the back of the belt on the right hand side, designed for purses, keys, or other things players may want to pickpocket.

4. "hand_r"

The right hand. Generally reserved for weapon use.

5. "slung_across_back_rl"

This is primarily used for weapons worn on the back, like hammers or bows.

List of Attachable Objects

The following are prop entities already created for def_attaching. After you select one and copy its spawnargs into the AI's entity window in DR, you may need to change the attach number to something unique.

For information on making new attachment points, or positioning new entities, see Attachment Positions.

Hand Objects - Lights

def_attach5        atdm:prop_torch_on         // a regular, lit torch
pos_attach5        hand_l
def_attach5        atdm:prop_torch_gothic_on  // a lit torch with a cage
pos_attach5        hand_l
def_attach5        atdm:prop_lantern_on       // a brass oil lantern
pos_attach5        hand_l
def_attach5        atdm:prop_lantern02_on     // an alternate metal oil lantern
pos_attach5        hand_l

Hand Objects - Other Than Lights

def_attach5        atdm:prop_halberd         // a long halberd; decorative only--dropped when AI alerted
pos_attach5        hand_l
def_attach5        atdm:prop_winebottle      // AI holds bottle and occasionally drinks from it
pos_attach5        hand_l
def_attach5        atdm:prop_cards           // AI holds hand of cards and occasionally draws another one.  For use when sitting.
pos_attach5        hand_l

Belt Objects

def_attach6        atdm:prop_lootbag          // used for loot
pos_attach6        belt_back_right
def_attach6        atdm:prop_belt_pouch       // used for decoration
pos_attach6        belt_back_right
def_attach6        atdm:prop_potion_healing  // for pick-pocketing; AI will not use it.
pos_attach6        belt_back_right
def_attach6        atdm:prop_smithyhammer    // a simple work hammer, decorative only at the moment
pos_attach6        hip_sheath_l

Belt Objects - Keys

Example of key attachment by bikerdude

def_attach6                atdm:prop_silverkey
pos_attach6                belt_back_right
name_attach6               gate_key
set inv_name on gate_key   gate key          // name shown in inventory
set name on gate_key       gate_key

More info can be found on the following thread - http://forums.thedarkmod.com/topic/13084-ai-attach-keys/

Other attachable key styles include:

atdm:prop_key_gold
atdm:prop_key_silver
atdm:prop_key_simple
atdm:prop_key_fancy01
atdm:prop_key_padlock

Changing the Behavior of Def-Attached Props

by Geep

As with the Keys example above, you have to name the prop:

name_attach[number]   [my_prop_name]   where [number] is the def_attach number and my_prop_name contains no spaces

Then reference that name:

set [spawnarg] on [my_prop_name]   [value]

This can be done not just for props you attach, but for those pre-provisioned with an AI. For example, consider an archer whose quiver comes with 1 frobable arrow. Suppose you wish to override the default frob behavior. If you examine the archer with the Entity Inspector (including inherited items), you will find that there's an arrow on def_attach3, but it is unnamed. Fix that:

name_attach3       quiver_arrow

Then, to replace the default frob action with a function FrobbedQuiverArrow you defined in <fm>.script:

set frob_action_script on quiver_arrow     FrobbedQuiverArrow

Suggested by Destined

If you want to instead use Stimulus/Response to affect behavior, note that props that are def_attached are not visible as selectable objects in DR. So the usual direct method of using the S/R Editor is not possible.

Instead, create all the S/R spawnargs manually. The easiest way to do that is create a dummy entity and, with it selected, set up the response effects you want with the S/R Editor. Once you have generated all the spawnargs you need, apply each to your AI as:

set [S/R spawnarg] on [my_prop_name]   [S/R value]   where [my_prop_name] might be "quiver_arrow" from above

If there is any problem when overriding a behavior for an existing prop, a safe bet is to write a new definition. Thus, in our arrow example, copy the definition of atdm:prop_quiver_arrow to a new definition file, rename the definition to a unique name (e.g. "atdm:prop_quiver_arrow_special"). Again, use a dummy entity to create the S/R spawnargs. Then add those spawnargs to the definition, and change the spawnarg def_attach_3 on the AI to the new name.

This latter alternative is especially useful if you want this response on multiple AI: just set up the S/R spawnargs once, then easily give the special arrow to various AI by changing the def_attach_3 spawnarg.

Binding

Benefits: You can bind any object to an AI, so it is a great deal more flexible. You can also see and position the object in DR.

Weaknesses: Bound objects cannot affect AI animations. You must adjust each object individually.

See BindToJoint and Attaching Items for more info on using bind.