Work on implementing salvage

This commit is contained in:
mackal 2013-04-07 22:38:43 -04:00
parent 88b9f96b91
commit 91c817d9dd
6 changed files with 58 additions and 2 deletions

View File

@ -0,0 +1,11 @@
-- Add row to tre
ALTER TABLE `tradeskill_recipe_entries` ADD `salvagecount` tinyint(2) DEFAULT '0' NOT NULL AFTER `componentcount`;
-- Fix level req on Salvage
UPDATE `altadv_vars` SET `level_inc` = '5' WHERE `skill_id` = '997';
-- Set aa_effects for Salvage
INSERT INTO `aa_effects` (`id`, `aaid`, `slot`, `effectid`, `base1`, `base2`) VALUES ('2374', '997', '1', '313', '5', '0');
INSERT INTO `aa_effects` (`id`, `aaid`, `slot`, `effectid`, `base1`, `base2`) VALUES ('2375', '998', '1', '313', '15', '0');
INSERT INTO `aa_effects` (`id`, `aaid`, `slot`, `effectid`, `base1`, `base2`) VALUES ('2376', '999', '1', '313', '25', '0');

View File

@ -837,6 +837,9 @@ void Client::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon)
break; break;
case SE_ForageAdditionalItems: case SE_ForageAdditionalItems:
newbon->ForageAdditionalItems += base1; newbon->ForageAdditionalItems += base1;
break;
case SE_Salvage:
newbon->SalvageChance += base1;
break; break;
case SE_ArcheryDamageModifier: case SE_ArcheryDamageModifier:
newbon->ArcheryDamageModifier += base1; newbon->ArcheryDamageModifier += base1;
@ -2197,6 +2200,10 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses* ne
case SE_ForageAdditionalItems: case SE_ForageAdditionalItems:
newbon->ForageAdditionalItems += effect_value; newbon->ForageAdditionalItems += effect_value;
break;
case SE_Salvage:
newbon->SalvageChance += effect_value;
break; break;
case SE_ArcheryDamageModifier: case SE_ArcheryDamageModifier:
@ -3342,6 +3349,12 @@ void Mob::NegateSpellsBonuses(uint16 spell_id)
spellbonuses.ForageAdditionalItems = effect_value; spellbonuses.ForageAdditionalItems = effect_value;
aabonuses.ForageAdditionalItems = effect_value; aabonuses.ForageAdditionalItems = effect_value;
itembonuses.ForageAdditionalItems = effect_value; itembonuses.ForageAdditionalItems = effect_value;
break;
case SE_Salvage:
spellbonuses.SalvageChance = effect_value;
aabonuses.SalvageChance = effect_value;
itembonuses.SalvageChance = effect_value;
break; break;
case SE_ArcheryDamageModifier: case SE_ArcheryDamageModifier:

View File

@ -346,6 +346,7 @@ struct StatBonuses {
uint8 FrontalBackstabChance; // Chance to backstab from the front for full damage uint8 FrontalBackstabChance; // Chance to backstab from the front for full damage
uint8 ConsumeProjectile; // Chance to not consume arrow. uint8 ConsumeProjectile; // Chance to not consume arrow.
uint8 ForageAdditionalItems; // Chance to forage another item. uint8 ForageAdditionalItems; // Chance to forage another item.
uint8 SalvageChance; // Chance to salvage a tradeskill components on fail.
uint16 ArcheryDamageModifier; // Increase Archery Damage by percent uint16 ArcheryDamageModifier; // Increase Archery Damage by percent
bool SecondaryDmgInc; // Allow off hand weapon to recieve damage bonus. bool SecondaryDmgInc; // Allow off hand weapon to recieve damage bonus.
uint16 GiveDoubleAttack; // Allow classes to double attack with a specified chance. uint16 GiveDoubleAttack; // Allow classes to double attack with a specified chance.

View File

@ -2716,6 +2716,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
case SE_ArcheryDamageModifier: case SE_ArcheryDamageModifier:
case SE_ConsumeProjectile: case SE_ConsumeProjectile:
case SE_ForageAdditionalItems: case SE_ForageAdditionalItems:
case SE_Salvage:
case SE_FrontalBackstabChance: case SE_FrontalBackstabChance:
case SE_FrontalBackstabMinDmg: case SE_FrontalBackstabMinDmg:
case SE_TripleBackstab: case SE_TripleBackstab:

View File

@ -1060,6 +1060,18 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
SummonItem(itr->first, itr->second); SummonItem(itr->first, itr->second);
itr++; itr++;
} }
// Rolls on each item, is possible to return everything
int SalvageChance = aabonuses.SalvageChance + itembonuses.SalvageChance + spellbonuses.SalvageChance;
if(SalvageChance) {
itr = spec->onsalvage.begin();
while(itr != spec->onsalvage.end()) {
if(MakeRandomInt(0,99) < SalvageChance)
SummonItem(itr->first, itr->second);
itr++;
}
}
} }
return(false); return(false);
} }
@ -1404,8 +1416,25 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
} }
mysql_free_result(result); mysql_free_result(result);
} }
safe_delete_array(query);
// Pull the salvage list
qlen = MakeAnyLenString(&query, "SELECT item_id,salvagecount FROM tradeskill_recipe_entries"
" WHERE salvagecount>0 AND recipe_id=%u", recipe_id);
spec->onsalvage.clear();
if (RunQuery(query, qlen, errbuf, &result)) {
qcount = mysql_num_rows(result);
uint8 r;
for(r = 0; r < qcount; r++) {
row = mysql_fetch_row(result);
uint32 item = (uint32)atoi(row[0]);
uint8 num = (uint8)atoi(row[1]);
spec->onsalvage.push_back(pair<uint32,uint8>(item, num));
}
mysql_free_result(result);
}
safe_delete_array(query);
return(true); return(true);
} }

View File

@ -46,6 +46,7 @@ struct DBTradeskillRecipe_Struct {
bool replace_container; bool replace_container;
vector< pair<uint32,uint8> > onsuccess; vector< pair<uint32,uint8> > onsuccess;
vector< pair<uint32,uint8> > onfail; vector< pair<uint32,uint8> > onfail;
vector< pair<uint32,uint8> > onsalvage;
string name; string name;
uint8 must_learn; uint8 must_learn;
bool has_learnt; bool has_learnt;