Even if it's no use to anybody else, it's documentation for me to return to if I want to improve core AI behaviour further, and my actual code and comments in GMDX's scripted pawn can remain intact also.
Thing is, I am NOT a programmer. I don't like coding. I've had little schooling in the subject. OK, I find it somewhat interesting but I know it's not for me and knew from the start. Ideally I should have an actual programmer doing these things, but the only actual programmers (about 3) that frequent this place have their own projects. Where the fuck are all the Deus Ex fans?
Question: when the code is running through the labels, it goes from top to bottom through the whole lot (all labels) unless otherwise specified with GoTo right?
The following sheds some light on the labels of state seeking (all vanilla code, my comments):
Code: Select all
Begin: //We start from here unless otherwise specified.
WaitForLanding(); //Calls this function which waits for the pawn to land before executing the code
PlayWaiting(); //plays a standing animation where the pawns appear to breathe.
if ((Weapon != None) && bKeepWeaponDrawn && (Weapon.CockingSound != None) && !bSeekPostCombat) //checks conditions
{
if(DeusExPlayer(GetPlayerPawn()).DrugEffectTimer < 0) //Nested check
PlaySound(Weapon.CockingSound, SLOT_None,,, 1024, 0.5); //play sound at half pitch because player is drugged?
else
PlaySound(Weapon.CockingSound, SLOT_None,,, 1024); //normal pitch if not drugged
}
Acceleration = vect(0,0,0); //No idea why this changes a pawn's acceleration
if (!PickNextDestination()) //check
Goto('DoneSeek'); //Go to the DoneSeek label
GoToLocation: //label for making pawns go to a certain location
bInterruptSeek = true; //bInterruptSeek is a bool used for checking for whether or not the state can be interrupted
Acceleration = vect(0,0,0); //Again, Why?
if ((DeusExWeapon(Weapon) != None) && DeusExWeapon(Weapon).CanReload() && !Weapon.IsInState('Reload')) //checks
DeusExWeapon(Weapon).ReloadAmmo(); //Reload weapon before or whilst moving to location?
if (bSeekPostCombat) //bSeekPostCombat is a bool for checking whether or not the pawn is seeking post 'attacking' state
PlayPostAttackSearchingSound(); //self explanatory
else if (SeekType == SEEKTYPE_Sound) //SEEKTYPES are self explanatory
PlayPreAttackSearchingSound(); //"" ""
else if (SeekType == SEEKTYPE_Sight) //"" ""
{
if (ReactionLevel > 0.5) //Another check. ReactionLevel. Not sure what this var is EXACTLY for.
PlayPreAttackSightingSound(); //playsound
}
else if ((SeekType == SEEKTYPE_Carcass) && bSeekLocation) //check
PlayCarcassSound(); //if spotted a carcass, play carcass react sound
StopBlendAnims(); //stop all pawn anims in progress I think
//THIS CODE BELOW HANDLES WHEN A PAWN HAS SPOTTED THE PLAYER BUT NOT CONFIRMED FRIEND OR FOE
if ((SeekType == SEEKTYPE_Sight) && bSeekLocation) //Check
Goto('TurnToLocation'); //If looking for player based on sight, go to TTL label.
//IF WE ARE NOT SEEKING BASED ON SIGHT WE RUN THROUGH THIS CODE
EnableCheckDestLoc(true); //Not sure what this function is for, but it gets enabled
while (GetNextLocation(useLoc)) //While loops. Basic stuff but I don't know the exact workings. DO this WHILE this is active i think
{
if (ShouldPlayWalk(useLoc)) //not sure what this function is for.
PlayRunning(); //Play running handles running anim
MoveTo(useLoc, MaxDesiredSpeed); //moveto useLoc at max class speed. useLoc is a var assigned the vector of the last known location of the player I believe.
CheckDestLoc(useLoc); //dont know. Will update when I check out this function
}
EnableCheckDestLoc(false); //This was enabled before the while loop. Now it is disabled once the while loop is finished. Time for me to figure out GetNextLocation and EnableCheckDestination functions...
//THIS CODE BELOW HANDLES SOUND EVENTS I BELIEVE
if ((SeekType == SEEKTYPE_Guess) && bSeekLocation) //check. Seektype guess I am not 100% on
{
MoveTarget = GetOvershootDestination(0.5); //GetOverShootDestination function makes pawns overshoot their destination
if (MoveTarget != None) //check
{
if (ShouldPlayWalk(MoveTarget.Location)) //ShouldPlayWalk is a function to check if pawns should move I think!!???
PlayRunning(); //start running anim.
MoveToward(MoveTarget, MaxDesiredSpeed); //Moves Toward MoveTarget at max desired speed
}
//OK, THIS IF STATEMENT BELOW IS FOR RANDOMIZED RUNNING AROUND CALLED IN THE LABEL 'FindAnotherPlace:'
if (AIPickRandomDestination(CollisionRadius*2, 200+FRand()*200, Rotation.Yaw, 0.75, Rotation.Pitch, 0.75, 2,
0.4, useLoc)) //This is a very specific check. WTF?
{
if (ShouldPlayWalk(useLoc)) //only do this if passed the insanely specific check above
PlayRunning(); //only do this if passed the insanely specific check above
MoveTo(useLoc, MaxDesiredSpeed); //only do this if passed the insanely specific check above
}
}
TurnToLocation: //Label that turns the pawn to look at the source of the disturbance
Acceleration = vect(0,0,0); //Again, why is acceleration modified? to make sure they cannot move?
PlayTurning(); //play turning animation
if ((SeekType == SEEKTYPE_Guess) && bSeekLocation) //check
destLoc = Location + Vector(Rotation+(rot(0,1,0)*(Rand(16384)-8192)))*1000; //formula for rotating the pawn to location which is then stored inside destLoc
if (bCanTurnHead) //Check.
{
Sleep(0); // needed to turn head
LookAtVector(destLoc, true, false, true); //Make pawn look (with it's head only I think) at a specific vector, which in this case is destLoc
TurnTo(Vector(DesiredRotation)*1000+Location); //PlayTurning() handles the anim. This however handles the vector of the pawn
}
else
TurnTo(destLoc); //else If is robot or anyhting else that cannot move it's head, just turn the robot's vector.
bSeekLocation = false; //used often for checks. fucks with me.
bInterruptSeek = false; //same as above. GRRR
PlayWaiting(); //Play the standing breathing anim again.
Sleep(FRand()*1.5+3.0); //Randomized time frame for the state code to stop executing right here momentarily.
LookAround: //Just for handling looking around anims for human. I am going to skip "documenting" it because it's all self explanatory.
if (bCanTurnHead)
{
if (FRand() < 0.5)
{
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Left, 1.0, 1.0);
Sleep(1.0);
}
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Forward, 1.0, 1.0);
Sleep(0.5);
}
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Right, 1.0, 1.0);
Sleep(1.0);
}
}
else
{
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Right, 1.0, 1.0);
Sleep(1.0);
}
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Forward, 1.0, 1.0);
Sleep(0.5);
}
if (!bSeekLocation)
{
PlayTurnHead(LOOK_Left, 1.0, 1.0);
Sleep(1.0);
}
}
PlayTurnHead(LOOK_Forward, 1.0, 1.0);
Sleep(0.5);
StopBlendAnims();
}
else
{
if (!bSeekLocation)
Sleep(1.0);
}
FindAnotherPlace: //Label for making pawns run to partially-randomized location.
SeekLevel--; //No idea what this is
if (PickNextDestination()) //????? If this function is executing, or if it is true, or what?
Goto('GoToLocation'); //Causes the code to Goto the GoToLocation label back up near the top.
DoneSeek: //label for handling the ending of the state.
if (bSeekPostCombat) //check
PlayTargetLostSound(); //playsound if post combat
else
PlaySearchGiveUpSound(); //playsound if not post combat
bSeekPostCombat = false; //sets the var to false
SeekPawn = None; //sets the var to none
if (Orders != 'Seeking') //check
FollowOrders(); //if no longer seeking, go back to default orders I think
else //check
GotoState('Wandering'); //if orders are seeking, GottoState wandering
ContinueSeek: //what the fuck? just an unused label I guess. The code will run through and ignore?
ContinueFromDoor: //Continue from door?
FinishAnim(); //Waits for the anim to finish before execution
Goto('FindAnotherPlace'); //Go to find another place label above. How come the code doesn't get stuck in an infinite loop if right at the end it is told to go back up to FindAnotherPlace again?
}
But again, this will come in handy if I have to go in fucking scripted fucking pawn again, and perhaps will help someone else understand the code easier. Maybe even mislead them, who knows? I'm not a fucking programmer.
Where is G-Flex? He'd get a kick out of correcting all this.
If I return to it I will update it as I make progress, or update it if someone provides clarity to certain lines.