Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dronelektron committed Dec 19, 2022
2 parents 0cf2600 + bdc5eae commit fbaa527
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Allows you to grab and move players
* sm_gravitygun_default_distance_enable - Enable (1) or disable (0) default capture distance [default: "1"]
* sm_gravitygun_default_distance - Default capture distance, must be at least 64.0 [default: "128.0"]
* sm_gravitygun_default_distance_step - Default distance step for increase/decrease [default: "64.0"]
* sm_gravitygun_velocity_factor - How fast to move a player [default: "5.0"]
* sm_gravitygun_show_activity - Show (1) or hide (0) admin activity for all players [default: "1"]

### Console Commands
Expand Down
2 changes: 1 addition & 1 deletion scripting/gravity-gun.sp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public Plugin myinfo = {
name = "Gravity gun",
author = "Dron-elektron",
description = "Allows you to manipulate players",
version = "1.1.0",
version = "1.2.0",
url = "https://github.com/dronelektron/gravity-gun"
};

Expand Down
1 change: 0 additions & 1 deletion scripting/include/gg/use-case.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#define CLIENT_NOT_FOUND -1
#define INVALID_CLIENT 0
#define VELOCITY_FACTOR 5.0
#define DISTANCE_MIN 64.0
#define OBSERVER_MODE_FIRST_PERSON 4

Expand Down
6 changes: 6 additions & 0 deletions scripting/modules/console-variable.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ static ConVar g_pluginEnabled = null;
static ConVar g_defaultDistanceEnabled = null;
static ConVar g_defaultDistance = null;
static ConVar g_defaultDistanceStep = null;
static ConVar g_velocityFactor = null;
static ConVar g_showActivity = null;

void Variable_Create() {
g_pluginEnabled = CreateConVar("sm_gravitygun_enable", "1", "Enable (1) or disable (0) plugin");
g_defaultDistanceEnabled = CreateConVar("sm_gravitygun_default_distance_enable", "1", "Enable (1) or disable (0) default capture distance");
g_defaultDistance = CreateConVar("sm_gravitygun_default_distance", "128.0", "Default capture distance, must be at least 64.0");
g_defaultDistanceStep = CreateConVar("sm_gravitygun_default_distance_step", "64.0", "Default distance step for increase/decrease");
g_velocityFactor = CreateConVar("sm_gravitygun_velocity_factor", "5.0", "How fast to move a player");
g_showActivity = CreateConVar("sm_gravitygun_show_activity", "1", "Show (1) or hide (0) admin activity for all players");
}

Expand All @@ -28,6 +30,10 @@ float Variable_DefaultDistanceStep() {
return g_defaultDistanceStep.FloatValue;
}

float Variable_VelocityFactor() {
return g_velocityFactor.FloatValue;
}

bool Variable_ShowActivity() {
return g_showActivity.IntValue == 1;
}
13 changes: 12 additions & 1 deletion scripting/modules/use-case.sp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void UseCase_CapturePlayer(int client) {

Client_SetTarget(client, target);
Client_SetDistance(client, distance);
UseCase_RemoveClientSpeedLimit(target);
CreateTimer(RETENTION_TIMER_INTERVAL, UseCaseTimer_PlayerRetention, clientId, RETENTION_TIMER_FLAGS);
Message_PlayerCaptured(client, target);
}
Expand All @@ -63,6 +64,7 @@ void UseCase_ReleaseTarget(int client) {

if (target != CLIENT_NOT_FOUND) {
Client_RemoveTarget(client, target);
UseCase_RestoreClientSpeedLimit(target);
Message_PlayerReleased(client, target);
}
}
Expand Down Expand Up @@ -100,6 +102,7 @@ void UseCase_ApplyForce(int client, int target) {
float rotatedDirection[VECTOR_SIZE];
float targetDestination[VECTOR_SIZE];
float velocity[VECTOR_SIZE];
float velocityFactor = Variable_VelocityFactor();

direction[X] = Client_GetDistance(client);

Expand All @@ -109,7 +112,7 @@ void UseCase_ApplyForce(int client, int target) {
Math_RotateVector(direction, clientEyeAngles, rotatedDirection);
AddVectors(clientEyePosition, rotatedDirection, targetDestination);
SubtractVectors(targetDestination, targetPosition, velocity);
ScaleVector(velocity, VELOCITY_FACTOR);
ScaleVector(velocity, velocityFactor);
TeleportEntity(target, NULL_VECTOR, NULL_VECTOR, velocity);
}

Expand Down Expand Up @@ -160,3 +163,11 @@ bool UseCase_IsInvalidObserverMode(int client) {

return IsClientObserver(client) && observerMode == OBSERVER_MODE_FIRST_PERSON;
}

void UseCase_RemoveClientSpeedLimit(int client) {
SetEntityMoveType(client, MOVETYPE_ISOMETRIC);
}

void UseCase_RestoreClientSpeedLimit(int client) {
SetEntityMoveType(client, MOVETYPE_WALK);
}

0 comments on commit fbaa527

Please sign in to comment.