func (g *Game) MakeHeatSeeker(pos linear.Vec2, entParams BaseEntParams, hsParams HeatSeekerParams) { mine := HeatSeeker{ BaseEnt: BaseEnt{ Side_: 10, Position: pos, }, HeatSeekerParams: hsParams, } mine.BaseEnt.StatsInst = stats.Make(stats.Base{ Health: entParams.Health, Mass: entParams.Mass, Size: entParams.Size, Acc: entParams.Acc, }) g.AddEnt(&mine) }
func (g *Game) MakeMine(pos, vel linear.Vec2, health, mass, damage, trigger float64) { mine := Mine{ BaseEnt: BaseEnt{ Side_: 10, Position: pos, Velocity: vel, }, Damage: damage, Trigger: trigger, } mine.BaseEnt.StatsInst = stats.Make(stats.Base{ Health: health, Mass: mass, Size: 5, }) g.AddEnt(&mine) }
func (g *Game) MakeControlPoints() { var cps []*ControlPoint for _, towerData := range g.Level.Room.Towers { cp := ControlPoint{ BaseEnt: BaseEnt{ Abilities_: []Ability{ability_makers["spawnCreeps"](map[string]float64{})}, Side_: towerData.Side, Position: towerData.Pos, Processes: make(map[int]Process), StatsInst: stats.Make(stats.Base{ Health: 100000, Mass: 1000000, Rate: 1, Size: 0, Vision: 900, }), }, Radius: 50, } cps = append(cps, &cp) g.AddEnt(&cp) if towerData.Side != -1 { cp.Controlled = true cp.Control = 1.0 cp.Controller = towerData.Side // Must do this after the call to AddEnt() because BindAi requires that // the ent's Gid has been set cp.BindAi("tower", g.local.Engine) } } // Now set up the target arrays for i := range cps { for _, index := range g.Level.Room.Towers[i].Targets { cps[i].Targets = append(cps[i].Targets, cps[index].Id()) } } }
func (g *Game) AddCreeps(pos linear.Vec2, count, side int, params map[string]interface{}) { if side < 0 || side >= len(g.Level.Room.SideData) { base.Error().Fatalf("Got side %d, but this level only supports sides from 0 to %d.", side, len(g.Level.Room.SideData)-1) return } for i := 0; i < count; i++ { var c CreepEnt c.StatsInst = stats.Make(stats.Base{ Health: 100, Mass: 250, Acc: 50.0, Rate: 0.0, Size: 8, Vision: 400, }) // Evenly space the players on a circle around the starting position. randAngle := rand.New(g.Rng).Float64() * math.Pi rot := (linear.Vec2{15, 0}).Rotate(randAngle + float64(i)*2*3.1415926535/float64(count)) c.Position = pos.Add(rot) c.Side_ = side c.Gid = g.NextGid() c.Abilities_ = append( c.Abilities_, ability_makers["asplode"](map[string]float64{"startRadius": 40, "endRadius": 70, "durationThinks": 50, "dps": 5})) // if playerData.gid[0:2] == "Ai" { // c.BindAi("simple", g.local.Engine) // } g.AddEnt(&c) c.BindAi("creep", g.local.Engine) for name, value := range params { c.ai.SetParam(name, value) } } }
func (g *Game) addPlayersToSide(playerDatas []addPlayerData, side int) { if side < 0 || side >= len(g.Level.Room.SideData) { base.Error().Fatalf("Got side %d, but this level only supports sides from 0 to %d.", len(g.Level.Room.SideData)-1) } for i, playerData := range playerDatas { var p PlayerEnt p.StatsInst = stats.Make(stats.Base{ Health: 1000, Mass: 750, Acc: 150.0, Turn: 0.07, Rate: 0.5, Size: 12, Vision: 500, }) // Evenly space the players on a circle around the starting position. rot := (linear.Vec2{25, 0}).Rotate(float64(i) * 2 * 3.1415926535 / float64(len(playerDatas))) p.Position = g.Level.Room.SideData[side].Base.Add(rot) p.Side_ = side p.Gid = playerData.gid p.Processes = make(map[int]Process) for _, ability := range g.Champs[playerData.champ].Abilities { p.Abilities_ = append( p.Abilities_, ability_makers[ability.Name](ability.Params)) } if playerData.gid[0:2] == "Ai" { // p.BindAi("simple", g.local.Engine) } g.AddEnt(&p) } }