View Issue Details

IDProjectCategoryView StatusLast Update
0000540The Dark ModCodingpublic09.07.2022 18:48
Reportercrispy Assigned ToObsttorte  
PrioritylowSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionTDM 2.10 
Target VersionTDM 2.11Fixed in VersionTDM 2.11 
Summary0000540: Add entity scriptfunctions for getting/setting animation rates
DescriptionIndividual animations played by an entity can be sped up or slowed down by an arbitrary factor by setting the anim_rate_[animname] spawnarg. See http://wiki.thedarkmod.com/index.php?title=Animation_playback_speed for details.

The values of these spawnargs are cached at runtime for performance reasons, so changing the spawnargs directly at runtime won't do anything. It would be nice to be able to access and change these cached values.

The most obvious way of enabling this is to create scriptfunctions for getting and setting the animation rates for each animation.
Additional InformationIf the getter is called with an animation name for which an animation rate is not cached, then return the default of 1.0 (meaning no change; play the animation as it appears in the file).

There are a number of use cases for this; for example, it could be used to make fine adjustments to the AI's walking/running speed rather than abruptly transitioning from "slow" to "fast" over the course of a few frames. If we decide we want that.
TagsNo tags attached.

Relationships

related to 0003913 feedback SetRate frame command 

Activities

nbohr1more

nbohr1more

01.09.2016 19:16

developer   ~0008293

getTurnRate() exists so perhaps this is mostly implemented.

As of 2.03 is has been reported that "anim_rate_x" args aren't functioning as expected.
nbohr1more

nbohr1more

01.09.2016 21:10

developer   ~0008295

Last edited: 01.09.2016 21:10

Probably AI.h:

ID_INLINE float GetAnimRate() { return m_animRates; }
ID_INLINE void SetAnimRate(float newAnimRate) { m_animRates = newAnimRate; }

nbohr1more

nbohr1more

01.09.2016 21:15

developer   ~0008296

and AI_events.cpp

const idEventDef AI_SetAnimRate( "setAnimRate", EventArgs(), 'f', "Gets the animation rate of the AI.");
const idEventDef AI_SetAnimRate( "setAnimRate", EventArgs('f', "rate", ""), EV_RETURNS_VOID, "Set the animation rate of the AI");
nbohr1more

nbohr1more

30.12.2020 21:25

developer   ~0013321

Yep, m_animRates is an Entity property in Entity.h should work as expected.
nbohr1more

nbohr1more

31.12.2020 03:39

developer   ~0013324

Hmm... Seems to be a bit bigger task than just copying GetTurnRate.

Probably need to add an animRate property to AI.
Obsttorte

Obsttorte

27.06.2022 08:08

developer   ~0014929

got it to work basically
need to make a few adjustments
Obsttorte

Obsttorte

28.06.2022 09:28

developer   ~0014931

Three script functions were added to idActor with rev. 9968:

float getAnimRate(int channel, string animName)
get the speed for the animation called animName for the respective channel, returns -1 if none-existent

float setAnimRate(int channel, string animName, float rate)
sets the speed for the animation on the channel to rate. Returns 1 if successful, otherwise -1. Negative rates are not allowed, but they can be 0.

string getAnimList(int channel)
lists all animation names for the respective channel, useful to get the names needed for the above two functions.

channel is usually one of the following
- ANIMCHANNEL_LEGS
- ANIMCHANNEL_TORSO
- ANIMCHANNEL_HEAD
stgatilov

stgatilov

02.07.2022 14:39

administrator   ~0014943

1) Why does setAnimRate returns 1 or -1?
Isn't usually bool value 1 for true and 0 for false? The same holds for scripts.

2) How can getAnimList be useful?
It returns a single string, how can script do anything with it?
Are there some parsing functions for scripting language?

3) How is "animator" different from "GetAnimatorForChannel(channel)" ?
   You use both interchangeably...
Obsttorte

Obsttorte

02.07.2022 14:50

developer   ~0014946

1.) I wanted it to be consistent with getAnimRate, which can return zero (anim on hold). As it is explicitely stated in the description and the return value will most probably not be needed anyways I don't see an issue here, even if it is non-standard.

2.) I added that for getting the necessary information that I needed to work on this issue. I thought it might be useful for mappers, too. It is not intented to be used on the fly but to receive the informations needed for the mapper to do the manipulations he wants to make. So it should be used during the creation of a FM, not in the released version.

3.) The GetAnim functions in getAnimRate and setAnimRate perform null-pointer checks. In getAnimList I needed to add it myself, hence the reference. The different channels can have different amounts of animations. I don't know whether it is really necessary, but it doesn't hurt.

Issue History

Date Modified Username Field Change
22.01.2008 08:57 crispy New Issue
01.09.2016 19:16 nbohr1more Note Added: 0008293
01.09.2016 19:16 nbohr1more Description Updated
01.09.2016 21:10 nbohr1more Note Added: 0008295
01.09.2016 21:10 nbohr1more Note Edited: 0008295
01.09.2016 21:15 nbohr1more Note Added: 0008296
17.10.2017 13:46 nbohr1more Relationship added related to 0003913
30.12.2020 21:25 nbohr1more Note Added: 0013321
31.12.2020 03:39 nbohr1more Note Added: 0013324
27.06.2022 07:45 Obsttorte Assigned To => Obsttorte
27.06.2022 07:45 Obsttorte Status new => assigned
27.06.2022 08:08 Obsttorte Note Added: 0014929
28.06.2022 09:28 Obsttorte Status assigned => resolved
28.06.2022 09:28 Obsttorte Resolution open => fixed
28.06.2022 09:28 Obsttorte Note Added: 0014931
02.07.2022 14:39 stgatilov Note Added: 0014943
02.07.2022 14:50 Obsttorte Note Added: 0014946
09.07.2022 18:48 Dragofer Product Version SVN => TDM 2.10
09.07.2022 18:48 Dragofer Fixed in Version => TDM 2.11
09.07.2022 18:48 Dragofer Target Version => TDM 2.11