UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: WhiteDevil on November 24, 2015, 01:14:45 pm

Title: [FUNCTIONS] Animation functions for script_models
Post by: WhiteDevil on November 24, 2015, 01:14:45 pm
4 Functions for managing Animations on a script_model.

When using this script it's expected you already have the following things:
 - xmodel with bones.
 - xanim that can be played on the xmodel.
 - animtree that contains the xanims that can be played on the xmodel.
 - All of these (xmodel, xanim and animtree) should be included in your mod.

Documentation
Spoiler: click to open...
play_anim_looped
  • @Name: play_anim_looped
  • @Summary: An looped animation will be played on an entity. That's currently not playing a animation.
  • @CalledOn: <entity>: A script_model with bones.
  • @MandatoryArg: <anim>: The animation that should be played(This name should be in your Animtree).
  • @Example: xmodelEntity play_anim_looped(%banana_peel);


stop_anim_looped
  • @Name: stop_anim_looped
  • @Summary: An looped animation will be stopped.
  • @CalledOn: <entity>: A script_model with bones that is currently playing a looped animation.
  • @Example: xmodelEntity stop_anim_looped();


play_anim_once
  • @Name: play_anim_once
  • @Summary: An animation will be played once on a entity.
  • @CalledOn: <entity>: A script_model with bones. That's currently not playing a animation.
  • @MandatoryArg: <anim>: The animation that should be played(This name should be in your Animtree).
  • @OptionalArg: <string>: The notify to send. When undefined a random value will be created(This value is returned by the function!);
  • @Return: <string>: The notify to send.
  • @Example: xmodelEntity play_anim_once(%banana_peel, "banana_peeling");


stop_anim_once
  • @Name: stop_anim_once
  • @Summary: An entity that's currently playing a one time animation will be stopped.
  • @CalledOn: <entity>: A script_model with bones that is currently playing a one time animation.
  • @Example: xmodelEntity stop_anim_once();

Setup

    1) Download the script: https://mega.nz/#!rEcXxIRL!Hlzq9LDFxY27vo5QzhS-upvwReL0x08SKo8eJfqIsv8 (https://mega.nz/#!rEcXxIRL!Hlzq9LDFxY27vo5QzhS-upvwReL0x08SKo8eJfqIsv8)
    2) Copy the script to MODNAME/maps/_easyAnimation.gsc
    3) Open MODNAME/maps/_easyAnimation.gsc you just pasted, and go to line 5. Change  ANIMTREE to the animtree your are using
Code Snippet
Plaintext
//Define the animtree you are using.
#using_animtree( "ANIMTREE" );
    4) You can change the other settings if you want they are one line 12, 14 and 16.
Code Snippet
Plaintext
//
// Note: If you are publishing your map, you should set them all to false.
//
//Errors are shown by default, change it to false to suppress them.
level.show_anim_errors = true;
//Warnings are shown by default, change it to false to suppress them.
level.show_anim_warnings = true;
//Information is hidden by default, change it to true to show them.
level.show_anim_info = false;
    5) Don't forget to include it in your launcher!, make sure you checked the script like this:
Spoiler: click to open...
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FyuL5dQ3.png&hash=eca26c4b2ce01096a2269e30daa42ffd03dd8949)


Usage
 1) Include _easyAnimation.gsc in your script, after that define your animtree again.

Example Script
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_loadout;

//Inludes _easyAnimation.gsc
#include maps\_easyAnimation;
//Your animtree
#using_animtree( "cube" );
//This animtree contains the animation used below: %viewmodel_cube_rotate

main(){
wait(10);
//Get the script model
cube = GetEnt("cube", "targetname");

//Plays a looped Animation on the script model
cube play_anim_looped( %viewmodel_cube_rotate );
wait(5.0);
//The looped animation will be stopped.
cube stop_anim_looped();

wait(10);
//Plays a Animation only once on the script model
cube play_anim_once( %viewmodel_cube_rotate );
}





Important
  • It doesn't matter wether your xanim is looped or not in asset manager it only plays once when play_anim_once is used.
  • Animation that are not looped in asset manager don't loop when play_anim_looped is used...


Having problems with including your xanim / animtree? Read this!
Spoiler: click to open...
Follow the following steps.
  • In asset manager export the XANIM with the following settings:
    • Use Bones = true
    • Type = Relative
    • Looping = true / false (depends on what you want)
  • Create / modify an existing animtree
    • Go to raw/animtrees and create/modify the desired animtree and add your xanim to it.
  • in your mod.csv add the created animtree and xanim. The XANIM must be included before the animtree! else it wont work...
    • xanim,XANIMNAME
    • rawfile,animtrees/ANIMTREENAME.atr



I hope this will help some people!  :) If you use this script don't forget to add me to the credits  ;)
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: MakeCents on November 24, 2015, 02:05:56 pm
Cool share man.  ;D You may, or may not, up to you, want to add to compile the maps patch when changing or adding animtrees. At least I have to. I do things similar but use arrays in my main and thread functions for each set of models, with #using_animtree( "ANIMTREE" ); before the function for each... I've always put the animtree at the end, by chance, but had no clue that it mattered, lol, that is good to know.
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: WhiteDevil on November 24, 2015, 02:36:07 pm
Cool share man.  ;D You may, or may not, up to you, want to add to compile the maps patch when changing or adding animtrees. At least I have to. I do things similar but use arrays in my main and thread functions for each set of models, with #using_animtree( "ANIMTREE" ); before the function for each... I've always put the animtree at the end, by chance, but had no clue that it mattered, lol, that is good to know.

Thanks man  :).

When adding it to your mod.csv(The .csv your launcher uses in the build mod section) you don't have to compile your map or map_patch, building your map is good enough. If you add it to your MODNAME.csv or MODNAME_patch.csv then yes you have to compile your map or map_patch depends on wicht csv youh have used.

When i was testing with this i didn't understand why it didn't work when i include first the xanim and then the animtree in my csv everything went fine. I'm not sure why this is.. :-\
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: MakeCents on November 24, 2015, 02:38:55 pm
Thanks man  :).

When adding it to your mod.csv you don't have to compile your map or map_patch, building your map is good enough. If you add it to your MODNAME.csv or MODNAME_patch.csv then yes you have to compile your map or map_patch depends on wicht csv youh have used.

When i was testing with this i didn't understand why it didn't work when i include first the xanim and then the animtree in my csv everything went fine. I'm not sure why this is.. :-\

Oh, so when I
Code Snippet
Plaintext
include,robots
in my mod.csv for my csv in zone_source that has the model, xanim, and animtrees inlcuded in it, (cause that is how I do things), that is what is causing me to compile my patch...? Interesting. I thought it was just always needed. Takes a second, I think I will still do it that way to be organized and it makes adding to other maps easier for me, lol. Thanks for the info though.
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: WhiteDevil on November 24, 2015, 03:37:48 pm
My english isn't very good, so i don't quite understand what you are saying but it works like this:

Almost every mod created with script_placer has 3 .csv files:

When you are compiling your MAP or MAP_patch and you have the option build fastfile selected the content of the .csv will be added to your fastfile of your mod.

This is how your fastfiles get updated from each .csv file:

So when you're working on your map, and you don't edit your MAP_patch.csv there is no need for compiling your MAP_patch.

Same goes for when you are working on your map in radiant and you have changed something in radiant for example you added a wall or something. You only have to compile your MAP and not your MAP_patch or build your mod.

You only build your mod when you have made changes to included files that are in you CODAWROOT/mods/MODNAME/mod.csv. Or the files that are in your IWD File List.


I hope you understand this :P
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: MakeCents on November 24, 2015, 04:10:39 pm
That is great info, you should put that in another tut really, cause lot of people wonder why they are checking each box and what is happening when you do.

I create csvs for everything myself, and perhaps that is why I have to do things the way I have to, not sure. I've talked to others that run into the same issues that don't do things my way, but who knows. Half the time I think if I pat my belly and rub my head, then spin around, it works, when it didn't 3 seconds ago, lol. When I add csvs that include atrs, I have to at least compile patch... unless I am miss-remembering and I have to compile the whole map. And anytime I add a anim to generic_human.atr or something like that, I have to compile  :-\  I guess I am wrong though and maybe I have just formed a habit, lol, I don't know.

Spoiler: click to open...
What I do is create separate csvs for everything, weapons, animations, fx, or anything I want to group together like my perk system assets or ammo counters. Then to add a feature to a map, all I do in mod.csv is include, thatfeaturescsv and I now have that feature without having to add all the things individually and figure things out again... But that is really unrelated, I just thought it may be causing me to have to compile.

Love the name btw, makes me laugh every time I see it, Equinsu Ocha, lol.
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: WhiteDevil on November 24, 2015, 05:12:04 pm
If you include all your csv's in your mod.csv the only thing you have to is build your mod. No need for compiling.
Title: Re: [FUNCTIONS] Animation functions for script_models
Post by: Harry Bo21 on January 09, 2016, 03:56:15 am
That is great info, you should put that in another tut really, cause lot of people wonder why they are checking each box and what is happening when you do.
Its in my memory management tut. Explains what csvs are compiled and when / how

Quote
If you include all your csv's in your mod.csv the only thing you have to is build your mod. No need for compiling.
This is good / preferable - or just calling those csvs "from" mod.csv. Be aware tho that impact FX do not work here ( for... um... reasons...? Never worked out why, but they "must" go in mapname.csv )