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

Members Online

»
0 Active | 70 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

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 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Punching animation
TheModDoctor
General Member
Since: Apr 27, 2007
Posts: 174
Last: Jan 10, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Feb. 17, 2008 03:03 pm
Hi there. In my SP map I want a part where I must rescue a soldier. When I get there he is sitting in a chair while a guard is beating him up. (Animation in the training level) Before I will put this into my map I will first test it in a sample map, but I don't know even where to begin. I looked into the stock script, but I don't really understand it. Can anybody give me help or a tutorial on this specific animation? Like what must I have; actor, nodes, a chair? and how to script the whole thing. Thanks[wave]
Share |
TheModDoctor
General Member
Since: Apr 27, 2007
Posts: 174
Last: Jan 10, 2009
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Sunday, Feb. 17, 2008 04:35 pm
Ah! I've got it! I found some much simpler scripts in the credits.gsc
What I did was place a chair, and named it prison_chair. Then I made 2 actors (spawners) and named them price and prison_guard.
And here is the script that I modified (I named it beat.gsc)
Code:
#include maps\_utility;

#include maps\_anim;

#include animscripts\utility;

#include animscripts\shared;

#using_animtree("generic_human");

main()
{
maps\_load::main();
maps\beat_anim::main();
level.player takeallweapons();
level.player giveweapon("m1carbine");
level.player giveweapon("colt");
level.player giveweapon("fraggrenade");
level.player switchtoweapon("colt");

flag_init ("spit");

thread beating();
}

beating()
{

chair = getent("prison_chair", "targetname");
guard = getent("prison_guard", "targetname")stalingradspawn();
price = getent("price", "targetname")stalingradspawn();

	level.price = price;
	level.chair = chair;
	level.guard = guard;
	
	spawn_failed(guard);
	spawn_failed(price);
	
	guard.ignoreme = true;
	price.ignoreme = true;
	guard.pacifist = true;
	price.pacifist = true;
	
	price.animname = "price";
	guard.animname = "guard";

	guys[0] = price;
	guys[1] = guard;

//To stop the animation if guard is killed
thread stop_beating();

//To loop the beating animation
	for (;;)
	{
		guard endon ("death");
		if (flag ("spit"))
		{
			flag_clear ("spit");
			level notify ("startSpit");
			chair melee_anim (guys, "spit");
		}
		else
			chair melee_anim (guys, "double");
			
	}
}

melee_anim (guys, anime)
{

	self notify ("stopIdle");
	guys[1] endon ("death");
	thread anim_single (guys, anime);
	array_thread(guys, ::loopStarter, self);
	self waittill (anime);	
}

loopStarter(chair)
{
	chair endon ("stopIdle");
	self waittillmatch ("single anim","end");
	chair anim_loop_solo(self, "idle", undefined, "stopIdle");
}

stop_beating()
{
	price = level.price;
	level.guard.ignoreme = false;
	level.guard.health = 1;
	level.guard.allowdeath = true;
	level.guard waittill ("death");
	
	flag_set("price_rescued");
	
	price stopanimscripted();
	level.chair notify ("stopIdle");
//level.chair thread anim_loop_solo (price, "idle", undefined, "stopIdle");
	}


And in the beat_anim.gsc:
Code:
#include maps\_utility;

#include maps\_anim;

#include animscripts\utility;

#using_animtree("generic_human");
main()
{
	level.scr_anim["price"]["idle"][0]	 		= %german_idle;
	level.scr_anim["price"]["double"]			= %german_doublepunch;
	level.scr_anim["price"]["spit"]				= %german_gethit3;
	
	level.scr_anim["guard"]["idle"][0]			= %guard_idle;
	level.scr_anim["guard"]["double"] 			= %guard_doublepunch;
	level.scr_anim["guard"]["spit"] 			= %guard_wipeface;
	
	addNotetrack_sound("guard", "punch", "double", "moscow_fistfist");
	addNotetrack_sound("guard", "punch", "double", "melee_hit");
}


The last line in beat.gsc is quoted so that once the guard is killed, Price immediately gets up. If you unquote the line, Price will remain in the chair, just sitting there.

For instance if you want to free Price after killing the guard unquote the last line, create a trigger_use over Price, deactivate it in the main() thread, and put
Code:
thread free_Price();

after the line you just unquoted. Then add the following to your script:
Code:
free_price()
{
free_trig=getent("free_price_trigger", "targetname");

//To activate the trigger again
free_trig triggeron();

free_trig waittill("trigger");
level.chair notify ("stopIdle");
}


In other words, your script would look like this now:
Code:

#include maps\_utility;

#include maps\_anim;

#include animscripts\utility;

#include animscripts\shared;

#using_animtree("generic_human");

main()
{
maps\_load::main();
maps\beat_anim::main();
level.player takeallweapons();
level.player giveweapon("m1carbine");
level.player giveweapon("colt");
level.player giveweapon("fraggrenade");
level.player switchtoweapon("colt");

flag_init ("spit");

free_trig=getent("free_price_trigger", "targetname");
free_trig triggeroff();

thread beating();
}
beating()
{

	chair = getent("prison_chair","targetname");
	guard = getent("prison_guard","targetname")stalingradspawn();
	price = getent("price","targetname")stalingradspawn();

	level.price = price;
	level.chair = chair;
	level.guard = guard;
	
	spawn_failed(guard);
	spawn_failed(price);
	
	guard.ignoreme = true;
	price.ignoreme = true;
	guard.pacifist = true;
	price.pacifist = true;
	
	price.animname = "price";
	guard.animname = "guard";

	guys[0] = price;
	guys[1] = guard;

thread stop_beating();
	for (;;)
	{
		guard endon ("death");
		if (flag ("spit"))
		{
			flag_clear ("spit");
			level notify ("startSpit");
			chair melee_anim (guys, "spit");
		}
		else
			chair melee_anim (guys, "double");
			
	}
}

melee_anim (guys, anime)
{

	self notify ("stopIdle");
	guys[1] endon ("death");
	thread anim_single (guys, anime);
	array_thread(guys, ::loopStarter, self);
	self waittill (anime);	
}

loopStarter(chair)
{
	chair endon ("stopIdle");
	self waittillmatch ("single anim","end");
	chair anim_loop_solo(self, "idle", undefined, "stopIdle");
}
stop_beating()
{
	price = level.price;
	level.guard.ignoreme = false;
	level.guard.health = 1;
	level.guard.allowdeath = true;
	level.guard waittill ("death");
	
	flag_set("price_rescued");
	
	price stopanimscripted();
	level.chair notify ("stopIdle");
	level.chair thread anim_loop_solo (price, "idle", undefined, "stopIdle");
	thread free_price();
}

free_price()
{
free_trig=getent("free_price_trigger", "targetname");
free_trig triggeron();

free_trig waittill("trigger");
level.chair notify ("stopIdle");
}
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

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

»