• 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 Distance sword ?

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello.
I made an distance sword in items.xml:
XML:
	<item id="13524" article="an" name="distance training sword" plural="distance training swords">
		<attribute key="weight" value="250"/>
		<attribute key="weaponType" value="sword" />
		<attribute key="slotType" value="two-handed" />
		<attribute key="attack" value="100" />
		<attribute key="range" value="4" />
		<attribute key="description" value="That sword you can throw from distance"/>
		<attribute key="maxHitChance" value="95" />
		<attribute key="ammoAction" value="removecount" />
	</item>

And script in weapons:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

Animation, removecount working good but when i attacking with this sword from distance i have problem:
This adding me skill == Distance Fighting not Sword Fighting.

Anyone can fix it ? (To gain sword fighting while using it ?)

Please
 
When you put:
LUA:
 		<attribute key="range" value="4" />
It automatically sets to distance weapon, I think that is not possible without a good script or source edit

Edit: Post the tag your usig on weapons.xml too
 
XML:
<!-- Training distance sword -->
<distance id="13524" range="4" event="script" value="ds.lua">
		<vocation id="74" showInDescription="1"/>
		<vocation id="75" showInDescription="0"/>
		<vocation id="76" showInDescription="0"/>
		<vocation id="77" showInDescription="0"/>
		<vocation id="78" showInDescription="0"/>
		<vocation id="79" showInDescription="0"/>
</distance>

Here is the tag from weapon.xml
 
remove this
Code:
		<attribute key="maxHitChance" value="95" />
		<attribute key="ammoAction" value="removecount" />
and add this
Code:
		<attribute key="charges" value="500"/>
		<attribute key="showcharges" value="1"/>
 
Change it in weapons.xml to
XML:
<!-- Training distance sword -->
<melee id="13524" range="4" event="script" value="ds.lua">
		<vocation id="74" showInDescription="1"/>
		<vocation id="75" showInDescription="0"/>
		<vocation id="76" showInDescription="0"/>
		<vocation id="77" showInDescription="0"/>
		<vocation id="78" showInDescription="0"/>
		<vocation id="79" showInDescription="0"/>
</melee>
And please add me some reputation if you don't mind if it works.
 
The part of melee working but the remove part not working good.
Now i cant stack swords if i put charges... and if i have ~2 swords it removes twice not one
 
weapons are stackable now? xD
anyway try doRemoveItem(item.type, 1)
or doChangeTypeItem(item.uid, item.type-1)
 
I tried:
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_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
doRemoveItem(item.type, 1)
return doCombat(cid, combat, var)
end

But nothing happen and error appear
 
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_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
doRemoveItem(item.uid,item.type, 1)
return doCombat(cid, combat, var)
end
 
I think this might work..
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_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
if doPlayerRemoveItem(cid,13524,1) then
return doCombat(cid, combat, var)
end
end
 
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_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 21)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
	if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 13524 then
		doChangeTypeItem(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).type-1)
	elseif getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == 13524 then
		doChangeTypeItem(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid, getPlayerSlotItem(cid, CONST_SLOT_RIGHT).type-1)
	end
return doCombat(cid, combat, var)
end
 
Last edited:

Similar threads

Back
Top