Skip to content

Commit

Permalink
spawn ground effects - using monsters, fix ground effects, fix spawns
Browse files Browse the repository at this point in the history
  • Loading branch information
tivvit committed Oct 13, 2023
1 parent 16e189e commit 1753d1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/dungeonsandtrolls/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()),
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions server/dungeonsandtrolls/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions server/dungeonsandtrolls/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -81,6 +82,7 @@ func parseLevel(level interface{}) (*api.Level, error) {
return nil, err
}
}
// Ground effects
return l, nil
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 1753d1f

Please sign in to comment.