aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/combat_interest.go (679B)


      1 package main
      2 
      3 func (server *server) combatInterest(client *worldClient, spawned map[uint32]bool) [][]byte {
      4 	// Both participants must exist in this observer's client before target selection.
      5 	var updates [][]byte
      6 	for _, attacker := range server.fighting {
      7 		target := server.characters[attacker.fighting]
      8 		if target == nil || attacker.playfield != server.characters[client.id].playfield ||
      9 			target.playfield != attacker.playfield ||
     10 			!client.sees(attacker) || !client.sees(target) {
     11 			continue
     12 		}
     13 		if spawned != nil && !spawned[attacker.id] && !spawned[target.id] {
     14 			continue
     15 		}
     16 		updates = append(updates, attackPacket(attacker.id, target.id))
     17 	}
     18 	return updates
     19 }