Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Tyrion.AI_BucklerDeflect


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
//=====================================================================
// AI_BucklerDeflect
// If a buckler is equipped, tries to deflect incoming projectiles
//=====================================================================

class AI_BucklerDeflect extends AI_WeaponAction
	editinlinenew;

//=====================================================================
// Variables

var BaseAICharacter ai;
var float endTime;
var float timeToHit;
var Rotator aimRotation;
var Pawn shooter;			// who fired the projectile I want to deflect

//=====================================================================
// Functions

//---------------------------------------------------------------------
// Selection Heuristic
// Returns a value in the range [0, 1], indicating how suitable this action is for achieving this goal

static function float selectionHeuristic( AI_Goal goal )
{
	local Weapon w;

	w = Weapon(Character(goal.resource.pawn()).nextEquipment( None, class'Buckler' ));

	// don't run action if no buckler equipped or buckler is flying (test could be moved to a sensor for efficiency)
	if ( w != None && w.hasAmmo() )
		return 1.0;
	else
		return 0.0;
}

//---------------------------------------------------------------------

function cleanup()
{
	super.cleanup();

	if ( resource.pawn().controller != None )
		AI_Controller(resource.pawn().controller).bAiming = true;
}

//=====================================================================
// State code

state Running
{
Begin:
	ai = baseAICharacter();

	if ( ai.logTyrion )
		log( name @ "started on" @ ai.name );

	// look towards enemy (unnecessary if a general "stay faced towards enemy" goal is ever added to AI's)
	if ( ai.controller != None )
		AI_Controller(ai.controller).bAiming = true;

	shooter = Pawn(characterResource().commonSenseSensorAction.dodgeSensor.queryObjectValue());

	timeToHit = 1.0f;	// todo: use actual "tomeToHit" (DodgeSensor would have to make this value available)
	endTime = ai.level.timeSeconds + timeToHit;

	while ( ai.level.timeSeconds < endTime )
	{
		aimRotation = Rotator(shooter.Location - ai.Location);
		ai.motor.setAIMoveRotation( aimRotation );
		ai.motor.setViewRotation( aimRotation );	// target needs to kept in view
		Sleep( 0.1f );	
	}

	if ( ai.logTyrion )
		log( name @ "(" @ ai.name @ ") stopped" );

	succeed();	// pawn death check handled inside "waitForAction" 
}

//=====================================================================

defaultproperties
{
	satisfiesGoal = class'AI_BucklerDeflectGoal'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:58.000 - Creation time: st 23.5.2018 00:10:40.943 - Created with UnCodeX