Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions db/skill_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -1693,19 +1693,6 @@ func SkillTreeSkillGroups(job int) []SkillTreeGroup {
return groups
}

func SkillTreeSkillIDs(job int) []uint16 {
groups := SkillTreeSkillGroups(job)
total := 0
for _, group := range groups {
total += len(group.SkillIDs)
}
out := make([]uint16, 0, total)
for _, group := range groups {
out = append(out, group.SkillIDs...)
}
return out
}

// SkillTreeLayoutJobs returns the client skill-tree tables which contribute
// positions to a class-level tab. Base and transcendent second classes share
// one tab, matching the classic expanded skill window.
Expand Down
8 changes: 8 additions & 0 deletions db/skill_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import (
"testing"
)

func SkillTreeSkillIDs(job int) []uint16 {
var ids []uint16
for _, group := range SkillTreeSkillGroups(job) {
ids = append(ids, group.SkillIDs...)
}
return ids
}

func TestSkillTreeGroupsClassifyTranscendentSkillsAsSecondClass(t *testing.T) {
groups := SkillTreeSkillGroups(JobKnightH)
if len(groups) != 2 {
Expand Down
10 changes: 0 additions & 10 deletions db/skill_units.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ type SkillUnitModelSpec struct {
HasFixedFrame bool
}

func (s SkillUnitModelSpec) ModelPaths() []string {
if len(s.FallbackModelPaths) == 0 {
return []string{s.ModelPath}
}
paths := make([]string, 0, len(s.FallbackModelPaths)+1)
paths = append(paths, s.ModelPath)
paths = append(paths, s.FallbackModelPaths...)
return paths
}

func rsmTrapModelSpec(robrPath string, fallbackPaths []string, triggerEffectID int) SkillUnitModelSpec {
return SkillUnitModelSpec{
ModelPath: robrPath,
Expand Down
2 changes: 1 addition & 1 deletion game/actor_shadow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestActorShadowRemainsAfterMaceSwing(t *testing.T) {
player := worldstate.Actor{ID: 200, Job: db.JobAcolyte, Weapon: db.WeaponMace}
mode := &WorldMode{actorAnims: map[uint32]actorAnimation{
player.ID: {
actionFamily: attackActionFamilyForActor(player),
actionFamily: attackActionFamilyForActorWithResources(nil, player),
started: now,
duration: time.Second,
next: readyFightAnimation(now.Add(time.Second)),
Expand Down
25 changes: 2 additions & 23 deletions game/battle.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ func actionAnimationDuration(action res.ACTAction, fallback time.Duration) time.
return duration
}

func combatHitDelayFromAction(action res.ACTAction, duration time.Duration) time.Duration {
return combatMotionDelayFromAction(action, duration, firstActionSoundMotion(action))
}

func combatMotionDelayFromAction(action res.ACTAction, duration time.Duration, motion int) time.Duration {
if duration <= 0 {
return 0
Expand Down Expand Up @@ -214,7 +210,6 @@ type actorLife struct {
hunger int
maxHunger int
hasHunger bool
updatedAt time.Time
}

type actorCastBar struct {
Expand Down Expand Up @@ -1011,9 +1006,8 @@ func (m *WorldMode) applyActorHPUpdate(update network.ActorHPUpdate) {
m.actorLife = make(map[uint32]actorLife)
}
m.actorLife[update.ID] = actorLife{
hp: hp,
maxHP: update.MaxHP,
updatedAt: time.Now(),
hp: hp,
maxHP: update.MaxHP,
}
glog.Debugf("actor hp id=%d hp=%d max_hp=%d tiny=%t", update.ID, hp, update.MaxHP, update.Tiny)
}
Expand Down Expand Up @@ -1328,10 +1322,6 @@ func (m *WorldMode) actorAnimation(id uint32, now time.Time) (actorAnimation, bo
return anim, true
}

func attackActionFamilyForActor(actor world.Actor) int {
return attackActionFamilyForActorWithResources(nil, actor)
}

func attackActionFamilyForActorWithResources(manager *res.Manager, actor world.Actor) int {
if actorIsMercenary(actor) {
return mercenaryAttackActionFamily(int(actor.Job), actor.Sex, int(actor.Weapon))
Expand Down Expand Up @@ -1552,16 +1542,6 @@ func normalAttackTargetWithinRange(playerX, playerY, targetX, targetY, attackRan
return dx*dx+dy*dy <= attackRange*attackRange
}

func attackApproachCell(ctx client.Context, actor world.Actor, attackRange int) (int, int, bool) {
playerX, playerY := currentPlayerCell(ctx, time.Now())
return attackApproachCellFrom(ctx, playerX, playerY, actor, attackRange)
}

func attackApproachCellFrom(ctx client.Context, sourceX, sourceY int, actor world.Actor, attackRange int) (int, int, bool) {
targetX, targetY := actorCurrentCell(actor, time.Now())
return normalAttackApproachCellFromTarget(ctx, sourceX, sourceY, targetX, targetY, attackRange)
}

func normalAttackApproachCellFromTarget(ctx client.Context, sourceX, sourceY, targetX, targetY int, attackRange int) (int, int, bool) {
attackRange = maxInt(1, attackRange)
if attackRange > 1 {
Expand Down Expand Up @@ -1824,7 +1804,6 @@ func (m *WorldMode) startActorDeath(ctx client.Context, id uint32) {
if m.actorLife != nil {
if life, ok := m.actorLife[id]; ok {
life.hp = 0
life.updatedAt = now
m.actorLife[id] = life
}
}
Expand Down
2 changes: 0 additions & 2 deletions game/companion.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ func (m *WorldMode) applyCompanionLife(ctx client.Context, id uint32, hp, maxHP,
life.maxSP = maxSP
life.hasSP = true
}
life.updatedAt = time.Now()
m.actorLife[id] = life
}

Expand Down Expand Up @@ -343,7 +342,6 @@ func (m *WorldMode) applyCompanionHunger(ctx client.Context, id uint32, hunger,
life.hunger = clampInt(hunger, 0, maxHunger)
life.maxHunger = maxHunger
life.hasHunger = true
life.updatedAt = time.Now()
m.actorLife[id] = life
}

Expand Down
3 changes: 1 addition & 2 deletions game/companion_ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type companionAI struct {
trace bool
magicNumber2Checked bool
magicNumber2Limit int
lastLoadErr error
}

type companionAISnapshot struct {
Expand Down Expand Up @@ -166,7 +165,7 @@ func (m *WorldMode) updateCompanionAIKind(ctx client.Context, kind companionAIKi
if ai == nil {
loaded, err := newCompanionAI(ctx, m, kind, now)
if err != nil {
m.setCompanionAIForKind(kind, &companionAI{kind: kind, custom: useCustom, disabled: true, lastLoadErr: err})
m.setCompanionAIForKind(kind, &companionAI{kind: kind, custom: useCustom, disabled: true})
glog.Debugf("%s AI unavailable: %v", companionAIKindName(kind), err)
return
}
Expand Down
29 changes: 13 additions & 16 deletions game/effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,6 @@ const (
effectEmotion = 1000000
)

const (
effectBottomDissonance = 277
effectBottomUglyDance = 290
)

const (
effectSoulBreaker = 361
effectLevel99Aura1 = 362
Expand Down Expand Up @@ -1808,10 +1803,6 @@ func buildItemEffects() map[uint16]itemEffectSpec {
return effects
}

func itemUseEffectIDs(itemID uint16) []int {
return itemUseEffectSpec(itemID).effectIDs
}

func itemUseEffectSpec(itemID uint16) itemEffectSpec {
return itemEffectSpecs[itemID]
}
Expand Down Expand Up @@ -1913,10 +1904,6 @@ func cloneSkillActionSpec(spec *skillActionSpec) *skillActionSpec {
return &clone
}

func (s skillActionSpec) actionFamilyForActor(actor worldstate.Actor) int {
return s.actionFamilyForActorWithResources(nil, actor)
}

func (s skillActionSpec) actionFamilyForActorWithResources(manager *res.Manager, actor worldstate.Actor) int {
if s.action == skillActorActionNone {
return -1
Expand Down Expand Up @@ -2489,7 +2476,7 @@ func effectFuncAdapterForName(name string) effectFuncAdapter {
}
}

func (m *WorldMode) drawWorldEffects(screen *render.Frame, ctx client.Context, projection sceneProjection, now time.Time) {
func (m *WorldMode) drawWorldEffects(screen *render.Frame, ctx client.Context, projection sceneProjection, now time.Time, beforeEntities bool) {
if len(m.worldEffects) == 0 || screen == nil || ctx.World == nil {
return
}
Expand All @@ -2502,9 +2489,16 @@ func (m *WorldMode) drawWorldEffects(screen *render.Frame, ctx client.Context, p
if effect.expired(now) {
continue
}
spec, ok := worldEffectSpecForID(effect.effectID)
spec, ok := m.effectSpecs[effect.effectID]
if !ok {
continue
spec, ok = worldEffectSpecForID(effect.effectID)
if !ok {
continue
}
if m.effectSpecs == nil {
m.effectSpecs = make(map[int]worldEffectSpec)
}
m.effectSpecs[effect.effectID] = spec
}
if now.Before(effect.starts) {
active = append(active, effect)
Expand All @@ -2518,6 +2512,9 @@ func (m *WorldMode) drawWorldEffects(screen *render.Frame, ctx client.Context, p
active = append(active, effect)
anchor := effectWorldAnchor(ctx, effect, now)
for index, component := range spec.components {
if component.renderBefore != beforeEntities {
continue
}
if effect.persistent {
component.repeat = true
}
Expand Down
3 changes: 3 additions & 0 deletions game/effects_3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (m *WorldMode) draw3DEffect(screen *render.Frame, ctx client.Context, proje
drawX := worldX + offsetX
drawY := worldY + offsetY
drawZ := worldZ + offsetZ
if component.shadowTexture {
drawZ = terrainHeightAtRenderPoint(ctx.World, drawX, drawY) + actorShadowTerrainLift
}
if component.textureFile != "" || len(component.textureFiles) > 0 {
texture := m.effectTextureFrame(ctx.Resources, component, progress)
if texture == nil {
Expand Down
6 changes: 3 additions & 3 deletions game/effects_hit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestHitRingGeometryAndCapturedFacing(t *testing.T) {
if !mode.addWorldEffectAt(ctx, effectHit1, 42, starts) {
t.Fatal("failed to add regular hit")
}
mode.drawWorldEffects(render.NewFrame(800, 600), ctx, sceneProjection{}, starts)
mode.drawWorldEffects(render.NewFrame(800, 600), ctx, sceneProjection{}, starts, false)
// Turning after the hit must not rotate the cylinder mid-flight.
world.Actors[42] = worldstate.Actor{ID: 42, Dir: (tt.dir + 2) % 8}
frame := render.NewFrame(800, 600)
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestHitRingCapturesFacingAtImpact(t *testing.T) {
starts := time.Unix(100, 0)
mode.addWorldEffectAt(ctx, effectHit1, 42, starts)
draw := func(at time.Time) {
mode.drawWorldEffects(render.NewFrame(800, 600), ctx, sceneProjection{}, at)
mode.drawWorldEffects(render.NewFrame(800, 600), ctx, sceneProjection{}, at, false)
}
draw(starts.Add(-time.Millisecond))
if mode.worldEffects[0].hasActorTransform {
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestHitRingDrawsWithOldROData(t *testing.T) {
projection := newSceneProjectionForTarget(800, 600, 10.5, 20.5, 0)
for _, elapsed := range []time.Duration{0, 100 * time.Millisecond, 200 * time.Millisecond} {
frame := render.NewFrame(800, 600)
mode.drawWorldEffects(frame, ctx, projection, starts.Add(elapsed))
mode.drawWorldEffects(frame, ctx, projection, starts.Add(elapsed), false)
commands := reflect.ValueOf(frame).Elem().FieldByName("worldCommands")
rings := 0
for i := 0; i < commands.Len(); i++ {
Expand Down
4 changes: 2 additions & 2 deletions game/effects_original_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func TestOriginalEffectsRenderWithOldROAssets(t *testing.T) {
t.Fatalf("effect %d failed to spawn", id)
}
frame := render.NewFrame(800, 600)
mode.drawWorldEffects(frame, ctx, projection, starts.Add(2*db.EffectFrameDuration))
mode.drawWorldEffects(frame, ctx, projection, starts.Add(2*db.EffectFrameDuration), false)
if len(mode.textureMiss) > 0 || len(mode.effectViewMiss) > 0 {
t.Fatalf("effect %d missing resources: %v %v", id, mode.textureMiss, mode.effectViewMiss)
}
Expand All @@ -284,7 +284,7 @@ func TestOriginalEffectsRenderWithOldROAssets(t *testing.T) {
if id != effectBlessing {
world.Actors[42] = worldstate.Actor{ID: 42, X: 30, Y: 40, Dir: 4}
moved := render.NewFrame(800, 600)
mode.drawWorldEffects(moved, ctx, projection, starts.Add(2*db.EffectFrameDuration))
mode.drawWorldEffects(moved, ctx, projection, starts.Add(2*db.EffectFrameDuration), false)
if !reflect.DeepEqual(frame, moved) {
t.Fatalf("effect %d moved with the target instead of staying at impact", id)
}
Expand Down
Loading
Loading