Dungeon Crawl custom code merge

Added numerous modding hooks.
Added rules:
	Character:KeepLevelOverMax - Don't delevel a character if they are found to be over max level rule.
	Spells:UseCHAScribeHack - Optionally omit spells with CHA in effect12 when using scribespells and traindiscs
	Combat:MonkACBonusWeight - Adjust the weight threshold for monk AC bonus
	Combat:ClientStunLevel - Adjust the level clients kicks and bashes start to roll for stuns
	Combat;QuiverWRHasteDiv - Adjust the divisor applied to weight reduction for haste calcs
	Combat:UseArcheryBonusRoll - Make archery stationary bonus a roll
	Combat:ArcheryBonusChance - Archery stationary bonus chance

Added account flags and associated perl wrappers
Added EVENT_ITEM_TICK for interactive items
Added EVENT_DUEL_WIN and EVENT_DUEL_LOSE, which exports $enemyname and $enemyid
Added timer and interval to console worldshutdown command
Added EQW interface for worldshutdown and server-wide messages
This commit is contained in:
Tabasco
2013-04-24 15:58:51 -05:00
parent b15cb08f54
commit 56490400ca
45 changed files with 1321 additions and 156 deletions
+128 -5
View File
@@ -166,7 +166,8 @@ Client::Client(EQStreamInterface* ieqs)
qglobal_purge_timer(30000),
TrackingTimer(2000),
RespawnFromHoverTimer(0),
merc_timer(RuleI(Mercs, UpkeepIntervalMS))
merc_timer(RuleI(Mercs, UpkeepIntervalMS)),
ItemTickTimer(10000)
{
for(int cf=0; cf < _FilterCount; cf++)
ClientFilters[cf] = FilterShow;
@@ -325,6 +326,8 @@ Client::Client(EQStreamInterface* ieqs)
}
MaxXTargets = 5;
XTargetAutoAddHaters = true;
//DCBOOKMARK
LoadAccountFlags();
}
Client::~Client() {
@@ -842,6 +845,9 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
safe_delete(pack);
}
//DCBOOKMARK - Return true to proceed, false to return
if(!mod_client_message(message, chan_num)) { return; }
// Garble the message based on drunkness
if (m_pp.intoxication > 0) {
GarbleMessage(message, (int)(m_pp.intoxication / 3));
@@ -2334,10 +2340,11 @@ bool Client::CheckIncreaseSkill(SkillType skillid, Mob *against_who, int chancem
if(against_who)
{
if(against_who->SpecAttacks[IMMUNE_AGGRO] || against_who->IsClient() ||
GetLevelCon(against_who->GetLevel()) == CON_GREEN)
if( against_who->SpecAttacks[IMMUNE_AGGRO] || against_who->IsClient() ||
GetLevelCon(against_who->GetLevel()) == CON_GREEN )
{
return false;
//DCBOOKMARK - false by default
return mod_can_increase_skill(skillid, against_who);
}
}
@@ -2349,6 +2356,10 @@ bool Client::CheckIncreaseSkill(SkillType skillid, Mob *against_who, int chancem
if (Chance < 1)
Chance = 1; // Make it always possible
Chance = (Chance * RuleI(Character, SkillUpModifier) / 100);
//DCBOOKMARK
Chance = mod_increase_skill_chance(Chance, against_who);
if(MakeRandomFloat(0, 99) < Chance)
{
SetSkill(skillid, GetRawSkill(skillid) + 1);
@@ -2717,6 +2728,9 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
max_percent = 70 + 10 * maxHPBonus;
}
//DCBOOKMARK
max_percent = mod_bindwound_percent(max_percent, bindmob);
int max_hp = bindmob->GetMaxHP()*max_percent/100;
// send bindmob new hp's
@@ -2735,7 +2749,10 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
int bindBonus = spellbonuses.BindWound + itembonuses.BindWound + aabonuses.BindWound;
bindhps += bindhps*bindBonus / 100;
//DCBOOKMARK
bindhps = mod_bindwound_hp(bindhps, bindmob);
//if the bind takes them above the max bindable
//cap it at that value. Dont know if live does it this way
//but it makes sense to me.
@@ -7606,3 +7623,109 @@ some day.
}
return 0;
}
//DCBOOKMARK
void Client::LoadAccountFlags()
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
accountflags.clear();
MakeAnyLenString(&query, "SELECT p_flag, p_value FROM account_flags WHERE p_accid = '%d'", account_id);
if(database.RunQuery(query, strlen(query), errbuf, &result))
{
while(row = mysql_fetch_row(result))
{
std::string fname(row[0]);
std::string fval(row[1]);
accountflags[fname] = fval;
}
mysql_free_result(result);
}
else
{
std::cerr << "Error in LoadAccountFlags query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
}
void Client::SetAccountFlag(std::string flag, std::string val)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MakeAnyLenString(&query, "REPLACE INTO account_flags (p_accid, p_flag, p_value) VALUES( '%d', '%s', '%s')", account_id, flag.c_str(), val.c_str());
if(!database.RunQuery(query, strlen(query), errbuf))
{
std::cerr << "Error in SetAccountFlags query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
accountflags[flag] = val;
}
std::string Client::GetAccountFlag(std::string flag)
{
return(accountflags[flag]);
}
void Client::TickItemCheck()
{
int i;
//Scan equip slots for items
for(i = 0; i <= 21; i++)
{
TryItemTick(i);
}
//Scan main inventory + cursor
for(i = 22; i < 31; i++)
{
TryItemTick(i);
}
//Scan bags
for(i = 251; i < 340; i++)
{
TryItemTick(i);
}
}
void Client::TryItemTick(int slot)
{
int iid = 0;
const ItemInst* inst = m_inv[slot];
if(inst == 0) { return; }
iid = inst->GetID();
if(zone->tick_items.count(iid) > 0)
{
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot < 22) )
{
ItemInst* e_inst = (ItemInst*)inst;
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, e_inst->GetID(), slot);
}
}
//Only look at augs in main inventory
if(slot > 21) { return; }
for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x)
{
ItemInst * a_inst = inst->GetAugment(x);
if(!a_inst) { continue; }
iid = a_inst->GetID();
if(zone->tick_items.count(iid) > 0)
{
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) )
{
ItemInst* e_inst = (ItemInst*)a_inst;
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, e_inst->GetID(), slot);
}
}
}
}