Table of Contents

Barman NPC - Code References

Barman NPC Sprite

Barman is a passive NPC in Remixed Dungeon that serves as a test/demo character for NPC functionality.

Entity Type

NPC (Non-Player Character) - JSON configuration with Lua script

Java Classes

This entity is implemented through JSON configuration with Lua script, no dedicated Java class exists. Uses standard NPC classes from:

JSON Configuration

mobsDesc/BarmanNPC.json:

{
   "baseSpeed"     :0,
   "spriteDesc"    :"spritesDesc/BarmanNPC.json",
   "scriptFile"    :"scripts/npc/Barman",
   "friendly"      :true,
   "movable"       :false,
   "aiState"       :"Passive",
   "fraction"      :"NEUTRAL"
}

Configuration Breakdown:

spritesDesc/BarmanNPC.json:

{
   "texture" : "mobs/barman.png",
   "width" : 16,
   "height" : 16,
   "idle" : {
      "fps" : 1,
      "looped" : true,
      "frames" : [0, 1,0,0,1, 2,0,2]
   },
   "run" : {
      "fps" : 8,
      "looped" : true,
      "frames" : [0, 1, 2]
   },
   "attack" : {
      "fps" : 8,
      "looped" : true,
      "frames" : [0, 1, 2]
   },
   "die" : {
      "fps" : 8,
      "looped" : true,
      "frames" : [0, 1, 2]
   }
}

Animation Details:

String Resources

English (values/strings_all.xml):

<string name="BarmanNPC_Name">Barman</string>

Russian (values-ru/strings_all.xml):

<string name="BarmanNPC_Name">Бармен</string>

Lua Scripts

scripts/npc/Barman.lua:

local RPD = require "scripts/lib/commonClasses"
local mob = require"scripts/lib/mob"
 
local dialog = function(index)
    if index == 0 then
        local hero = RPD.Dungeon.hero
        local pos = RPD.getXy(hero)
        RPD.Dungeon.hero:handle(RPD.Dungeon.level:cell(pos[1],pos[2]-3))
        return
    end
 
    if index == 1 then
        RPD.glog("okay...")
    end
end
 
return mob.init({
    interact = function(self, chr)
        RPD.chooseOption( dialog,
                "Test title",
                "Go back",
                "Yes",
                "No")
    end
})

Script Functionality:

Game Mechanics

Code Fragments

Example interaction pattern from Barman.lua:

-- Basic NPC interaction template
return mob.init({
    interact = function(self, chr)
        RPD.chooseOption( dialog,
                "Dialog Title",
                "Option 1",
                "Option 2",
                "Option 3")
    end
})

See Also