Skip to content
Sriep edited this page Aug 6, 2016 · 8 revisions

Role

A role is a wrapper around a useful set of tasks that a creep can make use of. The key function for understanding roles is the roleBase.switchRoles method.

    switchRoles: function (creep, role, para1, para2, para3, para4, para5,
                                         para6, para7, para8, para9, para10) {
        if (undefined === creep) {
            return false;
        }
        if (undefined === creep.memory.tasks)
            creep.memory.tasks = {};
        tasks.setTargetId(creep,undefined);
        creep.memory.tasks.state = undefined;
        module = this.getModuleFromRole(role);
        if (undefined === module) {
            return false;
        }
        creep.memory.tasks.tasklist = module.getTaskList(creep, para1, para2, para3, para4, para5,
                                                                para6, para7, para8, para9, para10 );
        creep.memory.role = role;
        return true;
    },

getModuleFromRole will construct the filename containing the role object from the role parameter containing the name of the role.

Role requirements.

  • The filename must start "role."
  • Ideally, the filename less the "role." part should be entered as an ROLE_ in gc.js
  • Must have a getTaskList member which returns an array of tasks.
  • If getTaskList has any parameters, then the first one must be the creep being assigned the role.
  • Probably advisable to keep to eleven or fewer parameters.
Clone this wiki locally