View Issue Details

IDProjectCategoryView StatusLast Update
0003597The Dark ModAnimationpublic21.08.2015 21:17
Reportersotha_sil Assigned ToSteveL  
PrioritynormalSeveritynormalReproducibilityalways
Status resolvedResolutionfixed 
Product VersionTDM 2.00 
Target VersionTDM 2.04Fixed in VersionTDM 2.04 
Summary0003597: Firing AI animations through a script has problems
DescriptionSometimes the mapper may need to run an anim for an AI via a script using the playAnim-commands.

There are bugs in this approach:
0) AI who has no targets behaves differently from AI who has targets
1) AI who has no target interrupts the script-fired animation if an idle animation runs while he is running the script-fired animation.
2) AI who has a target and is patrolling will get borked. They won't move anymore, just stand in place turning in random directions.

Presently, the only reliable way to play script-fired animations, uninterrupted, is to use the conversation system, which is a bit clunky. (Each AI affected by anim must have their own conversation set up.)

The desired way how this should work would be probably the same way the conversation animations work. When the AI receive a script-fired animation command, the AI stops whatever they are doing, plays the anim (without it being interrupted by idle anims) and once completed, resume their activities. Being alerted would cancel the animations, just like when using the conversation system.
Steps To ReproduceSee attached maps. There are a man and a woman there. When the lever is pulled, a script applies

$girl.playAnim(ANIMCHANNEL_TORSO ,"kneel_down");
$girl.playAnim(ANIMCHANNEL_LEGS ,"kneel_down");

$boy.playAnim(ANIMCHANNEL_TORSO ,"kneel_down");
$boy.playAnim(ANIMCHANNEL_LEGS ,"kneel_down");

For both the actors. The woman, who is patrolling between two path_corners, will get stuck. The man plays the anims, but you will see that the script-fired anim is interrupted by the idle animations. Both actors have idle_animations_interval of 5 to make it easier to catch idle anims.
TagsNo tags attached.
Attached Files
animation_issue.map (20,942 bytes)

Relationships

related to 0003800 resolvedSteveL anim tasks (path anim, path cycle anim, play anim) snap in without blending 

Activities

SteveL

SteveL

10.09.2014 19:49

reporter   ~0006978

playAnim isn't suitable for use by map scripts, so they have no tool to use. It's the internal mechanism used by Actor AnimState script objects to start anims, and it relies on the state scripts to set up the required blend frames, and to prevent different anims from clashing. The anim state scripts can also be completely borked (as reported above) by anything else calling playAnim, which they don't expect.

So "playAnim" needs to be marked "Do not use. Use XXX instead." in its documentation, and a new script event is needed for main map scripts to use. That script event can use the _CustomAnim states tweaked in 0003800, either directly or by pushing a Task, whichever restores previous state easier.
SteveL

SteveL

17.08.2015 18:48

reporter   ~0007724

Scripted animation sequences probably want more functionality adding, but I've added a new script event to fix the issues on this tracker: playCustomAnim("anim name"); which can be used on AI. It supports only whole-body animations, i.e. torso and legs. A walking AI will stop walking to play the anim.

It fixes the test cases in the attached map (thanks for that). The woman resumes patrolling after kneeling, and the man doesn't get interrupted. It uses the AI task system, so hopefully won't clash with the existing setup.

Not committed yet. I need to test it with fighting and chasing AI.
SteveL

SteveL

21.08.2015 20:37

reporter   ~0007727

It works ok with hostile civilians (fleeing). They kneel, while still complaining vocally about the scary intruder, then resume fleeing.
Searching, chasing, and fighting AI are ok too. They kneel, then resume what they were doing.
KO'd and dead AI need a further fix. They play the anim but on the wrists and ankles only, which looks creepy.
SteveL

SteveL

21.08.2015 21:16

reporter   ~0007728

The script event now only works on conscious AI.

Committed at rev 6533

/trunk/game/Actor.cpp
/trunk/game/ai/AI.cpp
/trunk/game/ai/AI.h
/trunk/game/ai/AI_events.cpp

Issue History

Date Modified Username Field Change
03.11.2013 18:24 sotha_sil New Issue
03.11.2013 18:24 sotha_sil File Added: animation_issue.map
03.11.2013 18:24 sotha_sil File Added: animation_issue.script
10.09.2014 19:19 SteveL Assigned To => SteveL
10.09.2014 19:19 SteveL Status new => assigned
10.09.2014 19:19 SteveL Relationship added related to 0003800
10.09.2014 19:49 SteveL Note Added: 0006978
17.08.2015 17:36 SteveL Target Version => TDM 2.04
17.08.2015 18:48 SteveL Note Added: 0007724
21.08.2015 20:37 SteveL Note Added: 0007727
21.08.2015 21:16 SteveL Note Added: 0007728
21.08.2015 21:17 SteveL Status assigned => resolved
21.08.2015 21:17 SteveL Resolution open => fixed
21.08.2015 21:17 SteveL Fixed in Version => TDM 2.04