mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Implement the option to specify how many times you want to allow intensive entity events to be forwarded to script callbacks.
Also expose several properties for the vehicle entity type that I forgot about.
This commit is contained in:
parent
6489dfdf08
commit
bc1e7dbde6
@ -219,6 +219,9 @@ protected:
|
|||||||
CPlayer * mInst;
|
CPlayer * mInst;
|
||||||
Object mObj;
|
Object mObj;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
SQInteger mTrackPosition;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
Int32 mLastWeapon;
|
Int32 mLastWeapon;
|
||||||
Float32 mLastHealth;
|
Float32 mLastHealth;
|
||||||
@ -312,6 +315,10 @@ protected:
|
|||||||
CVehicle * mInst;
|
CVehicle * mInst;
|
||||||
Object mObj;
|
Object mObj;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
SQInteger mTrackPosition;
|
||||||
|
SQInteger mTrackRotation;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
Int32 mLastPrimaryColour;
|
Int32 mLastPrimaryColour;
|
||||||
Int32 mLastSecondaryColour;
|
Int32 mLastSecondaryColour;
|
||||||
|
@ -921,7 +921,15 @@ void Core::EmitPlayerUpdate(Int32 player_id, vcmpPlayerUpdate update_type)
|
|||||||
if (pos != inst.mLastPosition)
|
if (pos != inst.mLastPosition)
|
||||||
{
|
{
|
||||||
// Trigger the event specific to this change
|
// Trigger the event specific to this change
|
||||||
EmitPlayerPosition(player_id);
|
if (inst.mTrackPosition != 0)
|
||||||
|
{
|
||||||
|
EmitPlayerPosition(player_id);
|
||||||
|
// Should we decrease the tracked position changes?
|
||||||
|
if (inst.mTrackPosition)
|
||||||
|
{
|
||||||
|
--inst.mTrackPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update the tracked value
|
// Update the tracked value
|
||||||
inst.mLastPosition = pos;
|
inst.mLastPosition = pos;
|
||||||
}
|
}
|
||||||
@ -980,7 +988,15 @@ void Core::EmitVehicleUpdate(Int32 vehicle_id, vcmpVehicleUpdate update_type)
|
|||||||
case vcmpVehicleUpdatePosition:
|
case vcmpVehicleUpdatePosition:
|
||||||
{
|
{
|
||||||
// Trigger the event specific to this change
|
// Trigger the event specific to this change
|
||||||
EmitVehiclePosition(vehicle_id);
|
if (inst.mTrackPosition != 0)
|
||||||
|
{
|
||||||
|
EmitVehiclePosition(vehicle_id);
|
||||||
|
// Should we decrease the tracked position changes?
|
||||||
|
if (inst.mTrackPosition)
|
||||||
|
{
|
||||||
|
--inst.mTrackPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update the tracked value
|
// Update the tracked value
|
||||||
_Func->GetVehiclePosition(vehicle_id, &inst.mLastPosition.x,
|
_Func->GetVehiclePosition(vehicle_id, &inst.mLastPosition.x,
|
||||||
&inst.mLastPosition.y, &inst.mLastPosition.z);
|
&inst.mLastPosition.y, &inst.mLastPosition.z);
|
||||||
@ -1019,13 +1035,19 @@ void Core::EmitVehicleUpdate(Int32 vehicle_id, vcmpVehicleUpdate update_type)
|
|||||||
} break;
|
} break;
|
||||||
case vcmpVehicleUpdateRotation:
|
case vcmpVehicleUpdateRotation:
|
||||||
{
|
{
|
||||||
Quaternion rot;
|
|
||||||
// Obtain the current position of this instance
|
|
||||||
_Func->GetVehicleRotation(vehicle_id, &rot.x, &rot.y, &rot.z, &rot.w);
|
|
||||||
// Trigger the event specific to this change
|
// Trigger the event specific to this change
|
||||||
EmitVehicleRotation(vehicle_id);
|
if (inst.mTrackRotation != 0)
|
||||||
// Update the tracked value
|
{
|
||||||
inst.mLastRotation = rot;
|
EmitVehicleRotation(vehicle_id);
|
||||||
|
// Should we decrease the tracked rotation changes?
|
||||||
|
if (inst.mTrackRotation)
|
||||||
|
{
|
||||||
|
--inst.mTrackRotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Obtain the current rotation of this instance
|
||||||
|
_Func->GetVehicleRotation(vehicle_id, &inst.mLastRotation.x, &inst.mLastRotation.y,
|
||||||
|
&inst.mLastRotation.z, &inst.mLastRotation.w);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,7 @@ void Core::ResetInst(PlayerInst & inst)
|
|||||||
{
|
{
|
||||||
inst.mID = -1;
|
inst.mID = -1;
|
||||||
inst.mFlags = ENF_DEFAULT;
|
inst.mFlags = ENF_DEFAULT;
|
||||||
|
inst.mTrackPosition = 0;
|
||||||
inst.mLastWeapon = -1;
|
inst.mLastWeapon = -1;
|
||||||
inst.mLastHealth = 0.0;
|
inst.mLastHealth = 0.0;
|
||||||
inst.mLastArmour = 0.0;
|
inst.mLastArmour = 0.0;
|
||||||
@ -66,6 +67,8 @@ void Core::ResetInst(VehicleInst & inst)
|
|||||||
{
|
{
|
||||||
inst.mID = -1;
|
inst.mID = -1;
|
||||||
inst.mFlags = ENF_DEFAULT;
|
inst.mFlags = ENF_DEFAULT;
|
||||||
|
inst.mTrackPosition = 0;
|
||||||
|
inst.mTrackRotation = 0;
|
||||||
inst.mLastPrimaryColour = -1;
|
inst.mLastPrimaryColour = -1;
|
||||||
inst.mLastSecondaryColour = -1;
|
inst.mLastSecondaryColour = -1;
|
||||||
inst.mLastHealth = 0.0;
|
inst.mLastHealth = 0.0;
|
||||||
|
@ -1174,6 +1174,24 @@ void CPlayer::SetMessagePrefix(Uint32 index, CSStr prefix)
|
|||||||
mMessagePrefixes[index].assign(prefix);
|
mMessagePrefixes[index].assign(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger CPlayer::GetTrackPosition() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetPlayer(m_ID).mTrackPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CPlayer::SetTrackPosition(SQInteger num) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Assign the requested information
|
||||||
|
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 CPlayer::GetLastWeapon() const
|
Int32 CPlayer::GetLastWeapon() const
|
||||||
{
|
{
|
||||||
@ -2075,6 +2093,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Away"), &CPlayer::IsAway)
|
.Prop(_SC("Away"), &CPlayer::IsAway)
|
||||||
.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("LastWeapon"), &CPlayer::GetLastWeapon)
|
.Prop(_SC("LastWeapon"), &CPlayer::GetLastWeapon)
|
||||||
.Prop(_SC("LastHealth"), &CPlayer::GetLastHealth)
|
.Prop(_SC("LastHealth"), &CPlayer::GetLastHealth)
|
||||||
.Prop(_SC("LastArmour"), &CPlayer::GetLastArmour)
|
.Prop(_SC("LastArmour"), &CPlayer::GetLastArmour)
|
||||||
|
@ -715,6 +715,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetMessagePrefix(Uint32 index, CSStr prefix);
|
void SetMessagePrefix(Uint32 index, CSStr prefix);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked position changes for the managed player entity.
|
||||||
|
*/
|
||||||
|
SQInteger GetTrackPosition() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked position changes for the managed player entity.
|
||||||
|
*/
|
||||||
|
void SetTrackPosition(SQInteger num) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the last known weapon for the managed player entity.
|
* Retrieve the last known weapon for the managed player entity.
|
||||||
*/
|
*/
|
||||||
|
@ -984,6 +984,87 @@ bool CVehicle::Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) co
|
|||||||
!= vcmpErrorRequestDenied);
|
!= vcmpErrorRequestDenied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger CVehicle::GetTrackPosition() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mTrackPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CVehicle::SetTrackPosition(SQInteger num) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Assign the requested information
|
||||||
|
Core::Get().GetVehicle(m_ID).mTrackPosition = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger CVehicle::GetTrackRotation() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mTrackRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void CVehicle::SetTrackRotation(SQInteger num) const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Assign the requested information
|
||||||
|
Core::Get().GetVehicle(m_ID).mTrackRotation = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Int32 CVehicle::GetLastPrimaryColour() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mLastPrimaryColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Int32 CVehicle::GetLastSecondaryColour() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mLastSecondaryColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Float32 CVehicle::GetLastHealth() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mLastHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
const Vector3 & CVehicle::GetLastPosition() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mLastPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
const Quaternion & CVehicle::GetLastRotation() const
|
||||||
|
{
|
||||||
|
// Validate the managed identifier
|
||||||
|
Validate();
|
||||||
|
// Return the requested information
|
||||||
|
return Core::Get().GetVehicle(m_ID).mLastRotation;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Float32 CVehicle::GetPositionX() const
|
Float32 CVehicle::GetPositionX() const
|
||||||
{
|
{
|
||||||
@ -1678,6 +1759,13 @@ void Register_CVehicle(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("HorizontalTurretRotation"), &CVehicle::GetHorizontalTurretRotation)
|
.Prop(_SC("HorizontalTurretRotation"), &CVehicle::GetHorizontalTurretRotation)
|
||||||
.Prop(_SC("VerTurretRotation"), &CVehicle::GetVerticalTurretRotation)
|
.Prop(_SC("VerTurretRotation"), &CVehicle::GetVerticalTurretRotation)
|
||||||
.Prop(_SC("VerticalTurretRotation"), &CVehicle::GetVerticalTurretRotation)
|
.Prop(_SC("VerticalTurretRotation"), &CVehicle::GetVerticalTurretRotation)
|
||||||
|
.Prop(_SC("TrackPosition"), &CVehicle::GetTrackPosition, &CVehicle::SetTrackPosition)
|
||||||
|
.Prop(_SC("TrackRotation"), &CVehicle::GetTrackRotation, &CVehicle::SetTrackRotation)
|
||||||
|
.Prop(_SC("LastPrimaryColour"), &CVehicle::GetLastPrimaryColour)
|
||||||
|
.Prop(_SC("LastSecondaryColour"), &CVehicle::GetLastSecondaryColour)
|
||||||
|
.Prop(_SC("LastHealth"), &CVehicle::GetLastHealth)
|
||||||
|
.Prop(_SC("LastPosition"), &CVehicle::GetLastPosition)
|
||||||
|
.Prop(_SC("LastRotation"), &CVehicle::GetLastRotation)
|
||||||
.Prop(_SC("PosX"), &CVehicle::GetPositionX, &CVehicle::SetPositionX)
|
.Prop(_SC("PosX"), &CVehicle::GetPositionX, &CVehicle::SetPositionX)
|
||||||
.Prop(_SC("PosY"), &CVehicle::GetPositionY, &CVehicle::SetPositionY)
|
.Prop(_SC("PosY"), &CVehicle::GetPositionY, &CVehicle::SetPositionY)
|
||||||
.Prop(_SC("PosZ"), &CVehicle::GetPositionZ, &CVehicle::SetPositionZ)
|
.Prop(_SC("PosZ"), &CVehicle::GetPositionZ, &CVehicle::SetPositionZ)
|
||||||
|
@ -590,6 +590,51 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
|
bool Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked position changes for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
SQInteger GetTrackPosition() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked position changes for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
void SetTrackPosition(SQInteger num) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked rotation changes for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
SQInteger GetTrackRotation() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the amount of tracked rotation changes for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
void SetTrackRotation(SQInteger num) const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the last known primary color for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
Int32 GetLastPrimaryColour() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the last known secondary color for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
Int32 GetLastSecondaryColour() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the last known health for the managed vehicle entity.
|
||||||
|
*/
|
||||||
|
Float32 GetLastHealth() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the last known position for the managed player entity.
|
||||||
|
*/
|
||||||
|
const Vector3 & GetLastPosition() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the last known rotation for the managed player entity.
|
||||||
|
*/
|
||||||
|
const Quaternion & GetLastRotation() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the position on the x axis of the managed vehicle entity.
|
* Retrieve the position on the x axis of the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user