|
@@ -1396,6 +1396,25 @@ int16 Player::ConvertSlotFromClient(int8 slot, int16 version) {
|
|
|
return slot;
|
|
|
}
|
|
|
|
|
|
+int16 Player::GetNumSlotsEquip(int16 version) {
|
|
|
+ if(version <= 546) {
|
|
|
+ return CLASSIC_NUM_SLOTS;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NUM_SLOTS;
|
|
|
+}
|
|
|
+
|
|
|
+int8 Player::GetMaxBagSlots(int16 version) {
|
|
|
+ if(version <= 283) {
|
|
|
+ return CLASSIC_EQ_MAX_BAG_SLOTS;
|
|
|
+ }
|
|
|
+ else if(version = 546) {
|
|
|
+ return DOF_EQ_MAX_BAG_SLOTS;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 255;
|
|
|
+}
|
|
|
+
|
|
|
vector<EQ2Packet*> Player::UnequipItem(int16 index, sint32 bag_id, int8 slot, int16 version, int8 appearance_type, bool send_item_updates) {
|
|
|
vector<EQ2Packet*> packets;
|
|
|
EquipmentItemList* equipList = &equipment_list;
|
|
@@ -1403,7 +1422,7 @@ vector<EQ2Packet*> Player::UnequipItem(int16 index, sint32 bag_id, int8 slot, in
|
|
|
if(appearance_type)
|
|
|
equipList = &appearance_equipment_list;
|
|
|
|
|
|
- if(index >= NUM_SLOTS) {
|
|
|
+ if(index >= GetNumSlotsEquip(version)) {
|
|
|
LogWrite(PLAYER__ERROR, 0, "Player", "%u index is out of range for equip items, bag_id: %i, slot: %u, version: %u, appearance: %u", index, bag_id, slot, version, appearance_type);
|
|
|
return packets;
|
|
|
}
|
|
@@ -2653,33 +2672,26 @@ vector<Spell*> Player::GetSpellBookSpellsByTimer(int32 timerID) {
|
|
|
}
|
|
|
|
|
|
void Player::ModifySpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast, int16 recast) {
|
|
|
- if (modify_recast) {
|
|
|
- spell->recast = recast;
|
|
|
- spell->recast_available = Timer::GetCurrentTime2() + (recast * 100);
|
|
|
- }
|
|
|
+ SetSpellEntryRecast(spell, modify_recast, recast);
|
|
|
if (modify_recast || spell->recast_available <= Timer::GetCurrentTime2() || value == 4) {
|
|
|
spell->status += value; // use set/remove spell status now
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
void Player::AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast, int16 recast) {
|
|
|
- if (modify_recast) {
|
|
|
- spell->recast = recast;
|
|
|
- spell->recast_available = Timer::GetCurrentTime2() + (recast * 100);
|
|
|
- }
|
|
|
+ SetSpellEntryRecast(spell, modify_recast, recast);
|
|
|
if (modify_recast || spell->recast_available <= Timer::GetCurrentTime2() || value == 4) {
|
|
|
spell->status = spell->status | value;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
void Player::RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast, int16 recast) {
|
|
|
- if (modify_recast) {
|
|
|
- spell->recast = recast;
|
|
|
- spell->recast_available = Timer::GetCurrentTime2() + (recast * 100);
|
|
|
- }
|
|
|
+ SetSpellEntryRecast(spell, modify_recast, recast);
|
|
|
if (modify_recast || spell->recast_available <= Timer::GetCurrentTime2() || value == 4) {
|
|
|
spell->status = spell->status & ~value;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
void Player::SetSpellStatus(Spell* spell, int8 status){
|
|
|
MSpellsBook.lock();
|
|
|
vector<SpellBookEntry*>::iterator itr;
|
|
@@ -2694,6 +2706,21 @@ void Player::SetSpellStatus(Spell* spell, int8 status){
|
|
|
MSpellsBook.unlock();
|
|
|
}
|
|
|
|
|
|
+void Player::SetSpellEntryRecast(SpellBookEntry* spell, bool modify_recast, int16 recast) {
|
|
|
+ if (modify_recast) {
|
|
|
+ spell->recast = recast;
|
|
|
+ float override_recast = static_cast<float>(recast);
|
|
|
+ Spell* spell_ = master_spell_list.GetSpell(spell->spell_id, spell->tier);
|
|
|
+ if(spell_) {
|
|
|
+ int32 recast_time = spell_->CalculateRecastTimer(this, override_recast);
|
|
|
+ spell->recast_available = Timer::GetCurrentTime2() + (recast_time / 10);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ spell->recast_available = Timer::GetCurrentTime2() + (recast * 100);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
vector<SpellBookEntry*>* Player::GetSpellsSaveNeeded(){
|
|
|
vector<SpellBookEntry*>* ret = 0;
|
|
|
vector<SpellBookEntry*>::iterator itr;
|
|
@@ -6947,13 +6974,13 @@ void Player::SaveSpellEffects()
|
|
|
continue;
|
|
|
|
|
|
savedEffects.AddQueryAsync(GetCharacterID(), &database, Q_INSERT,
|
|
|
- "insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
|
|
|
+ "insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, has_damaged, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
|
|
|
database.getSafeEscapeString(info->spell_effects[i].spell->spell->GetName()).c_str(), caster_char_id,
|
|
|
target_char_id, 0 /*no target_type for spell_effects*/, DB_TYPE_SPELLEFFECTS /* db_effect_type for spell_effects */, info->spell_effects[i].spell->spell->IsCopiedSpell() ? info->spell_effects[i].spell->spell->GetSpellData()->inherited_spell_id : info->spell_effects[i].spell_id, i, info->spell_effects[i].spell->slot_pos,
|
|
|
info->spell_effects[i].icon, info->spell_effects[i].icon_backdrop, 0 /* no conc_used for spell_effects */, info->spell_effects[i].tier,
|
|
|
info->spell_effects[i].total_time, timestamp, database.getSafeEscapeString(info->spell_effects[i].spell->file_name.c_str()).c_str(), info->spell_effects[i].spell->spell->IsCopiedSpell(), GetCharacterID(),
|
|
|
info->spell_effects[i].spell->damage_remaining, info->spell_effects[i].spell->effect_bitmask, info->spell_effects[i].spell->num_triggers, info->spell_effects[i].spell->had_triggers, info->spell_effects[i].spell->cancel_after_all_triggers,
|
|
|
- info->spell_effects[i].spell->crit, info->spell_effects[i].spell->last_spellattack_hit, info->spell_effects[i].spell->interrupted, info->spell_effects[i].spell->resisted, (info->maintained_effects[i].expire_timestamp) == 0xFFFFFFFF ? "" : database.getSafeEscapeString(spellProcess->SpellScriptTimerCustomFunction(info->spell_effects[i].spell).c_str()).c_str());
|
|
|
+ info->spell_effects[i].spell->crit, info->spell_effects[i].spell->last_spellattack_hit, info->spell_effects[i].spell->interrupted, info->spell_effects[i].spell->resisted, info->spell_effects[i].spell->has_damaged, (info->maintained_effects[i].expire_timestamp) == 0xFFFFFFFF ? "" : database.getSafeEscapeString(spellProcess->SpellScriptTimerCustomFunction(info->spell_effects[i].spell).c_str()).c_str());
|
|
|
}
|
|
|
if (i < NUM_MAINTAINED_EFFECTS && info->maintained_effects[i].spell_id != 0xFFFFFFFF){
|
|
|
Spawn* spawn = GetZone()->GetSpawnByID(info->maintained_effects[i].spell->initial_target);
|
|
@@ -6975,12 +7002,12 @@ void Player::SaveSpellEffects()
|
|
|
if(info->maintained_effects[i].spell->spell->GetSpellData() && !info->maintained_effects[i].spell->spell->GetSpellData()->duration_until_cancel)
|
|
|
timestamp = info->maintained_effects[i].expire_timestamp - Timer::GetCurrentTime2();
|
|
|
savedEffects.AddQueryAsync(GetCharacterID(), &database, Q_INSERT,
|
|
|
- "insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
|
|
|
+ "insert into character_spell_effects (name, caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos, icon, icon_backdrop, conc_used, tier, total_time, expire_timestamp, lua_file, custom_spell, charid, damage_remaining, effect_bitmask, num_triggers, had_triggers, cancel_after_triggers, crit, last_spellattack_hit, interrupted, resisted, has_damaged, custom_function) values ('%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %f, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, '%s')",
|
|
|
database.getSafeEscapeString(info->maintained_effects[i].name).c_str(), caster_char_id, target_char_id, info->maintained_effects[i].target_type, DB_TYPE_MAINTAINEDEFFECTS /* db_effect_type for maintained_effects */, info->maintained_effects[i].spell->spell->IsCopiedSpell() ? info->maintained_effects[i].spell->spell->GetSpellData()->inherited_spell_id : info->maintained_effects[i].spell_id, i, info->maintained_effects[i].slot_pos,
|
|
|
info->maintained_effects[i].icon, info->maintained_effects[i].icon_backdrop, info->maintained_effects[i].conc_used, info->maintained_effects[i].tier,
|
|
|
info->maintained_effects[i].total_time, timestamp, database.getSafeEscapeString(info->maintained_effects[i].spell->file_name.c_str()).c_str(), info->maintained_effects[i].spell->spell->IsCopiedSpell(), GetCharacterID(),
|
|
|
info->maintained_effects[i].spell->damage_remaining, info->maintained_effects[i].spell->effect_bitmask, info->maintained_effects[i].spell->num_triggers, info->maintained_effects[i].spell->had_triggers, info->maintained_effects[i].spell->cancel_after_all_triggers,
|
|
|
- info->maintained_effects[i].spell->crit, info->maintained_effects[i].spell->last_spellattack_hit, info->maintained_effects[i].spell->interrupted, info->maintained_effects[i].spell->resisted, (info->maintained_effects[i].expire_timestamp) == 0xFFFFFFFF ? "" : database.getSafeEscapeString(spellProcess->SpellScriptTimerCustomFunction(info->maintained_effects[i].spell).c_str()).c_str());
|
|
|
+ info->maintained_effects[i].spell->crit, info->maintained_effects[i].spell->last_spellattack_hit, info->maintained_effects[i].spell->interrupted, info->maintained_effects[i].spell->resisted, info->maintained_effects[i].spell->has_damaged, (info->maintained_effects[i].expire_timestamp) == 0xFFFFFFFF ? "" : database.getSafeEscapeString(spellProcess->SpellScriptTimerCustomFunction(info->maintained_effects[i].spell).c_str()).c_str());
|
|
|
|
|
|
info->maintained_effects[i].spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);
|
|
|
std::string insertTargets = string("insert into character_spell_effect_targets (caster_char_id, target_char_id, target_type, db_effect_type, spell_id, effect_slot, slot_pos) values ");
|