Fighting and gathering


After playing with movement of entities the whole weekend (kids were gone), I ended up with an Action class that each entities will have.

var ACTION_TYPE_NONE = -1;
var ACTION_TYPE_IDLE = 0;
var ACTION_TYPE_MOVE = 1;
var ACTION_TYPE_ATTACK = 2;
var ACTION_TYPE_GATHER = 3;
var ACTION_TYPE_TALK = 4;
function ActionInformation() {
    this.animation = null; // Current running animation
    this.currentActionType = ACTION_TYPE_IDLE;
    this.isExecuting = false; // Are we doing the end going or going to the end goal
    this.isReady = false; // Temporary variable used in planning  
    // Most actions are done on a tile beside the entity
    this.startLocation = null; // { x: 0, y: 0 };
    this.angle = -1; // Which angle to walk, attack, gather, talk, ...
    // The end goal of the action
    // It could be going to an entity or going to a specific location
    this.longTermActionEntity = null;
    this.longTermActionLocation = null; // { x: 0, y: 0 };
    // When the action is taking place
    this.goalExecutionTurns = 0; // When the action end goal is starting, count the number of times it's been running
    // Action for next turn
    // When an event need to interupt the current action, need to keep this information
    // until the next turn starts
    this.nextTurnActionType = ACTION_TYPE_NONE;
    this.nextTurnActionEntity = null;
    this.nextTurnActionLocation = null; // { x: 0, y: 0 };
}

Anyone know how to add empty new line in the code here?

It works well, but when fighting enemies, I coded a "walking through enemies" logic by mistake :)


I used some sort of A* path finding and it works well.  This time, the engine allow having walls on the edge of tiles. This gives me the opportunity to have things in the corner of walls.


Leave a comment

Log in with itch.io to leave a comment.