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

Dual wield?

Thylonn

New Member
Joined
Dec 15, 2012
Messages
52
Reaction score
3
Im trying to set up a Dual wield vocation, being able to hold 2 axes or 2 swords without a shield.
If i do that will the character get damage for both the weapons? or will it just take 1 of the 2 items atk damage?

I am not very familiar with this, so please don't judge me ;)
 
I'm judging you.

No jk, i honestly can't help you. But i was looking to do something similar some time ago so i figured i would bump the post :p
 
Would require source edits.. tons.. along with interfering with combat and attack speed/attack, if it was a wand or a rod it might mess up.. Just tons of things wrong with that.
 
Not need of source edit... There is an items.xml attribute called "dualwield"... If you give that attribute to a weapon, ALL players can wear it in both hand at the same time and it attacks at x2 speed....

But you should do script to prevent all players and let some vocations...
 
Mmm...

In OTX in all versions...
In TFS I can see it on trunk.r3777 in advance, dont know if its on older versions, but in 0.3.6 it isnt compiled...
In other distributions I dont know...
 
If i were you i would choose a bunch of weapons that you want as "off-hand" weapons and have it look like a weapon but its acutally a shield and make it add skills to its skill tree like a Sword and the off hand weap a dagger but the dagger adds 15+swording. Or something along those lines.
 
bump, is it posible tomcompile the function into 0.3.6? it would be awsome to actually make it dual weild weps and not only wear a shield whit a diefrent sprite :eek:, altho is rlly good temporary solution n.n gj
 
I think you should use normal dual wield, there is some tutorial how to do on tfs 0.3.6pl1, and then add atributes to weapon for x vocation.
 
Items.cpp

Under:
Lua:
armor = 0;

Add:
Lua:
dual = 0;


Under:
Lua:
else if(tmpStrValue == "attack")
{
	if(readXMLInteger(itemAttributesNode, "value", intValue))
		it.attack = intValue;
}

Add:
Lua:
else if(tmpStrValue == "dual")
{
	if(readXMLInteger(itemAttributesNode, "value", intValue))
		it.dual = intValue;
}


Items.h​

Change this:
Lua:
int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance,
runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder;

Whith this:
Lua:
int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance,
runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder, dual;

Item.cpp​

Under:
Lua:
if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense())))
{
	if(begin)
	{
		begin = false;
		s << " (";
	}
	else
		s << ", ";

	s << "Def:" << int32_t(item ? item->getDefense() : it.defense);
	if(it.extraDefense || (item && item->getExtraDefense()))
		s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos;
}

Add:
Lua:
if(it.dual || (item && item->isDual()))
{
	if(begin)
	{
		begin = false;
		s << " (";
	}
	else
		s << ", ";

	s << "dual-wield";
}


Under:
Lua:
case ATTR_ATTACK:
{
	int32_t attack;
	if(!propStream.GET_ULONG((uint32_t&)attack))
		return ATTR_READ_ERROR;

	setAttribute("attack", attack);
	break;
}

Add:
Lua:
case ATTR_DUAL:
{
	int32_t dual;
	if(!propStream.GET_ULONG((uint32_t&)dual))
		return ATTR_READ_ERROR;

	setAttribute("dual", dual);
	break;
}

Item.h​

Under:
Lua:
ATTR_SCRIPTPROTECTED = 42,

Add:
Lua:
ATTR_DUAL = 43,


Under:
Lua:
int32_t getAttack() const;

Add:
Lua:
int32_t isDual() const;


Under:
Lua:
inline int32_t Item::getAttack() const
{
	const int32_t* v = getIntegerAttribute("attack");
	if(v)
		return *v;

	return items[id].attack;
}

Add:

Lua:
inline int32_t Item::isDual() const
{
	const int32_t* v = getIntegerAttribute("dual");
	if(v)
		return *v;

	return items[id].dual;
}

Player.cpp​

Under:
Lua:
WeaponType_t Player::getWeaponType()
{
	if(Item* item = getWeapon())
		return item->getWeaponType();

	return WEAPON_NONE;
}

Add:
Lua:
Item* Player::getLeftWeapon()
{
      Item* item = getEquippedItem(SLOT_LEFT);

      if(const Weapon* weapon = g_weapons->getWeapon(item))
		   return item;
}

Item* Player::getRightWeapon()
{
      Item* item = getEquippedItem(SLOT_RIGHT);

      if(const Weapon* weapon = g_weapons->getWeapon(item))
           return item;
}

bool Player::isUsingDual()
{
     Item* right = getRightWeapon();
     Item* left = getLeftWeapon();

     if(left && right && left->isDual() && right->isDual())
         return true;

     return false;
}


In function __queryAdd find:
Lua:
else if(leftType == WEAPON_SHIELD && type == WEAPON_SHIELD)
ret = RET_CANONLYUSEONESHIELD;

And add:
Lua:
else if(leftType < WEAPON_SHIELD && type < WEAPON_SHIELD && item->isDual() && leftItem->isDual())
ret = RET_NOERROR;


Then find:
Lua:
else if(rightType == WEAPON_SHIELD && type == WEAPON_SHIELD)
ret = RET_CANONLYUSEONESHIELD;

And add:
Lua:
else if(rightType < WEAPON_SHIELD && type < WEAPON_SHIELD && item->isDual() && rightItem->isDual())
ret = RET_NOERROR;


In function doAttacking find:
Lua:
if(hasCondition(CONDITION_PACIFIED) && !hasCustomFlag(PlayerCustomFlag_IgnorePacification))
{
lastAttack = OTSYS_TIME();
return;
}

And add below:
Lua:
    if(isUsingDual())
	{
        const Weapon* rweapon = g_weapons->getWeapon(getRightWeapon());
        const Weapon* lweapon = g_weapons->getWeapon(getLeftWeapon());

        if(rweapon->interruptSwing() && lweapon->interruptSwing() && !canDoAction())
		{
			SchedulerTask* task = createSchedulerTask(getNextActionTime(), boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
			setNextActionTask(task);
		}
		else if(((!rweapon->hasExhaustion() && !lweapon->hasExhaustion()) || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && (rweapon->useWeapon(this, getRightWeapon(), attackedCreature) && lweapon->useWeapon(this, getLeftWeapon(), attackedCreature)))
			lastAttack = OTSYS_TIME();
    }


And change this:
Lua:
Item* tool = getWeapon();
if(const Weapon* weapon = g_weapons->getWeapon(tool))

With this:
Lua:
else if(const Weapon* weapon = g_weapons->getWeapon(getWeapon()))


And change this:
Lua:
else if((!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && weapon->useWeapon(this, tool, attackedCreature))

With this:
Lua:
else if((!weapon->hasExhaustion() || !hasCondition(CONDITION_EXHAUST, EXHAUST_COMBAT)) && weapon->useWeapon(this, getWeapon(), attackedCreature))

Player.h​

Under:
Lua:
virtual WeaponType_t getWeaponType();

Add:
Lua:
Item* getLeftWeapon();
Item* getRightWeapon();
bool isUsingDual();


It's all. Tutorial isn't mine, so all reps and thanks to Dantez (TNP).
 
Oh i forget about that xD
You have to add:
Lua:
		<attribute key="dual" value="1" />

And that is all :)
 
I can't find theses code(the others i found) i'm using 0.3.6pl1.r101
Code:
armor = 0;
Code:
else if(tmpStrValue == "attack")
{
	if(readXMLInteger(itemAttributesNode, "value", intValue))
		it.attack = intValue;
}
What i can do?
 
try not searching for the whole thing, try the start or just try searching for =="attack" and see if what you find, then put it in the right place...
 
Back
Top