Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 64 Guests
Online:

LATEST FORUM THREADS

»
New BF2 Mod
BF2 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 SP Mapping
CoD 4 mapping and level design for single player.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: need help: animation example
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Sunday, Dec. 6, 2015 04:26 pm
Hi everyone.

I wonder if you can help me, i'm trying to do a single animation of a civilian running with no success. Basically i took some part of code of the "coup" map, but my scripting skill isn't very helpful XD.

if someone can explain me step by step how to do it properly it would be appreciated.

this is the animation that i want to play in my map test:

Code:
level.scr_anim[ "human" ][ "run_panicked1" ] 					 = %unarmed_panickedrun_loop_V1;
level.scr_anim[ "human" ][ "run_panicked2" ] 					 = %unarmed_panickedrun_loop_V2;


in Radiant i got an actor>civilian>arab>a_male with k/v:
k:targetname
v:runner1
i made a trigger_multiple and give it this k/v values:
k:targetname
v:runner1trigger
k:target
v:runner1

then, i link the actor with a final pathnode.

in the scripting part i got:

mymap.gsc:

Code:

include maps\_utility;
#include common_scripts\utility;

#include maps\_anim;


main()
{
	maps\_load::main();
        maps\mymap_anim::main();
	level.player.ignoreme = true;

	trigger = getEnt( "runner1trigger", "targetname" );;
	
        wait 1;

        trigger waittill ( "trigger" );
	thread runner();	

}

runner()
{
        civilian1 = getent( "runner1", "targetname");
	civilian1.animname = "human";

	runanims[ 0 ] = "run_panicked1";
 	runanims[ 1 ] = "run_panicked2";
        civilian1 setRandomRun( runanims );

	
	wait 10;
	runner1 delete();
	
}


mymap_anim.gsc i have:

Code:

#include common_scripts\utility;

#include maps\_utility;

#include maps\_anim;


main()
{
	anim_human();
}

#using_animtree( "generic_human" );

anim_human()
{
	// merge into this animname when possible
	level.scr_animtree[ "human" ]						 	 		 = #animtree;

	level.scr_anim[ "human" ][ "run_panicked1" ] 					 = %unarmed_panickedrun_loop_V1;
	level.scr_anim[ "human" ][ "run_panicked2" ] 					 = %unarmed_panickedrun_loop_V2;
	
}


Thanks for your time[wave]
Share |
lolwot
General Member
Since: May 15, 2010
Posts: 53
Last: Dec 15, 2015
[view latest posts]
Level 3
Category: CoD4 SP Mapping
Posted: Sunday, Dec. 6, 2015 05:40 pm
Are you getting any errors? This information is very helpful in debugging.

Looking at your code it seems you are missing the setRandomRun function that is being called, and that exists in coup.gsc, but not here.

Add the following to mymap.gsc and it may work:

Code:
setRandomRun( array ) 
{ 	
    self set_run_anim( array[ RandomInt( array.size ) ], true ); 
}


If you can't get that to work just use set_run_anim instead of setRandomRun.

edited on Dec. 6, 2015 05:40 pm by lolwot

edited on Dec. 6, 2015 05:41 pm by lolwot
Share |
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Sunday, Dec. 6, 2015 07:08 pm
lolwot writes...
Quote:
Are you getting any errors? This information is very helpful in debugging.
]


Hi man, thanks for helping me.

yes, i got an error:

"undefined is not a field object"

Maybe because im using the test_traverses default map, idk. im gonna move the code to a new map and see what happens.

this is how it looks now the .gsc file:

Code:


#include maps\_utility;

#include common_scripts\utility;

#include maps\_anim;


main()
{
	maps\_load::main();
        maps\test_traverses_anim::main();
	level.player.ignoreme = true;
	ai_count = 1;

	battlechatter_off( "allies" );
	battlechatter_off( "axis" );

	triggers = getEntArray( "aitrigger", "targetname" );
	
	array_thread( triggers, ::triggerThink );
	
	thread killAIOnUse();
       	println( "Press X (use) at any time to kill all AI" );

        trigger = getEnt( "runner1trigger", "targetname" );
	
        wait 1;

        trigger waittill ( "trigger" );
	thread runner();
	

}

killAIOnUse()
{
	while(1)
	{
		if ( level.player useButtonPressed() )
		{
			ai = getaiarray();
			for ( i = 0; i < ai.size; i++ )
				ai[i] doDamage( ai[i].health, ai[i].origin );
		}
		wait .05;
	}
}

triggerThink()
{
	spawner = getEnt( self.target, "targetname" );
	spawner.count = 1;
	spawner.script_moveoverride = 1;

	for( ;; )
	{
		self waittill ( "trigger" );
		
		guy = spawner stalingradSpawn();
		spawner.count++;
		if ( spawn_failed( guy ) )
		{
			wait ( 0.05 );
			continue;
		}
		
		guy thread aiThink();		
		guy waittill ( "death" );
	}
}


aiThink()
{
	self endon ( "death" );
	
	self.goalradius = 64;
	node = getNode( self.target, "targetname" );
	for ( ;; )
	{
		self setGoalNode( node );
		self waittill ( "goal" );
		if ( isDefined( self.node ) )
			wait 3;
		self delete();
	}
}

runner()
{
        civilian1 = getent( "runner1", "targetname");
        civilian1.animname = "human";

	runanims[ 0 ] = "run_panicked1";
	runanims[ 1 ] = "run_panicked2";
	//civilian1 setRandomRun( runanims );
        civilian1 set_run_anim( runanims[ RandomInt( 1 ) ], true );

	wait 10;
	civilian1 delete();
}


thanks again.[thumbs_up]
Share |
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Monday, Dec. 7, 2015 02:27 pm
After moving the script to a new map, the error still appear.

Do i need to put a script_node in order to get my actor do the anim? and if "yes", how can i do it properly?


Thanks for your time[wave]
Share |
SPi
General Member
Since: Jul 4, 2012
Posts: 531
Last: Nov 9, 2019
[view latest posts]
Level 6
Category: CoD4 SP Mapping
Posted: Tuesday, Dec. 8, 2015 04:37 am
So the Civilian is a Spawner right?
He is spawned after the trigger is triggered?

If so then it wont be that simple to make him run.

First of all. Change the "human" animname in your map_anim.gsc
with "generic"

Then in your main script, in the runner function,
since the AI is spawner and not pre-spawner (Spawner key in radiant not checked means AI is prespawned) you need to define the AI with script_noteworthy.
Its mostly something like a second targetname.
so you set in your AI in radiant
k:script_noteworthy
v:whateveryouwant

define it in script like this, and also apply the run anim in the way i show you:
Code:

runner()
{
        civilian1 = getent( "runner1", "script_noteworthy");
        civilian1.animname = "human"; 

        civilian1 set_generic_run_anim( "run_panicked1" );

	wait 10;
	civilian1 delete();
}


Now as you noticed that is for one run anim. you can experiment with the array you did in previous posts based on the code i send now.

Now if you have defining issues, i mean if the spawner wont be defined in script the way i did it then you must uncheck Trigger spawn from radiant and keep the AI spawner, we will spawn him in script.

Then simply do this:

Code:

#include maps\_utility;

#include common_scripts\utility;


#include maps\_anim;



main()
{
	maps\_load::main();
        maps\mymap_anim::main();
	level.player.ignoreme = true;

	trigger = getEnt( "runner1trigger", "targetname" );;
        wait 1;
        trigger waittill ( "trigger" );
	thread runner();	

}

runner()
{
        civilian1_spawner = getent( "civilian1_spawner", "targetname");
        civilian1_spawner dospawn(); // change dospawn with stalingradspawn if player can see him.

        civilian1 = getent( "runner1", "script_noteworthy");
        civilian1.animname = "human"; 

        civilian1 set_generic_run_anim( "run_panicked1" );

	wait 10;
	civilian1 delete();	
}



I hope you can see how I used targetname and noteworthy.
I used targetname to define the spawner and spawn it, and the noteworthy to set other misc settings to the AI.

It didnt work the other way around for me. I mean set settings to targetname defined AI if its spawner.

Hope it helps.




Share |
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Tuesday, Dec. 8, 2015 11:43 am
Hi SPi, thanks for you time, and BTW, great work on your maps [thumbs_up]

I did the changes but still got de error: "undefined is not a field object".

the result: the civilian runs with a ak47 like normal AI (combat run i think)

heres my map_anim.gsc:

Code:

#include common_scripts\utility;

#include maps\_utility;

#include maps\_anim;


main()
{
	anim_runners();
}

#using_animtree( "generic_human" );

anim_runners()
{
	// merge into this animname when possible
	level.scr_animtree[ "generic" ]						 	 		 = #animtree;

	level.scr_anim[ "generic" ][ "run_panicked1" ] 					 = %unarmed_panickedrun_loop_V1;
	level.scr_anim[ "generic" ][ "run_panicked2" ] 					 = %unarmed_panickedrun_loop_V2;
	
}


and my map.gsc:

Code:


#include maps\_utility;

#include common_scripts\utility;

#include maps\_anim;


main()
{

setdvar( "cg_fov", 80 );

precacheitem("usp_silencer");
precachemodel( "viewhands_black_kit" );

maps\_load::main();
maps\test1_anim::main();

level.player.ignoreme = true; 
level.player takeallweapons();
level.player giveWeapon( "usp_silencer" );
level.player givemaxammo( "usp_silencer");
level.player setViewmodel( "viewhands_black_kit" );

thread switchweapon();

trigger1 = getEnt( "runner1trigger", "targetname" );
	
wait 1;

trigger1 waittill ( "trigger" );
thread runner();

}


switchweapon()
{

wait 4;
level.player switchtoWeapon( "usp_silencer" );

}


runner()
{

        civilian1 = getent( "person1", "script_noteworthy");
        civilian1.animname = "generic";

//	runanims[ 0 ] = "run_panicked1";
//	runanims[ 1 ] = "run_panicked2";
        civilian1 set_generic_run_anim("run_panicked1");
//	civilian1 setRandomRun( runanims );
//      civilian1 set_run_anim( runanims[ RandomInt( 1 ) ], true );

	wait 10;
	civilian1 delete();
}


The error has a conflict with the _utility script:

self.a.combatrunning = level.scr_anim["generic"][anime];

any ideas of what's wrong?

thanks again[wave]
Share |
SPi
General Member
Since: Jul 4, 2012
Posts: 531
Last: Nov 9, 2019
[view latest posts]
Level 6
Category: CoD4 SP Mapping
Posted: Tuesday, Dec. 8, 2015 07:51 pm
Thanks, I really work hard on my maps.
You didn't follow my steps 100%

Try my 2nd suggestion

Try unlink the AI with trigger and uncheck Trigger Spawn from trigger entity window.

Then give the AI targetname and script_noteworthy
like:
targetname
civilian1_spawner

script_noteworthy
civilian1

Then in the function do this:
Code:
runner()
{
        civilian1_spawner = getent( "civilian1_spawner", "targetname");
        civilian1_spawner dospawn(); // change dospawn with stalingradspawn if player can see him.

        civilian1 = getent( "civilian1", "script_noteworthy");
        civilian1.animname = "human"; //set_generic_run_anim does notnecessarily  need him to have animname generic

        civilian1 set_generic_run_anim( "run_panicked1" );

	wait 10;
	civilian1 delete();	
}


PS:
setdvar may not work at the dawn of your script.
Try make a function dvars()
and put this in it:
Code:

dvars()
{
wait 0.05; // YOU NEED TO WAIT 0.05 so wont get error for some reason idk why.
setsaveddvar( "cg_fov", 80 ); // setsaveddvar i think its better but generally does the same.

}


GG.

Share |
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Wednesday, Dec. 9, 2015 10:49 am
SPi writes...
Quote:


Try my 2nd suggestion

Try unlink the AI with trigger and uncheck Trigger Spawn from trigger entity window.

Then give the AI targetname and script_noteworthy
like:
targetname
civilian1_spawner

script_noteworthy
civilian1



I did this first, but give me this error:

Code:
"getent used with more than one entity"


So i did the old way but i still have the first error. Even when i discard the script_noteworthy, i mean, using the targetname to do AI spawning and anim stuff, i got the undefined error. [confused]

What it could be? idk i hope you can help me, i'm gonna check the coup script again to see if im missing something.

Thanks again SPi.





Share |
SPi
General Member
Since: Jul 4, 2012
Posts: 531
Last: Nov 9, 2019
[view latest posts]
Level 6
Category: CoD4 SP Mapping
Posted: Wednesday, Dec. 9, 2015 08:44 pm
getent is used with more than 1 entity means you accidentally set the same targetname in two radiant entities. You should go back in radiant and check if you did so before discarding anything.

Try that last step again with more attention.

EDIT:

Did a testmap myself.
Neutral AI for some reason dont work same way as Allies or Axis.
WTF COD4
I changed the AI with Allies with the settings i suggested to you and they worked!
When they were civilian/neutral they didnt!
WTF.

Only way i can see out of this is to make your own character AItypes with arab models but set them allies.
This can be done through assets manager.
Ask me for info if confused.


edited on Dec. 9, 2015 09:23 pm by SPi
Share |
Faper86
General Member
Since: Dec 6, 2015
Posts: 9
Last: Dec 12, 2015
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Thursday, Dec. 10, 2015 11:36 am
Hi, SPi.

I did check the map looking for double targetname, only the actor got it and it's only one targetname:

K:targetname
V:civilian1_spawner

K: script_noteworthy
V: civilian1

Also, i replace the arab actor for ally>vip_president and give it the parameters above.

I did copy your script exactly that you post, but it's not working. both errors:
"undefined is not a field object" and "getent used in more than 1 entity"

I found a script in the "coup" map.gsc, but doesn't work, so i discard the line:

Code:
array_thread( getentarray( "runner1", "script_noteworthy" ), ::add_spawn_function, ::setTeam, "allies" );


This is my entire work so far, i hope we can see something:

1) Radiant:

A) actor>ally>vip_president

K/v: targetname, civilian1_spawner
K/v: script_noteworthy, civilian1
K/v: target, goal
Spawner checked


B) Trigger_multiple

K/v: targetname, trigger_runner1
Trigger_spawn not checked


C) node_pathnode; there's 8 in the map, but in the final node i put this values:
K/v: targetname, goal

2) Map.gsc:

Code:
#include maps\_utility;

#include common_scripts\utility;

#include maps\_anim;


main()
{

//setdvar( "cg_fov", 80 );

precacheitem("usp_silencer");
precachemodel( "viewhands_black_kit" );

maps\_load::main();
maps\test1_anim::main();

level.player.ignoreme = true;
level.player takeallweapons();
level.player giveWeapon( "usp_silencer" );
level.player givemaxammo( "usp_silencer");
level.player setViewmodel( "viewhands_black_kit" );

thread switchweapon();
thread dvars();


trigger1 = getEnt( "trigger_runner1", "targetname" );
	
wait 1;

trigger1 waittill ( "trigger" );
thread runner();

}



switchweapon()
{

wait 4;
level.player switchtoWeapon( "usp_silencer" );

}



dvars()
{

wait 0.05; // YOU NEED TO WAIT 0.05 so wont get error for some reason idk why.
setsaveddvar( "cg_fov", 80 ); // setsaveddvar i think its better but generally does the same.

}


runner()
{
        civilian1_spawner = getent( "civilian1_spawner", "targetname");
        civilian1_spawner dospawn(); // change dospawn with stalingradspawn if player can see him.

        civilian1 = getent( "civilian1", "script_noteworthy");
        civilian1.animname = "human"; //set_generic_run_anim does notnecessarily  need him to have animname generic

        civilian1 set_generic_run_anim( "run_panicked1" );

	wait 10;
	civilian1 delete();	
}


3) And finally, map_anim.gsc:

Code:
#include common_scripts\utility;

#include maps\_utility;

#include maps\_anim;


main()
{
	anim_runners();
}

#using_animtree( "generic_human" );

anim_runners()
{
	// merge into this animname when possible
	level.scr_animtree[ "generic" ]						 	 		 = #animtree;

       // also i try with "generic" in the lines below, same results :(
	level.scr_anim[ "human" ][ "run_panicked1" ] 					 = %unarmed_panickedrun_loop_V1;
	level.scr_anim[ "human" ][ "run_panicked2" ] 					 = %unarmed_panickedrun_loop_V2;
	
}


I hope this info helps to find the problem.
Thanks for your time, SPi.


Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 SP Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»