Omni-bot WikiMain Page | About | Help | FAQ | Special pages | Log in

Category: Enemy Territory 0.71 Scripts
Printable version | Disclaimers | Privacy policy

ET 071 VoiceChat

From Omni-bot Wiki

ET 0.71 Scripts goal_voicechat

Description: 0.71 conversion of d00d's 0.66 voice chat script

Download: Goal_voicechat.gm

Installation: Rename Goal_voicechat.gm so that the G is lowercase (goal_voicechat.gm) and place the file in ~/omni-bot/et/scripts/goals



// This script contains functionality to allow bots respond to miscelaneous events
 
// These parameters are required
this.Name = "VoiceChat";		// The name of the goal.
this.Parent = "LowLevel";		// The name of the parent. This setting determines where in the state tree the goal will reside in.
this.AlwaysRecieveEvents = true;
 
// set this to 0 to disable and / or set AlwaysRecieveEvents to false
// valid values are from 1 to 10, each representing a 10% chance of responding
// a value of 5 means the bots will respond 50% less than when this goal was originally created
this.Frequency = 10;
 
this.Initialize = function()
{
	//set some initial vars to keep track of some things..
	this.responded_to_class = false;
	this.responded_to_weaponfire = false;
	this.teamkilltable = {};
	this.sniper_deaths = 0;
	this.lastkill = null;
	this.lastkilltime = null;
	this.inguilt = false;
	this.responded_to_teamdamage = false;
};
 
this.ThrottleFrequency = function()
{
	if ( this.Frequency > 0 && RandInt(1, 10) <= this.Frequency  )
	{
		sleep(0.5);
		return true;
	}
 
	return false;
};
 
this.Events[EVENT.TEAM_CHAT_MSG] = function(whosaidit, whattheysaid)
{
	if (!this.ThrottleFrequency()){ return; }
	respond = false;
	foreach ( message in this.teamchatthanks )
	{
		if ( message == whattheysaid )
		{
			respond = true;
			break;
		}
	}
 
	if ( respond )
	{
		r = RandInt(1, 10);
		if ( r < 8 )
		{
			if ( this.Bot.DistanceTo(GetEntPosition(whosaidit)) > 200 )
				{ return; }
 
			if ( r < 3 )
			{
				this.Bot.SayVoice(VOICE.WELCOME);
			}
			else if ( r < 5 )
			{
				this.Bot.SayTeam("np!");
			}
			else
			{
				this.Bot.SayTeam("You're welcome!");
			}
		}
	}
};
 
this.Events[EVENT.TEAM_VOICE] = function(source, id)
{
	if (!this.ThrottleFrequency()){ return; }
	cls = this.Bot.GetClass();
	// meds and lt's responding to voice thanks
	if ( id == VOICE.THANKS && (cls == CLASS.MEDIC || cls == CLASS.FIELDOPS) )
	{
		pos = GetEntPosition(source);
		if ( pos && this.Bot.DistanceTo( pos ) < 80 )
		{
			sleep(0.5);
			this.Bot.SayVoice(VOICE.WELCOME);
		}
		return;
	}
 
	// some all clear messages
	if ( id == VOICE.ALL_CLEAR && !this.Bot.GetTarget() )
	{
		r = RandInt( 1, 10 );
		if ( r < 2 )
			{  this.Bot.SayVoice( VOICE.AFFIRMATIVE ); }
		else if ( r > 8 )
			{ this.Bot.SayTeam("Affirmative: No enemy in sight!"); }
 
		return;
	}
 
	// state your class
	if ( !this.responded_to_class && (id == VOICE.IMA_SOLDIER || id == VOICE.IMA_ENGINEER || id ==VOICE.IMA_FIELDOPS ||
			id == VOICE.IMA_MEDIC|| id == VOICE.IMA_COVERTOPS) )
	{
		sleep( 0.5 );
		if ( cls == CLASS.FIELDOPS )
			{ this.Bot.SayVoice( VOICE.IMA_FIELDOPS ); }
		else if ( cls == CLASS.COVERTOPS )
			{ this.Bot.SayVoice( VOICE.IMA_COVERTOPS ); }
		else if ( cls == CLASS.MEDIC )
			{ this.Bot.SayVoice( VOICE.IMA_MEDIC ); }
		else if ( cls == CLASS.ENGINEER )
			{ this.Bot.SayVoice( VOICE.IMA_ENGINEER ); }
		else if ( cls == CLASS.SOLDIER )
			{ this.Bot.SayVoice( VOICE.IMA_SOLDIER ); }
 
		this.responded_to_class = true;
	}
};
 
this.Events[EVENT.WEAPON_FIRE] = function(weaponId, projectileEntity)
{
	if (!this.ThrottleFrequency()){ return; }
	if ( this.responded_to_weapon_fire )
		{ return; }
 
	if ( weaponId == WEAPON.AXIS_GRENADE  || weaponId == WEAPON.ALLY_GRENADE || weaponId == WEAPON.SMOKE_MARKER )
	{
		if ( RandInt(1,10) < 8 && this.Bot.GetNearestAlly( CAT.PLAYER, CLASS.ANYPLAYER) )
		{
			this.Bot.SayVoice(VOICE.FIRE_IN_THE_HOLE);
 
			this.responded_to_weapon_fire = true;
			sleep(5);
			this.responded_to_weapon_fire = false;
		}
 
		return;
	}
 
	if ( weaponId == WEAPON.SYRINGE && this.Bot.GetClass() == CLASS.MEDIC )
	{
		r = RandInt( 1, 10 );
 
		if ( r < 4 )
		{
			if ( r < 2 )
			{
				this.Bot.SayVoice(VOICE.IMA_MEDIC);
			}
			else if ( r < 5 )
			{
				this.Bot.SayTeam("You should really choose a less dangerous style of living, mate!");
			}
			else
			{
				this.Bot.SayTeam("He's dead, Jim!");
			}
 
			this.responded_to_weapon_fire = true;
			sleep(5);
			this.responded_to_weapon_fire = false;
		}
 
		return;
	}
};
 
this.Events[EVENT.DEATH] = function(attacker, mod)
{
	if (!this.ThrottleFrequency()){ return; }
	if ( !attacker || !mod )
		{ return; }
 
	// oops killed self
	if ( attacker == this.Bot.GetGameEntity() )
	{
		if ( mod == "MOD_GRENADE" && RandInt(1,10) < 4 )
		{
			this.Bot.Say("Sigh. Some day I'll learn how to use grenades ...");
			return;
		}
		if ( (mod == "MOD_CRUSH_CONSTRUCTION" || mod == "MOD_CONSTRUCTION") && RandInt(1,10) < 4 )
		{
			this.Bot.Say("Stop laughing! This is more difficult than you think.");
			return;
		}
		else if ( RandInt(1,10) < 2 )
		{
			this.Bot.SayTeam("Oh my, that's embarrassing ...");
			return;
		}
 
		return;
	}
 
	// team killed by player
	if ( this.Bot.IsAllied(attacker) && GetGameIdFromEntity(attacker) < 64 )
	{
		if( mod == "MOD_K43_SCOPE" || mod == "MOD_FG42SCOPE" || mod == "MOD_KNIFE" || mod == "MOD_GARAND_SCOPE" )
		{
			rand = RandInt(1,10);
			if (rand < 4)
			{
				this.Bot.SayTeam("Bastard!");
			}
			else if (rand < 10)
			{
				this.Bot.SayTeam("Asshole!");
			}
		}
 
		foreach ( weapon in this.noblameweapons )
		{
			if ( weapon == mod )
			{
				return;
			}
		}
 
		found = false;
		foreach ( teamkiller in this.teamkilltable )
		{
			if ( teamkiller.entity && teamkiller.entity == attacker )
			{
				found = true;
				teamkiller.kills += 1;
				teamkiller.name = GetEntityName(attacker);
 
				if ( teamkiller.kills > 3 && RandInt(1,10) < 6 )
				{
					s = teamkiller.name + "^1, you have killed me " + teamkiller.kills + " times!";
					this.Bot.SayTeam(s);
					return;
				}
				else if ( teamkiller.kills > 6 && RandInt(1,10) < 9 )
				{
					this.Bot.SayTeam( "^1STOP IT WILL YOU!!!!" );
					return;
				}
				else if (!this == null && teamkiller.kills > 7 && RandInt(1,10) == 10)
				{
					this.Bot.SayTeam( "I guess some people never change. Or, they quickly change and then quickly change back." );
					return;
				}
				else if (!this == null && teamkiller.kills > 8 && RandInt(1,10) == 2)
				{
					s = teamkiller.name + "^2, you must have some terrible emotional problems.";
					this.Bot.SayTeam(s);
					return;
				}
 
				return;
			}
		}
 
		if ( !found )
		{
			i = tableCount( this.teamkilltable );
			this.teamkilltable[i] = table({entity="",name="",kills=0});
			this.teamkilltable[i].name = GetEntityName(attacker);
			this.teamkilltable[i].kills = 1;
			this.teamkilltable[i].entity = attacker;
		}
 
		return;
	}
 
	if( !this.Bot.IsAllied(attacker) && (MeansOfDeath == "MOD_K43_SCOPE" || MeansOfDeath == "MOD_FG42SCOPE" || MeansOfDeath == "MOD_GARAND_SCOPE") && this.GetNearestAlly(CAT.PLAYER,CLASS.ANYPLAYER) == null )
	{
		this.sniper_deaths += 1;
		rand = RandInt(1,10);
		if (rand < 4 && this.sniper_deaths > 5 && this.Bot.GetTeam() == TEAM.AXIS)
		{
			this.SayTeam("Achtung, Scharfschuetze!");
			this.sniper_deaths -= 1;
		}
		else if (rand < 4 && this.sniper_deaths > 5 && this.Bot.GetTeam() == TEAM.ALLIES)
		{
			this.SayTeam("Sniper out there, beware!");
			this.sniper_deaths -= 1;
		}
 
		return;
	}
 
	// don't say anything when killed by dynamite etc.
	foreach ( weapon in this.nopraiseweapons )
	{
		if (weapon == mod)
			{ return; }
	}
 
	if( !this.Bot.IsAllied(attacker) && RandRange(1, 100) < 3 )
	{
		this.Bot.SayVoice(VOICE.G_GREATSHOT);
	}
	else if( !this.Bot.IsAllied(attacker) && RandRange(1, 150) > 149 )
	{
		this.Bot.SayVoice(VOICE.G_OOPS);
	}
 
};
 
this.Events[EVENT.REVIVED] = function(whoDoneIt)
{
	if (!this.ThrottleFrequency()){ return; }
	rand_rev = RandRange(0, 100);
	if (rand_rev > 30)
	{
		this.Bot.SayVoice(VOICE.THANKS);
	}
	if (rand_rev < 5)
	{
		if(this.Bot.GetTeam() == TEAM.ALLIES)
		{
			this.Bot.SayTeam("Thx, m8!");
		}
		else
		{
			this.Bot.SayTeam("Danke, Kamerad!");
		}
	}
};
 
this.Events[EVENT.HEALED] = function(whoDoneIt)
{
	if (!this.ThrottleFrequency()){ return; }
	if ( whoDoneIt != this.Bot.GetGameEntity() && this.Bot.IsAllied(whoDoneIt) && RandInt(1,10) < 5 )
		{ this.Bot.SayVoice(VOICE.THANKS); }
};
 
this.Events[EVENT.AMMO_RECIEVED] = function(whoDoneIt)
{
	if (!this.ThrottleFrequency()){ return; }
	if ( whoDoneIt != this.Bot.GetGameEntity() && RandInt(1,10) < 5 )
		{ this.Bot.SayVoice(VOICE.THANKS); }
};
 
this.Events[EVENT.KILLEDSOMEONE] = function(victim, mod)
{
	if (!this.ThrottleFrequency()){ return; }
	dont_taunt_them = false;
	dont_say_sorry = false;
 
	if( !victim || !mod || GetGameIdFromEntity(victim) > 63 )
		{ return; }
 
	this.lastkill = victim;
	this.lastkilltime = GetTime();
 
	foreach ( weapon in this.notauntweapons )
	{
		if (weapon == _params)
		{
			dont_taunt_them = true;
			break;
		}
	}
 
	if ( !this.Bot.IsAllied(victim) && !dont_taunt_them )
	{
		if ( RandInt(0,10) < 4 )
		{
			rand = RandInt(0, tableCount(this.oneliners)-1);
			if (rand < tableCount(this.oneliners))
				{ this.Bot.Say(this.oneliners[rand]); }
		}
 
		return;
	}
	else if ( this.Bot.IsAllied(victim) && victim != this.Bot.GetGameEntity() )
	{
		if ( GetEntityName(victim) )
		{
			foreach( weapon in this.nosorryweapons )
			{
				if ( weapon == mod )
				{
					dont_say_sorry = true;
					break;
				}
			}
 
			if ( !dont_say_sorry && !this.inguilt )
			{
				this.inguilt = true;
				sleep(1);
				this.Bot.SayVoice(VOICE.SORRY);
				sleep(1.5);
				this.inguilt = false;
			}
		}
	}
};
 
this.Events[EVENT.FEEL_PAIN] = function(Inflictor, PreviousHealth, CurrentHealth)
{
	if (!this.ThrottleFrequency()){ return; }
	if ( GetGameIdFromEntity(Inflictor) > 63 )
		{ return;}
 
	if ( !this.responded_to_teamdamage && this.Bot.IsAllied(Inflictor)  && Inflictor != this.Bot.GetGameEntity()  )
	{
		if ( RandInt(0,10) < 4 )
		{
			this.Bot.SayVoice( VOICE.HOLD_FIRE );
			this.responded_to_teamdamage = true;
			sleep(5);
			this.responded_to_teamdamage = false;
		}
	}
};
 
this.Events[EVENT.GLOBAL_VOICE] = function(WhoSaidIt,VoiceId)
{	
	if (this.Bot.DelayResponse) { 
		sleep(this.Bot.DelayResponse);
		this.Bot.DelayResponse = null;
		return;
	}
 
	if (this.ThrottleFrequency())
	{
		if(VoiceId == VOICE.G_BYE && WhoSaidIt != this.Bot.GetGameEntity() && RandInt(1,100)<20)
		{
			this.Bot.SayVoice(VOICE.G_BYE);
		}
 
		if(VoiceId == VOICE.G_HI && WhoSaidIt != this.Bot.GetGameEntity() && RandInt(1,100)<20)
		{
			this.Bot.SayVoice(VOICE.G_HI);
		}
	}
 
	this.Bot.DelayResponse = 5;
};
 
this.teamchatthanks =
{
	"Thanks",
	"Thank you",
	"Thank you.",
	"Thank you!",
	"THANK YOU!",
	"Thanks!",
	"Thanks.",
	"THANKS!",
	"thanks!",
	"thanks",
	"thnaks",
	"thx",
	"thx.",
	"thx!",
	"THX",
	"THX!",
	"Thx, m8!",
	"thx m8",
	"thx m8!",
	"Thx m8!",
	"Thx, mate!",
	"Thanks, mate!",
	"Thanks mate!",
	"Thanks mate",
	"thanks mate",
	"Danke, Kamerad!",
	"danke",
	"danke!",
	"danke!!",
	"danke!!!",
	"Danke",
	"Danke!",
	"Danke!!",
	"Danke!!!",
	"DANKE!!!",
	"DANKE!!",
	"DANKE!",
	"DANKE",
};
 
this.nocryweapons =
{
   "MOD_SATCHEL",
   "MOD_MORTAR",
   "MOD_ARTY",
   "MOD_DYNAMITE",
   "MOD_WORLD",
   "MOD_LANDMINE",
   "MOD_EXPLOSIVE",
   "MOD_CONSTRUCTION",
   "MOD_CRUSH_CONSTRUCTION",
   "MOD_CRUSH",
   "MOD_TRIGGER_HURT",
   "MOD_WATER",
   "MOD_FALLING",
};
 
this.nopraiseweapons =
{
   "MOD_PANZERFAUST",
   "MOD_FLAMETHROWER",
   "MOD_BROWNING",
   "MOD_MACHINEGUN",
   "MOD_SATCHEL",
   "MOD_MORTAR",
   "MOD_GRENADE",
   "MOD_GRENADE_LAUNCHER",
   "MOD_AIRSTRIKE",
   "MOD_ARTY",
   "MOD_DYNAMITE",
   "MOD_WORLD",
   "MOD_MINE",
   "MOD_LANDMINE",
   "MOD_EXPLOSIVE",
   "MOD_CONSTRUCTION",
   "MOD_CRUSH_CONSTRUCTION",
   "MOD_CRUSH",
   "MOD_TRIGGER_HURT",
   "MOD_WATER",
   "MOD_FALLING",
};
 
this.notauntweapons =
{
   "MOD_BROWNING",
   "MOD_MACHINEGUN",
   "MOD_SATCHEL",
   "MOD_MORTAR",
   "MOD_DYNAMITE",
   "MOD_WORLD",
   "MOD_MINE",
   "MOD_LANDMINE",
   "MOD_EXPLOSIVE",
   "MOD_CONSTRUCTION",
   "MOD_CRUSH_CONSTRUCTION",
   "MOD_TRIGGER_HURT",
   "MOD_WATER",
   "MOD_CRUSH",
   "MOD_FALLING",
};
 
this.nosorryweapons =
{
   "MOD_MORTAR",
   "MOD_DYNAMITE",
   "MOD_WORLD",
   "MOD_MINE",
   "MOD_LANDMINE",
   "MOD_EXPLOSIVE",
   "MOD_CONSTRUCTION",
   "MOD_CRUSH_CONSTRUCTION",
   "MOD_CRUSH",
   "MOD_TRIGGER_HURT",
   "MOD_WATER",
};
 
this.noblameweapons =
{
   "MOD_SATCHEL",
   "MOD_MORTAR",
   "MOD_GRENADE",
   "MOD_AIRSTRIKE",
   "MOD_ARTY",
   "MOD_DYNAMITE",
   "MOD_WORLD",
   "MOD_LANDMINE",
   "MOD_EXPLOSIVE",
   "MOD_CONSTRUCTION",
   "MOD_CRUSH_CONSTRUCTION",
   "MOD_CRUSH",
   "MOD_TRIGGER_HURT",
   "MOD_WATER",
   "MOD_FALLING",
};
 
this.oneliners =
{
   "Oh, I'm sorry. Did I break your concentration?",
   "We should have shotguns for this.",
   "Shocking! Positively shocking!", //this is from an early James Bond movie ;-)
   "Hasta la vista, baby!",
   "You missed, Mr. Bond!",
   "Good bye, Mr. Bond!",
   "I like big fat men like you. When they fall they make more noise!",
   "Never send a human to do a machine's job.",
   "Dodge this!",
   "Zed's dead, baby, Zed's dead.",
   "He, he! pwnage!",
   "Call in Aunt Hilary!",
   "Ze enemy is vegan!",
   "Heh heh heh -- right in the butt. That was great.",
   "You know that hard look I get in my eyes? They saw that and ran like school girls with tails between their legs.",
   "I thought I had an appetite for destruction, but all I wanted was a club sandwich.",
   "I don't have to be careful. I got a gun.",
   "Oh, they're defending themselves somehow!",
   "Shhhhh. Be vewwwy qwiet ... I'm hunting wabbits.",
   "Need more cannon-food!",
   "Ya look like swiss cheese!",
   "^1BUAHAHAHAHARRR!",
};

Retrieved from "http://www.omni-bot.com/wiki/index.php?title=ET_071_VoiceChat"

This page has been accessed 895 times. This page was last modified 02:56, 25 March 2010.


Find

Browse
Main Page
Community portal
Current events
Recent changes
Random page
Help
Donations
Most Recent Blogs
Edit
View source
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Log in / create account
Special pages
New pages
File list
Statistics
Bug reports
More...