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 |
//===================================================================== // AI_Dodge // Dodges projectiles // // Dodging is usually handled inside the navigation code (the DodgeSensor // sets a displacement vector on the controller). This action is only // activated when the pawn isn't already moving. That's why the priority // of the dodge goal is low. //===================================================================== class AI_Dodge extends AI_MovementAction editinlinenew; //===================================================================== // Variables var BaseAICharacter ai; var AI_Controller c; var ACT_ErrorCodes errorCode; // errorcode from child action var Vector destination; var Pawn shooter; var array<Actor> ignore; var Vector lastValidLocation; //===================================================================== // Functions //--------------------------------------------------------------------- // Callbacks from Navigation System actions function actionSucceededCB( NS_Action child ) { super.actionSucceededCB( child ); errorCode = ACT_SUCCESS; } function actionFailedCB( NS_Action child, ACT_ErrorCodes anErrorCode ) { super.actionFailedCB( child, anErrorCode ); errorCode = anErrorCode; } //--------------------------------------------------------------------- function cleanup() { super.cleanup(); if ( class'Pawn'.static.checkAlive( resource.pawn() ) ) AI_Controller(resource.pawn().controller).stopMove(); } //===================================================================== // State code state Running { Begin: ai = BaseAICharacter(resource.pawn()); c = AI_Controller(ai.controller); if ( ai.logTyrion ) log( name @ "started on" @ ai.name ); if ( c.dodgeStartTime > c.level.TimeSeconds ) { if ( ai.logTyrion ) log( name @ "(" @ ai.name @ ") delaying by" @ c.dodgeStartTime - c.level.TimeSeconds ); Sleep( c.dodgeStartTime - c.level.TimeSeconds ); } if ( class'Pawn'.static.checkDead( ai )) fail( ACT_ALL_RESOURCES_DIED ); // compute destination based on dodgeDisplacement destination = ai.Location + c.dodgeDisplacement; c.canPointBeReached( ai.Location, destination, ai, ignore, lastValidLocation ); lastValidLocation.Z += c.dodgeDisplacement.Z; if ( c.dodgeDisplacement.Z == 0 ) waitForAction( class'NS_DoLocalMove'.static.startAction( c, self, lastValidLocation, false )); else waitForAction( class'NS_DoLocalMove'.static.startAction( c, self, lastValidLocation, false, ,,,,,,,5000,1, true )); // look towards enemy (unnecessary if a general "stay faced towards enemy" goal is ever added to AI's) shooter = Pawn(characterResource().commonSenseSensorAction.dodgeSensor.queryObjectValue()); if ( class'Pawn'.static.checkAlive( shooter ) ) { waitForAction( class'NS_Turn'.static.startAction( c, self, Rotator(shooter.Location - ai.Location) )); // cheat: accessing shooter's location } if ( ai.logTyrion ) log( name @ "(" @ ai.name @ ") stopped" ); succeed(); // pawn death check handled inside "waitForAction" } //===================================================================== defaultproperties { satisfiesGoal = class'AI_DodgeGoal' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |