From 1753d1fd24b62bf2a849692a01b1433ecbc6455f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20List=C3=ADk?= Date: Fri, 13 Oct 2023 14:07:09 +0200 Subject: [PATCH] spawn ground effects - using monsters, fix ground effects, fix spawns --- server/dungeonsandtrolls/commands.go | 9 +++++---- server/dungeonsandtrolls/game.go | 2 ++ server/dungeonsandtrolls/map.go | 11 +++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/server/dungeonsandtrolls/commands.go b/server/dungeonsandtrolls/commands.go index 993165c..30b4282 100644 --- a/server/dungeonsandtrolls/commands.go +++ b/server/dungeonsandtrolls/commands.go @@ -193,12 +193,12 @@ func TilesInRange(game *Game, startingPosition *api.Coordinates, rng int32) []*a } p := proto.Clone(startingPosition).(*api.Coordinates) for x := startingPosition.PositionX - rng; x <= startingPosition.PositionX+rng; x++ { - if x < 0 || x >= lc.Height { + if x < 0 || x >= lc.Width { continue } p.PositionX = x for y := startingPosition.PositionY - rng; y <= startingPosition.PositionY+rng; y++ { - if y < 0 || y >= lc.Width { + if y < 0 || y >= lc.Height { continue } p.PositionY = y @@ -358,7 +358,8 @@ func ExecuteSkill(game *Game, player gameobject.Skiller, su *api.SkillUse) error } } - if s.CasterEffects.Flags.GroundEffect { + // Ground effect + if s.CasterEffects.Flags.GroundEffect && s.TargetEffects != nil { game.LogEvent(&api.Event{ Type: &aoeEvent, Message: fmt.Sprintf("%s (%s): caused aoe ground effect", player.GetId(), player.GetName()), @@ -367,7 +368,7 @@ func ExecuteSkill(game *Game, player gameobject.Skiller, su *api.SkillUse) error Radius: pointy.Float32(float32(radiusValue)), }) - e, err := gameobject.EvaluateSkillAttributes(s.CasterEffects.Attributes, player.GetAttributes()) + e, err := gameobject.EvaluateSkillAttributes(s.TargetEffects.Attributes, player.GetAttributes()) if err != nil { return err } diff --git a/server/dungeonsandtrolls/game.go b/server/dungeonsandtrolls/game.go index 74bce26..e5ab8e7 100644 --- a/server/dungeonsandtrolls/game.go +++ b/server/dungeonsandtrolls/game.go @@ -742,9 +742,11 @@ func (g *Game) processCommands() { // TODO case *api.Droppable_Item: o.Item.Id = gameobject.GetNewId() + g.Register(o.Item) po.Items = append(po.Items, o.Item) case *api.Droppable_Monster: o.Monster.Id = gameobject.GetNewId() + g.Register(o.Monster) po.Monsters = append(po.Monsters, o.Monster) g.Register(gameobject.CreateMonster(o.Monster, c.GetPosition())) case *api.Droppable_Decoration: diff --git a/server/dungeonsandtrolls/map.go b/server/dungeonsandtrolls/map.go index 88e0e7d..eaf200e 100644 --- a/server/dungeonsandtrolls/map.go +++ b/server/dungeonsandtrolls/map.go @@ -7,6 +7,7 @@ import ( "github.com/gdg-garage/dungeons-and-trolls/server/dungeonsandtrolls/gameobject" "github.com/rs/zerolog/log" "github.com/solarlune/paths" + "go.openly.dev/pointy" "google.golang.org/protobuf/encoding/protojson" ) @@ -81,6 +82,7 @@ func parseLevel(level interface{}) (*api.Level, error) { return nil, err } } + // Ground effects return l, nil } @@ -247,6 +249,15 @@ func parseMapObjects(tile map[string]interface{}, o *api.MapObjects) error { o.Decorations = append(o.Decorations, i.Decoration) case *api.Droppable_Waypoint: o.Portal = i.Waypoint + case *api.Droppable_Skill: + // Spawn ground effects - using dummy monster + m := &api.Monster{ + Name: "dummy - ground effect", + Faction: "none", + Attributes: &api.Attributes{Life: pointy.Float32(0), Constant: pointy.Float32(1)}, + OnDeath: []*api.Droppable{d}} + nonNilMonster(m) + o.Monsters = append(o.Monsters, m) default: log.Info().Msgf("I found something(%T) %v", i, i) }