Skip to content
This repository was archived by the owner on Dec 4, 2020. It is now read-only.

Commit 2fe384b

Browse files
authored
Merge pull request #1072 from Xaver-DaRed/crafting-fixes
Crafting: Various Fixes
2 parents a95781b + fcbcaed commit 2fe384b

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/map/utils/synthutils.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ bool isRightRecipe(CCharEntity* PChar)
117117
uint16 skillValue = 0;
118118
uint16 currentSkill = 0;
119119

120-
for (uint8 skillID = 49; skillID < 57; ++skillID) // range for all 8 synth skills
120+
for (uint8 skillID = SKILL_WOODWORKING; skillID <= SKILL_COOKING; ++skillID) // range for all 8 synth skills
121121
{
122122
skillValue = (uint16)Sql_GetUIntData(SqlHandle,(skillID-49+2));
123123
currentSkill = PChar->RealSkills.skill[skillID];
@@ -235,7 +235,7 @@ uint8 calcSynthResult(CCharEntity* PChar)
235235
double chance = 0;
236236
double random = tpzrand::GetRandomNumber(1.);
237237

238-
for(uint8 skillID = 49; skillID < 57; ++skillID)
238+
for (uint8 skillID = SKILL_WOODWORKING; skillID <= SKILL_COOKING; ++skillID)
239239
{
240240
uint8 checkSkill = PChar->CraftContainer->getQuantity(skillID-40);
241241
if(checkSkill != 0)
@@ -410,7 +410,7 @@ uint8 calcSynthResult(CCharEntity* PChar)
410410

411411
int32 doSynthSkillUp(CCharEntity* PChar)
412412
{
413-
for(uint8 skillID = 49; skillID < 57; ++skillID) // Check for all skills involved in a recipe, to check for skill up
413+
for (uint8 skillID = SKILL_WOODWORKING; skillID <= SKILL_COOKING; ++skillID) // Check for all skills involved in a recipe, to check for skill up
414414
{
415415
if (PChar->CraftContainer->getQuantity(skillID-40) == 0) // Get the required skill level for the recipe
416416
{
@@ -448,9 +448,9 @@ int32 doSynthSkillUp(CCharEntity* PChar)
448448

449449
if (random < skillUpChance) // If character skills up
450450
{
451-
int32 skillAmount = 1;
451+
int32 skillUpAmount = 1;
452452

453-
if (charSkill < map_config.craft_common_cap) // no skill ups over 0.1 happen over level cap
453+
if (charSkill < 600) // no skill ups over 0.1 happen over level 60
454454
{
455455
int32 satier = 0;
456456
double chance = 0;
@@ -470,7 +470,7 @@ int32 doSynthSkillUp(CCharEntity* PChar)
470470
for(uint8 i = 0; i < 4; i ++) // cicle up to 4 times until cap (0.5) or break. The lower the satier, the more likely it will break
471471
{
472472
#ifdef _TPZ_SYNTH_DEBUG_MESSAGES_
473-
ShowDebug(CL_CYAN"SkillAmount Tier: %i Random: %g\n" CL_RESET, satier, random);
473+
ShowDebug(CL_CYAN"SkillUpAmount Tier: %i Random: %g\n" CL_RESET, satier, random);
474474
#endif
475475

476476
switch(satier)
@@ -486,67 +486,71 @@ int32 doSynthSkillUp(CCharEntity* PChar)
486486
if(chance < random)
487487
break;
488488

489-
skillAmount++;
489+
skillUpAmount++;
490490
satier--;
491491
}
492492
}
493493

494494
// Do craft amount multiplier
495495
if (map_config.craft_amount_multiplier > 1)
496496
{
497-
skillAmount += (int32)(skillAmount * map_config.craft_amount_multiplier);
498-
if (skillAmount > 9)
497+
skillUpAmount += (int32)(skillUpAmount * map_config.craft_amount_multiplier);
498+
if (skillUpAmount > 9)
499499
{
500-
skillAmount = 9;
500+
skillUpAmount = 9;
501501
}
502502
}
503503

504504
// Cap skill gain if character hits the current cap
505-
if((skillAmount + charSkill) > maxSkill)
505+
if((skillUpAmount + charSkill) > maxSkill)
506506
{
507-
skillAmount = maxSkill - charSkill;
507+
skillUpAmount = maxSkill - charSkill;
508508
}
509509

510-
uint16 skillCumulation = skillAmount;
510+
uint16 skillCumulation = skillUpAmount;
511511
uint8 skillHighest = skillID;
512+
uint16 skillHighestValue = map_config.craft_common_cap;
512513

513-
if ((charSkill + skillAmount) > map_config.craft_common_cap) // If character is using the specialization system
514+
if ((charSkill + skillUpAmount) > map_config.craft_common_cap) // If character is using the specialization system
514515
{
515516
// Cycle through all skills
516-
for (int i = SKILL_WOODWORKING; i <= SKILL_COOKING; i++)
517+
for (uint8 i = SKILL_WOODWORKING; i <= SKILL_COOKING; i++)
517518
{
518519
if (PChar->RealSkills.skill[i] > map_config.craft_common_cap) // If the skill being checked is above the cap from wich spezialitation points start counting.
519520
{
520521
skillCumulation += (PChar->RealSkills.skill[i] - map_config.craft_common_cap); //Add to the ammount of specialization points in use.
521-
if (skillID != i && PChar->RealSkills.skill[i] > PChar->RealSkills.skill[skillHighest]) //Set the ID of the highest craft UNLESS it's the craft currently in use.
522+
if (skillID != i && PChar->RealSkills.skill[i] > skillHighestValue) //Set the ID of the highest craft UNLESS it's the craft currently in use.
522523
{
523524
skillHighest = i;
525+
skillHighestValue = PChar->RealSkills.skill[i];
524526
}
525527
}
526528
}
527529
}
528530

529-
PChar->RealSkills.skill[skillID] += skillAmount;
530-
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillID, skillAmount, 38));
531+
PChar->RealSkills.skill[skillID] += skillUpAmount;
532+
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillID, skillUpAmount, 38));
531533

532-
if ((charSkill / 10) < (charSkill + skillAmount) / 10)
534+
if ((charSkill / 10) < (charSkill + skillUpAmount) / 10)
533535
{
534536
PChar->WorkingSkills.skill[skillID] += 0x20;
535537

536538
PChar->pushPacket(new CCharSkillsPacket(PChar));
537-
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillID, (charSkill + skillAmount) / 10, 53));
539+
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillID, (charSkill + skillUpAmount) / 10, 53));
538540
}
539541

540542
charutils::SaveCharSkills(PChar, skillID);
541543

542544
if (skillHighest != 0 && skillCumulation > map_config.craft_specialization_points)
543545
{
544-
PChar->RealSkills.skill[skillHighest] -= skillAmount;
546+
PChar->RealSkills.skill[skillHighest] -= skillUpAmount;
547+
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillHighest, skillUpAmount, 310));
545548

546-
if ((PChar->RealSkills.skill[skillHighest] + skillAmount) / 10 > (PChar->RealSkills.skill[skillHighest]) / 10)
549+
if ((PChar->RealSkills.skill[skillHighest] + skillUpAmount) / 10 > (PChar->RealSkills.skill[skillHighest]) / 10)
547550
{
548551
PChar->WorkingSkills.skill[skillHighest] -= 0x20;
549552
PChar->pushPacket(new CCharSkillsPacket(PChar));
553+
PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, skillHighest, (PChar->RealSkills.skill[skillHighest] - skillUpAmount) / 10, 53));
550554
}
551555

552556
charutils::SaveCharSkills(PChar, skillHighest);

0 commit comments

Comments
 (0)