• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua doCombat(cid, combat, VAR?)

andu

Sold 649 scripts, 25 maps and 9 events!
Joined
Aug 7, 2009
Messages
978
Solutions
17
Reaction score
375
GitHub
olrios
Twitch
jamagowy
doCombat(cid, combat, var) - what "var" means? And how to add "doCombat" into onUse function?

e.g. script:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 2)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 2.5, 0, 3.5, 0)

function onUse(cid, item, frompos, item2, topos)
	local var = ?????
	doCombat(cid, combat, var)
	return true
end
 
Var is like the target, on what the combat should effect.
So you can do for example
LUA:
doCombat(cid, combat, numberToVariant(item2.uid))
Or if it's for the person who is using the item
LUA:
doCombat(cid, combat, numberToVariant(cid))
 
I made a spell using this parameter, it helped me find the target's position and teleport me to him/her.

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ASSASSIN)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_NONE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
 
local function delayedTeleport(cid, position)
	if(not isCreature(cid)) then return true end
	doTeleportThing(cid, position)
	return true
end
 
function onCastSpell(cid, var)
	addEvent(delayedTeleport, 500, cid, getCreaturePosition(cid))
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	doTeleportThing(cid, getThingPos(variantToNumber(var)), true)
	return doCombat(cid, combat, var)
end

In here, I used var to get the position of the target player.
I converted the var into a number (which is some kind of player ID in the game), then used this in getThingPos() to get the position.

There's a lot of different ways you can use it.
 
Back
Top