2020-07-04 00:48:31 -04:00
|
|
|
package d2object
|
|
|
|
|
|
|
|
import (
|
2020-07-06 20:12:53 -04:00
|
|
|
"math/rand"
|
|
|
|
|
2020-07-04 00:48:31 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Finds an init function for the given object
|
|
|
|
func initObject(ob *Object) bool {
|
|
|
|
funcs := map[int]func(*Object){
|
|
|
|
8: initTorch,
|
|
|
|
14: initTorch,
|
|
|
|
17: initWaypoint,
|
2020-07-06 20:12:53 -04:00
|
|
|
34: initTorchRnd,
|
2020-07-04 00:48:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fun, ok := funcs[ob.objectRecord.InitFn]
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
fun(ob)
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initializes torch/brazier type objects
|
|
|
|
func initTorch(ob *Object) {
|
|
|
|
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
|
2020-07-06 20:12:53 -04:00
|
|
|
ob.setMode("ON", 0, true)
|
2020-07-04 00:48:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func initWaypoint(ob *Object) {
|
|
|
|
// Turn these on unconditionally for now, they look nice :)
|
|
|
|
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
|
2020-07-06 20:12:53 -04:00
|
|
|
ob.setMode("ON", 0, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Randomly spawns in either NU or OP
|
|
|
|
func initTorchRnd(ob *Object) {
|
|
|
|
n := rand.Intn(2)
|
|
|
|
|
|
|
|
if n > 0 {
|
|
|
|
ob.setMode("NU", 0, true)
|
|
|
|
} else {
|
|
|
|
ob.setMode("OP", 0, true)
|
2020-07-04 00:48:31 -04:00
|
|
|
}
|
|
|
|
}
|