• 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 Problem with enchanted weapons

breispodeu

Mapper/Scripter/C++ Programmer
Joined
Jul 25, 2009
Messages
75
Reaction score
2
I do not know where is the place to post this, then I will post here.

In my server, enchanted weapons works perfectly on normal monsters but when some player try to attack some ghost monster simply gives no hit, as if the monster was immune...

some1 know what is happening? Thanks...
 
Yes, have magic damage. With normal monsters the weapon hit the elemental damage. And I can kill ghosts with exori frigo, etc. It's impossible they are immune to it.

My monster:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Ghost" nameDescription="a ghost" race="undead" experience="120" speed="160" manacost="100">
	<health now="150" max="150"/>
	<look type="48" corpse="5993"/>
	<targetchange interval="5000" chance="8"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="1"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="90"/>
		<flag runonhealth="0"/>
	</flags>
	<attacks>
		<attack name="melee" interval="2000" skill="45" attack="28"/>
		<attack name="lifedrain" interval="1000" chance="15" range="1" min="-25" max="-45"/>
	</attacks>
	<defenses armor="10" defense="10"/>
	<elements>
		<element physicalPercent="100"/>
		<element earthPercent="100"/>
		<element deathPercent="100"/>
	</elements>
	<immunities>
		<immunity lifedrain="1"/>
		<immunity paralyze="1"/>
	</immunities>
	<voices interval="5000" chance="10">
		<voice sentence="Huh!"/>
		<voice sentence="Shhhhhh"/>
		<voice sentence="Buuuuuh"/>
	</voices>
	<loot>
		<item id="2148" countmax="15" chance="100000"/><!-- gold coin -->
		<item id="2642" chance="10000"/><!-- sandals -->
		<item id="2404" chance="10000"/><!-- combat knife -->
		<item id="10607" countmax="1" chance="1980"/><!-- ghostly tissue -->
		<item id="5909" countmax="1" chance="10000"/><!-- white piece of cloth -->
		<item id="2394" chance="6666"/><!-- morning star -->
		<item id="2804" countmax="2" chance="20000"/><!-- shadow herb -->
		<item id="2532" chance="1666"/><!-- ancient shield -->
		<item id="2182" chance="1333"/><!-- snakebite rod -->
		<item id="2165" chance="1538"/><!-- stealth ring -->
		<item id="2423" chance="10000"/><!-- clerical mace -->
		<item id="1962" chance="5000"/><!-- book -->
	</loot>
</monster>
 
Code:
<element physicalPercent="100"/>
elemental damage is a % of physical. Ghosts got immunity 100% against physical damages, then, no elemental hit.
 
hum, i think that if you want the ghosts to recive that element damage then you can remove his physical damage inmmunity, then make a creature scrip for ghosts OnStatsChange and if they recive health loss due to a physical damage to be healed the same amount that he recived damage? idk this is something i thou out of 3 secs, can work and maybe if you get more creative you can make it work 100% as you want.
 
That is a terrible way to do it (above).
Just off the top of my head I would use something like this:

Go to your weapons folder, and in the scripts folder make a melee.lua.

(you'll need one script for each element if you do it this way)
In this meleeIce.lua use something like this:

Lua:
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, 1, 0, 1, 0)

local combatelement = createCombatObject()
setCombatParam(combatelement , COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, element, factor)
	-- elemental damage
	local attackelement = attack + element
	local elementp = element/attackelement
	
	local min = ((level/10+skill/20)*(attack/5))*elementp -- minimum element damage example
	local max =((level/10+skill/20)*(attack/4))*elementp -- maximum element damage example
	local max = max/factor -- changes damage depending on stance
	if min > max then min = max end -- Makes sure minimum damage is not higher than maximum damage

	return -min, -max
end

setCombatCallback(combatelement, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
	doCombat(cid, combatelement, var)
	return doCombat(cid, combat, var)
end

(This is not a perfect way of doing it, but I am just showing that it CAN be done)
 
Back
Top