Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00116 00117 |
//===================================================================== // AI_GuardAttack // Engages any enemies within a specified area // Doesn't require movement resource // // If guardAttack priority is higher than priority of the actions using // the movement resource, Guard will use the characters regular attack. // If not, guardAttack will just fire its weapon. //===================================================================== class AI_GuardAttack extends AI_CharacterAction editinlinenew; //===================================================================== // 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; var Pawn target; var AI_Goal subGoal; var int origPriority; // original priority of GuardAttackGoal //===================================================================== // 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 0.9; // lower than Protect if Protect applies } //--------------------------------------------------------------------- function cleanup() { super.cleanup(); // clear GuardSensor value so action can be activated again // (also important because GuardSensor doesn't terminate when LOS is lost - it relies on the action to do this) if ( achievingGoal.activationSentinel.sensor != None ) achievingGoal.activationSentinel.sensor.setObjectValue( None ); weaponSelection = None; followFunction = None; if ( subGoal != None ) { subGoal.Release(); subGoal = None; } } //===================================================================== // State code state Running { Begin: target = Pawn(achievingGoal.activationSentinel.sensor.queryObjectValue()); AI_Guard(achievingGoal.parentAction).lastGuardTarget = target; if ( target == None ) { log( "AI WARNING:" @ name $ ":" @ pawn.name @ "has no guard target" ); } else { if ( pawn.logTyrion ) log( name @ "started on" @ pawn.name $ ". Attacking" @ target.name ); do { if ( subGoal != None ) { subGoal.unPostGoal( self ); subGoal.Release(); subGoal = None; } origPriority = achievingGoal.priorityFn(); subGoal = (new class'AI_AttackGoal'( characterResource(), achievingGoal.priorityFn(), target,,, followFunction )).postGoal( self ).myAddRef(); // if priority changes, repost goals while ( class'Pawn'.static.checkAlive( pawn ) && class'Pawn'.static.checkAlive( target ) && !subGoal.hasCompleted() && achievingGoal.priorityFn() == origPriority ) { Sleep( 1.0f ); } } until ( class'Pawn'.static.checkDead( pawn ) || class'Pawn'.static.checkDead( target ) || subGoal.hasCompleted() ) } if ( pawn.logTyrion ) log( name @ "(" @ pawn.name @ ") succeeded" ); succeed(); } //===================================================================== defaultproperties { satisfiesGoal = class'AI_GuardAttackGoal' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |