2020-06-26 20:03:00 -04:00
|
|
|
package d2netpacket
|
|
|
|
|
|
|
|
import "github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// CastPacket contains a cast command for an entity. It is sent by the server
|
|
|
|
// and instructs the client to trigger the use of the given skill on the given
|
|
|
|
// entity.
|
2020-06-26 20:03:00 -04:00
|
|
|
// TODO: Need to handle being on different maps
|
|
|
|
type CastPacket struct {
|
|
|
|
SourceEntityID string `json:"sourceEntityId"`
|
|
|
|
SkillID int `json:"skillId"`
|
|
|
|
TargetX float64 `json:"targetX"`
|
|
|
|
TargetY float64 `json:"targetY"`
|
|
|
|
TargetEntityID string `json:"targetEntityId"`
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// CreateCastPacket returns a NetPacket which declares a CastPacket with the
|
|
|
|
// given skill command.
|
2020-06-26 20:03:00 -04:00
|
|
|
func CreateCastPacket(entityID string, skillID int, targetX, targetY float64) NetPacket {
|
|
|
|
return NetPacket{
|
|
|
|
PacketType: d2netpackettype.CastSkill,
|
|
|
|
PacketData: CastPacket{
|
|
|
|
SourceEntityID: entityID,
|
|
|
|
SkillID: skillID,
|
|
|
|
TargetX: targetX,
|
|
|
|
TargetY: targetY,
|
|
|
|
TargetEntityID: "", // TODO implement targeting entities
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|