mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Add the option to specify a header and payload when tracking player position changes.
This commit is contained in:
parent
463dc75d91
commit
6be526924d
@ -222,6 +222,11 @@ protected:
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
SQInteger mTrackPosition;
|
SQInteger mTrackPosition;
|
||||||
|
SQInteger mTrackHeading;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
Int32 mTrackPositionHeader;
|
||||||
|
Object mTrackPositionPayload;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
Int32 mLastWeapon;
|
Int32 mLastWeapon;
|
||||||
|
@ -712,7 +712,7 @@ void Core::EmitPlayerHeading(Int32 player_id, Float32 old_heading, Float32 new_h
|
|||||||
void Core::EmitPlayerPosition(Int32 player_id)
|
void Core::EmitPlayerPosition(Int32 player_id)
|
||||||
{
|
{
|
||||||
PlayerInst & _player = m_Players.at(player_id);
|
PlayerInst & _player = m_Players.at(player_id);
|
||||||
Emit(_player.mOnPosition);
|
Emit(_player.mOnPosition, _player.mTrackPositionHeader, _player.mTrackPositionPayload);
|
||||||
Emit(mOnPlayerPosition, _player.mObj);
|
Emit(mOnPlayerPosition, _player.mObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,7 +909,15 @@ void Core::EmitPlayerUpdate(Int32 player_id, vcmpPlayerUpdate update_type)
|
|||||||
if (!EpsEq(heading, inst.mLastHeading))
|
if (!EpsEq(heading, inst.mLastHeading))
|
||||||
{
|
{
|
||||||
// Trigger the event specific to this change
|
// Trigger the event specific to this change
|
||||||
|
if (inst.mTrackHeading != 0)
|
||||||
|
{
|
||||||
EmitPlayerHeading(player_id, inst.mLastHeading, heading);
|
EmitPlayerHeading(player_id, inst.mLastHeading, heading);
|
||||||
|
// Should we decrease the tracked position changes?
|
||||||
|
if (inst.mTrackHeading)
|
||||||
|
{
|
||||||
|
--inst.mTrackHeading;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update the tracked value
|
// Update the tracked value
|
||||||
inst.mLastHeading = heading;
|
inst.mLastHeading = heading;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,9 @@ void Core::ResetInst(PlayerInst & inst)
|
|||||||
inst.mID = -1;
|
inst.mID = -1;
|
||||||
inst.mFlags = ENF_DEFAULT;
|
inst.mFlags = ENF_DEFAULT;
|
||||||
inst.mTrackPosition = 0;
|
inst.mTrackPosition = 0;
|
||||||
|
inst.mTrackHeading = 0;
|
||||||
|
inst.mTrackPositionHeader = 0;
|
||||||
|
inst.mTrackPositionPayload.Release();
|
||||||
inst.mLastWeapon = -1;
|
inst.mLastWeapon = -1;
|
||||||
inst.mLastHealth = 0.0;
|
inst.mLastHealth = 0.0;
|
||||||
inst.mLastArmour = 0.0;
|
inst.mLastArmour = 0.0;
|
||||||
|
@ -1311,6 +1311,35 @@ void CPlayer::SetTrackPosition(SQInteger num) const
|
|||||||
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CPlayer::SetTrackPositionEx(SQInteger num, Int32 header, const Object & payload) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Assign the requested information
|
||||||
|
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
||||||
|
Core::Get().GetPlayer(m_ID).mTrackPositionHeader = header;
|
||||||
|
Core::Get().GetPlayer(m_ID).mTrackPositionPayload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger CPlayer::GetTrackHeading() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetPlayer(m_ID).mTrackHeading;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CPlayer::SetTrackHeading(SQInteger num) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Assign the requested information
|
||||||
|
Core::Get().GetPlayer(m_ID).mTrackHeading = num;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 CPlayer::GetLastWeapon() const
|
Int32 CPlayer::GetLastWeapon() const
|
||||||
{
|
{
|
||||||
@ -2223,6 +2252,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Spec"), &CPlayer::GetSpectator, &CPlayer::SetSpectator)
|
.Prop(_SC("Spec"), &CPlayer::GetSpectator, &CPlayer::SetSpectator)
|
||||||
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
||||||
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
||||||
|
.Prop(_SC("TrackHeading"), &CPlayer::GetTrackHeading, &CPlayer::SetTrackHeading)
|
||||||
.Prop(_SC("LastWeapon"), &CPlayer::GetLastWeapon)
|
.Prop(_SC("LastWeapon"), &CPlayer::GetLastWeapon)
|
||||||
.Prop(_SC("LastHealth"), &CPlayer::GetLastHealth)
|
.Prop(_SC("LastHealth"), &CPlayer::GetLastHealth)
|
||||||
.Prop(_SC("LastArmor"), &CPlayer::GetLastArmour)
|
.Prop(_SC("LastArmor"), &CPlayer::GetLastArmour)
|
||||||
@ -2268,6 +2298,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("PlaySound"), &CPlayer::PlaySound)
|
.Func(_SC("PlaySound"), &CPlayer::PlaySound)
|
||||||
.Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix)
|
.Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix)
|
||||||
.Func(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix)
|
.Func(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix)
|
||||||
|
.Func(_SC("SetTrackPosition"), &CPlayer::SetTrackPositionEx)
|
||||||
.Func(_SC("StreamByte"), &CPlayer::StreamByte)
|
.Func(_SC("StreamByte"), &CPlayer::StreamByte)
|
||||||
.Func(_SC("StreamShort"), &CPlayer::StreamShort)
|
.Func(_SC("StreamShort"), &CPlayer::StreamShort)
|
||||||
.Func(_SC("StreamInt"), &CPlayer::StreamInt)
|
.Func(_SC("StreamInt"), &CPlayer::StreamInt)
|
||||||
|
@ -761,10 +761,25 @@ public:
|
|||||||
SQInteger GetTrackPosition() const;
|
SQInteger GetTrackPosition() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the amount of tracked position changes for the managed player entity.
|
* Modify the amount of tracked position changes for the managed player entity.
|
||||||
*/
|
*/
|
||||||
void SetTrackPosition(SQInteger num) const;
|
void SetTrackPosition(SQInteger num) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the amount of tracked position changes for the managed player entity.
|
||||||
|
*/
|
||||||
|
void SetTrackPositionEx(SQInteger num, Int32 header, const Object & payload) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked heading changes for the managed player entity.
|
||||||
|
*/
|
||||||
|
SQInteger GetTrackHeading() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the amount of tracked heading changes for the managed player entity.
|
||||||
|
*/
|
||||||
|
void SetTrackHeading(SQInteger num) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the last known weapon for the managed player entity.
|
* Retrieve the last known weapon for the managed player entity.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user