valkryja.xml 31.3 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
3
<MudletPackage version="1.001">
Maiyannah Bishop's avatar
Maiyannah Bishop committed
4 5 6 7 8 9 10 11 12
	<TriggerPackage />
	<TimerPackage />
	<AliasPackage />
	<ActionPackage />
	<ScriptPackage>
		<Script isActive="yes" isFolder="no">
			<name>Valkryja.Core</name>
			<packageName></packageName>
			<script>-- =============================================================================
13 14
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
15 16
-- This system is distributed under specific licensing terms specified in
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
17
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
18
--
19
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
20
--
21
-- Valkryja.Core
22
--    System-internal stuff like configuration, internal timings, and so forth.
23
--
24
-- @package     Scripts
25
-- @category    Valkryja
26
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
27
-- @copyright   2006-2020 Maiyannah Bishop
28
-- @link        valkryja.com
29
-- =============================================================================
30

31
Valkryja = Valkryja or {};
32

33
Character = Character or {};
34

35
Players = Players or {};
36

37
Map = Map or {};
38 39
Map.Contents = Map.Contents or ""

40
UI = UI or {};
41

42
Room = Room or {};
43
Room.Name = Room.Name or ""
44

45

46 47 48
-- =============================================================================
-- Startup functions
-- -----------------------------------------------------------------------------
49
-- Function: Valkryja.Startup()
50
-- Set up the operating environment for the system
51
function Valkryja.Startup()
52
   -- System state and transient variables that are needed in the global context
53
    cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; Initializing superglobals...\n")
54

55 56 57 58 59 60 61 62 63 64 65 66
   -- --------------------------------------------------------------------------
   -- Raise bootstrapping events
   --
   -- beginClearSystem     - handler should reset status of system
   -- beginInitCharacter   - handler should initialize the Character class
   -- beginInitRoom        - handler should initialize the Room class
   -- beginInitInventory   - handler should initialize the inventory class
   -- beginInitMUDSpecific - handler should initialize any MUD specific classes
   --
   -- all begin* event handlers should raise a corresponding end* event when
   -- completed.
   --
67
   -- The parameters of all Valkryja events are the caller and an optional table
68
   -- of additional arguments.
69
    cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; Performing routine initalization events...\n")
70
   raiseEvent("beginInitValkryja", "core")
71 72 73 74 75
   raiseEvent("beginClearSystem", "core")
   raiseEvent("beginInitCharacter", "core")
   raiseEvent("beginInitRoom", "core")
   raiseEvent("beginInitInventory", "core")
   raiseEvent("beginInitMUDSpecific", "core")
76

77
   -- Perform integrity check
78
   Valkryja.IntegrityCheck("all")
79
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; &lt;yellow&gt;Note:&lt;reset&gt; Not all failures above constitute an actual problem.\n")
80

81
   -- Initalize bashing
82
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; Initializing auto-basher...\n")
83
   Valkryja.CurrTarget         = Valkryja.CurrTarget or false
84
    
85 86
   -- Initialize UI harvester
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; Initializing UI harvesting...\n")
87 88
   Valkryja.HarvestingScore    = Valkryja.HarvestingScore or false
   Valkryja.HarvestingDefences = Valkryja.HarvestingDefences or false
89
   Valkryja.Harvesting         = Valkryja.Harvesting or {};
90
   Valkryja.TotalRoomObjects   = Valkryja.TotalRoomObjects or 0
91

92
   -- Defaults for console width and height assume 1080p monitor &amp; maximized window
93
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):&lt;reset&gt; Resizing main console...\n")
94 95
   Valkryja.consoleWidth  = Valkryja.consoleWidth or 790
   Valkryja.consoleHeight = Valkryja.consoleHeight or 798
96
   return true
97
end
98

99
-- -----------------------------------------------------------------------------
100
-- Function: Valkryja.IntegrityCheck
101
-- Make sure we have all the files we require for system initialization
102 103 104 105
--
-- This will only check if modules are present, it does not have any logic to
-- know which should be or shouldn't be.  It's intended as a master, hard-coded
-- safeguard against the manifest failing.
106 107
function Valkryja.IntegrityCheck(mud)
   mud = mud or false
108
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;): &lt;snow&gt;Commencing system integrity check...&lt;reset&gt;\n")
109
    
110 111
   -- Core
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):    &lt;snow&gt;Checking core modules...&lt;reset&gt;\n")
112 113 114
   check = pcall(Valkryja.CheckModule("valkryja", "Valkryja", true))
   check = pcall(Valkryja.CheckModule("berkana", "Berkana", true))
   check = pcall(Valkryja.CheckModule("kauna", "Kauna", true))
115 116
    -- check = pcall(Valkryja.CheckModule("laeknishendr", "Laeknishendr", true))
    -- check = pcall(Valkryja.CheckModule("raido", "Raido", true))
117 118 119 120 121 122

   if (mud=="all") or (mud=="achaea") or (Config.MUD=="achaea") then
      check = pcall(Valkryja.CheckMUDModules("achaea", "Achaea", true)) end
   if (mud=="all") or (mud=="acetolia") or (Config.MUD=="aetolia") then
      check = pcall(Valkryja.CheckMUDModules("aetolia", "Aetolia", true)) end
   if (mud=="all") or (mud=="alteraeon") or (Config.MUD=="alteraeon") then
123 124 125
      check = pcall(Valkryja.CheckMUDModules("alteraeon", "Alter Aeon", true)) end        
   if (mud=="all") or (mud=="asteria") or(Config.MUD=="asteria") then    
       check = pcall(Valkryja.CheckMUDModules("asteria", "Asteria", true)) end
126
   if (mud=="all") or (mud=="imperian") or(Config.MUD=="imperian") then 
127
       check = pcall(Valkryja.CheckMUDModules("imperian", "Imperian", true)) end
128
   if (mud=="all") or (mud=="luminari") or (Config.MUD=="luminari") then
129
      check = pcall(Valkryja.CheckMUDModules("luminari", "Realms of Luminari", true)) end  
130 131 132 133 134
   if (mud=="all") or (mud=="lusternia") or (Config.MUD=="lusternia") then
      check = pcall(Valkryja.CheckMUDModules("lusternia", "Lusternia", true)) end
   if (mud=="all") or (mud=="mm") or (Config.MUD=="mm") then
      check = pcall(Valkryja.CheckMUDModules("mm", "Materia Magica", true)) end
   if (mud=="all") or (mud=="starmourn") or (Config.MUD=="starmourn") then
135 136 137 138
       check = pcall(Valkryja.CheckMUDModules("starmourn", "Starmourn", true)) end
    
    check = nil
    return true
139 140
end

141 142 143 144
-- Function: Valkryja.CheckMUDModules
-- Check the modules for a given MUD alias
function Valkryja.CheckMUDModules(mud_alias, mud_fullname)
   if mud_alias == nil then return false end
145
    if mud_fullname == nil then return false end
146
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;):    &lt;snow&gt;Checking MUD-specific modules for "..mud_fullname.."...&lt;reset&gt;\n")
147 148 149 150 151 152 153 154 155
   check = pcall(Valkryja.CheckModule("valkryja_"..mud_alias, "Valkryja - "..mud_fullname, true))
   check = pcall(Valkryja.CheckModule("valkryja_"..mud_alias.."_triggers", "Valkryja - "..mud_fullname.." Triggers", true))
   check = pcall(Valkryja.CheckModule("valkryja_"..mud_alias.."_alias", "Valkryja - "..mud_fullname.." Aliases", true))
   check = pcall(Valkryja.CheckModule("berkana_"..mud_alias, "Berkana - "..mud_fullname, true))
   check = pcall(Valkryja.CheckModule("berkana_"..mud_alias.."_triggers", "Berkana - "..mud_fullname.." Triggers", true))
   check = pcall(Valkryja.CheckModule("berkana_"..mud_alias.."_alias", "Berkana - "..mud_fullname.." Aliases", true))
   check = pcall(Valkryja.CheckModule("kauna_"..mud_alias, "Kauna - "..mud_fullname, true))
   check = pcall(Valkryja.CheckModule("kauna_"..mud_alias.."_triggers", "Kauna - "..mud_fullname.." Triggers", true))
   check = pcall(Valkryja.CheckModule("kauna_"..mud_alias.."_alias", "Kauna - "..mud_fullname.." Aliases", true))
156 157 158 159 160 161
   -- check = pcall(Valkryja.CheckModule("laeknishendr_"..mud_alias, "Laeknishendr - "..mud_fullname, true))
   -- check = pcall(Valkryja.CheckModule("laeknishendr_"..mud_alias.."_triggers", "Laeknishendr - "..mud_fullname.." Triggers", true))
   -- check = pcall(Valkryja.CheckModule("laeknishendr_"..mud_alias.."_alias", "Laeknishendr - "..mud_fullname.." Aliases", true))
   -- check = pcall(Valkryja.CheckModule("raido_"..mud_alias, "Raido - "..mud_fullname, true))
   -- check = pcall(Valkryja.CheckModule("raido_"..mud_alias.."_triggers", "Raido - "..mud_fullname.." Triggers", true))
   -- check = pcall(Valkryja.CheckModule("raido_"..mud_alias.."_alias", "Raido - "..mud_fullname.." Aliases", true))
162 163
    check = nil
    return true
164
end
165

166

167 168
-- =============================================================================
-- HELPER FUNCTIONS
169
function Valkryja.toboolean(value)
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
   if (value=="true") then
       return true
    elseif (value=="false") then
       return false
    elseif (value) and (tonumber(value)==0) then
       return false
   elseif (value) and (tonumber(value)&gt;0) then
       return true
   elseif (value) and (string.len(tostring(value))&gt;0) then
       return true
   else
       return false
   end
end

185
function Valkryja.toBoolean(value)
186
  return Valkryja.toboolean(value)
187 188
end

189
function Valkryja.RightPad(string, length, char)
190
   local char = char or " "
191
   string = tostring(string)
192
   local res  = string..string.rep(char, length - #string)
193
   return res
194 195
end

196 197
-- ============================================================================
-- Actual bootstrapping goes here
198
Valkryja.Startup()
199

200
-- END OF FILE
201
-- ============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
202 203 204
			<eventHandlerList />
		</Script>
		<Script isActive="yes" isFolder="no">
205
			<name>Valkryja.Equipment</name>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
206 207
			<packageName></packageName>
			<script>-- Scripts-Valkryja-Equipment
208 209 210 211 212 213 214
-- =============================================================================
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
-- This system is distributed under specific licensing terms specified in
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
--
215
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
216 217 218 219 220 221 222 223
--
-- Equipment
--    Functions and tables related to player equipment
--
-- @package     Scripts
-- @category    Valkryja
-- @subcategory Equipment
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
224
-- @copyright   2006-2020 Maiyannah Bishop
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
-- @link        valkryja.com
-- =============================================================================

function Valkryja.LoadEquipmentIcons()
   Valkryja.EquipmentIcons["lh_bardiche"]    = Valkryja.SystemPath.."img/equipment/lh-bardiche.png"
   Valkryja.EquipmentIcons["lh_broadsword"]  = Valkryja.SystemPath.."img/equipment/lh-broadsword.png"
   Valkryja.EquipmentIcons["lh_club"]        = Valkryja.SystemPath.."img/equipment/lh-club.png"
   Valkryja.EquipmentIcons["lh_dagger"]      = Valkryja.SystemPath.."img/equipment/lh-dagger.png"
   Valkryja.EquipmentIcons["lh_dirk"]        = Valkryja.SystemPath.."img/equipment/lh-dirk.png"
   Valkryja.EquipmentIcons["lh_glaive"]      = Valkryja.SystemPath.."img/equipment/lh-glaive.png"
   Valkryja.EquipmentIcons["lh_halberd"]     = Valkryja.SystemPath.."img/equipment/lh-halberd.png"
   Valkryja.EquipmentIcons["lh_handaxe"]     = Valkryja.SystemPath.."img/equipment/lh-handaxe.png"
   Valkryja.EquipmentIcons["lh_longsword"]   = Valkryja.SystemPath.."img/equipment/lh-longsword.png"
   Valkryja.EquipmentIcons["lh_morningstar"] = Valkryja.SystemPath.."img/equipment/lh-morningstar.png"
   Valkryja.EquipmentIcons["lh_sabre"]       = Valkryja.SystemPath.."img/equipment/lh-sabre.png"
   Valkryja.EquipmentIcons["lh_shortsword"]  = Valkryja.SystemPath.."img/equipment/lh-shortsword.png"
   Valkryja.EquipmentIcons["lh_spear"]       = Valkryja.SystemPath.."img/equipment/lh-spear.png"
   Valkryja.EquipmentIcons["lh_warhammer"]   = Valkryja.SystemPath.."img/equipment/lh-warhammer.png"

   Valkryja.EquipmentIcons["lh_banded"]  = Valkryja.SystemPath.."img/equipment/lh-cavalry.png"
   Valkryja.EquipmentIcons["lh_buckler"] = Valkryja.SystemPath.."img/equipment/lh-buckler.png"
   Valkryja.EquipmentIcons["lh_shield"]  = Valkryja.SystemPath.."img/equipment/lh-shield.png"

   Valkryja.EquipmentIcons["rh_bardiche"]    = Valkryja.SystemPath.."img/equipment/rh-bardiche.png"
   Valkryja.EquipmentIcons["rh_broadsword"]  = Valkryja.SystemPath.."img/equipment/rh-broadsword.png"
   Valkryja.EquipmentIcons["rh_club"]        = Valkryja.SystemPath.."img/equipment/rh-club.png"
   Valkryja.EquipmentIcons["rh_dagger"]      = Valkryja.SystemPath.."img/equipment/rh-dagger.png"
   Valkryja.EquipmentIcons["rh_dirk"]        = Valkryja.SystemPath.."img/equipment/rh-dirk.png"
   Valkryja.EquipmentIcons["rh_glaive"]      = Valkryja.SystemPath.."img/equipment/rh-glaive.png"
   Valkryja.EquipmentIcons["rh_halberd"]     = Valkryja.SystemPath.."img/equipment/rh-halberd.png"
   Valkryja.EquipmentIcons["rh_handaxe"]     = Valkryja.SystemPath.."img/equipment/rh-handaxe.png"
   Valkryja.EquipmentIcons["rh_longsword"]   = Valkryja.SystemPath.."img/equipment/rh-longsword.png"
   Valkryja.EquipmentIcons["rh_morningstar"] = Valkryja.SystemPath.."img/equipment/rh-morningstar.png"
   Valkryja.EquipmentIcons["rh_sabre"]       = Valkryja.SystemPath.."img/equipment/rh-sabre.png"
   Valkryja.EquipmentIcons["rh_shortsword"]  = Valkryja.SystemPath.."img/equipment/rh-shortsword.png"
   Valkryja.EquipmentIcons["rh_spear"]       = Valkryja.SystemPath.."img/equipment/rh-spear.png"
   Valkryja.EquipmentIcons["rh_warhammer"]   = Valkryja.SystemPath.."img/equipment/rh-warhammer.png"

   Valkryja.EquipmentIcons["rh_banded"]  = Valkryja.SystemPath.."img/equipment/rh-cavalry.png"
   Valkryja.EquipmentIcons["rh_buckler"] = Valkryja.SystemPath.."img/equipment/rh-buckler.png"
   Valkryja.EquipmentIcons["rh_shield"]  = Valkryja.SystemPath.."img/equipment/rh-shield.png"

   Valkryja.EquipmentIcons["blank"] = Valkryja.SystemPath.."img/equipment/blank.png"
end
if (Valkryja.EquipmentIcons==nil) then
   Valkryja.EquipmentIcons={};
   Valkryja.LoadEquipmentIcons()
end

-- END OF SCRIPT
275
-- ============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
276 277 278 279 280 281
			<eventHandlerList />
		</Script>
		<Script isActive="yes" isFolder="no">
			<name>Valkryja.Timings</name>
			<packageName></packageName>
			<script>-- Scripts-Valkryja-Timing
282
-- =============================================================================
283 284
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
285 286
-- This system is distributed under specific licensing terms specified in
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
287
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
288
--
289
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
290
--
291
-- Valkryja.Timings
292 293 294
--    Functions related to system timings
--
-- @package     Scripts
295
-- @category    Valkryja
296
-- @subcategory Timing
297
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
298
-- @copyright   2006-2020 Maiyannah Bishop
299
-- @link        valkryja.com
300
-- =============================================================================
301 302

-- ----------------------------------------------------------------------------
303
-- Function: Valkryja.DetermineStepTiming
304
-- For convinence in series of actions with steps, this function returns a
305 306 307 308 309 310 311
-- timing offset for a timer based on the step you're on and the currently-
-- reported lag.  It will cap it at no longer than $cap if provided, or no more
-- than 5s if not.
--
-- Todo: ensure a step 2 timing doesn't undercut a step 1 timing, etc
-- If these are called all at the same time we won't have this problem but in the
-- heat of combat they may not be.
312
function Valkryja.DetermineStepTiming(step, cap)
313 314 315 316 317 318 319
   -- Set defaults
   cap  = cap or 5.0
   step = step or 1

   -- Get latency, cap the value if its too high
   local lag    = getNetworkLatency()
   if (lag&gt;cap) then lag = cap end
320

321 322 323
   -- Each step is .05s + lag
   local timing = (step*0.05)
   timing = timing + lag
324
   Valkryja.Debug("timing="..tostring(timing).." cap="..tostring(cap), false)
325 326 327 328 329 330 331 332 333

   -- Garbage collection
   cap  = nil
   step = nil

   -- Return timing
   return timing
end

334 335
-- END OF SCRIPT
-- ============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
336 337 338 339 340 341
			<eventHandlerList />
		</Script>
		<Script isActive="yes" isFolder="no">
			<name>Valkryja.Discord</name>
			<packageName></packageName>
			<script>-- =============================================================================
342 343
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
344
-- This system is distributed under specific licensing terms specified in
345 346
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
347
--
348
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
349 350
--
-- Discord
351
--    Discord rich presence for Valkryja
352 353
--
-- @package     Scripts
354
-- @category    Valkryja
355
-- @subcategory Discord
356
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
357
-- @copyright   2006-2020 Maiyannah Bishop
358
-- @link        valkryja.com
359 360
-- =============================================================================

361 362
Valkryja.Discord = Valkryja.Discord or {};
Valkryja.Discord.ApplicationID     = "501101864067268619"
363
Valkryja.Discord.ApplicationIconID = "valk-logo-huge"
364 365

-- ----------------------------------------------------------------------------
366
-- Function: Valkryja.Discord.Initialize()
367
-- Set up the rich presence display in Discord
368
function Valkryja.Discord.Initialize()
369
   -- Core Valk settings
370 371
   setDiscordApplicationID(Valkryja.Discord.ApplicationID)
   setDiscordLargeIcon(Valkryja.Discord.ApplicationIconID)
372 373 374 375 376

   -- State (default to 'idle')
   setDiscordState("idle")

   -- Configurables
377
   Valkryja.Discord.UpdateDetail()
378 379 380 381 382 383 384

   -- Party
end

-- ============================================================================
-- HELPER FUNCTIONS
-- ----------------------------------------------------------------------------
385
-- Function: Valkryja.Discord.UpdateDetail
386
-- Update the player name and current game display in detail field.
387
function Valkryja.Discord.UpdateDetail()
388 389 390
   if (not Character) then return end
   if (Character.Vitals.Name) then
      if (Config.ShowNameInDiscord==true) then
391
         setDiscordDetail(Valkryja.getCurrentGame() ..": "..Character.Vitals.Name)
392
      else
393
         setDiscordDetail(Valkryja.getCurrentGame())
394 395 396 397
      end
   end
end

398 399
function Valkryja.getCurrentGame()
   if (Valkryja.isImperian()) then
400
      return "Imperian"
401
   elseif (Valkryja.isAetolia()) then
402
      return "Aetolia"
403
   elseif (Valkryja.isLuminari()) then
404
      return "Luminari"
405
   elseif (Valkryja.isMateriaMagica()) then
406 407 408 409 410 411
      return "Materia Magica"
   end
end

-- END OF SCRIPT
-- ============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
412 413 414 415 416 417
			<eventHandlerList />
		</Script>
		<Script isActive="yes" isFolder="no">
			<name>Valkryja.Room</name>
			<packageName></packageName>
			<script>-- =============================================================================
418 419 420 421 422 423
-- VALKRYJA V4.0  |     IRE MUD SYSTEM FOR MUDLET 3.0      |  Imperian version
-- ----------------+----------------------------------------+-------------------
-- This system is distributed under specific licensing terms specified in
-- &amp;lt;readme.md&amp;gt;   You should have received a copy of this file with the system
-- and if you did not, you can receive a copy from &amp;lt;katorina@viantha.com&amp;gt;
--
424
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
425 426 427 428 429 430 431 432
--
-- scripts_room.xml
--    The various backend scripts that keep track of room contents, mobs, and
--    things like consecration, shrines, etc.
--
--
-- @package     Scripts
-- @category    Room
433 434
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
-- @copyright   2006-2020 Maiyannah Bishop
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
-- @link        valkryja.com
-- =============================================================================

Room = Room or {};
Room.Items    = Room.Items or {};
Room.Mobiles  = Room.Mobiles or {};
Room.Specials = Room.Specials or {};

-- -----------------------------------------------------------------------------
-- Function: NumMiscItems
-- Returns the number of items in the room that do not fall under another
-- category.
function Room.NumMiscItems()
   local other_objs = tonumber(Room.Items.Total)
   if (Room.Specials.Jeken==true) then
      other_objs = other_objs-1
   end
   if (Room.Specials.Rakaraska==true) then
      other_objs = other_objs-1
   end
   if (Room.Specials.Shrine~="none" and Room.Specials.Shrine~=nil) then
      other_objs = other_objs-1
   end
   if (Room.Specials.Idol~="none" and Room.Specials.Idol~=nil) then
      other_objs = other_objs-1
   end
   if (Room.Specials.Generator==true) then
      other_objs = other_objs-1
   end
464
--  other_objs = other_objs - tonumber(Room.Mobiles.NPCs)
465 466 467 468 469 470
   other_objs = other_objs - tonumber(Room.Mobiles.Guards)
   other_objs = other_objs - tonumber(Room.Mobiles.Horde)
   other_objs = other_objs - tonumber(Room.Mobiles.Undead)
   other_objs = other_objs - tonumber(Room.Mobiles.Mounts)
   other_objs = other_objs - tonumber(Room.Items.Charms)
   return other_objs
471 472
end

473 474 475 476 477 478 479 480 481 482 483
Room.Items.Charms = Room.Items.Charms or 0
Room.Items.Total  = Room.Items.Total or 0
Room.Mobiles.Guards = Room.Mobiles.Guards or 0
Room.Mobiles.Horde  = Room.Mobiles.Horde or 0
Room.Mobiles.Undead = Room.Mobiles.Undead or 0
Room.Mobiles.Mounts = Room.Mobiles.Mounts or 0
Room.Specials.Rakaraska = Room.Specials.Rakaraska or false
Room.Specials.Jeken     = Room.Specials.Jeken or false
Room.Specials.Generator = Room.Specials.Generator or false
Room.Specials.Shrine    = Room.Specials.Shrine or false
Room.Specials.Idol      = Room.Specials.Idol or false</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
484 485 486 487 488 489
			<eventHandlerList />
		</Script>
		<Script isActive="yes" isFolder="no">
			<name>Valkryja.Exceptions</name>
			<packageName></packageName>
			<script>-- =============================================================================
490 491 492 493 494 495
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
-- This system is distributed under specific licensing terms specified in
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
--
496
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
497
--
498
-- Valkryja.Exceptions
499 500 501 502 503 504 505
--    Functions to handle the reporting and logging of exceptions and debug
--    information.
--
-- @package     Valkryja
-- @category    Core
-- @subcategory Exception Handling
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
506
-- @copyright   2006-2020 Maiyannah Bishop
507 508 509 510 511 512
-- @link        valkryja.com
-- =============================================================================

-- TODO: have PHP-style error level suppression/filtering here

-- ----------------------------------------------------------------------------
513
-- Function: Valkryja.Exception
514
-- Prints a system error message.
515
function Valkryja.Exception(reason)
516 517 518 519 520 521
   cecho("&lt;dark_orange&gt;(&lt;red&gt;Valkryja Exception&lt;dark_orange&gt;): &lt;reset&gt;" ..tostring(reason).. "&lt;reset&gt;\n")
end

-- ----------------------------------------------------------------------------
-- Function: Debug
-- Prints a system debug message.
522
function Valkryja.Debug(line, enabled)
523 524 525 526 527 528
   if (enabled==false) then
      return
   end
   cecho("&lt;MidnightBlue&gt;(&lt;RoyalBlue&gt;Valkryja Debug&lt;MidnightBlue&gt;): &lt;reset&gt;" ..tostring(line).. "&lt;reset&gt;\n")
end

529
function Valkryja.SystemMessage(line)
530 531 532 533 534
   cecho("&lt;BlueViolet&gt;(&lt;CornflowerBlue&gt;Valkryja&lt;BlueViolet&gt;): &lt;reset&gt;" ..tostring(line).. "&lt;reset&gt;\n")
end

-- END OF FILE
-- ============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
535 536 537 538 539 540
			<eventHandlerList />
		</Script>
		<ScriptGroup isActive="yes" isFolder="yes">
			<name>Character</name>
			<packageName></packageName>
			<script>-------------------------------------------------
541 542 543 544 545
--         Put your Lua functions here.        --
--                                             --
-- Note that you can also use external scripts --
-------------------------------------------------
</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
546 547 548 549 550
			<eventHandlerList />
			<Script isActive="yes" isFolder="no">
				<name>Valkryja.Character</name>
				<packageName></packageName>
				<script>-- =============================================================================
551 552 553 554 555 556
-- VALKRYJA V1.0   |          MULTI-MUD UI AND SYSTEM FOR MUDLET 3.21.0
-- ----------------+------------------------------------------------------------
-- This system is distributed under specific licensing terms specified in
-- &lt;readme.md&gt;   You should have received a copy of this file with the system
-- and if you did not, you can receive a copy from &lt;maiyannah@valkryja.com&gt;
--
557
-- VALKYRJA MUD SYSTEM is (c) 2006-2020 Maiyannah Bishop
558 559 560 561 562 563 564
--
-- Statuses
--    Backend functions to manage status effects
--
-- @package     Scripts
-- @category    Valkryja
-- @author      Maiyannah Bishop &lt;maiyannah@valkryja.com&gt;
565
-- @copyright   2006-2020 Maiyannah Bishop
566 567 568 569
-- @link        valkryja.com
-- =============================================================================

Character = Character or {};
570 571 572 573 574 575
Character.Afflictions = Character.Affilictions or {};
Character.Defences    = Character.Defences or {};
Character.Attributes  = Character.Attributes or {};
Character.Vitals      = Character.Vitals or {};
Character.Currencies  = Character.Currencies or {};
Character.Extras      = Character.Extras or {};
576 577 578 579 580 581 582 583 584 585

-- -----------------------------------------------------------------------------
-- Function: Character.hasDefence
-- Returns boolean true if the character has a given defence, boolean false if
-- it does not.
function Character.hasDefence(def)
   -- explicit typecast
   def = tostring(def)

   -- debug information
586
   Valkryja.Debug("Looking up def: " ..def, false)
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642

   -- Look up the value of that defence key
   local hasDef = Character.Defences[def] or nil

   -- If it's the number of claimed defs value, bail
   if (def=="Claimed") then
      return false
   end

   -- Otherwise return boolean true/false as appropriate
   if (hasDef==true) then
      return true
   elseif (hasDef==false) then
      return false
   elseif (tonumber(hasDef)~=nil) then
      if (tonumber(hasDef)&gt;0) then
         return true
      else
         return false
      end
   else
      return false
   end

   -- If we've gotten this far and not had a return value, default to false
   return false
end

-- -----------------------------------------------------------------------------
-- Function: Character.getStatusName
-- Returns the pretty name for a given def key
function Character.getStatusName(def)
   -- explicit typecast
   def = tostring(def)

   -- local vars for the iterators
   local n=0

   -- Iterate over the values in the Character.Defences table to find the given
   -- def
   for key,value in pairs(Valkryja.StatusNames) do
      n=n+1
      if (tostring(key)==def) then
         return value
      end
   end

   -- If we've made it this far we just don't have a key for that def, so we
   -- obviously don't have it.  In that case, just use lowercase key name
   n = nil
   return def
end

-- -----------------------------------------------------------------------------
-- Function: Character.GainStatus
-- Modular function to record gaining a status effect.
643
function Character.GainStatus(defence, isNegative, matchingString)
644
   -- Default to the status being non-negative
645
   isNegative = isNegative or false
646 647 648 649 650 651 652 653 654 655 656

   -- A negative status goes in Character.Afflictions
   -- A positive status goes in Character.Defences
   if (isNegative==true) then
      defOld = Character.Afflictions[defence]
   else
      defOld = Character.Defences[defence]
   end

   -- Get the pretty name of the defence
   local defName = Character.getStatusName(defence) or tostring(defence)
657 658 659 660
   matchingString = matchingString or "&lt;red&gt;(Matching string not specified in Character.GainStatus()) &lt;reset&gt;"

   -- Add our line decorations
   deleteLine()
Maiyannah Bishop's avatar
Maiyannah Bishop committed
661
   Character.StatusMessage(matchingString, defName, not isNegative)
662
   Valkryja.Debug("In Character.GainStatus: defence="..tostring(defence).." defName="..tostring(defName).. " \nCharacter.Defences[defence]="..tostring(Character.Defences[defence]).."\n",false)   
663 664 665 666 667 668

   -- Set our def
   if (isNegative==true) then
      Character.Afflictions[defence] = true
   else
      Character.Defences[defence]    = true
669
   end 
670
    
671
   def, defName, def_name, defOld = nil, nil, nil, nil
672
   matchingString = nil
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700
end


-- -----------------------------------------------------------------------------
-- Function: Character.Defences.Lose
-- Modular function to record lose a defence.
function Character.LoseStatus(defence, isNegative, matchingString)
   isNegative = isNegative or false
   Character.Defences    = Character.Defences or {};
   Character.Afflictions = Character.Afflictions or {};

   -- Use Character.Defences for positive statuses, Character.Afflictions for
   -- negative statuses
   if (isNegative==true) then
      defOld = Character.Afflictions[defence]
   else
      defOld = Character.Defences[defence], Character.getStatusName(defence)
   end

    matchingString = matchingString or "&lt;red&gt;(Matching string not specified in Character.GainStatus()) &lt;reset&gt;"

    -- Get the pretty name of the defence
   defName = Character.getStatusName(defence) or tostring(defence)

   deleteLine()

   -- Add our line decorations
   Character.StatusMessage(matchingString, defName, isNegative)
701
   Valkryja.Debug("In Defences.Lose: defence="..tostring(defence).." defName="..tostring(defName).. " \nCharacter.Defences[defence]="..tostring(Character.Defences[defence]).."\n",false)
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720

   -- Set our def
    if (isNegative==true) then
      Character.Afflictions[defence] = false
    else
      Character.Defences[defence]    = false
   end

   -- Update icons
   Kauna.StatusIcons.Populate()

   -- Unalloc
   defOld  = nil
   defName = nil
   matchingString = nil
end

-- END OF SCRIPT
-- =============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
721 722 723 724 725 726
				<eventHandlerList />
			</Script>
			<Script isActive="yes" isFolder="no">
				<name>Valkryja.gainAffliction</name>
				<packageName></packageName>
				<script>-- =============================================================================
727
-- Function: Valkryja.gainAffliction()
728 729 730 731
-- Event for if a character has received a negative status
--   o alias   = table alias of the affliction in the status table
--   o caller  = the string that matched
--   o squelch = whether or not to gag the display of the status gain
732
function Valkryja.gainAffliction(alias, caller, squelch)
733
   Character.GainStatus(alias, true)
734 735 736 737
end

-- END OF SCRIPT
-- =============================================================================</script>
Maiyannah Bishop's avatar
Maiyannah Bishop committed
738 739 740 741 742 743 744 745 746 747
				<eventHandlerList>
					<string>gainAffliction</string>
				</eventHandlerList>
			</Script>
		</ScriptGroup>
	</ScriptPackage>
	<KeyPackage />
	<HelpPackage>
		<helpURL></helpURL>
	</HelpPackage>
748
</MudletPackage>