Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
require("battle.Unit")
|
|
|
|
|
|
|
|
local ReceiverBase = require("core:erm.ReceiverBase")
|
|
|
|
|
|
|
|
local BU = ReceiverBase:new()
|
|
|
|
|
|
|
|
function BU:new(ERM)
|
|
|
|
return ReceiverBase.new(self,{ERM = ERM})
|
|
|
|
end
|
|
|
|
|
|
|
|
local BattleLogMessage = require("netpacks.BattleLogMessage")
|
|
|
|
local BattleUnitsChanged = require("netpacks.BattleUnitsChanged")
|
|
|
|
|
|
|
|
local battle = BATTLE
|
|
|
|
|
|
|
|
function BU:C(x, p1)
|
|
|
|
assert(type(p1) == "nil", "!!BU:C can only check value")
|
|
|
|
|
|
|
|
local ret = battle:isFinished()
|
|
|
|
|
|
|
|
if type(ret) == "nil" then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:D(x, hex, p1)
|
|
|
|
assert(type(p1) == "nil", "!!BU:D can only check value")
|
|
|
|
|
|
|
|
local unit = battle:getUnitByPos(hex, false)
|
|
|
|
|
|
|
|
if unit then
|
|
|
|
if unit:isAlive() then
|
|
|
|
return nil, -2
|
|
|
|
else
|
|
|
|
return nil, unit:unitId()
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return nil, -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:E(x, hex, p1)
|
|
|
|
assert(type(p1) == "nil", "!!BU:E can only check value")
|
|
|
|
|
|
|
|
local unit = battle:getUnitByPos(hex, false)
|
|
|
|
|
|
|
|
if unit and unit:isAlive() then
|
|
|
|
return nil, unit:unitId()
|
|
|
|
else
|
|
|
|
return nil, -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local SPECIAL_FIELDS = {}
|
|
|
|
|
2022-06-28 10:05:30 +02:00
|
|
|
SPECIAL_FIELDS['sand_shore'] = 0
|
|
|
|
SPECIAL_FIELDS['cursed_ground'] = 1
|
|
|
|
SPECIAL_FIELDS['magic_plains'] = 2
|
|
|
|
SPECIAL_FIELDS['holy_ground'] = 3
|
|
|
|
SPECIAL_FIELDS['evil_fog'] = 4
|
|
|
|
SPECIAL_FIELDS['clover_field'] = 5
|
|
|
|
SPECIAL_FIELDS['lucid_pools'] = 6
|
|
|
|
SPECIAL_FIELDS['fiery_fields'] = 7
|
|
|
|
SPECIAL_FIELDS['rocklands'] = 8
|
|
|
|
SPECIAL_FIELDS['magic_clouds'] = 9
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
function BU:G(x, p1)
|
|
|
|
assert(type(p1) == "nil", "!!BU:G? is not implemented")
|
|
|
|
|
|
|
|
local bfield = SPECIAL_FIELDS[battle:getBattlefieldType()]
|
|
|
|
|
|
|
|
if bfield then
|
|
|
|
return bfield
|
|
|
|
else
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:M(x, message)
|
|
|
|
local pack = BattleLogMessage.new()
|
|
|
|
pack:addText(message)
|
|
|
|
SERVER:addToBattleLog(pack)
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:O(x, ...)
|
|
|
|
error("!!BU:O is not implemented")
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:R(x, ...)
|
|
|
|
error("!!BU:R is not implemented")
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:S(x, typ, count, hex, side, slot)
|
|
|
|
local pack = BattleUnitsChanged.new()
|
|
|
|
|
|
|
|
local id = battle:getNextUnitId()
|
|
|
|
|
|
|
|
pack:add(id,
|
|
|
|
{
|
|
|
|
newUnitInfo =
|
|
|
|
{
|
|
|
|
["count"] = count,
|
|
|
|
["type"] = typ,
|
|
|
|
["side"] = side,
|
|
|
|
["position"] = hex,
|
|
|
|
["summoned"] = (slot == -1),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
SERVER:changeUnits(pack)
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:T(x)
|
|
|
|
local tacticDistance = battle:getTacticDistance()
|
|
|
|
|
|
|
|
if tacticDistance == 0 then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function BU:V(x, ...)
|
|
|
|
error("!!BU:V is not implemented")
|
|
|
|
end
|
|
|
|
|
|
|
|
return BU
|