Character's random animation.

  • #1, by ke4Saturday, 15. November 2014, 21:28 6 years ago
    Hi,

    how can i change the duration between random animations of my specific NPC character? To make them more frequent.

    Thank you

    Key Killer

    810 Posts


  • #2, by afrlmeSaturday, 15. November 2014, 22:15 6 years ago
    Hmm it seems I've not yet updated all of the data structure of the new wiki yet. Anyway there are 2 tables for setting the min/max random time that random animations should be triggered. Unfortunately the old wiki is saying that they are not scriptable (whether that's true or not I don't know).

    Anyway here's how you would set a custom time if they do happen to be scriptable.
    getObject("Game.GameCurrentCharacter.CharacterCurrentOutfit"):setValue(VOutfitRandomMinTime, 3000) -- 3000ms = 3s
    getObject("Game.GameCurrentCharacter.CharacterCurrentOutfit"):setValue(VOutfitRandomMaxTime, 10000) -- 10,000ms = 10s
    1
    2
    3

    Hopefully it should work.

    Imperator

    6805 Posts

  • #3, by SCUD24Sunday, 16. November 2014, 05:12 6 years ago
    It would be nice if this was true, as an nonadjustable frequency for random animations was a gripe I had with version 3... Here's the workaround I've been using, not realizing that this might be resolved.

    I would use a call-action once my static animation was completed (it would be the primary animation for the character). The call-action (BELOW) would pause for a few seconds, then use a random number to determine what it would do next. 40% it would be the same primary animation, with a 20% chance of doing something different. It's a pain in the ass to have to do this for each character, but as I stated, I was not pleased with the lack of options given in version 3.

    Newbie

    28 Posts

  • #4, by afrlmeSunday, 16. November 2014, 05:20 6 years ago
    Why have images magically appeared on my reply? strange.

    You really did that for each character? & by the way: you are missing a few end if's from the end of your query.

    Imperator

    6805 Posts

  • #5, by SCUD24Sunday, 16. November 2014, 06:01 6 years ago
    I addressed the problems with the random animations years ago, and no one that works here seemed concerned, so I had to come up with something on my own or else be happy with a 1-15 second random time for them to actually work during the compiled games.

    I probably don't quite grasp the point of the "end if's" as I should. It seems to work fine like this, or does it continue to process this script in memory, eventually slowing down the game because of it?

    Newbie

    28 Posts

  • #6, by ke4Sunday, 16. November 2014, 08:46 6 years ago
    The code is working, so for specefic character it would be something like this?

    getObject("Game.Characters["name"].CharacterCurrentOutfit"):setValue(VOutfitRandomMinTime, 3000)
    1
    2

    Key Killer

    810 Posts

  • #7, by afrlmeSunday, 16. November 2014, 12:38 6 years ago
    yeah minus the quotes around the characters name because you have already converted it to a string at the beginning of the getObject("... & minus "Game" because Game is only used for data structure tables that are in the global game table. http://wiki.visionaire-tracker.net/wiki/Data_Structure#Game
    getObject("Characters[Tom].CharacterCurrentOutfit"):setValue(VOutfitRandomMinTime, 3000)
    getObject("Characters[Tom].CharacterCurrentOutfit"):setValue(VOutfitRandomMaxTime, 8000)
    1
    2
    3

    ...remember that names are case sensitive.


    @ scud: no idea, but you should always make sure you close off any queries correctly. It's easy enough to see what your queries are linked to now with the tree/branching.

    Quick note: you could whittle down what you have done there by naming your random animations all the same with a number on the end & then you use the value you created for setting a random value of the amount of milliseconds you want it to take before it should trigger the random animation.
    -- action parts
    set random value 'value_name' between x & x -- min max time in ms.
    pause for 'value_name' -- good for creating dynamic pauses by combining random values
    execute a script > (see below)
    1
    2
    3
    4
    5

    -- let's say I named all random animations as "rand_1", "rand_2" & "rand_3"
    local char = "getObject("Characters[Tom].CharacterCurrentOutfit")
    startAnimation( char:getObject(".OutfitRandomAnimations[rand_"..math.random(#char:getLinks(VOutfitRandomAnimations).."]") )
    1
    2
    3
    4

    ...here I've used a prefix so all random animations use same name but have a different number (index) on the end of the name. In the code block above we have used a math.random function to return a value from 1 to the total amount of animations found inside of the random animation table for the current outfit.

    P.S: sorry, tried to reply ages ago but my internet went off for a while.

    Imperator

    6805 Posts

  • #8, by ke4Sunday, 16. November 2014, 18:30 6 years ago
    Thank you.. :-)

    Can i find somewhere in wiki those stuff, like VOutfitRandomMinTime?

    Key Killer

    810 Posts

  • #9, by afrlmeSunday, 16. November 2014, 20:13 6 years ago
    Hmm not currently. It's not yet been added to the data structure page. It's only written down in old wiki at the minute.

    http://wiki.visionaire2d.net/index.php?title=Data_Structure_3.x -- old
    http://wiki.visionaire-tracker.net/wiki/Data_Structure -- new

    Problem is that neither of the data structure pages contain exactly what is & is not available.Most of the tables are documented between the 2 though.

    Imperator

    6805 Posts

Write post