diff --git a/makefile b/makefile index 621244a72d..47a8dd198d 100644 --- a/makefile +++ b/makefile @@ -196,11 +196,22 @@ release: wowsimwotlk wowsimwotlk-windows.exe sim/core/proto/api.pb.go: proto/*.proto protoc -I=./proto --go_out=./sim/core ./proto/*.proto -.PHONY: lib -lib: +# Only useful for building the lib on a host platform that matches the target platform +.PHONY: locallib +locallib: protoc -I=./proto --go_out=./sim/core ./proto/*.proto go build -buildmode=c-shared -o wowsimwotlk.so ./sim/lib/library.go +.PHONY: nixlib +nixlib: + protoc -I=./proto --go_out=./sim/core ./proto/*.proto + GOOS=linux GOARCH=amd64 GOAMD64=v2 go build -buildmode=c-shared -o wowsimwotlk-linux.so ./sim/lib/library.go + +.PHONY: winlib +winlib: + protoc -I=./proto --go_out=./sim/core ./proto/*.proto + GOOS=windows GOARCH=amd64 GOAMD64=v2 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -buildmode=c-shared -o wowsimwotlk-windows.dll ./sim/lib/library.go + .PHONY: items items: sim/core/items/all_items.go sim/core/proto/api.pb.go diff --git a/proto/api.proto b/proto/api.proto index f1795bb646..d159f97d1b 100644 --- a/proto/api.proto +++ b/proto/api.proto @@ -110,6 +110,7 @@ message SimOptions { bool debug_first_iteration = 6; bool is_test = 5; // Only used internally. bool save_all_values = 7; // Only used internally. + bool interactive = 8; // Enables interactive mode. } // The aggregated results from all uses of a particular action. diff --git a/sim/core/attack.go b/sim/core/attack.go index f2b611d5f3..56f6bcd0fb 100644 --- a/sim/core/attack.go +++ b/sim/core/attack.go @@ -505,7 +505,9 @@ func (aa *AutoAttacks) TrySwingMH(sim *Simulation, target *Unit) { aa.MainhandSwingAt = sim.CurrentTime + aa.MainhandSwingSpeed() aa.previousMHSwingAt = sim.CurrentTime aa.PreviousSwingAt = sim.CurrentTime - aa.agent.OnAutoAttack(sim, attackSpell) + if !sim.Options.Interactive { + aa.agent.OnAutoAttack(sim, attackSpell) + } } // Optionally replaces the given swing spell with an Agent-specified MH Swing replacer. @@ -549,7 +551,9 @@ func (aa *AutoAttacks) TrySwingOH(sim *Simulation, target *Unit) { aa.OHAuto.Cast(sim, target) aa.OffhandSwingAt = sim.CurrentTime + aa.OffhandSwingSpeed() aa.PreviousSwingAt = sim.CurrentTime - aa.agent.OnAutoAttack(sim, aa.OHAuto) + if !sim.Options.Interactive { + aa.agent.OnAutoAttack(sim, aa.OHAuto) + } } // Performs an autoattack using the ranged weapon, if the ranged CD is ready. @@ -561,7 +565,9 @@ func (aa *AutoAttacks) TrySwingRanged(sim *Simulation, target *Unit) { aa.RangedAuto.Cast(sim, target) aa.RangedSwingAt = sim.CurrentTime + aa.RangedSwingSpeed() aa.PreviousSwingAt = sim.CurrentTime - aa.agent.OnAutoAttack(sim, aa.RangedAuto) + if !sim.Options.Interactive { + aa.agent.OnAutoAttack(sim, aa.RangedAuto) + } } func (aa *AutoAttacks) UpdateSwingTime(sim *Simulation) { diff --git a/sim/core/character.go b/sim/core/character.go index fa456f66fe..2234184075 100644 --- a/sim/core/character.go +++ b/sim/core/character.go @@ -378,6 +378,14 @@ func (character *Character) initialize(agent Agent) { return } + if sim.Options.Interactive { + if character.GCD.IsReady(sim) { + sim.NeedsInput = true + character.doNothing = false + } + return + } + if character.Rotation != nil { character.Rotation.DoNextAction(sim) return diff --git a/sim/core/energy.go b/sim/core/energy.go index 3362d448e7..d89a007439 100644 --- a/sim/core/energy.go +++ b/sim/core/energy.go @@ -40,7 +40,7 @@ func (unit *Unit) EnableEnergyBar(maxEnergy float64, onEnergyGain OnEnergyGain) unit: unit, maxEnergy: MaxFloat(100, maxEnergy), onEnergyGain: func(sim *Simulation) { - if !unit.IsWaitingForEnergy() || unit.DoneWaitingForEnergy(sim) { + if !sim.Options.Interactive && (!unit.IsWaitingForEnergy() || unit.DoneWaitingForEnergy(sim)) { onEnergyGain(sim) } }, diff --git a/sim/core/rage.go b/sim/core/rage.go index 808931dcd0..18897d48f0 100644 --- a/sim/core/rage.go +++ b/sim/core/rage.go @@ -138,7 +138,9 @@ func (rb *rageBar) AddRage(sim *Simulation, amount float64, metrics *ResourceMet } rb.currentRage = newRage - rb.onRageGain(sim) + if !sim.Options.Interactive { + rb.onRageGain(sim) + } } func (rb *rageBar) SpendRage(sim *Simulation, amount float64, metrics *ResourceMetrics) { diff --git a/sim/core/sim.go b/sim/core/sim.go index 5e5a637287..4cd4773702 100644 --- a/sim/core/sim.go +++ b/sim/core/sim.go @@ -28,6 +28,7 @@ type Simulation struct { pendingActions []*PendingAction CurrentTime time.Duration // duration that has elapsed in the sim since starting Duration time.Duration // Duration of current iteration + NeedsInput bool // Sim is in interactive mode and needs input ProgressReport func(*proto.ProgressMetrics) diff --git a/sim/lib/library.go b/sim/lib/library.go index aa915a129d..d3af7dc7ac 100644 --- a/sim/lib/library.go +++ b/sim/lib/library.go @@ -70,6 +70,9 @@ func trySpell(act int) bool { if spell.CanCast(_active_sim, target) { casted = spell.Cast(_active_sim, target) } + if casted { + _active_sim.NeedsInput = false + } return casted } @@ -221,6 +224,11 @@ func step() bool { return _active_sim.Step(core.NeverExpires) } +//export needsInput +func needsInput() bool { + return _active_sim.NeedsInput +} + //export cleanup func cleanup() { _active_sim.Cleanup()