Eastern Warrior – Day 19

Ok, let’s back to Eastern Warrior. I was on another project so couldn’t work on this frequently like before =.=

So we will discuss:

  • AI
  • Enemy HUD

AI

So to create an AI, we need 2 main things – AIController and Pawn. It’s very similar to PlayerControl but there is a bit difference. AIController is different then PlayerController so we cannot reuse the code we write for PC fully (so greedy) but partially can. I reuse quite a lot things from my PC class, such as AttackHandler and StatControl. It brings me extreme convenience ūüėÄ

Day 19-1 SS

 

So from the screenshot, you can see I have 4 archetypes, and basically everything we need for 1 enemy (my SmallDragon). This combination help me to control all the element of an AI without go back to the code and just need to edit from here. After all the set up, I just need to drag the Pawn object to the map and that’s it. We got a beautiful AI.

For the AIController, I use different states to control the AI, separating into Idle, Follow, Attack, Hurt and Dead. By switching between these states, it’s easier to debug and monitor the action of the AI. My AI Pawn class is extend from the same Player Pawn so it minimize all the extra code needed and no states control need at all.

Enemy HUD

So to create enemy HUD and call it inside the AIController, I need to have all enemy controller class implement an HUD interface, so from the PlayerController class, I can call:

function DrawHUD( HUD H )
{
¬† ¬† foreach DynamicActors(class’Actor’,a,class’HUDInterface’)
     {
             HUDInterface(a).DrawMyHUD(MyHUD(H));
     }
}

So in the end, basically we can have:

Day 19-2 SS

 

Here the video: