• 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] Dual weapons

Edwin2705

Nothing :)
Joined
Aug 6, 2007
Messages
32
Reaction score
1
Location
Poland -> Szczecinek
Hello.
So I need help in dual weapons\wielding. I'm using code made by Nfries. And I have only 1 problem. <_<
When I logout with 2 weapons and login with them function can't find my weapons, so I'm fighting with fist. (I'm using Avesta 7.6.)
Here's code:
doAttacking function:
Code:
void Player::doAttacking(uint32_t interval)
{
	if(lastAttack == 0)
		lastAttack = OTSYS_TIME() - getAttackSpeed() - 1;

	if((OTSYS_TIME() - lastAttack) < getAttackSpeed())
		return;

	Item* tool = getWeapon();
	if(const Weapon* weapon = g_weapons->getWeapon(tool))
	{
		if(weapon->interruptSwing() && !canDoAction())
		{
			SchedulerTask* task = createSchedulerTask(getNextActionTime(), boost::bind(&Game::checkCreatureAttack, &g_game, getID()));
			setNextActionTask(task);
		}
		else if((!hasCondition(CONDITION_EXHAUST_COMBAT) || !weapon->hasExhaustion()) && weapon->useWeapon(this, tool, attackedCreature))
			lastAttack = OTSYS_TIME();
	}
	else if(Weapon::useFist(this, attackedCreature)){
		lastAttack = OTSYS_TIME();
    }
    findNextWeapon();
}
findNextWeapon function:
Code:
void Player::findNextWeapon()
{
   Item* left = getWeaponLeft();
   Item* right = getWeaponRight();
   if((right != NULL) && (nextWeapon == left || (left == NULL) || left->getWeaponType() == WEAPON_SHIELD)) {
      nextWeapon = right;
   } else if((left != NULL) && (nextWeapon == right || (right == NULL) || right->getWeaponType() == WEAPON_SHIELD)) {
      nextWeapon = left;
   } else {
      nextWeapon = NULL;
   }
   if((nextWeapon != NULL)) {
      shootRange = nextWeapon->getShootRange();
   }
}
Code:
Item* Player::getWeaponLeft() const
{
   Item* item = inventory[SLOT_LEFT];
   if(item){
      switch(item->getWeaponType()){
         case WEAPON_NONE: case WEAPON_AMMO:
            break;
         default:
            return item;
            break;
      }
   }
   return NULL;
}

Item* Player::getWeaponRight() const
{
   Item* item = inventory[SLOT_RIGHT];
   if(item){
      switch(item->getWeaponType()){
         case WEAPON_NONE: case WEAPON_AMMO:
            break;
         default:
            return item;
            break;
      }
   }
   return NULL;
}

Please, help me if you can.
Greetings,
Edwin.
 
Back
Top