Thread: Fishing issue
View Single Post
  #2  
Old 09-11-2014, 10:09 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,604
Default

Not sure what your exact issue is, but here's the Client::CanFish code in forage.cpp, the code giving your error is green. Maybe you could un-comment the yellow and recompile and see what it sends you?:
Code:
bool Client::CanFish() {
    //make sure we still have a fishing pole on:
    const ItemInst* Pole = m_inv[MainPrimary];
    int32 bslot = m_inv.HasItemByUse(ItemTypeFishingBait, 1, invWhereWorn|invWherePersonal);
    const ItemInst* Bait = nullptr;
    if (bslot != INVALID_INDEX)
        Bait = m_inv.GetItem(bslot);

    if(!Pole || !Pole->IsType(ItemClassCommon) || Pole->GetItem()->ItemType != ItemTypeFishingPole) {
        if (m_inv.HasItemByUse(ItemTypeFishingPole, 1, invWhereWorn|invWherePersonal|invWhereBank|invWhereSharedBank|invWhereTrading|invWhereCursor))    //We have a fishing pole somewhere, just not equipped
            Message_StringID(MT_Skills, FISHING_EQUIP_POLE);    //You need to put your fishing pole in your primary hand.
        else    //We don't have a fishing pole anywhere
            Message_StringID(MT_Skills, FISHING_NO_POLE);    //You can't fish without a fishing pole, go buy one.
        return false;
    }

    if (!Bait || !Bait->IsType(ItemClassCommon) || Bait->GetItem()->ItemType != ItemTypeFishingBait) {
        Message_StringID(MT_Skills, FISHING_NO_BAIT);    //You can't fish without fishing bait, go buy some.
        return false;
    }

    if(zone->zonemap != nullptr && zone->watermap != nullptr && RuleB(Watermap, CheckForWaterWhenFishing)) {
        float RodX, RodY, RodZ;
        // Tweak Rod and LineLength if required
        const float RodLength = RuleR(Watermap, FishingRodLength);
        const float LineLength = RuleR(Watermap, FishingLineLength);
        int HeadingDegrees;

        HeadingDegrees = (int) ((GetHeading()*360)/256);
        HeadingDegrees = HeadingDegrees % 360;

        RodX = x_pos + RodLength * sin(HeadingDegrees * M_PI/180.0f);
        RodY = y_pos + RodLength * cos(HeadingDegrees * M_PI/180.0f);

        // Do BestZ to find where the line hanging from the rod intersects the water (if it is water).
        // and go 1 unit into the water.
        Map::Vertex dest;
        dest.x = RodX;
        dest.y = RodY;
        dest.z = z_pos+10;

        RodZ = zone->zonemap->FindBestZ(dest, nullptr) - 1;
        bool in_lava = zone->watermap->InLava(RodX, RodY, RodZ);
        bool in_water = zone->watermap->InWater(RodX, RodY, RodZ) || zone->watermap->InVWater(RodX, RodY, RodZ);
        //Message(0, "Rod is at %4.3f, %4.3f, %4.3f, InWater says %d, InLava says %d", RodX, RodY, RodZ, in_water, in_lava);
        if (in_lava) {
            Message_StringID(MT_Skills, FISHING_LAVA);    //Trying to catch a fire elemental or something?
            return false;
        }
        if((!in_water) || (z_pos-RodZ)>LineLength) {    //Didn't hit the water OR the water is too far below us
            Message_StringID(MT_Skills, FISHING_LAND);    //Trying to catch land sharks perhaps?
            return false;
        }
    }
    return true;
}
Reply With Quote