server/corpse_placement.go (1085B)
1 package main 2 3 import "ao/server/gamedata" 4 5 func (server *server) placeCorpse(character *character) { 6 pose, exists := gamedata.CorpsePoses[character.monsterData] 7 if !exists { 8 return 9 } 10 ground := server.terrain[character.playfield] 11 if ground == nil { 12 return 13 } 14 15 // The native corpse stays upright. Raise its held mesh until its sampled 16 // vertices clear the terrain, retaining the death's horizontal position/yaw. 17 x, y, z, w := character.rotation[0], character.rotation[1], character.rotation[2], character.rotation[3] 18 rotation := [3][3]float32{ 19 {1 - 2*y*y - 2*z*z, 2*x*y + 2*z*w, 2*x*z - 2*y*w}, 20 {2*x*y - 2*z*w, 1 - 2*x*x - 2*z*z, 2*y*z + 2*x*w}, 21 {2*x*z + 2*y*w, 2*y*z - 2*x*w, 1 - 2*x*x - 2*y*y}, 22 } 23 var lift float32 24 for _, vertex := range pose.Vertices { 25 point := character.position 26 for axis := range 3 { 27 for component := range 3 { 28 point[axis] += vertex[component] * rotation[component][axis] 29 } 30 } 31 if height, inside := ground.elevation(point[0], point[2]); inside { 32 lift = max(lift, height+.01-point[1]) 33 } 34 } 35 character.position[1] += lift 36 }