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

# Tyrion.AI_CivilianReactToFire

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

    //=====================================================================
    // AI_CivilianReactToFire
    //=====================================================================

    class AI_CivilianReactToFire extends AI_CharacterAction
    	editinlinenew
    	dependsOn(AI_ReactToFireSensor);

    import enum TriggerCategories from AI_ReactToFireSensor;

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

    var(Parameters)	float panicChance "chance of panicking when being shot at";
    var(Parameters) float nearHitDistance "Max distance to react to near hit";
    var(Parameters) float allyShotDistance "Max distance to react to an ally getting shot";

    var Pawn enemy;
    var TriggerCategories trigger;	// what triggered ReactToFire?

    //=====================================================================
    // 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 )
    {
    	return 1.0;
    }

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

    state Running
    {
    Begin:
    	// This bit of code assumes that the reactToFire action is started by the reactToFire sensor
    	// (and consequently, that the sensor has meaningful values when this action runs).
    	// todo: Think of a way to formalize this dependency? The action could declare its interest in a value even though it doesn't require callbacks?)
    	enemy = characterResource().commonSenseSensorAction.reactToFireSensor.attacker;	// knowing who fired the shot is a bit a cheat, but the AI does have to spot the enemy before reacting
    	trigger = characterResource().commonSenseSensorAction.reactToFireSensor.triggerCategory;

    	if ( pawn.logTyrion )
    		log( name @ "(" @ pawn.name @ ") started." @ enemy @ trigger );

    	if ( trigger != RTF_MOVEMENT_SOUND && class'Pawn'.static.checkAlive( enemy ) )
    	{
    		waitForGoal( (new class'AI_TurnGoal'( movementResource(), 99, Rotator(enemy.Location - pawn.Location) )).postGoal( self ), true );
    	}

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

    	succeed();
    }

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

    defaultproperties
    {
    	satisfiesGoal = class'AI_ReactToFireGoal'
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
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.991 - Created with UnCodeX