示例#1
0
void GameObject::UseFishingNode(Player* player)
{
	sEventMgr.RemoveEvents( this );
	if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked
	{
		player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED );
		EndFishing( player, true );
		return;
	}

	FishingZoneEntry *entry = NULL;

	uint32 zone = player->GetAreaID();
	if(zone != 0)
	{
		entry = FishingZoneStorage.LookupEntry( zone );
		if( entry == NULL ) // No fishing information found for area, log an error
		{
			OUT_DEBUG( "ERROR: Fishing area information for area %d not found!", zone );
		}
	}
	if(zone == 0 || entry == NULL)
	{
		zone = player->GetZoneId();
		entry = FishingZoneStorage.LookupEntry( zone );
		if( entry == NULL ) // No fishing information found for area, log an error
		{
			OUT_DEBUG( "ERROR: Fishing zone information for zone %d not found!", zone );
			EndFishing( player, true );
			return;
		}
	}

	uint32 maxskill = entry->MaxSkill;
	uint32 minskill = entry->MinSkill;

	if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill )	
		player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) );

	// Open loot on success, otherwise FISH_ESCAPED.
	if( Rand(((player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill) * 100) / maxskill) )
	{
		lootmgr.FillFishingLoot( &m_loot, zone );
		player->SendLoot( GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
	}
	else // Failed
	{
		player->GetSession()->OutPacket( SMSG_FISH_ESCAPED );
		EndFishing( player, true );
	}
}
示例#2
0
void GameObject::UseFishingNode(Player *player)
{
	sEventMgr.RemoveEvents(this);
	if(GetUInt32Value(GAMEOBJECT_STATE))//click on bobber before somth is hooked
	{
		player->GetSession()->OutPacket(SMSG_FISH_NOT_HOOKED);
		EndFishing(player,true);
		return;
	}
	
	uint32 zone=sAreaStore.LookupEntry(GetMapMgr()->GetAreaID(GetPositionX(),GetPositionY()))->ZoneId;

	FishingZoneEntry *entry = FishingZoneStorage.LookupEntry(zone);
	if(entry == NULL)
	{
		sLog.outError("ERROR: Fishing zone information for zone %d not found!", zone);
		EndFishing(player, true);
		return;
	}
	uint32 maxskill=entry->MaxSkill;
//	uint32 minskill=entry->MaxSkill;
	uint32 minskill=entry->MinSkill;

	if(player->GetBaseSkillAmt(SKILL_FISHING)<maxskill)	
		player->AdvanceSkillLine(SKILL_FISHING);

	//Open loot on success, otherwise FISH_ESCAPED.
	if(Rand(((player->GetSkillAmt(SKILL_FISHING)-minskill)*100)/maxskill))
	{			  
		lootmgr.FillProfessionLoot(&lootmgr.FishingLoot,&loot,zone);
		player->SendLoot(GetGUID(),3);
		EndFishing(player, false);
	}
	else //failed
	{
		player->GetSession()->OutPacket(SMSG_FISH_ESCAPED);
		EndFishing(player,false);
	}

}
示例#3
0
void GameObject::UseFishingNode(Player *player)
{
	sEventMgr.RemoveEvents( this );
	if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked
	{
		player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED );
		EndFishing( player, true );
		return;
	}
	
	/* Unused code: sAreaStore.LookupEntry(GetMapMgr()->GetAreaID(GetPositionX(),GetPositionY()))->ZoneId*/
	uint32 zone = player->GetAreaID();
	if( zone == 0 ) // If the player's area ID is 0, use the zone ID instead
		zone = player->GetZoneId();

	FishingZoneEntry *entry = FishingZoneStorage.LookupEntry( zone );
	if( entry == NULL ) // No fishing information found for area or zone, log an error, and end fishing
	{
		sLog.outError( "ERROR: Fishing zone information for zone %d not found!", zone );
		EndFishing( player, true );
		return;
	}
	uint32 maxskill = entry->MaxSkill;
	uint32 minskill = entry->MinSkill;

	if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill )	
		player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) );

	GameObject * school = NULL;
	this->AquireInrangeLock(); //make sure to release lock before exit function !
	for ( InRangeSet::iterator it = GetInRangeSetBegin(); it != GetInRangeSetEnd(); ++it )
	{
		if ( (*it) == NULL || (*it)->GetTypeId() != TYPEID_GAMEOBJECT || (*it)->GetUInt32Value(GAMEOBJECT_TYPE_ID) != GAMEOBJECT_TYPE_FISHINGHOLE)
			continue;
		school = static_cast<GameObject *>( *it );
		if ( !isInRange( school, (float)school->GetInfo()->sound1 ) )
		{
			school = NULL;
			continue;
		}
		else
			break;
	}
	this->ReleaseInrangeLock();

	if ( school != NULL ) // open school loot if school exists
	{
		lootmgr.FillGOLoot( &school->loot, school->GetEntry(), school->GetMapMgr() ? ( school->GetMapMgr()->iInstanceMode ? true : false ) : false );
		player->SendLoot( school->GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
		school->CatchFish();
		if ( !school->CanFish() )
			sEventMgr.AddEvent( school, &GameObject::Despawn, ( 1800000 + RandomUInt( 3600000 ) ), EVENT_GAMEOBJECT_EXPIRE, 10000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); // respawn in 30 - 90 minutes
	}
	else if( Rand( ( ( player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill ) * 100 ) / maxskill ) ) // Open loot on success, otherwise FISH_ESCAPED.
	{
		lootmgr.FillFishingLoot( &loot, zone );
		player->SendLoot( GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
	}
	else // Failed
	{
		player->GetSession()->OutPacket( SMSG_FISH_ESCAPED );
		EndFishing( player, true );
	}

}