Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Fishing skill up #6100

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions conf/map_darkstar.conf
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,6 @@ healing_tick_delay: 10
#Central message server settings (ensure these are the same on both all map servers and the central (lobby) server
msg_server_port: 54003
msg_server_ip: 127.0.0.1

#Fishing daily limit ( 0 : unlimited , any other number : number of catches a player can get daily ) 200 is retail limit
fishing_daily_limit: 200
2 changes: 2 additions & 0 deletions src/map/entities/charentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ CCharEntity::CCharEntity()

PAI = std::make_unique<CAIContainer>(this, nullptr, std::make_unique<CPlayerController>(this),
std::make_unique<CTargetFind>(this));

fishingCatches = 0;
}

CCharEntity::~CCharEntity()
Expand Down
2 changes: 2 additions & 0 deletions src/map/entities/charentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ class CCharEntity : public CBattleEntity
bool m_EffectsChanged;
time_point m_LastSynthTime;

uint8 fishingCatches; // number of catches done over a real day period. reseted at server midnight. only affected if limit (set in map config file) != 0

int16 addTP(int16 tp) override;
int32 addHP(int32 hp) override;
int32 addMP(int32 mp) override;
Expand Down
20 changes: 20 additions & 0 deletions src/map/items/item_fish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,30 @@ CItemFish::CItemFish(const CItem &PItem) : CItem(PItem)
m_rodflag = 0;
}

CItemFish::CItemFish(const CItem& PItem, uint8 min, uint8 max) : CItem(PItem)
{
m_min = min;
m_max = max;
m_watertype = 0;
m_size = 0;
m_stamina = 0;
m_rodflag = 0;
}

CItemFish::~CItemFish()
{
}

uint8 CItemFish::GetMin()
{
return m_min;
}

uint8 CItemFish::GetMax()
{
return m_max;
}

uint16 CItemFish::GetLength()
{
return ref<uint16>(m_extra, 0);
Expand Down
2 changes: 2 additions & 0 deletions src/map/items/item_fish.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CItemFish : public CItem
public:

CItemFish(const CItem &PItem);

CItemFish(const CItem& PItem, uint8 min, uint8 max);

uint8 GetMin();
uint8 GetMax();
Expand Down
5 changes: 5 additions & 0 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ int32 map_config_default()
map_config.msg_server_ip = "127.0.0.1";
map_config.healing_tick_delay = 10;
map_config.skillup_bloodpact = true;
map_config.fishing_daily_limit = 200;
return 0;
}

Expand Down Expand Up @@ -1339,6 +1340,10 @@ int32 map_config_read(const int8* cfgName)
{
map_config.skillup_bloodpact = atoi(w2);
}
else if (strcmp(w1, "fishing_daily_limit") == 0)
{
map_config.fishing_daily_limit = atoi(w2);
}
else
{
ShowWarning(CL_YELLOW"Unknown setting '%s' in file %s\n" CL_RESET, w1, cfgName);
Expand Down
1 change: 1 addition & 0 deletions src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct map_config_t
uint16 msg_server_port; // central message server port
std::string msg_server_ip; // central message server IP
bool skillup_bloodpact; // Enable/disable skillups for bloodpacts
uint16 fishing_daily_limit;
};

/************************************************************************
Expand Down
5 changes: 3 additions & 2 deletions src/map/time_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "lua/luautils.h"
#include "entities/charentity.h"
#include "latent_effect_container.h"

#include "utils/fishingutils.h"

int32 time_server(time_point tick,CTaskMgr::CTask* PTask)
{
Expand Down Expand Up @@ -86,6 +86,7 @@ int32 time_server(time_point tick,CTaskMgr::CTask* PTask)
{
guildutils::UpdateGuildPointsPattern();
CVanaTime::getInstance()->lastMidnight = tick;
fishingutils::ClearPlayersFishingCatches();
}
}

Expand Down Expand Up @@ -131,4 +132,4 @@ int32 time_server(time_point tick,CTaskMgr::CTask* PTask)

instanceutils::CheckInstance();
return 0;
}
}
29 changes: 29 additions & 0 deletions src/map/utils/charutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,20 @@ namespace charutils
PChar->health.mp = zoneutils::IsResidentialArea(PChar) ? PChar->GetMaxMP() : MP;
PChar->UpdateHealth();
PChar->m_event.EventID = luautils::OnZoneIn(PChar);
fmtQuery =
"SELECT "
"value " // 0
"FROM char_vars "
"WHERE charid = %u and varname = 'FishingCatches';";

ret = Sql_Query(SqlHandle, fmtQuery, PChar->id);

if (ret != SQL_ERROR &&
Sql_NumRows(SqlHandle) != 0 &&
Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
PChar->fishingCatches = (uint8)Sql_GetUIntData(SqlHandle, 0);
}
luautils::OnGameIn(PChar, zoning == 1);
}

Expand Down Expand Up @@ -4967,4 +4981,19 @@ namespace charutils
return 0;
}

int32 SetVar(CCharEntity* PChar, const char* var, int32 value)
{
const char* fmtQuery = "INSERT INTO char_vars SET charid = %u, varname = '%s', value = %i ON DUPLICATE KEY UPDATE value = %i;";

int32 ret = Sql_Query(SqlHandle, fmtQuery, PChar->id, var, value, value);

if (ret != SQL_ERROR &&
Sql_NumRows(SqlHandle) != 0 &&
Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
return Sql_GetIntData(SqlHandle, 0);
}
return 0;
}

}; // namespace charutils
1 change: 1 addition & 0 deletions src/map/utils/charutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ namespace charutils
bool AddWeaponSkillPoints(CCharEntity*, SLOTTYPE, int);

int32 GetVar(CCharEntity* PChar, const char* var);
int32 SetVar(CCharEntity* PChar, const char* var, int32 value);
};

#endif
Loading