User Tools

Site Tools


mr:zombie_mob

Zombie Mob - Code References

Zombie Mob

Java Classes

JSON Configuration

Mob configuration in mobsDesc/Zombie.json:

{
   "name"          : "Zombie_Name",
   "name_objective": "Zombie_Name_Objective",
   "description"   : "Zombie_Desc",
   "gender"        : "Zombie_Gender",
   "attackSkill"   : 10,
   "defenseSkill"  : 10,
   "dmgMin"        : 3,
   "dmgMax"        : 10,
   "dr"            : 10,
   "str"           : 13,
   "ht"            : 33,
   "exp"           : 6,
   "maxLvl"        : 15,
   "baseSpeed"     : 1,
   "attackDelay"   : 1,
   "viewDistance"  : 8,
   "walkingType"   : "NORMAL",
   "spriteDesc"    : "spritesDesc/Zombie.json",
   "scriptFile"    : "scripts/mobs/Zombie",
   "lootChance"    : 0.02,
   "loot"          : { "kind": "Gold" },
   "undead"        : true,
   "isHumanoid"    : true,
   "canBePet"      : true,
   "friendly"      : false,
   "fraction"      : "DUNGEON"
}

  • mobsDesc/Zombie.json - Main mob configuration
  • spritesDesc/Zombie.json - Sprite configuration
  • Spawn configuration in Bestiary.json:
    • necro1: Zombie spawn rate 1.0
    • necro2: Zombie spawn rate 1.0 (with ExplodingSkull, EnslavedSoul, DeathKnight, DreadKnight)
    • necro3: Zombie spawn rate 2.0 (with ExplodingSkull, EnslavedSoul, DeathKnight, DreadKnight)

String Resources

English string resources:

<string name="Zombie_Name">zombie</string>
<string name="Zombie_Name_Objective">zombie</string>
<string name="Zombie_Desc">An animated corpse from the necropolis. It has quite a bit of health, and has a chance to poison the hero on hit. Like all undead creatures, it has immunity to many effects.</string>
<string name="Zombie_Gender">masculine</string>

String resources available in multiple languages:

Lua Scripts

  • Zombie.lua - Custom attack behavior (poison on hit)

Key Code Fragments

JSON Configuration (mobsDesc/Zombie.json):

{
   "name"          : "Zombie_Name",
   "name_objective": "Zombie_Name_Objective",
   "description"   : "Zombie_Desc",
   "gender"        : "Zombie_Gender",
   "attackSkill"   : 10,
   "defenseSkill"  : 10,
   "dmgMin"        : 3,
   "dmgMax"        : 10,
   "dr"            : 10,
   "str"           : 13,
   "ht"            : 33,
   "exp"           : 6,
   "maxLvl"        : 15,
   "baseSpeed"     : 1,
   "attackDelay"   : 1,
   "viewDistance"  : 8,
   "walkingType"   : "NORMAL",
   "spriteDesc"    : "spritesDesc/Zombie.json",
   "scriptFile"    : "scripts/mobs/Zombie",
   "lootChance"    : 0.02,
   "loot"          : { "kind": "Gold" },
   "undead"        : true,
   "isHumanoid"    : true,
   "canBePet"      : true,
   "friendly"      : false,
   "fraction"      : "DUNGEON"
}

Lua Script (scripts/mobs/Zombie.lua):

local RPD = require "scripts/lib/commonClasses"
local mob = require "scripts/lib/mob"
 
return mob.init{
    attackProc = function(self, enemy, dmg)
        -- 1/3 chance to poison; java rolled Random.Int(2,3) which is [2,3)
        -- i.e. always 2 turns
        if enemy ~= nil and math.random(3) == 1 then
            local factor = RPD.CharUtils:durationFactor(enemy)
            RPD.Buffs.Buff:affect(enemy, "Poison", 2 * factor)
        end
        return dmg
    end
}

mr/zombie_mob.txt · Last modified: by 127.0.0.1