Wednesday, June 15, 2011

r818 - Scripted Entities

The big feature in this version is the addition of scripted entities.

  • Scripted Entities are defined by txt files in the entitys directory of a map.
    • They consist of a list of properties which are used to initialize the entity or determine which script is executed on events. Note all scripts have access to the entity with the variable named entity.
      • health - How much health this entity starts with
      • texture - The texture to initialize the entity with
      • height - Height of the entity
      • width - Width of the entity
      • onCreated - Script run when an entity of this type is created (on either first spawn or reloading a saved map)
      • onUpdate - Script ran once a tick for the entity
      • onPathReached - Script ran once the pathed to target is reached
      • onDeath - Script upon the entity dieing
      • onAttacked - Script executed whenever this entity is attacked.  The variable attackingEntity has the entity performing the attack and attackingDamage the amount of damage being taken.  If the last line executed of this script is false then the rest of the attack doesn't go through.
    • Has the functions isPathing(), clearPath(), pathToEntity(Entity e), and pathToBlock(x, y, z)
  • All UI Elements can have their parent specified as their last argument in the constructor.
  • Paths being followed are rendered in debug mode and can be enabled outside of debug mode with /renderpaths

Demonstration of a scripted entity that just grows whenever its hit.  Nothing too complex just meant to demonstrate the new features.


  1. I have an issue working with the entity script "ent.getAttackStrength or set" on spawners... i dont know if im using it wrong but it doesnt work well with any mob, only skeletons work.

  2. Will have to look at that later though CyborgDragon exposed that so not sure.

  3. How is the image stretched along with the creature? I wish to make large mobs for boss fights but do not know how to get the .png file to stretch with the size of the mob. I am using this script for on spawn. Any Help would be Greatly Appreciated.

    for (var i = 0; i < spawnedEntities.length; i++) {
    var ent = spawnedEntities[i];
    ent.attackStrength = 40;
    ent.maxHealth = 100; = 100;
    ent.hurtTime = 4;
    ent.width = 2;
    ent.height = 4;
    ent.texture = "/newmobs/Tree-Ent.png";