mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-07 14:23:20 +00:00
Bug fixes
This commit is contained in:
parent
cfa976cd95
commit
848fa7e76e
9 changed files with 1102 additions and 1050 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -31,7 +31,8 @@ enum {
|
||||||
Edit_Copy = 1,
|
Edit_Copy = 1,
|
||||||
Edit_Preview = 2,
|
Edit_Preview = 2,
|
||||||
Edit_WallCreator = 4,
|
Edit_WallCreator = 4,
|
||||||
Edit_Manager = 8
|
Edit_Manager = 8, // Edit started via manager
|
||||||
|
Edit_Grab = 16 // Edit started via +editor grab command
|
||||||
}
|
}
|
||||||
|
|
||||||
enum buildType {
|
enum buildType {
|
||||||
|
@ -141,7 +142,6 @@ enum struct EditorData {
|
||||||
this.angles[0] = RoundToNearestInterval(this.angles[0], this.snapAngle);
|
this.angles[0] = RoundToNearestInterval(this.angles[0], this.snapAngle);
|
||||||
this.angles[1] = RoundToNearestInterval(this.angles[1], this.snapAngle);
|
this.angles[1] = RoundToNearestInterval(this.angles[1], this.snapAngle);
|
||||||
this.angles[2] = RoundToNearestInterval(this.angles[2], this.snapAngle);
|
this.angles[2] = RoundToNearestInterval(this.angles[2], this.snapAngle);
|
||||||
|
|
||||||
}
|
}
|
||||||
TeleportEntity(this.entity, this.origin, this.angles, NULL_VECTOR);
|
TeleportEntity(this.entity, this.origin, this.angles, NULL_VECTOR);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ enum struct EditorData {
|
||||||
// Is edit, do nothing, just reset
|
// Is edit, do nothing, just reset
|
||||||
PrintHintText(this.client, "Edit Complete");
|
PrintHintText(this.client, "Edit Complete");
|
||||||
this.Reset();
|
this.Reset();
|
||||||
entity = 0;
|
this.entity = 0;
|
||||||
|
|
||||||
type = Complete_EditSuccess;
|
type = Complete_EditSuccess;
|
||||||
}
|
}
|
||||||
|
@ -921,6 +921,35 @@ Action Command_Editor(int client, int args) {
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Action Cmd_EditorGrab(int client, int args) {
|
||||||
|
int entity = GetLookingEntity(client, Filter_ValidHats);
|
||||||
|
if(entity > 0) {
|
||||||
|
int parent = GetEntPropEnt(entity, Prop_Data, "m_hParent");
|
||||||
|
if(parent > 0) {
|
||||||
|
entity = parent;
|
||||||
|
}
|
||||||
|
if(!CheckBlacklist(entity)) {
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
Editor[client].ImportEntity(entity, view_as<int>(Edit_Grab), MOVE_ORIGIN);
|
||||||
|
char classname[64];
|
||||||
|
char targetname[32];
|
||||||
|
GetEntityClassname(entity, classname, sizeof(classname));
|
||||||
|
GetEntPropString(entity, Prop_Data, "m_target", targetname, sizeof(targetname));
|
||||||
|
PrintToChat(client, "\x04[Editor]\x01 Editing entity \x05%d (%s) [%s]\x01. End with \x05/edit done\x01", entity, classname, targetname);
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action Cmd_EditorRelease(int client, int args) {
|
||||||
|
if(Editor[client].IsActive() && Editor[client].flags & Edit_Grab) {
|
||||||
|
int entity;
|
||||||
|
Editor[client].Done(entity);
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int GetWallId(int client, const char[] arg) {
|
int GetWallId(int client, const char[] arg) {
|
||||||
int id;
|
int id;
|
||||||
if(StringToIntEx(arg, id) > 0 && id > 0 && id <= createdWalls.Length) {
|
if(StringToIntEx(arg, id) > 0 && id > 0 && id <= createdWalls.Length) {
|
||||||
|
|
|
@ -415,7 +415,7 @@ int GetSpawnedIndex(int client, int index) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#define MAX_SEARCH_RESULTS 10
|
#define MAX_SEARCH_RESULTS 30
|
||||||
ArrayList SearchItems(const char[] query) {
|
ArrayList SearchItems(const char[] query) {
|
||||||
// We have to put it into SearchData enum struct, then convert it back to ItemResult
|
// We have to put it into SearchData enum struct, then convert it back to ItemResult
|
||||||
LoadCategories();
|
LoadCategories();
|
||||||
|
|
|
@ -209,12 +209,14 @@ methodmap PeekCamera {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Enable(int client = -1) {
|
public void Enable(int client = -1) {
|
||||||
|
if(seekerCam == -1) return;
|
||||||
AcceptEntityInput(seekerCam, "Enable", client);
|
AcceptEntityInput(seekerCam, "Enable", client);
|
||||||
if(client > 0) {
|
if(client > 0) {
|
||||||
isViewingCam[client] = true;
|
isViewingCam[client] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Disable(int client = -1) {
|
public void Disable(int client = -1) {
|
||||||
|
if(seekerCam == -1) return;
|
||||||
AcceptEntityInput(seekerCam, "Disable", client);
|
AcceptEntityInput(seekerCam, "Disable", client);
|
||||||
if(client > 0) {
|
if(client > 0) {
|
||||||
isViewingCam[client] = false;
|
isViewingCam[client] = false;
|
||||||
|
|
|
@ -84,6 +84,8 @@ public void OnPluginStart() {
|
||||||
RegAdminCmd("sm_edit", Command_Editor, ADMFLAG_CUSTOM2);
|
RegAdminCmd("sm_edit", Command_Editor, ADMFLAG_CUSTOM2);
|
||||||
RegAdminCmd("sm_wall", Command_Editor, ADMFLAG_CUSTOM2);
|
RegAdminCmd("sm_wall", Command_Editor, ADMFLAG_CUSTOM2);
|
||||||
RegAdminCmd("sm_prop", Command_Props, ADMFLAG_CUSTOM2);
|
RegAdminCmd("sm_prop", Command_Props, ADMFLAG_CUSTOM2);
|
||||||
|
RegAdminCmd("+editor", Cmd_EditorGrab, ADMFLAG_CHEATS, "Grab the entity in your crosshair.");
|
||||||
|
RegAdminCmd("-editor", Cmd_EditorRelease, ADMFLAG_CHEATS, "Releases the entity you grabbed.");
|
||||||
|
|
||||||
if(SQL_CheckConfig(DATABASE_CONFIG_NAME)) {
|
if(SQL_CheckConfig(DATABASE_CONFIG_NAME)) {
|
||||||
if(!ConnectDB()) {
|
if(!ConnectDB()) {
|
||||||
|
@ -219,7 +221,6 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
switch(Editor[client].mode) {
|
switch(Editor[client].mode) {
|
||||||
case MOVE_ORIGIN: {
|
case MOVE_ORIGIN: {
|
||||||
SetWeaponDelay(client, 0.5);
|
SetWeaponDelay(client, 0.5);
|
||||||
|
|
||||||
bool isRotate;
|
bool isRotate;
|
||||||
int flags = GetEntityFlags(client);
|
int flags = GetEntityFlags(client);
|
||||||
if(buttons & IN_RELOAD) {
|
if(buttons & IN_RELOAD) {
|
||||||
|
@ -267,8 +268,11 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
if(g_inRotate[client]) {
|
if(g_inRotate[client]) {
|
||||||
g_inRotate[client] = false;
|
g_inRotate[client] = false;
|
||||||
}
|
}
|
||||||
// Move position
|
float moveAmount = 1.0;
|
||||||
float moveAmount = (buttons & IN_SPEED) ? 2.0 : 1.0;
|
if(buttons & IN_SPEED) {
|
||||||
|
// If holding shift, move distance expoentionally faster the farther away
|
||||||
|
moveAmount += Pow(2.0, Editor[client].moveDistance / 200.0);
|
||||||
|
}
|
||||||
if(buttons & IN_ATTACK) Editor[client].moveDistance += moveAmount;
|
if(buttons & IN_ATTACK) Editor[client].moveDistance += moveAmount;
|
||||||
else if(buttons & IN_ATTACK2) Editor[client].moveDistance -= moveAmount;
|
else if(buttons & IN_ATTACK2) Editor[client].moveDistance -= moveAmount;
|
||||||
}
|
}
|
||||||
|
@ -278,8 +282,10 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
flags = flags & ~FL_FROZEN;
|
flags = flags & ~FL_FROZEN;
|
||||||
SetEntityFlags(client, flags);
|
SetEntityFlags(client, flags);
|
||||||
}
|
}
|
||||||
if(Editor[client].stackerDirection == Stack_Off)
|
// Update the position of entity to cursor
|
||||||
|
if(Editor[client].stackerDirection == Stack_Off) {
|
||||||
CalculateEditorPosition(client, Filter_IgnorePlayerAndWall);
|
CalculateEditorPosition(client, Filter_IgnorePlayerAndWall);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case SCALE: {
|
case SCALE: {
|
||||||
SetWeaponDelay(client, 0.5);
|
SetWeaponDelay(client, 0.5);
|
||||||
|
@ -563,6 +569,21 @@ stock float SnapTo(const float value, const float degree) {
|
||||||
return float(RoundFloat(value / degree)) * degree;
|
return float(RoundFloat(value / degree)) * degree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Taken from GrabEnt
|
||||||
|
stock bool GetInitialRayPosition(int client, float endPos[3]) {
|
||||||
|
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
|
||||||
|
float clientEye[3], clientAngle[3];
|
||||||
|
GetClientEyePosition(client, clientEye);
|
||||||
|
GetClientEyeAngles(client, clientAngle);
|
||||||
|
|
||||||
|
TR_TraceRayFilter(clientEye, clientAngle, MASK_SOLID, RayType_Infinite, Filter_IgnorePlayer, client);
|
||||||
|
if (TR_DidHit(INVALID_HANDLE))
|
||||||
|
TR_GetEndPosition(endPos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
stock bool CalculateEditorPosition(int client, TraceEntityFilter filter) {
|
stock bool CalculateEditorPosition(int client, TraceEntityFilter filter) {
|
||||||
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
|
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
|
||||||
float clientEye[3], clientAngle[3], direction[3];
|
float clientEye[3], clientAngle[3], direction[3];
|
||||||
|
|
|
@ -1113,7 +1113,7 @@ void spawnVariant(SceneVariantData choice) {
|
||||||
void spawnEntity(VariantEntityData entity) {
|
void spawnEntity(VariantEntityData entity) {
|
||||||
if(StrEqual(entity.type, "env_fire")) {
|
if(StrEqual(entity.type, "env_fire")) {
|
||||||
Debug("spawning \"%s\" at (%.1f %.1f %.1f) rot (%.0f %.0f %.0f)", entity.type, entity.origin[0], entity.origin[1], entity.origin[2], entity.angles[0], entity.angles[1], entity.angles[2]);
|
Debug("spawning \"%s\" at (%.1f %.1f %.1f) rot (%.0f %.0f %.0f)", entity.type, entity.origin[0], entity.origin[1], entity.origin[2], entity.angles[0], entity.angles[1], entity.angles[2]);
|
||||||
CreateFire(entity.origin, 20.0, 100.0, 0.0);
|
CreateFire(entity.origin, 20.0, 100.0, 1.0);
|
||||||
} else if(StrEqual(entity.type, "env_physics_blocker") || StrEqual(entity.type, "env_player_blocker")) {
|
} else if(StrEqual(entity.type, "env_physics_blocker") || StrEqual(entity.type, "env_player_blocker")) {
|
||||||
CreateEnvBlockerScaled(entity.type, entity.origin, entity.scale);
|
CreateEnvBlockerScaled(entity.type, entity.origin, entity.scale);
|
||||||
} else if(StrEqual(entity.type, "infodecal")) {
|
} else if(StrEqual(entity.type, "infodecal")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue