COMBATS_INIT_OPERATIONS =
{
["damagetype"] = COMBAT_PARAM_TYPE;
["magiceffect"] = COMBAT_PARAM_EFFECT;
["distanceeffect"] = COMBAT_PARAM_DISTANCEEFFECT;
["aggressive"] = COMBAT_PARAM_AGGRESSIVE;
["dispel"] = COMBAT_PARAM_DISPEL;
["blockarmor"] = COMBAT_PARAM_BLOCKARMOR;
["blockshield"] = COMBAT_PARAM_BLOCKSHIELD;
["casterortop"] = COMBAT_PARAM_TARGETCASTERORTOPMOST;
["createitem"] = COMBAT_PARAM_CREATEITEM;
["useCharges"] = COMBAT_PARAM_USECHARGES;
["playerorsummons"] = COMBAT_PARAM_TARGETPLAYERSORSUMMONS;
["randomize"] = COMBAT_PARAM_DIFFERENTAREADAMAGE;
["hiteffect"] = COMBAT_PARAM_HITEFFECT;
["hitcolor"] = COMBAT_PARAM_HITCOLOR;
["elementtype"] = COMBAT_PARAM_ELEMENTTYPE;
["elementdamage"] = COMBAT_PARAM_ELEMENTDAMAGE;
["formulaskills"] = function(combat, value)
_G["dmgskills"..combat] = value
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "dmgskills"..combat)
end;
["formulamagic"] = function(combat, value)
_G["dmgmagic"..combat] = value
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "dmgmagic"..combat)
end;
["targettile"] = function(combat, value)
_G["targettile"..combat] = value
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "targettile"..combat)
end;
["targetcreature"] = function(combat, value)
_G["targetcreature"..combat] = value
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "ontargetcreature"..combat)
end;
["condition"] = function(combat, value)
setCombatCondition(combat, value)
end;
}
function Combat(options)
local c = createCombatObject()
--Prepare stuff
for id, v in pairs(options) do
local o = COMBATS_INIT_OPERATIONS[string.lower(id)]
if o then
if type(o) == "number" then
setCombatParam(c, o, v)
elseif type(o) == "function" then
o(c, v)
end
end
end
--Bind area:
if options.Area then
local ar = 0
if options.DiagonalArea then
ar = createCombatArea(options.Area, options.DiagonalArea)
else
ar = createCombatArea(options.Area)
end
setCombatArea(c, ar)
end
return c
end
CONDITION_INIT_OPERATIONS =
{
owner = CONDITION_PARAM_OWNER;
ticks = CONDITION_PARAM_TICKS;
outfit = CONDITION_PARAM_OUTFIT;
healthgain = CONDITION_PARAM_HEALTHGAIN;
healthticks = CONDITION_PARAM_HEALTHTICKS;
managain = CONDITION_PARAM_MANAGAIN;
manaticks = CONDITION_PARAM_MANATICKS;
delayed = CONDITION_PARAM_DELAYED;
speed = CONDITION_PARAM_SPEED;
lightlevel = CONDITION_PARAM_LIGHT_LEVEL;
lightcolor = CONDITION_PARAM_LIGHT_COLOR;
soulgain = CONDITION_PARAM_SOULGAIN;
soulticks = CONDITION_PARAM_SOULTICKS;
min = CONDITION_PARAM_MINVALUE;
max = CONDITION_PARAM_MAXVALUE;
start = CONDITION_PARAM_STARTVALUE;
interval = CONDITION_PARAM_TICKINTERVAL;
forceupdate = CONDITION_PARAM_FORCEUPDATE;
melee = CONDITION_PARAM_SKILL_MELEE;
fist = CONDITION_PARAM_SKILL_FIST;
club = CONDITION_PARAM_SKILL_CLUB;
sword = CONDITION_PARAM_SKILL_SWORD;
axe = CONDITION_PARAM_SKILL_AXE;
distance = CONDITION_PARAM_SKILL_DISTANCE;
shield = CONDITION_PARAM_SKILL_SHIELD;
fishing = CONDITION_PARAM_SKILL_FISHING;
maxhealth = CONDITION_PARAM_STAT_MAXHEALTH;
maxmana = CONDITION_PARAM_STAT_MAXMANA;
soul = CONDITION_PARAM_STAT_SOUL;
magic = CONDITION_PARAM_STAT_MAGICLEVEL;
maxhealthpercent= CONDITION_PARAM_STAT_MAXHEALTHPERCENT;
maxmanapercent = CONDITION_PARAM_STAT_MAXMANAPERCENT;
soulpercent = CONDITION_PARAM_STAT_SOULPERCENT;
magicpercent = CONDITION_PARAM_STAT_MAGICLEVELPERCENT;
meleepercent = CONDITION_PARAM_SKILL_MELEEPERCENT;
fistpercent = CONDITION_PARAM_SKILL_FISTPERCENT;
clubpercent = CONDITION_PARAM_SKILL_CLUBPERCENT;
swordpercent = CONDITION_PARAM_SKILL_SWORDPERCENT;
axepercent = CONDITION_PARAM_SKILL_AXEPERCENT;
distancepercent = CONDITION_PARAM_SKILL_DISTANCEPERCENT;
shieldpercent = CONDITION_PARAM_SKILL_SHIELDPERCENT;
fishingpercent = CONDITION_PARAM_SKILL_FISHINGPERCENT;
periodicdamage = CONDITION_PARAM_PERIODICDAMAGE;
buff = CONDITION_PARAM_BUFF;
subid = CONDITION_PARAM_SUBID;
field = CONDITION_PARAM_FIELD;
formula = function(c, v)
setConditionFormula(condition, v[1], v[2], v[3], v[4])
end;
}
function Condition(options)
local t = 0
for id, v in pairs(options) do
if string.lower(id) then
t = v
break
end
end
if t == 0 then return nil end
local c = createConditionObject(t)
for id, v in pairs(options) do
local o = CONDITION_INIT_OPERATIONS[string.lower(id)]
if o then
if type(o) == "number" then
setConditionParam(c, o, v)
elseif type(o) == "function" then
o(c, v)
end
end
if type(id) == "number" then
if v[1] == "Outfit" then
addOutfitCondition(c, v.item, v.type, v.head, v.body, v.legs, v.feet)
elseif v[1] == "Damage" then
addDamageCondition(c, v.rounds, v.interval, v.damage)
end
end
end
return c
end
function Outfit(options)
table.insert(options, 1, "Outfit")
return options
end
function Damage(options)
table.insert(options, 1, "Damage")
return options
end