Skip to content

Commit

Permalink
Parse talents from protoreflection so they don't need to be included …
Browse files Browse the repository at this point in the history
…separately in protos
  • Loading branch information
jimmyt857 committed Jan 10, 2023
1 parent e347696 commit 0695796
Show file tree
Hide file tree
Showing 120 changed files with 8,854 additions and 10,330 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ sim/web/__debug_bin
wowsimwotlk

# old result file
TestDestruction.results
sim/priest/healing/TestHealing.results
TestHunter.results
TestRotation.results
TestWarlock.results

#macos
.DS_Store
Expand Down
3 changes: 2 additions & 1 deletion proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ message Player {
TankDeathknight tank_deathknight = 32;
}

string talentsString = 17;
// Talents in wowhead format, e.g. '01102123133-12312312-'
string talents_string = 17;
Glyphs glyphs = 28;
Profession profession1 = 29;
Profession profession2 = 30;
Expand Down
4 changes: 0 additions & 4 deletions proto/deathknight.proto
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ message Deathknight {
bool use_gargoyle = 23;
}
Rotation rotation = 1;

DeathknightTalents talents = 2;

message Options {
double starting_runic_power = 1;
Expand Down Expand Up @@ -287,8 +285,6 @@ message TankDeathknight {
BloodSpell blood_spell = 3;
}
Rotation rotation = 1;

DeathknightTalents talents = 2;

message Options {
double starting_runic_power = 1;
Expand Down
42 changes: 17 additions & 25 deletions proto/druid.proto
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ message BalanceDruid {
bool maintain_faerie_fire = 10;
int32 player_latency = 11;
}

Rotation rotation = 1;
DruidTalents talents = 2;

message Options {
RaidTarget innervate_target = 1;
Expand All @@ -192,33 +190,31 @@ message FeralDruid {
Mangle = 1;
Lacerate = 2;
}
enum BiteModeType {
enum BiteModeType {
Emperical = 0;
Analytical = 1;
}

BearweaveType bear_weave_type = 1;
bool maintain_faerie_fire = 2;
int32 min_combos_for_rip = 3;
bool use_rake = 4;
bool use_bite = 5;
bool mangle_spam = 6;
float bite_time = 7;
int32 min_combos_for_bite = 8;
int32 berserk_bite_thresh = 9;
bool powerbear = 10;
float min_roar_offset = 11;
BiteModeType bite_mode_type = 12;
float hot_uptime = 13;
bool snek_weave = 14;
bool flower_weave = 15;
int32 raid_targets = 16;
bool manual_params = 17;
bool maintain_faerie_fire = 2;
int32 min_combos_for_rip = 3;
bool use_rake = 4;
bool use_bite = 5;
bool mangle_spam = 6;
float bite_time = 7;
int32 min_combos_for_bite = 8;
int32 berserk_bite_thresh = 9;
bool powerbear = 10;
float min_roar_offset = 11;
BiteModeType bite_mode_type = 12;
float hot_uptime = 13;
bool snek_weave = 14;
bool flower_weave = 15;
int32 raid_targets = 16;
bool manual_params = 17;
}
Rotation rotation = 1;

DruidTalents talents = 2;

message Options {
RaidTarget innervate_target = 1;
int32 latency_ms = 2;
Expand All @@ -238,8 +234,6 @@ message FeralTankDruid {
}
Rotation rotation = 1;

DruidTalents talents = 2;

message Options {
RaidTarget innervate_target = 1;
double starting_rage = 2;
Expand All @@ -252,8 +246,6 @@ message RestorationDruid {
}
Rotation rotation = 1;

DruidTalents talents = 2;

message Options {
RaidTarget innervate_target = 1;
}
Expand Down
2 changes: 0 additions & 2 deletions proto/hunter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ message Hunter {
bool allow_explosive_shot_downrank = 10;
}
Rotation rotation = 1;

HunterTalents talents = 2;

message Options {
enum Ammo {
Expand Down
2 changes: 0 additions & 2 deletions proto/mage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ message Mage {
AoeRotation aoe = 7;
}
Rotation rotation = 1;

MageTalents talents = 2;

message Options {
enum ArmorType {
Expand Down
17 changes: 0 additions & 17 deletions proto/paladin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,16 @@ message RetributionPaladin {
RotationType type = 9;

bool use_divine_plea = 11;

bool avoid_clipping_consecration = 12;

bool hold_last_avenging_wrath_until_execution = 13;
}

Rotation rotation = 1;

PaladinTalents talents = 2;

message Options {
PaladinJudgement judgement = 1;

PaladinSeal seal = 2;

PaladinAura aura = 3;

double damage_taken_per_second = 4;

bool use_avenging_wrath = 5;
}
Options options = 3;
Expand Down Expand Up @@ -238,17 +229,11 @@ message ProtectionPaladin {
}
Rotation rotation = 1;

PaladinTalents talents = 2;

message Options {
PaladinJudgement judgement = 1;

PaladinSeal seal = 2;

PaladinAura aura = 3;

double damage_taken_per_second = 4;

bool use_avenging_wrath = 5;
}
Options options = 3;
Expand All @@ -259,8 +244,6 @@ message HolyPaladin {
}
Rotation rotation = 1;

PaladinTalents talents = 2;

message Options {
PaladinJudgement judgement = 1;
PaladinAura aura = 2;
Expand Down
6 changes: 0 additions & 6 deletions proto/priest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ message ShadowPriest {
double latency = 3; // Latency between actions
}
Rotation rotation = 1;

PriestTalents talents = 2;

message Options {
enum Armor {
Expand All @@ -178,8 +176,6 @@ message SmitePriest {
double allowed_holy_fire_delay_ms = 6;
}
Rotation rotation = 1;

PriestTalents talents = 2;

message Options {
bool use_inner_fire = 3;
Expand Down Expand Up @@ -213,8 +209,6 @@ message HealingPriest {
CustomRotation custom_rotation = 2;
}
Rotation rotation = 1;

PriestTalents talents = 2;

message Options {
bool use_inner_fire = 3;
Expand Down
2 changes: 0 additions & 2 deletions proto/rogue.proto
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ message Rogue {
int32 envenom_energy_threshold = 16;
}
Rotation rotation = 1;

RogueTalents talents = 2;

message Options {
RaidTarget tricks_of_the_trade_target = 1;
Expand Down
3 changes: 0 additions & 3 deletions proto/shaman.proto
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ message ElementalShaman {
}

Rotation rotation = 1;
ShamanTalents talents = 2;
Options options = 3;
}

Expand Down Expand Up @@ -303,7 +302,6 @@ message EnhancementShaman {
}

Rotation rotation = 1;
ShamanTalents talents = 2;
Options options = 3;
}

Expand All @@ -319,6 +317,5 @@ message RestorationShaman {
}

Rotation rotation = 1;
ShamanTalents talents = 2;
Options options = 3;
}
3 changes: 0 additions & 3 deletions proto/warlock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ message Warlock {
Type type = 8;
bool use_infernal = 9;
}

Rotation rotation = 1;

WarlockTalents talents = 2;

message Options {
enum Summon {
Expand Down
6 changes: 1 addition & 5 deletions proto/warrior.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ message WarriorTalents {
int32 two_handed_weapon_specialization = 11;
int32 taste_for_blood = 12;
int32 poleaxe_specialization = 13;
bool sweeping_strikes = 14;
bool sweeping_strikes = 14;
int32 mace_specialization = 15;
int32 sword_specialization = 16;
int32 weapon_mastery = 17;
Expand Down Expand Up @@ -193,8 +193,6 @@ message Warrior {
}
Rotation rotation = 1;

WarriorTalents talents = 2;

message Options {
double starting_rage = 1;
bool use_recklessness = 2;
Expand Down Expand Up @@ -241,8 +239,6 @@ message ProtectionWarrior {
}
Rotation rotation = 1;

WarriorTalents talents = 2;

message Options {
double starting_rage = 1;

Expand Down
26 changes: 26 additions & 0 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

"github.com/wowsims/wotlk/sim/core/proto"
"github.com/wowsims/wotlk/sim/core/stats"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/reflect/protoreflect"
)

type CharacterBuildPhase uint8
Expand Down Expand Up @@ -637,3 +639,27 @@ func GetPrimaryTalentTreeIndex(talentStr string) uint8 {

return uint8(bestTree)
}

// Uses proto reflection to set fields in a talents proto (e.g. MageTalents,
// WarriorTalents) based on a talentsStr. treeSizes should contain the number
// of talents in each tree, usually around 30. This is needed because talent
// strings truncate 0's at the end of each tree so we can't infer the start index
// of the tree from the string.
func FillTalentsProto(data protoreflect.Message, talentsStr string, treeSizes [3]int) {
treeStrs := strings.Split(talentsStr, "-")
fieldDescriptors := data.Descriptor().Fields()

var offset int
for treeIdx, treeStr := range treeStrs {
for talentIdx, talentValStr := range treeStr {
talentVal, _ := strconv.Atoi(string(talentValStr))
fd := fieldDescriptors.ByNumber(protowire.Number(offset + talentIdx + 1))
if fd.Kind() == protoreflect.BoolKind {
data.Set(fd, protoreflect.ValueOfBool(talentVal == 1))
} else { // Int32Kind
data.Set(fd, protoreflect.ValueOfInt32(int32(talentVal)))
}
}
offset += treeSizes[treeIdx]
}
}
Loading

0 comments on commit 0695796

Please sign in to comment.