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

Help with equipping items on some wrong slots

tretaa

New Member
Joined
Dec 26, 2012
Messages
13
Reaction score
0
Hello Guys..

I have a problem here and I really wanted to solve the problem without change my sources..
The problem is that I can equipe some items wherever I want. A shield can be equipped in the weapon slot, for example...Also a bow can be equipped at the ammo slot.
That's really bad...can anyone help me?

Here is my movements.xml with Snake God's Wristguard's id....

PHP:
	<movevent type="Equip" itemid="12647" slot="shield" level="100" event="function" value="onEquipItem">
		<vocation id="1"/>
		<vocation id="5" showInDescription="0"/>
		<vocation id="2"/>
		<vocation id="6" showInDescription="0"/>
	</movevent>
	<movevent type="DeEquip" itemid="12647" slot="shield" event="function" value="onDeEquipItem"/>

Is there a way to solve this?
Also does anyone know where can I found stables sources for 9.80 or 9.80+?

Thanks for reading the topic...

Regards.
 
then define it, slot="left-hand" slot="right-hand" set those values for all the itmes for whatever hand you would like
 
PHP:
<movevent type="Equip" itemid="8902" slot="right-hand" level="50" event="function" value="onEquipItem">
		<vocation id="1"/>
		<vocation id="5" showInDescription="0"/>
		<vocation id="2"/>
		<vocation id="6" showInDescription="0"/>
	</movevent>

you mean like this? doesn't work

- - - Updated - - -

BUMP

Anyone please??
 
Last edited:
With using right-hand the attributes would only have effect when the shield is in the right hand, you are still able to put your shield in your left hand same as other items, but it just don't have effect then.
 
Yeah the only other way to to it exactly as you want it is through complicated lua script for each item or source edits, this way I gave you is exactly as limos said
 
Hum....So instead of using something like this:

PHP:
<movevent type="Equip" itemid="8902" slot="right-hand" level="50" event="function" value="onEquipItem">
        <vocation id="1"/>
        <vocation id="5" showInDescription="0"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="0"/>
    </movevent>

Shall I use this?

PHP:
<movevent type="Equip" itemid="8902" slot="shield" level="50" event="function" value="onEquipeShield.lua">
        <vocation id="1"/>
        <vocation id="5" showInDescription="0"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="0"/>
    </movevent>

That's right?
 
Didn't tested but should work...

LUA:
function onEquip(cid, item, slot)
	 if slot == 5 then --right hand, change to your wanted slot id
		return true
	 end
end
 
Hum I was checking in the movement.cpp from my sources and I fount this method:

PHP:
bool MoveEvent::EquipItem(MoveEvent* moveEvent, Player* player, Item* item, slots_t slot, bool isCheck)
{
	if(player->isItemAbilityEnabled(slot))
		return true;

	if(!player->hasFlag(PlayerFlag_IgnoreEquipCheck) && moveEvent->getWieldInfo() != 0)
	{
		if(player->getLevel() < (uint32_t)moveEvent->getReqLevel() || player->getMagicLevel() < (uint32_t)moveEvent->getReqMagLv())
			return false;

		if(moveEvent->isPremium() && !player->isPremium())
			return false;

		if(!moveEvent->getVocEquipMap().empty() && moveEvent->getVocEquipMap().find(player->getVocationId()) == moveEvent->getVocEquipMap().end())
			return false;
	}

	if(isCheck)
		return true;

	const ItemType& it = Item::items[item->getID()];
	if(it.transformEquipTo)
	{
		Item* newItem = g_game.transformItem(item, it.transformEquipTo);
		g_game.startDecay(newItem);
	}

	player->setItemAbility(slot, true);
	if(!it.hasAbilities())
		return true;

	if(it.abilities->invisible)
	{
		Condition* condition = Condition::createCondition((ConditionId_t)slot, CONDITION_INVISIBLE, -1, 0);
		player->addCondition(condition);
	}

	if(it.abilities->manaShield)
	{
		Condition* condition = Condition::createCondition((ConditionId_t)slot, CONDITION_MANASHIELD, -1, 0);
		player->addCondition(condition);
	}

	if(it.abilities->speed)
		g_game.changeSpeed(player, it.abilities->speed);

	if(it.abilities->conditionSuppressions)
	{
		player->setConditionSuppressions(it.abilities->conditionSuppressions, false);
		player->sendIcons();
	}

	if(it.abilities->regeneration)
	{
		Condition* condition = Condition::createCondition((ConditionId_t)slot, CONDITION_REGENERATION, -1, 0);
		if(it.abilities->healthGain)
			condition->setParam(CONDITIONPARAM_HEALTHGAIN, it.abilities->healthGain);

		if(it.abilities->healthTicks)
			condition->setParam(CONDITIONPARAM_HEALTHTICKS, it.abilities->healthTicks);

		if(it.abilities->manaGain)
			condition->setParam(CONDITIONPARAM_MANAGAIN, it.abilities->manaGain);

		if(it.abilities->manaTicks)
			condition->setParam(CONDITIONPARAM_MANATICKS, it.abilities->manaTicks);

		player->addCondition(condition);
	}

	bool needUpdateSkills = false;
	for(uint32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
	{
		if(it.abilities->skills[i])
		{
			player->setVarSkill((skills_t)i, it.abilities->skills[i]);
			if(!needUpdateSkills)
				needUpdateSkills = true;
		}

		if(it.abilities->skillsPercent[i])
		{
			player->setVarSkill((skills_t)i, (int32_t)(player->getSkill((skills_t)i, SKILL_LEVEL) * ((it.abilities->skillsPercent[i] - 100) / 100.f)));
			if(!needUpdateSkills)
				needUpdateSkills = true;
		}
	}

	if(needUpdateSkills)
		player->sendSkills();

	bool needUpdateStats = false;
	for(uint32_t s = STAT_FIRST; s <= STAT_LAST; ++s)
	{
		if(it.abilities->stats[s])
		{
			player->setVarStats((stats_t)s, it.abilities->stats[s]);
			if(!needUpdateStats)
				needUpdateStats = true;
		}

		if(it.abilities->statsPercent[s])
		{
			player->setVarStats((stats_t)s, (int32_t)(player->getDefaultStats((stats_t)s) * ((it.abilities->statsPercent[s] - 100) / 100.f)));
			if(!needUpdateStats)
				needUpdateStats = true;
		}
	}

	if(needUpdateStats)
		player->sendStats();

	return true;
}


I think we can fix from that...do you guys have any ideas how to?

Also I tried this script and didn't work:

PHP:
function onEquip(cid, item, slot)
	 if slot == 5 then --right hand, change to your wanted slot id
		return true
	 end
end

It's almost good, because I cant equip at weapon slot or others but I can only at SHIELD slot and AMMO slot. But even equipping at shield slot, it doesnt add its attributes (ML +3).

:(
 
Last edited:
are you sure you have it in your movements.xml correctly tretaa?

make sure that it is set as
XML:
    <movevent type="Equip" itemid="8902" slot="shield" level="50" event="script" value="onEquipShield.lua">
        <vocation id="1"/>
        <vocation id="5" showInDescription="0"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="0"/>
    </movevent>
using
Code:
event="function"
wont work when using a script it must be
Code:
event="script"
 
are you sure you have it in your movements.xml correctly tretaa?

make sure that it is set as
XML:
    <movevent type="Equip" itemid="8902" slot="shield" level="50" event="script" value="onEquipShield.lua">
        <vocation id="1"/>
        <vocation id="5" showInDescription="0"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="0"/>
    </movevent>
using
Code:
event="function"
wont work when using a script it must be
Code:
event="script"

yes, That's right..
I was testing at another item...

Here is it:

PHP:
<movevent type="Equip" itemid="12647" slot="shield" level="100" event="script" value="onEquipShield.lua">
		<vocation id="1"/>
		<vocation id="5" showInDescription="0"/>
		<vocation id="2"/>
		<vocation id="6" showInDescription="0"/>
	</movevent>

:(

I was thinking: Is it possible to call the same function at onEquipShield.lua that used to be called on onEquipItem?
PHP:
function onEquip(cid, item, slot)
	 if slot == 5 then --right hand, change to your wanted slot id
                onEquipItem() --something like this...works?
		return true
	 end
end


possible?
 
Last edited:
LUA:
callFunction(cid, item.uid, slot, false)

Sadly I don't know how to manage the ammo slot, is just not working if I check for the Slot ID :S

What function exactly should be called?

I tryed this on my onEquipShield.lua:

PHP:
onEquipItem(cid, item.uid, slot, false);

And when I tryed to equip shield gives me an error:

data/movements/scripts/onEquipShield.lua:onEquip
Description:
data/movements/scripts/onEquipShield.lua:3: attempt to call global 'onEquipItem' (a nil value)
stack traceback:
data/movements/scripts/onEquipShield.lua:3: in function <data/movements/scripts/onEquipShield.lua:1>
 
What function exactly should be called?

I tryed this on my onEquipShield.lua:

PHP:
onEquipItem(cid, item.uid, slot, false);

And when I tryed to equip shield gives me an error:

data/movements/scripts/onEquipShield.lua:onEquip
Description:
data/movements/scripts/onEquipShield.lua:3: attempt to call global 'onEquipItem' (a nil value)
stack traceback:
data/movements/scripts/onEquipShield.lua:3: in function <data/movements/scripts/onEquipShield.lua:1>

Just copy and paste it :P
 
Back
Top