Bug fixes

This commit is contained in:
Jackzie 2024-07-21 10:49:44 -05:00
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.

View file

@ -31,7 +31,8 @@ enum {
Edit_Copy = 1,
Edit_Preview = 2,
Edit_WallCreator = 4,
Edit_Manager = 8
Edit_Manager = 8, // Edit started via manager
Edit_Grab = 16 // Edit started via +editor grab command
}
enum buildType {
@ -141,7 +142,6 @@ enum struct EditorData {
this.angles[0] = RoundToNearestInterval(this.angles[0], this.snapAngle);
this.angles[1] = RoundToNearestInterval(this.angles[1], this.snapAngle);
this.angles[2] = RoundToNearestInterval(this.angles[2], this.snapAngle);
}
TeleportEntity(this.entity, this.origin, this.angles, NULL_VECTOR);
}
@ -342,7 +342,7 @@ enum struct EditorData {
// Is edit, do nothing, just reset
PrintHintText(this.client, "Edit Complete");
this.Reset();
entity = 0;
this.entity = 0;
type = Complete_EditSuccess;
}
@ -921,6 +921,35 @@ Action Command_Editor(int client, int args) {
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 id;
if(StringToIntEx(arg, id) > 0 && id > 0 && id <= createdWalls.Length) {

View file

@ -415,7 +415,7 @@ int GetSpawnedIndex(int client, int index) {
}
return -1;
}
#define MAX_SEARCH_RESULTS 10
#define MAX_SEARCH_RESULTS 30
ArrayList SearchItems(const char[] query) {
// We have to put it into SearchData enum struct, then convert it back to ItemResult
LoadCategories();

View file

@ -209,12 +209,14 @@ methodmap PeekCamera {
}
public void Enable(int client = -1) {
if(seekerCam == -1) return;
AcceptEntityInput(seekerCam, "Enable", client);
if(client > 0) {
isViewingCam[client] = true;
}
}
public void Disable(int client = -1) {
if(seekerCam == -1) return;
AcceptEntityInput(seekerCam, "Disable", client);
if(client > 0) {
isViewingCam[client] = false;

View file

@ -84,6 +84,8 @@ public void OnPluginStart() {
RegAdminCmd("sm_edit", Command_Editor, ADMFLAG_CUSTOM2);
RegAdminCmd("sm_wall", Command_Editor, 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(!ConnectDB()) {
@ -219,7 +221,6 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
switch(Editor[client].mode) {
case MOVE_ORIGIN: {
SetWeaponDelay(client, 0.5);
bool isRotate;
int flags = GetEntityFlags(client);
if(buttons & IN_RELOAD) {
@ -267,8 +268,11 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
if(g_inRotate[client]) {
g_inRotate[client] = false;
}
// Move position
float moveAmount = (buttons & IN_SPEED) ? 2.0 : 1.0;
float moveAmount = 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;
else if(buttons & IN_ATTACK2) Editor[client].moveDistance -= moveAmount;
}
@ -278,9 +282,11 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
flags = flags & ~FL_FROZEN;
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);
}
}
case SCALE: {
SetWeaponDelay(client, 0.5);
allowMove = false;
@ -563,6 +569,21 @@ stock float SnapTo(const float value, const float 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) {
if (client > 0 && client <= MaxClients && IsClientInGame(client)) {
float clientEye[3], clientAngle[3], direction[3];

View file

@ -1113,7 +1113,7 @@ void spawnVariant(SceneVariantData choice) {
void spawnEntity(VariantEntityData entity) {
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]);
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")) {
CreateEnvBlockerScaled(entity.type, entity.origin, entity.scale);
} else if(StrEqual(entity.type, "infodecal")) {