85 lines
3.0 KiB
Go
85 lines
3.0 KiB
Go
package gameserver
|
|
|
|
import (
|
|
"log"
|
|
|
|
"ananta-ps/pkg/protocol"
|
|
)
|
|
|
|
func (s *Server) handleAskSetWantedLevel(sess *Session, pkt *protocol.RpcPacket) error {
|
|
r := protocol.NewUxReader(pkt.Body)
|
|
wantedLevel, _ := r.U32()
|
|
|
|
sess.wantedLevel = wantedLevel
|
|
log.Printf("[POLICE] Wanted level set to %d for player %d", wantedLevel, sess.pid)
|
|
|
|
if err := sess.ReturnEmptyOk(pkt.InvokeID, pkt.MethodID); err != nil {
|
|
return err
|
|
}
|
|
|
|
w := protocol.NewUxWriter()
|
|
w.U64(sess.pid).U32(wantedLevel)
|
|
return sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncWantedLevel", 68582860), w.Bytes())
|
|
}
|
|
|
|
func (s *Server) handleAskPoliceArrest(sess *Session, pkt *protocol.RpcPacket) error {
|
|
r := protocol.NewUxReader(pkt.Body)
|
|
officerId, _ := r.U64()
|
|
log.Printf("[POLICE] Officer %d arresting player %d", officerId, sess.pid)
|
|
|
|
if err := sess.ReturnEmptyOk(pkt.InvokeID, pkt.MethodID); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Trigger Arrest Cutscene
|
|
w := protocol.NewUxWriter()
|
|
w.U64(sess.unitId).U64(officerId).Bool(true)
|
|
return sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncPoliceArrestCutscene", 68582861), w.Bytes())
|
|
}
|
|
|
|
func (s *Server) handleReportPoliceArrestFinish(sess *Session, pkt *protocol.RpcPacket) error {
|
|
log.Printf("[POLICE] ReportPoliceArrestFinish received, teleporting player %d to prison", sess.pid)
|
|
if err := sess.ReturnEmptyOk(pkt.InvokeID, pkt.MethodID); err != nil {
|
|
return err
|
|
}
|
|
|
|
sess.wantedLevel = 0
|
|
// Teleport to Lixi Police Department Prison Cell
|
|
prisonX, prisonY, prisonZ, facing := float32(2300.0), float32(10.0), float32(1420.0), float32(180.0)
|
|
_ = sess.Teleport(prisonX, prisonY, prisonZ, facing)
|
|
|
|
wWanted := protocol.NewUxWriter()
|
|
wWanted.U64(sess.pid).U32(0)
|
|
_ = sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncWantedLevel", 68582860), wWanted.Bytes())
|
|
|
|
wPrison := protocol.NewUxWriter()
|
|
wPrison.U64(sess.pid).Bool(true)
|
|
return sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncPolicePrisonStatus", 68582862), wPrison.Bytes())
|
|
}
|
|
|
|
func (s *Server) handleAskPayFine(sess *Session, pkt *protocol.RpcPacket) error {
|
|
log.Printf("[POLICE] AskPayFine received, clearing criminal record for player %d", sess.pid)
|
|
sess.wantedLevel = 0
|
|
if err := sess.ReturnEmptyOk(pkt.InvokeID, pkt.MethodID); err != nil {
|
|
return err
|
|
}
|
|
|
|
w := protocol.NewUxWriter()
|
|
w.U64(sess.pid).U32(0)
|
|
return sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncWantedLevel", 68582860), w.Bytes())
|
|
}
|
|
|
|
func (s *Server) handleAskReleaseFromPrison(sess *Session, pkt *protocol.RpcPacket) error {
|
|
log.Printf("[POLICE] AskReleaseFromPrison, releasing player %d to police station lobby", sess.pid)
|
|
if err := sess.ReturnEmptyOk(pkt.InvokeID, pkt.MethodID); err != nil {
|
|
return err
|
|
}
|
|
|
|
lobbyX, lobbyY, lobbyZ, facing := float32(2285.0), float32(10.0), float32(1405.0), float32(90.0)
|
|
_ = sess.Teleport(lobbyX, lobbyY, lobbyZ, facing)
|
|
|
|
wPrison := protocol.NewUxWriter()
|
|
wPrison.U64(sess.pid).Bool(false)
|
|
return sess.NotifyData(protocol.MethodGetMethodIDDefault("SyncPolicePrisonStatus", 68582862), wPrison.Bytes())
|
|
}
|