• 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!

[Weapon] Hit or block?

trollebror

Developer
Joined
Aug 8, 2009
Messages
362
Reaction score
58
Location
Sweden, Linköping
Is it possible to check if the attack is blocked or not inside a weapon-script? Check the code below for a more illustrative explanation.

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)

function onUseWeapon(cid, var)
	local ret = doCombat(cid, combat, var)

	if([COLOR="#FF0000"]ret == BLOCK[/COLOR]) then
		[B]doThis()[/B]
	else
		[B]doThat()[/B]
	end
end
 
Hi trollebror,
Sorry but onUseWeapon runs before the weapon damage is done so the player has not blocked yet.
Also onStatsChange (Creaturescript) is also run before Defense rolls are calculated (which determines if you block or not).

Personally I don't know of any way to do this in LUA. You could always change the way Armor and Defense work on your server, and use onStatsChange to calculate all damage, but that is a lot of work.
 
Back
Top