• 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
 
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_RIGHT).itemid == 13524 then
		item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT).uid
	elseif getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 13524 then
		item = getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid
	end
doRemoveItem(item,item.type, 1)
return doCombat(cid, combat, var)
end

You aren't familiar with coding I assume.
How is the function doRemoveItem suppose to remove "item" that isn't handled by the onUseWeapon function?

function onUseWeapon(cid, var), Cid and var.. that's the ONLY thing you can use here. you can use item.uid and similar if the function would have this (cid, item, var) but now the spell functions doesn't have the "item".
So that will never work.
To do so you need to change the C++ code to deliver the "item" into the function.

doPlayerRemoveItem and using an id and count/charge of item works, but then it doesn't remove the used weapon, it use the first one located on your character,
for example if you have this weapon in your hand and in your bp, and you use the one that's in the bp, then the one in the hand will disappear first.
It's not that big of a deal, but if you're serious and don't want bug-looking features you should arrange that it's the item you're using that's supposed to become "used".
 
sound like you are the one who isn't familiar with lua :P
what do you think getPlayerSlotItem(cid, CONST_SLOT_RIGHT) for?
 
with the getPlayerSlotItem not working .. same error

Bump. I don't have any idea for that.
 
Last edited by a moderator:
I got that code:
XML:
bool WeaponDistance::getSkillType(const Player* player, const Item* item,
	skills_t& skill, uint32_t& skillpoint) const
{
	skill = SKILL_DIST;
	skillpoint = 0;

	if(player->getAddAttackSkill())
	{
		switch(player->getLastAttackBlockType())
		{
			case BLOCK_NONE:
				skillpoint = 2;
				break;

			case BLOCK_ARMOR:
				skillpoint = 1;
				break;

			case BLOCK_DEFENSE:
			default:
				skillpoint = 0;
				break;
		}
	}
	return true;
}

Maybe in that part i must hack the sword to gain skill == sword while i set in weapons.xml type - distance ?
 

Similar threads

Back
Top