mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 15:43: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.
|
@ -30,8 +30,9 @@ enum {
|
|||
Edit_None,
|
||||
Edit_Copy = 1,
|
||||
Edit_Preview = 2,
|
||||
Edit_WallCreator = 4,
|
||||
Edit_Manager = 8
|
||||
Edit_WallCreator = 4,
|
||||
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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,295 +1,297 @@
|
|||
#include <gamemodes/cvars.inc>
|
||||
char GAMEMODE_NAME[30] = "_UNINITIALIZED_GAMEMODE_";
|
||||
char GAMEMODE_PREFIX[32];
|
||||
|
||||
|
||||
// Meta
|
||||
char gamemode[32];
|
||||
bool isEnabled, lateLoaded;
|
||||
|
||||
char g_currentSet[16];
|
||||
char g_currentMap[64];
|
||||
char nextRoundMap[64];
|
||||
|
||||
// Legacy:
|
||||
bool isNavBlockersEnabled = true, isPropsEnabled = true, isPortalsEnabled = true
|
||||
|
||||
static int _debugFlags = BaseDebug_Server;
|
||||
|
||||
enum {
|
||||
BaseDebug_None,
|
||||
BaseDebug_Server = 1,
|
||||
BaseDebug_ConsoleAll = 2,
|
||||
BaseDebug_ChatAll = 4
|
||||
}
|
||||
|
||||
static bool ents_NavBlockers = true;
|
||||
static bool ents_Props = true;
|
||||
static bool ents_Portals = true;
|
||||
|
||||
int g_iLaserIndex;
|
||||
|
||||
// Gamemode state
|
||||
bool isPendingPlay[MAXPLAYERS+1];
|
||||
static char buffer[256];
|
||||
|
||||
methodmap BaseGame {
|
||||
property int DebugFlags {
|
||||
public get() { return _debugFlags; }
|
||||
public set(int flags) {
|
||||
_debugFlags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
public void Init(const char[] name, const char[] prefix = "") {
|
||||
strcopy(GAMEMODE_NAME, sizeof(GAMEMODE_NAME), name);
|
||||
if(StrEqual(prefix, ""))
|
||||
Format(GAMEMODE_PREFIX, sizeof(GAMEMODE_PREFIX), "[%s]", name);
|
||||
else
|
||||
Format(GAMEMODE_PREFIX, sizeof(GAMEMODE_PREFIX), "[%s]", prefix);
|
||||
}
|
||||
|
||||
public void Cleanup() {
|
||||
ClearPortalData();
|
||||
}
|
||||
|
||||
public void PrintToServer(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToServer("[%s] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Warn(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToServer("[%s::WARN] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Broadcast(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToChatAll("[%s] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Debug(const char[] format, any ...) {
|
||||
if(_debugFlags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
if(_debugFlags & BaseDebug_Server)
|
||||
PrintToServer("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(_debugFlags & BaseDebug_ChatAll)
|
||||
PrintToChatAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(_debugFlags & BaseDebug_ConsoleAll)
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void DebugConsole(const char[] format, any ...) {
|
||||
if(_debugFlags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void DebugCustom(const char[] format, int flags, any ...) {
|
||||
if(flags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
if(flags & BaseDebug_Server)
|
||||
PrintToServer("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(flags & BaseDebug_ChatAll)
|
||||
PrintToChatAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(flags & BaseDebug_ConsoleAll)
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
property bool Enabled {
|
||||
public get() {
|
||||
return isEnabled
|
||||
}
|
||||
public set(bool value) {
|
||||
isEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Blockers {
|
||||
public get() {
|
||||
return ents_NavBlockers;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_NavBlockers = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Props {
|
||||
public get() {
|
||||
return ents_Props;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_Props = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Portals {
|
||||
public get() {
|
||||
return ents_Portals;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_Portals = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PeekCam specifics
|
||||
PeekCamera PeekCam;
|
||||
static int seekerCam = INVALID_ENT_REFERENCE;
|
||||
static bool isViewingCam[MAXPLAYERS+1];
|
||||
static int seekerTarget;
|
||||
|
||||
enum PeekPerspective {
|
||||
Cam_Unknown,
|
||||
Cam_FirstPerson,
|
||||
Cam_ThirdPerson
|
||||
}
|
||||
|
||||
methodmap PeekCamera {
|
||||
property int Target {
|
||||
public get() {
|
||||
return GetClientOfUserId(seekerTarget);
|
||||
}
|
||||
public set(int client) {
|
||||
this.Create();
|
||||
seekerTarget = GetClientUserId(client);
|
||||
|
||||
AcceptEntityInput(seekerCam, "ClearParent");
|
||||
AcceptEntityInput(seekerCam, "Disable");
|
||||
}
|
||||
}
|
||||
|
||||
property PeekPerspective Perspective {
|
||||
public set(PeekPerspective perspective) {
|
||||
this.SetPerspective(perspective);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPerspective(PeekPerspective perspective) {
|
||||
float pos[3], ang[3];
|
||||
int client = this.Target;
|
||||
GetClientEyePosition(this.Target, pos);
|
||||
GetClientEyeAngles(client, ang);
|
||||
|
||||
if(perspective == Cam_FirstPerson) {
|
||||
|
||||
TeleportEntity(seekerCam, pos, ang, NULL_VECTOR);
|
||||
SetParent(seekerCam, client);
|
||||
SetParentAttachment(seekerCam, "primary", false);
|
||||
} else if(perspective == Cam_ThirdPerson) {
|
||||
float endPos[3];
|
||||
TR_TraceRayFilter(pos, ang, CONTENTS_PLAYERCLIP | MASK_SOLID | MASK_VISIBLE, RayType_Infinite, Filter_IgnoreAll);
|
||||
if(TR_DidHit()) {
|
||||
TR_GetEndPosition(endPos);
|
||||
}
|
||||
endPos[2] += 50.0;
|
||||
|
||||
ang[0] = 0.0;
|
||||
float deltaA = endPos[0] - pos[0];
|
||||
float deltaB = endPos[1] - pos[1];
|
||||
float deltaC = endPos[2] - pos[2];
|
||||
ang[0] = RadToDeg(ArcTangent(deltaC / GetVectorDistance(endPos, pos, false) ));
|
||||
ang[1] = RadToDeg(ArcTangent2(deltaA, deltaB));
|
||||
TeleportEntity(seekerCam, endPos, ang, NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetViewing(int client, bool active) {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE) {
|
||||
AcceptEntityInput(seekerCam, "Enable", client); // Need to always activate before deactivating to fix a semi-common bug
|
||||
if(!active) {
|
||||
AcceptEntityInput(seekerCam, "Disable", client);
|
||||
}
|
||||
} else {
|
||||
PrintToServer("WARN: SetPeekCamActive(%d, %b) when seekerCam invalid", client, active);
|
||||
}
|
||||
isViewingCam[client] = active;
|
||||
}
|
||||
|
||||
public void Enable(int client = -1) {
|
||||
AcceptEntityInput(seekerCam, "Enable", client);
|
||||
if(client > 0) {
|
||||
isViewingCam[client] = true;
|
||||
}
|
||||
}
|
||||
public void Disable(int client = -1) {
|
||||
AcceptEntityInput(seekerCam, "Disable", client);
|
||||
if(client > 0) {
|
||||
isViewingCam[client] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsViewing(int client) {
|
||||
return isViewingCam[client];
|
||||
}
|
||||
|
||||
public void Create() {
|
||||
if(seekerCam == INVALID_ENT_REFERENCE || !IsValidEntity(seekerCam)) {
|
||||
seekerCam = CreateEntityByName("point_viewcontrol_survivor");
|
||||
DispatchKeyValue(seekerCam, "targetname", "hscam");
|
||||
DispatchSpawn(seekerCam);
|
||||
for(int i = 0; i <= MaxClients; i++) {
|
||||
isViewingCam[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exists() {
|
||||
return seekerCam != INVALID_ENT_REFERENCE && IsValidEntity(seekerCam)
|
||||
}
|
||||
|
||||
public void Destroy() {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE && IsValidEntity(seekerCam)) {
|
||||
AcceptEntityInput(seekerCam, "Disable");
|
||||
AcceptEntityInput(seekerCam, "Kill");
|
||||
seekerCam = INVALID_ENT_REFERENCE
|
||||
}
|
||||
seekerTarget = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Filter_IgnoreAll(int entity, int mask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enum struct EntityConfig {
|
||||
float origin[3];
|
||||
float rotation[3];
|
||||
char type[32];
|
||||
char model[64];
|
||||
float scale[3];
|
||||
float offset[3];
|
||||
}
|
||||
|
||||
enum struct MapConfig {
|
||||
ArrayList entities;
|
||||
ArrayList inputs;
|
||||
float spawnpoint[3];
|
||||
bool hasSpawnpoint;
|
||||
int mapTime;
|
||||
bool canClimb;
|
||||
bool pressButtons;
|
||||
}
|
||||
|
||||
MapConfig mapConfig;
|
||||
ArrayList validMaps;
|
||||
ArrayList validSets;
|
||||
|
||||
stock void SetParent(int child, int parent) {
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(child, "SetParent", parent);
|
||||
}
|
||||
|
||||
stock void SetParentAttachment(int child, const char[] attachment, bool withOffset = false) {
|
||||
SetVariantString(attachment);
|
||||
if(withOffset)
|
||||
AcceptEntityInput(child, "SetParentAttachmentMaintainOffset");
|
||||
else
|
||||
AcceptEntityInput(child, "SetParentAttachment");
|
||||
}
|
||||
|
||||
stock void ClearParent(int child) {
|
||||
AcceptEntityInput(child, "ClearParent");
|
||||
}
|
||||
#include <gamemodes/cvars.inc>
|
||||
char GAMEMODE_NAME[30] = "_UNINITIALIZED_GAMEMODE_";
|
||||
char GAMEMODE_PREFIX[32];
|
||||
|
||||
|
||||
// Meta
|
||||
char gamemode[32];
|
||||
bool isEnabled, lateLoaded;
|
||||
|
||||
char g_currentSet[16];
|
||||
char g_currentMap[64];
|
||||
char nextRoundMap[64];
|
||||
|
||||
// Legacy:
|
||||
bool isNavBlockersEnabled = true, isPropsEnabled = true, isPortalsEnabled = true
|
||||
|
||||
static int _debugFlags = BaseDebug_Server;
|
||||
|
||||
enum {
|
||||
BaseDebug_None,
|
||||
BaseDebug_Server = 1,
|
||||
BaseDebug_ConsoleAll = 2,
|
||||
BaseDebug_ChatAll = 4
|
||||
}
|
||||
|
||||
static bool ents_NavBlockers = true;
|
||||
static bool ents_Props = true;
|
||||
static bool ents_Portals = true;
|
||||
|
||||
int g_iLaserIndex;
|
||||
|
||||
// Gamemode state
|
||||
bool isPendingPlay[MAXPLAYERS+1];
|
||||
static char buffer[256];
|
||||
|
||||
methodmap BaseGame {
|
||||
property int DebugFlags {
|
||||
public get() { return _debugFlags; }
|
||||
public set(int flags) {
|
||||
_debugFlags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
public void Init(const char[] name, const char[] prefix = "") {
|
||||
strcopy(GAMEMODE_NAME, sizeof(GAMEMODE_NAME), name);
|
||||
if(StrEqual(prefix, ""))
|
||||
Format(GAMEMODE_PREFIX, sizeof(GAMEMODE_PREFIX), "[%s]", name);
|
||||
else
|
||||
Format(GAMEMODE_PREFIX, sizeof(GAMEMODE_PREFIX), "[%s]", prefix);
|
||||
}
|
||||
|
||||
public void Cleanup() {
|
||||
ClearPortalData();
|
||||
}
|
||||
|
||||
public void PrintToServer(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToServer("[%s] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Warn(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToServer("[%s::WARN] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Broadcast(const char[] format, any ...) {
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToChatAll("[%s] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void Debug(const char[] format, any ...) {
|
||||
if(_debugFlags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
if(_debugFlags & BaseDebug_Server)
|
||||
PrintToServer("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(_debugFlags & BaseDebug_ChatAll)
|
||||
PrintToChatAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(_debugFlags & BaseDebug_ConsoleAll)
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void DebugConsole(const char[] format, any ...) {
|
||||
if(_debugFlags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
public void DebugCustom(const char[] format, int flags, any ...) {
|
||||
if(flags == BaseDebug_None) return;
|
||||
VFormat(buffer, sizeof(buffer), format, 3);
|
||||
if(flags & BaseDebug_Server)
|
||||
PrintToServer("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(flags & BaseDebug_ChatAll)
|
||||
PrintToChatAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
if(flags & BaseDebug_ConsoleAll)
|
||||
PrintToConsoleAll("[%s/debug] %s", GAMEMODE_NAME, buffer);
|
||||
}
|
||||
|
||||
property bool Enabled {
|
||||
public get() {
|
||||
return isEnabled
|
||||
}
|
||||
public set(bool value) {
|
||||
isEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Blockers {
|
||||
public get() {
|
||||
return ents_NavBlockers;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_NavBlockers = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Props {
|
||||
public get() {
|
||||
return ents_Props;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_Props = value;
|
||||
}
|
||||
}
|
||||
|
||||
property bool Portals {
|
||||
public get() {
|
||||
return ents_Portals;
|
||||
}
|
||||
public set(bool value) {
|
||||
ents_Portals = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PeekCam specifics
|
||||
PeekCamera PeekCam;
|
||||
static int seekerCam = INVALID_ENT_REFERENCE;
|
||||
static bool isViewingCam[MAXPLAYERS+1];
|
||||
static int seekerTarget;
|
||||
|
||||
enum PeekPerspective {
|
||||
Cam_Unknown,
|
||||
Cam_FirstPerson,
|
||||
Cam_ThirdPerson
|
||||
}
|
||||
|
||||
methodmap PeekCamera {
|
||||
property int Target {
|
||||
public get() {
|
||||
return GetClientOfUserId(seekerTarget);
|
||||
}
|
||||
public set(int client) {
|
||||
this.Create();
|
||||
seekerTarget = GetClientUserId(client);
|
||||
|
||||
AcceptEntityInput(seekerCam, "ClearParent");
|
||||
AcceptEntityInput(seekerCam, "Disable");
|
||||
}
|
||||
}
|
||||
|
||||
property PeekPerspective Perspective {
|
||||
public set(PeekPerspective perspective) {
|
||||
this.SetPerspective(perspective);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPerspective(PeekPerspective perspective) {
|
||||
float pos[3], ang[3];
|
||||
int client = this.Target;
|
||||
GetClientEyePosition(this.Target, pos);
|
||||
GetClientEyeAngles(client, ang);
|
||||
|
||||
if(perspective == Cam_FirstPerson) {
|
||||
|
||||
TeleportEntity(seekerCam, pos, ang, NULL_VECTOR);
|
||||
SetParent(seekerCam, client);
|
||||
SetParentAttachment(seekerCam, "primary", false);
|
||||
} else if(perspective == Cam_ThirdPerson) {
|
||||
float endPos[3];
|
||||
TR_TraceRayFilter(pos, ang, CONTENTS_PLAYERCLIP | MASK_SOLID | MASK_VISIBLE, RayType_Infinite, Filter_IgnoreAll);
|
||||
if(TR_DidHit()) {
|
||||
TR_GetEndPosition(endPos);
|
||||
}
|
||||
endPos[2] += 50.0;
|
||||
|
||||
ang[0] = 0.0;
|
||||
float deltaA = endPos[0] - pos[0];
|
||||
float deltaB = endPos[1] - pos[1];
|
||||
float deltaC = endPos[2] - pos[2];
|
||||
ang[0] = RadToDeg(ArcTangent(deltaC / GetVectorDistance(endPos, pos, false) ));
|
||||
ang[1] = RadToDeg(ArcTangent2(deltaA, deltaB));
|
||||
TeleportEntity(seekerCam, endPos, ang, NULL_VECTOR);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetViewing(int client, bool active) {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE) {
|
||||
AcceptEntityInput(seekerCam, "Enable", client); // Need to always activate before deactivating to fix a semi-common bug
|
||||
if(!active) {
|
||||
AcceptEntityInput(seekerCam, "Disable", client);
|
||||
}
|
||||
} else {
|
||||
PrintToServer("WARN: SetPeekCamActive(%d, %b) when seekerCam invalid", client, active);
|
||||
}
|
||||
isViewingCam[client] = active;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsViewing(int client) {
|
||||
return isViewingCam[client];
|
||||
}
|
||||
|
||||
public void Create() {
|
||||
if(seekerCam == INVALID_ENT_REFERENCE || !IsValidEntity(seekerCam)) {
|
||||
seekerCam = CreateEntityByName("point_viewcontrol_survivor");
|
||||
DispatchKeyValue(seekerCam, "targetname", "hscam");
|
||||
DispatchSpawn(seekerCam);
|
||||
for(int i = 0; i <= MaxClients; i++) {
|
||||
isViewingCam[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exists() {
|
||||
return seekerCam != INVALID_ENT_REFERENCE && IsValidEntity(seekerCam)
|
||||
}
|
||||
|
||||
public void Destroy() {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE && IsValidEntity(seekerCam)) {
|
||||
AcceptEntityInput(seekerCam, "Disable");
|
||||
AcceptEntityInput(seekerCam, "Kill");
|
||||
seekerCam = INVALID_ENT_REFERENCE
|
||||
}
|
||||
seekerTarget = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Filter_IgnoreAll(int entity, int mask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enum struct EntityConfig {
|
||||
float origin[3];
|
||||
float rotation[3];
|
||||
char type[32];
|
||||
char model[64];
|
||||
float scale[3];
|
||||
float offset[3];
|
||||
}
|
||||
|
||||
enum struct MapConfig {
|
||||
ArrayList entities;
|
||||
ArrayList inputs;
|
||||
float spawnpoint[3];
|
||||
bool hasSpawnpoint;
|
||||
int mapTime;
|
||||
bool canClimb;
|
||||
bool pressButtons;
|
||||
}
|
||||
|
||||
MapConfig mapConfig;
|
||||
ArrayList validMaps;
|
||||
ArrayList validSets;
|
||||
|
||||
stock void SetParent(int child, int parent) {
|
||||
SetVariantString("!activator");
|
||||
AcceptEntityInput(child, "SetParent", parent);
|
||||
}
|
||||
|
||||
stock void SetParentAttachment(int child, const char[] attachment, bool withOffset = false) {
|
||||
SetVariantString(attachment);
|
||||
if(withOffset)
|
||||
AcceptEntityInput(child, "SetParentAttachmentMaintainOffset");
|
||||
else
|
||||
AcceptEntityInput(child, "SetParentAttachment");
|
||||
}
|
||||
|
||||
stock void ClearParent(int child) {
|
||||
AcceptEntityInput(child, "ClearParent");
|
||||
}
|
||||
|
|
|
@ -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,8 +282,10 @@ 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);
|
||||
|
@ -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];
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue