Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Tyrion.AI_GuardAttackGoal

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
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115

    //=====================================================================
    // AI_GuardAttackGoal
    // Engages any enemies within a specified area
    // Doesn't require movement resource
    //=====================================================================

    class AI_GuardAttackGoal extends AI_CharacterGoal;

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

    var(InternalParameters) float engagementAreaRadius "Radius of engagement area";
    var(InternalParameters) float movementAreaRadius "Radius of movement area";
    var(InternalParameters) class<Weapon> preferredWeaponClass "AI will use this weapon if at all possible";

    var(InternalParameters) editconst Vector engagementAreaCenter;
    var(InternalParameters) editconst Actor engagementAreaTarget;
    var(InternalParameters) editconst Vector movementAreaCenter;
    var(InternalParameters) editconst Actor movementAreaTarget;
    var(InternalParameters) editconst IWeaponSelectionFunction weaponSelection;
    var(InternalParameters) editconst IFollowFunction followFunction;

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

    overloaded function construct( AI_Resource r, int pri,
    							  Vector _engagementAreaCenter, Actor _engagementAreaTarget, float _engagementAreaRadius,
    							  optional Vector _movementAreaCenter, optional Actor _movementAreaTarget, optional float _movementAreaRadius,
    							  optional IWeaponSelectionFunction _weaponSelection,
    							  optional class<Weapon> _preferredWeaponClass, optional IFollowFunction _followFunction )
    {
    	priority = pri;

    	engagementAreaCenter = _engagementAreaCenter;
    	engagementAreaTarget = _engagementAreaTarget;
    	engagementAreaRadius = _EngagementAreaRadius;
    	movementAreaCenter = _movementAreaCenter;
    	movementAreaTarget = _movementAreaTarget;
    	movementAreaRadius = _movementAreaRadius;
    	weaponSelection = _weaponSelection;
    	preferredWeaponClass = _preferredWeaponClass;
    	followFunction = _followFunction;

    	super.construct( r );
    }

    //---------------------------------------------------------------------
    // Called when a goal is removed

    function cleanup()
    {
    	super.cleanup();

    	followFunction = None;
    	weaponSelection = None;
    }

    //---------------------------------------------------------------------
    // Called explicitly at start of gameplay

    function init( AI_Resource r )
    {
    	super.init( r );

    	// userData is always 'None' for deactivation sensors, and != None for activation sensors
    	activationSentinel.activateSentinel( self, class'AI_GuardSensor', r,, class'AI_Sensor'.const.ONLY_NON_NONE_VALUE, self );
    	AI_GuardSensor(activationSentinel.sensor).setParameters( engagementAreaRadius, engagementAreaCenter, engagementAreaTarget );
    }

    //---------------------------------------------------------------------
    // Setup deactivation sentinel

    function setUpDeactivationSentinel()
    {
    	deactivationSentinel.activateSentinel( self, class'AI_GuardSensor', resource,, class'AI_Sensor'.const.ONLY_NONE_VALUE, None );
    }

    //---------------------------------------------------------------------
    // returns the priority of this goal

    event int priorityFn()
    {
    	local float distanceSquared;

    	// lower goal priority if outside movementArea
    	if ( resource != None )
    	{
    		if ( movementAreaTarget == None )
    			distanceSquared = VDistSquared( movementAreaCenter, resource.pawn().Location );
    		else
    			distanceSquared = VDistSquared( movementAreaTarget.Location, resource.pawn().Location );

    		if ( distanceSquared > movementAreaRadius * movementAreaRadius )
    		{
    			//log( "goal priority debumped!" );
    			return priority-2;
    		}
    	}

    	return priority;
    }

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

    defaultproperties
    {
    	engagementAreaRadius = 5000
    	movementAreaRadius = 4000

    	bInactive = true
    	bPermanent = true
    	priority = 40
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:54:26.000 - Creation time: st 23.5.2018 00:10:41.275 - Created with UnCodeX