diff --git a/VScripts/scripting/include/vscripts.inc b/VScripts/scripting/include/vscripts.inc new file mode 100644 index 00000000..38d4848c --- /dev/null +++ b/VScripts/scripting/include/vscripts.inc @@ -0,0 +1,137 @@ +/* +** +*/ +#if defined _ENT_INDEX_included + #endinput +#endif +#define _ENT_INDEX_included + + +public int GetEntityIndexByHammerID(int HammerID, const char[] classname) { + int i = -1; + while((i = FindEntityByClassname(i,classname))!= -1){ + if(IsValidEntity(i)){ + if (GetEntProp(i, Prop_Data, "m_iHammerID") == HammerID) return i; + } + } + return -1; +} + +public int GetEntityIndexByName(const char[] name, const char[] classname){ + int i = -1; + char buffer[500]; + while((i = FindEntityByClassname(i, classname))!= -1){ + if(IsValidEntity(i)){ + GetEntPropString(i, Prop_Data, "m_iName", buffer, sizeof(buffer)); + if (strcmp(name, buffer, false) == 0) + return i; + } + } + return -1; +} + +public int FindEntityByClassnameWithin(int startEnt, const char[] classname, const float[3] origin, const float radius){ //Tested. Works properly. + float torigin[3]; + while((startEnt = FindEntityByClassname(startEnt,classname))!= -1){ + GetOrigin(startEnt, torigin); + if (GetVectorDistance(torigin, origin) <= radius)return startEnt; + } + return -1; +} + +public float TraceLine(const float[3] origin, const float[3] v2, int entity){ //Tested. Works properly + Handle trace = TR_TraceRayFilterEx(origin, v2, CONTENTS_SOLID, RayType_EndPoint, TraceEntityFilterSelf, entity); + float pos[3], dist = 1.0; + if(TR_DidHit(trace)){ + TR_GetEndPosition(pos, trace); + dist = GetVectorDistance(origin, pos)/GetVectorDistance(origin, v2); + } + CloseHandle(trace); + return dist; +} + +public bool TraceEntityFilterSelf(int entity, int contentsMask, any data) +{ + return (data != entity && entity > 64); +} + +public void GetOrigin(int entity, float[3] buffer){ //Tested. Works properly. + if(IsValidEntity(entity)) + GetEntPropVector(entity, Prop_Send, "m_vecOrigin", buffer); +} + +public void GetAngles(int entity, float[3] buffer){ //Gives you wrong values after spawn it via env_entity_maker + if(IsValidEntity(entity)) + GetEntPropVector(entity, Prop_Send, "m_angRotation", buffer); +} + +public void SetAngles(int entity, const float[3] buffer){ //Tested. Works properly. + if(IsValidEntity(entity)) + TeleportEntity(entity, NULL_VECTOR, buffer, NULL_VECTOR); +} + +public void SetOrigin(int entity, const float[3] buffer){ //Tested. Works properly. + if(IsValidEntity(entity)) + TeleportEntity(entity, buffer, NULL_VECTOR, NULL_VECTOR); +} + +public void GetForwardVector(int entity, float[3] buffer) //Tested. Works properly. +{ + if(IsValidEntity(entity)) + { + float tmp[3]; + GetAngles(entity, tmp); + GetAngleVectors(tmp, buffer, NULL_VECTOR, NULL_VECTOR); + } +} + +public void SetForwardVector(int entity, const float[3] buffer) //Tested. Works properly. +{ + if(IsValidEntity(entity)) + { + float tmp[3]; + //GetAngles(entity, tmp); + //tmp[0] = RadToDeg(-ArcSine(buffer[2])); + //tmp[1] = RadToDeg(ArcTangent2(buffer[1], buffer[0])); + GetVectorAngles(buffer, tmp); + SetAngles(entity, tmp); + } +} + +public void EntFire(const char[] target, const char[] input, const char[] parametr, const char[] delay, int activator){ //Tested. Works properly. + char output[500]; + int tmp = CreateEntityByName("info_target"); + Format(output, sizeof(output), "OnUser1 %s:%s:%s:%s", target, input, parametr, delay); + SetVariantString(output); + AcceptEntityInput(tmp, "AddOutput"); + AcceptEntityInput(tmp, "FireUser1", activator); + AcceptEntityInput(tmp, "Kill"); +} + +public void EntFireByIndex(int target, const char[] input, const char[] parametr, const char[] delay, int activator){ //Tested. Works properly. + if(!IsValidEntity(target)) + return; + float fDelay = StringToFloat(delay); + DataPack data = CreateDataPack(); + data.WriteString(input); + data.WriteString(parametr); + data.WriteCell(activator); + data.WriteCell(EntIndexToEntRef(target)); + CreateTimer(fDelay, InputDelay, data, TIMER_DATA_HNDL_CLOSE|TIMER_FLAG_NO_MAPCHANGE); +} + +public Action InputDelay(Handle timer, DataPack data) +{ + char input[250], parametr[250]; + data.Reset(); + data.ReadString(input, sizeof(input)); + data.ReadString(parametr, sizeof(parametr)); + int activator = data.ReadCell(); + int target = EntRefToEntIndex(data.ReadCell()); + data.Reset(true); + if(IsValidEntity(target)) + { + SetVariantString(parametr); + AcceptEntityInput(target, input, activator); + } +} \ No newline at end of file diff --git a/VScripts/scripting/include/vscripts/Aesthetic.inc b/VScripts/scripting/include/vscripts/Aesthetic.inc new file mode 100644 index 00000000..13000f9c --- /dev/null +++ b/VScripts/scripting/include/vscripts/Aesthetic.inc @@ -0,0 +1,568 @@ +/* +** +*/ +#if defined _AESTHETIC_included + #endinput +#endif +#define _AESTHETIC_included +#include +#include +#define CELL_SIZE 128.0 + +methodmap Chess < Basic +{ + public Chess(int greenStart, int greenEnd, int purpleStart, int purpleEnd) + { + Basic myclass = new Basic(); + myclass.SetFloat("fGreenX", 2.0); + myclass.SetFloat("fGreenY", 6.0); + myclass.SetFloat("fPurpleX", 4.0); + myclass.SetFloat("fPurpleY", 1.0); + myclass.SetInt("iGreenStart", greenStart); + myclass.SetInt("iGreenEnd", greenEnd); + myclass.SetInt("iPurpleStart", purpleStart); + myclass.SetInt("iPurpleEnd", purpleEnd); + myclass.SetBool("bDead", false); + return view_as(myclass); + } + + property bool bDead + { + public get() + { + return this.GetBool("bDead"); + } + public set(bool val) + { + this.SetBool("bDead", val); + } + } + + property float greenX + { + public get() + { + return this.GetFloat("fGreenX"); + } + public set(float val) + { + this.SetFloat("fGreenX", val); + } + } + + property float greenY + { + public get() + { + return this.GetFloat("fGreenY"); + } + public set(float val) + { + this.SetFloat("fGreenY", val); + } + } + + property float purpleX + { + public get() + { + return this.GetFloat("fPurpleX"); + } + public set(float val) + { + this.SetFloat("fPurpleX", val); + } + } + + property float purpleY + { + public get() + { + return this.GetFloat("fPurpleY"); + } + public set(float val) + { + this.SetFloat("fPurpleY", val); + } + } + + property int greenStart + { + public get() + { + return this.GetInt("iGreenStart"); + } + } + + property int greenEnd + { + public get() + { + return this.GetInt("iGreenEnd"); + } + } + + property int purpleStart + { + public get() + { + return this.GetInt("iPurpleStart"); + } + } + + property int purpleEnd + { + public get() + { + return this.GetInt("iPurpleEnd"); + } + } + + public bool Check(float x, float y) + { + return (-1.0 < x && x < 8.0 && -1.0 < y && y < 8.0 && !((x == this.greenX && y == this.greenY) || (x == this.purpleX && y == this.purpleY))); + } + + public void UpdateGreen(float dx, float dy) + { + this.greenX += dx; + this.greenY += dy; + } + + public void UpdateGreenEnd(float dx, float dy) + { + float currentPos[3]; + GetOrigin(this.greenEnd, currentPos); + float moveVector[3] = { 0.0, ... }; + moveVector[0] = dx * CELL_SIZE; + moveVector[1] = dy * CELL_SIZE; + float tmp[3]; + AddVectors(currentPos, moveVector, tmp); + SetOrigin(this.greenEnd, tmp); + } + + public void MoveGreen(float dx, float dy) + { + if (this.Check(this.greenX + dx, this.greenY + dy)) + { + this.UpdateGreen(dx, dy); + this.UpdateGreenEnd(dx, dy); + } + } + + public void MoveStartToEnd(int start, int end) + { + float e_Orig[3]; + GetOrigin(end, e_Orig); + SetOrigin(start, e_Orig); + } + + public void UpdatePurple(float dx, float dy) + { + this.purpleX += dx; + this.purpleY += dy; + } + + public void UpdatePurpleEnd(float dx, float dy) + { + float currentPos[3]; + GetOrigin(this.purpleEnd, currentPos); + float moveVector[3] = { 0.0, ... }; + moveVector[0] = dx * CELL_SIZE; + moveVector[1] = dy * CELL_SIZE; + float tmp[3]; + AddVectors(currentPos, moveVector, tmp); + SetOrigin(this.purpleEnd, tmp); + } + + public void MovePurple(float dx, float dy) + { + if (this.Check(this.purpleX + dx, this.purpleY + dy)) + { + this.UpdatePurple(dx, dy); + this.UpdatePurpleEnd(dx, dy); + } + } + + public void CheckInLove() + { + if(this.bDead) + return; + float dx = this.greenX - this.purpleX; + float dy = this.greenY - this.purpleY; + if (dx < 0.0) dx *= -1.0; + if (dy < 0.0) dy *= -1.0; + if (dx + dy == 1.0) + { + this.bDead = true; + EntFire("TotalTrigger", "FireUser2", "", "0.0", -1); + } + } +} + +const int DEFAULT_RETARGET_TICKS = 200; +const float DEFAULT_MAX_VEL = 16.0; +const float DEFAULT_MAX_ACC = 0.1; +const float DEFAULT_RANGE = 100000.0; +const float DEFAULT_PER_FRAME_MAX_VEL_DELTA = 0.0003333; // 2.0 / (120.0 * 50.0); +const float DEFAULT_PER_FRAME_MAX_ACC_DELTA = 0.0000125; // 0.075 / (120.0 * 50.0); +#define PI 3.14159 + +public bool SphereCollideWithWorld(const float[3] orig, const float radius, float degree, float[3] buffer, int entity) +{ + + float inc = PI / degree; + float phiStop = PI - inc; + + float minDist = 1.0; + for (float phi = 0.0; phi < PI; phi += inc) + { + // Avoid computing the full circle on the edge cases + float theta = 0.0; + if (phi == 0.0 || phi == phiStop) + theta = PI - inc; + + float cp = Cosine(phi); + float sp = Sine(phi); + for (; theta < 2 * PI; theta += inc) + { + float ct = Cosine(theta); + float st = Sine(theta); + float vec[3]; + vec[0] = ct * sp; + vec[1] = st * sp; + vec[2] = cp; + ScaleVector(vec, radius); + + float end[3]; + AddVectors(orig, vec, end); + float dist = TraceLine(orig, end, entity); + if ( 0 < dist && dist < minDist) + { + ScaleVector(vec, dist); + AddVectors(orig, vec, buffer); + return true; + } + } + } + return false; +} + +methodmap Eye < Basic +{ + public Eye(int entity) + { + Basic myclass = new Basic(); + myclass.SetInt("iEntity", entity); + myclass.SetInt("iTarget", -1); + myclass.SetFloat("fBossRadius", 72.0); + myclass.SetInt("iBossTeamTarget", 3); + myclass.SetInt("iRetargetTicks", 0); + myclass.SetFloat("fMaxVel", DEFAULT_MAX_VEL); + myclass.SetFloat("fMaxAcc", DEFAULT_MAX_ACC); + myclass.SetVector("vVec", { 0.0, 0.0, 0.0 } ); + myclass.SetVector("vAcc", { 0.0, 0.0, 0.0 } ); + myclass.SetFloat("fSavedVel", 0.0); + myclass.SetFloat("fSavedAcc", 0.0); + return view_as(myclass); + } + + property int entity + { + public get() + { + return this.GetInt("iEntity"); + } + } + + property int target + { + public get() + { + return this.GetInt("iTarget"); + } + public set(int val) + { + this.SetInt("iTarget", val); + } + } + + property float bossRadius + { + public get() + { + return this.GetFloat("fBossRadius"); + } + public set(float val) + { + this.SetFloat("fBossRadius", val); + } + } + + property int bossTeamTarget + { + public get() + { + return this.GetInt("iBossTeamTarget"); + } + public set(int val) + { + this.SetInt("iBossTeamTarget", val); + } + } + + property int retargetTicks + { + public get() + { + return this.GetInt("iRetargetTicks"); + } + public set(int val) + { + this.SetInt("iRetargetTicks", val); + } + } + + property float maxVel + { + public get() + { + return this.GetFloat("fMaxVel"); + } + public set(float val) + { + this.SetFloat("fMaxVel", val); + } + } + + property float maxAcc + { + public get() + { + return this.GetFloat("fMaxAcc"); + } + public set(float val) + { + this.SetFloat("fMaxAcc", val); + } + } + + property float savedVel + { + public get() + { + return this.GetFloat("fSavedVel"); + } + public set(float val) + { + this.SetFloat("fSavedVel", val); + } + } + + property float savedAcc + { + public get() + { + return this.GetFloat("fSavedAcc"); + } + public set(float val) + { + this.SetFloat("fSavedAcc", val); + } + } + + public void GetVel(float[3] vel) + { + this.GetVector("vVel", vel); + } + + public void SetVel(const float[3] vel) + { + this.SetVector("vVel", vel); + } + + public void GetAcc(float[3] acc) + { + this.GetVector("vAcc", acc); + } + + public void SetAcc(const float[3] acc) + { + this.SetVector("vAcc", acc); + } + + public void Retarget() + { + + // Start the gig + this.retargetTicks = 0; + int tempPlayer = -1; + int currentPlayer = -1; + int checkedPlayers = 0; + float distance = DEFAULT_RANGE; + + // While there is no target or + // players found as potential targets aren't humans + while (checkedPlayers < MaxClients) { + currentPlayer = FindEntityByClassname(currentPlayer, "player"); + + // Only humans are valid + if(currentPlayer != -1 && + IsPlayerAlive(currentPlayer) && + GetClientTeam(currentPlayer) == this.bossTeamTarget) + { + float tmp[3], s_orig[3], p_orig[3]; + GetOrigin(this.entity, s_orig); + GetOrigin(currentPlayer, p_orig); + SubtractVectors(s_orig, p_orig, tmp); + float length = GetVectorLength(tmp); + + // Make sure we're close enough + if (length < distance) + { + tempPlayer = currentPlayer; + distance = length; + } + } + // Make sure we don't stay here forever + checkedPlayers++; + } + + // Try the last bet if no player was found + this.target = tempPlayer; + + } + + public void Stop() + { + // Save the values + this.savedVel = this.maxVel; + this.savedAcc = this.maxAcc; + + // Block movement (with a bit of velocity to avoid spinning) + this.maxVel = 0.01; + this.maxAcc = 0.0001; + } + + public void AllowMovement() + { + // Set either default or saved vals + if (this.savedVel == 0.0) this.maxVel = DEFAULT_MAX_VEL; + else this.maxVel = this.savedVel; + + if (this.savedAcc == 0.0) this.maxAcc = DEFAULT_MAX_ACC; + else this.maxAcc = this.savedAcc; + + // Reset saved values + this.savedVel = 0.0; + this.savedAcc = 0.0; + } + + public void FakePhysicsMovement() + { + + // Get the center and end point + float cnt[3]; + GetOrigin(this.entity, cnt); + + // Make the boss face the target + float tmp[3]; + this.GetVel(tmp); + SetForwardVector(this.entity, tmp); + + // If there is an impact, bounce + float collPoint[3]; + if (SphereCollideWithWorld(cnt, this.bossRadius, 5.0, collPoint, this.entity)) + { + + float vec[3]; + SubtractVectors(cnt, collPoint, vec); + float norm[3], norm_copy[3]; + NormalizeVector(vec, norm); + norm_copy[0] = norm[0]; + norm_copy[1] = norm[1]; + norm_copy[2] = norm[2]; + // Reflect velocity in a hacky way (not plane-accurate) + float nn[3]; + NormalizeVector(norm, nn); + this.GetVel(tmp); + float dot = GetVectorDotProduct(tmp, nn); + ScaleVector(norm_copy, 2 * dot); + SubtractVectors(tmp, norm_copy, tmp); + this.SetVel(tmp); + EntFireByIndex(this.entity, "FireUser1", "", "0.0", this.target); + // Move as far as we can + ScaleVector(norm, this.bossRadius); + AddVectors(cnt, norm, tmp); + SetOrigin(this.entity, tmp); + } + else + { + + this.GetVel(tmp); + AddVectors(cnt, tmp, tmp); + SetOrigin(this.entity, tmp); + } + } + + public void Move() + { + + // If there is no target or the target is gone/dead, retarget + if (this.target == -1 || + !IsValidEntity(this.target) || + !IsPlayerAlive(this.target) || + this.retargetTicks++ >= DEFAULT_RETARGET_TICKS) this.Retarget(); + + // Perform the update with the data from the previous moment + float vel[3], tmp[3], acc[3]; + this.GetVel(vel); + this.GetAcc(acc); + AddVectors(vel, acc, tmp); + this.SetVel(tmp); + float length = GetVectorLength(tmp); + if (length > this.maxVel) + { + ScaleVector(tmp, this.maxVel / length); + this.SetVel(tmp); + } + this.SetAcc( { 0.0, 0.0, 0.0 } ); + + // Apply the higher accuracy movement deltas + this.maxVel += DEFAULT_PER_FRAME_MAX_VEL_DELTA; + this.maxAcc += DEFAULT_PER_FRAME_MAX_ACC_DELTA; + + // Try to move, finally + this.FakePhysicsMovement(); + + // Keep going if no target's there still + if (this.target == -1) return; + + // Try moving towards our target if it exists, otherwise don't + + float tgtPos[3]; + GetOrigin(this.target, tgtPos); + float bssPos[3]; + GetOrigin(this.entity, bssPos); + float dir[3]; + SubtractVectors(tgtPos, bssPos, dir); + + // Compute the length for later and normalize it if needed + + length = GetVectorLength(dir); + if (length > this.maxVel) + ScaleVector(dir, this.maxVel / length); + + // Compute the acceleration + + this.GetVel(vel); + SubtractVectors(dir, vel, acc); + length = GetVectorLength(acc); + if (length > this.maxAcc) + { + ScaleVector(acc, this.maxAcc / length); + this.SetAcc(acc); + } + + } +} \ No newline at end of file diff --git a/VScripts/scripting/include/vscripts/Fly.inc b/VScripts/scripting/include/vscripts/Fly.inc new file mode 100644 index 00000000..a9c01d61 --- /dev/null +++ b/VScripts/scripting/include/vscripts/Fly.inc @@ -0,0 +1,1330 @@ +/* +** +*/ +#if defined _FLY_MM_included + #endinput +#endif +#define _FLY_MM_included +#include +#include +#include +#include + +enum Fly_Type +{ + eFlyBase = 0, + eFlySmall = 1, + eFly = 2, + eFlyEnd = 3, + eFlyEndHovno = 4 +}; + +float TOASTER_POSITION[] = { 7063.0, 2329.0, -360.0 }; + +const int t_len = 6; +float TARGET_NODES[][] = { + {-2400.0, 5136.0, -611.0}, + {5824.0, 2337.0, -64.0}, + {3600.0, 4496.0, -256.0}, + {3456.0, 7680.0, -375.98}, + {2080.0, 9790.1, -2696.0}, + {1100.99, 10777.0, -2680.0} + }; + +//const int t_len_0 = 6, t_len_1 = 1; +//float TARGET_NODES2[][][] = { + //{ + //{5756.0, 4749.0, -390.0}, + //{6000.0, 2336.0, -288.0}, + //{3608.0, 4496.0, -472.0}, + //{3456.0, 7680.0, -375.98}, + //{2080.0, 9790.1, -2696.0}, + //{1100.99, 10777.0, -2680.0} + //}, + //{ + //{895.99, 11192.0, -2216.0}, + //{0.0, 0.0, 0.0}, + //{0.0, 0.0, 0.0}, + //{0.0, 0.0, 0.0}, + //{0.0, 0.0, 0.0}, + //{0.0, 0.0, 0.0} + //} + //}; + +public bool IsValidPlayer(int player) +{ + return player >= 1 && player <= 64 && IsValidEntity(player) && IsPlayerAlive(player); +} + +methodmap Fly_base < Basic +{ + public Fly_base(int entity) + { + Basic myclass = new Basic(); + myclass.SetInt("iEntity", entity); + myclass.SetFloat("fSpeed", 25.0); + myclass.SetFloat("fRotation_speed", 0.05); + myclass.SetFloat("fPrevious_distance_to_target", -1.0); + myclass.SetFloat("fCurrent_distance_to_target", -1.0); + myclass.SetFloat("fBlocker1", 0.0); + myclass.SetFloat("fBlocker2", 100.0); + myclass.SetFloat("fRot_speed_min", 0.05); + myclass.SetFloat("fRot_speed_max", 0.2); + myclass.SetFloat("fRot_speed_acceleration", 0.0005); + myclass.SetFloat("fRot_err", 0.15); + myclass.SetFloat("fSpeed_acceleration", 0.3); + myclass.SetFloat("fMax_speed", 50.0); + myclass.SetInt("iType", view_as(eFlyBase)); + myclass.SetBool("bDoNextTick", true); + return view_as(myclass); + } + + property bool doNextTick + { + public get() + { + return this.GetBool("bDoNextTick"); + } + public set(bool val) + { + this.SetBool("bDoNextTick", val); + } + } + + property Fly_Type type + { + public get() + { + return view_as(this.GetInt("iType")); + } + public set(Fly_Type val) + { + this.SetInt("iType", view_as(val)); + } + } + + property float max_speed + { + public get() + { + return this.GetFloat("fMax_speed"); + } + public set(float val) + { + this.SetFloat("fMax_speed", val); + } + } + + property float speed_acceleration + { + public get() + { + return this.GetFloat("fSpeed_acceleration"); + } + public set(float val) + { + this.SetFloat("fSpeed_acceleration", val); + } + } + + property float rot_err + { + public get() + { + return this.GetFloat("fRot_err"); + } + public set(float val) + { + this.SetFloat("fRot_err", val); + } + } + + property float rot_speed_acceleration + { + public get() + { + return this.GetFloat("fRot_speed_acceleration"); + } + public set(float val) + { + this.SetFloat("fRot_speed_acceleration", val); + } + } + + property float rot_speed_min + { + public get() + { + return this.GetFloat("fRot_speed_min"); + } + public set(float val) + { + this.SetFloat("fRot_speed_min", val); + } + } + + property float rot_speed_max + { + public get() + { + return this.GetFloat("fRot_speed_max"); + } + public set(float val) + { + this.SetFloat("fRot_speed_max", val); + } + } + + property float blocker1 + { + public get() + { + return this.GetFloat("fBlocker1"); + } + public set(float val) + { + this.SetFloat("fBlocker1", val); + } + } + + property float blocker2 + { + public get() + { + return this.GetFloat("fBlocker2"); + } + public set(float val) + { + this.SetFloat("fBlocker2", val); + } + } + + property int entity + { + public get() + { + return this.GetInt("iEntity"); + } + } + + property float speed + { + public get() + { + return this.GetFloat("fSpeed"); + } + public set(float val) + { + this.SetFloat("fSpeed", val); + } + } + + property float rotation_speed + { + public get() + { + return this.GetFloat("fRotation_speed"); + } + public set(float val) + { + this.SetFloat("fRotation_speed", val); + } + } + + property float previous_distance_to_target + { + public get() + { + return this.GetFloat("fPrevious_distance_to_target"); + } + public set(float val) + { + this.SetFloat("fPrevious_distance_to_target", val); + } + } + + property float current_distance_to_target + { + public get() + { + return this.GetFloat("fCurrent_distance_to_target"); + } + public set(float val) + { + this.SetFloat("fCurrent_distance_to_target", val); + } + } + public void MoveTowardsTarget(const float[3] fly, const float[3] target) + { + float targetDir[3]; + SubtractVectors(target, fly, targetDir); + NormalizeVector(targetDir, targetDir); + float currentDir[3]; + GetForwardVector(this.entity, currentDir); + float dir[3]; + GetNewDir(this, targetDir, currentDir, dir); + dir[2] = targetDir[2]; + SetForwardVector(this.entity, dir); + MoveForward(this, this.blocker1, this.blocker2); + } +} + +methodmap Fly_Small < Fly_base +{ + public Fly_Small(int entity) + { + Fly_base myclass = new Fly_base(entity); + myclass.SetBool("bDead", false); + myclass.SetInt("iRetarget", 10); + myclass.SetInt("iTarget", -1); + myclass.type = eFlySmall; + return view_as(myclass); + } + + property bool dead + { + public get() + { + return this.GetBool("bDead"); + } + public set(bool val) + { + this.SetBool("bDead", val); + } + } + + property int retarget + { + public get() + { + return this.GetInt("iRetarget"); + } + public set(int val) + { + this.SetInt("iRetarget", val); + } + } + + property int target + { + public get() + { + return this.GetInt("iTarget"); + } + public set(int val) + { + this.SetInt("iTarget", val); + } + } + + public void Start() + { + + float currentAngle[3]; + GetForwardVector(this.entity, currentAngle); + currentAngle[2] = 0.0; + SetForwardVector(this.entity, currentAngle); + float orig[3]; + GetOrigin(this.entity, orig); + orig[2] += 40.0; + SetOrigin(this.entity, orig); + + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + + public void Tick() + { + + float flyPos[3], flyPos_copy[3]; + GetOrigin(this.entity, flyPos); + GetOrigin(this.entity, flyPos_copy); + flyPos_copy[2] -= 300.0; + if (this.dead) + { + float distToFloor = TraceLine(flyPos, flyPos_copy, this.entity); + if (distToFloor < 0.03) + { + + EntFireByIndex(this.entity, "SetAnimation", "dead", "0.0", -1); + EntFireByIndex(this.entity, "SetAnimation", "dead_loop", "2.0", -1); + EntFireByIndex(this.entity, "kill", "", "20.0", -1); + delete this; + return; + } + else + { + + MoveDir(this, {0.0, 0.0, -1.0}); + } + } + + /*** Move towards a targetted player ***/ + else if(IsValidPlayer(this.target)) + { + + ChasePlayer(this, flyPos); + } + + /*** Search for a target player ***/ + else + { + + this.target = GetNewTarget(this); + flyPos_copy[2] += 400.0; + if (this.target == -1 && TraceLine(flyPos, flyPos_copy, this.entity) >= 1.0) + { + MoveDir(this, {0.0, 0.0, 1.0}); + } + } + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + public void Die() + { + + this.dead = true; + this.speed = 0.0; + } +} + +methodmap Fly < Fly_Small +{ + public Fly(int entity) + { + Fly_Small myclass = new Fly_Small(entity); + myclass.type = eFly; + myclass.speed = 35.0; + myclass.retarget = 8; + myclass.blocker1 = 50.0; + myclass.blocker2 = 160.0; + myclass.rot_speed_min = 0.025; + myclass.rot_speed_max = 0.1; + myclass.speed_acceleration = 0.25; + myclass.max_speed = 85.0; + myclass.SetBool("bStarted", false); + myclass.SetBool("bGrabbed_player", false); + myclass.SetBool("bReturn_to_toaster", false); + myclass.SetBool("bSpawn_eggs", false); + myclass.SetInt("iHealth", 1000); + myclass.SetInt("iPlayers_in_arena", 0); + myclass.SetInt("iEggs_currently_spawned", 0); + myclass.SetInt("iMax_spawned_eggs", 0); + myclass.SetHandle("lGrabbed_players", new ArrayList()); + myclass.SetHandle("lGrabbed_players_dead", new ArrayList()); + return view_as(myclass); + } + + property bool started + { + public get() + { + return this.GetBool("bStarted"); + } + public set(bool val) + { + this.SetBool("bStarted", val); + } + } + property bool grabbed_player + { + public get() + { + return this.GetBool("bGrabbed_player"); + } + public set(bool val) + { + this.SetBool("bGrabbed_player", val); + } + } + property bool return_to_toaster + { + public get() + { + return this.GetBool("bReturn_to_toaster"); + } + public set(bool val) + { + this.SetBool("bReturn_to_toaster", val); + } + } + property bool spawn_eggs + { + public get() + { + return this.GetBool("bSpawn_eggs"); + } + public set(bool val) + { + this.SetBool("bSpawn_eggs", val); + } + } + property int health + { + public get() + { + return this.GetInt("iHealth"); + } + public set(int val) + { + this.SetInt("iHealth", val); + } + } + property int players_in_arena + { + public get() + { + return this.GetInt("iPlayers_in_arena"); + } + public set(int val) + { + this.SetInt("iPlayers_in_arena", val); + } + } + property int eggs_currently_spawned + { + public get() + { + return this.GetInt("iEggs_currently_spawned"); + } + public set(int val) + { + this.SetInt("iEggs_currently_spawned", val); + } + } + property int max_spawned_eggs + { + public get() + { + return this.GetInt("iMax_spawned_eggs"); + } + public set(int val) + { + this.SetInt("iMax_spawned_eggs", val); + } + } + property ArrayList grabbed_players + { + public get() + { + return view_as(this.GetHandle("lGrabbed_players")); + } + public set(ArrayList list) + { + this.SetHandle("lGrabbed_players", list); + } + } + property ArrayList grabbed_players_dead + { + public get() + { + return view_as(this.GetHandle("lGrabbed_players_dead")); + } + public set(ArrayList list) + { + this.SetHandle("lGrabbed_players_dead", list); + } + } + + public void TeleportGrabbedPlayers(const float[3] position) + { + for (int i = 0; i < this.grabbed_players.Length; i++) + { + if (IsValidPlayer(this.grabbed_players.Get(i))) + { + if(GetClientTeam(this.grabbed_players.Get(i)) == 3) + SetOrigin(this.grabbed_players.Get(i), position); + } + } + } + + public bool IsValidTarget() + { + return IsValidPlayer(this.target) && !IsElementInArray(this.target, this.grabbed_players) && !IsElementInArray(this.target, this.grabbed_players_dead); + } + + public void Start() + { + this.max_spawned_eggs = this.players_in_arena / 6; + this.started = true; + EntFireByIndex(this.entity, "SetAnimation", "fly", "0.00", -1); + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + + public void KillFly() + { + delete this.grabbed_players_dead; + delete this.grabbed_players; + delete this; + } + + public void Tick() + { + float flyPos[3], flyPos_copy[3]; + GetOrigin(this.entity, flyPos); + GetOrigin(this.entity, flyPos_copy); + flyPos_copy[2] -= 300.0; + float distToFloor = TraceLine(flyPos, flyPos_copy, this.entity); + + /*****************************/ + /*** Stuff done every tick ***/ + /*****************************/ + + /*** Grab a near player ***/ + int playerNear; + float point[3], fwd[3]; + GetForwardVector(this.entity, fwd); + ScaleVector(fwd, 80.0); + AddVectors(flyPos, fwd, point); + + if(!this.dead && (playerNear = FindEntityByClassnameWithin(playerNear, "player", point, 64.0)) != -1) + { + if(GetClientTeam(playerNear) == 3) + { + if(!IsElementInArray(playerNear, this.grabbed_players) && !IsElementInArray(playerNear, this.grabbed_players_dead)) + { + this.grabbed_players.Push(playerNear); + this.grabbed_players_dead.Push(playerNear); + + if ((this.target = GetNewTarget(this)) == -1 || !this.IsValidTarget()) + this.return_to_toaster = true; + else if (!this.grabbed_player) + CreateTimer(15.0, SetReturn_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + if (playerNear == this.target) + this.target = -1; + + this.grabbed_player = true; + } + } + } + + /*** Teleport grabbed players ***/ + if (!this.dead) + { + flyPos_copy[2] += 260; + this.TeleportGrabbedPlayers(flyPos_copy); + } + + /*** Random chance to spawn an egg ***/ + if (!this.grabbed_player && this.eggs_currently_spawned != this.max_spawned_eggs && GetRandomInt(0, 500) == 0 && distToFloor > 0.1) + { + this.spawn_eggs = true; + } + + /*************************/ + /*** Decide what to do ***/ + /*************************/ + + /*** Fly died - fall to the ground ***/ + if (this.dead) + { + + if (distToFloor < 0.05) + { + EntFire("fly_dead", "FireUser1", "", "0.00", -1); + EntFire("fly", "Kill", "", "0.02", -1); + return; + } + else + { + MoveDir(this, {0.0, 0.0, -1.0}); + } + } + + /*** Move to the floor to spawn eggs ***/ + else if (!this.grabbed_player && this.spawn_eggs && this.eggs_currently_spawned < this.max_spawned_eggs && distToFloor < 1.0 && this.speed < this.max_speed / 2.0) + { + this.spawn_eggs = false; + this.eggs_currently_spawned++; + int eggSpawner = GetEntityIndexByHammerID(1248969, "env_entity_maker"); + TeleportEntity(eggSpawner, flyPos, { 0.0, 0.0, 0.0 }, NULL_VECTOR); + AcceptEntityInput(eggSpawner, "ForceSpawn"); + } + + /*** Move towards a targetted player ***/ + else if(!this.return_to_toaster && IsValidPlayer(this.target)) + { + ChasePlayer(this, flyPos); + } + + /*** Take the grabbed player(s) above the toaster ***/ + else if(this.return_to_toaster) + { + // Fast approx of distance without needing sqrt + this.current_distance_to_target = FloatAbs(TOASTER_POSITION[0] - flyPos[0]) + FloatAbs(TOASTER_POSITION[1] - flyPos[1]); + + float distToToaster[3]; + SubtractVectors(flyPos, TOASTER_POSITION, distToToaster); + if (FloatAbs(distToToaster[0]) < 80.0 && FloatAbs(distToToaster[1]) < 80.0 && FloatAbs(distToToaster[2]) < 80.0) + { + this.grabbed_player = false; + this.return_to_toaster = false; + this.grabbed_players.Clear(); + this.previous_distance_to_target = -1.0; + } + else + { + this.MoveTowardsTarget(flyPos, TOASTER_POSITION); + this.previous_distance_to_target = this.current_distance_to_target; + } + } + + /*** Search for a target player ***/ + else + { + this.target = GetNewTarget(this); + if (!this.IsValidTarget()) + this.target = -1; + flyPos_copy[2] += 140; + if (this.target == -1 && TraceLine(flyPos, flyPos_copy, this.entity) >= 1.0) + MoveDir(this, { 0.0, 0.0, 1.0 } ); + } + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + + public void SetReturn(bool state) + { + this.return_to_toaster = state; + } + + public void AddHealth(int hp) + { + this.health += hp; + this.players_in_arena++; + } + + public void Hit() + { + if (this.started && !this.dead) + { + this.health--; + char param[256]; + Format(param, sizeof(param), "message Fly %i HP", this.health); + EntFire("fly_text", "AddOutput", param, "0.0", -1); + EntFire("fly_text", "Display", "", "0.01", -1); + } + + if (this.health == 0 && !this.dead) + { + EntFire("fly_dead_relay", "Trigger", "", "0.0", -1); + this.dead = true; + float flyPos[3]; + GetOrigin(this.entity, flyPos); + flyPos[2] += 160.0; + this.TeleportGrabbedPlayers(flyPos); + this.grabbed_player = false; + this.grabbed_players.Clear(); + this.speed = 0.0; + } + } + + public void IncrementEggCount(int count) + { + this.eggs_currently_spawned += count; + } +} + +public Action SetReturn_Cb(Handle timer, Fly fly) +{ + KillTimer(timer); + fly.SetReturn(true); + return Plugin_Stop; +} + +methodmap Fly_End < Fly_base +{ + public Fly_End(int entity) + { + Fly_base myclass = new Fly_base(entity); + myclass.type = eFlyEnd; + myclass.blocker1 = 60.0; + myclass.blocker2 = 60.0; + myclass.rot_speed_max = 0.4; + myclass.rot_speed_min = 0.1; + myclass.speed_acceleration = 0.25; + myclass.max_speed = 85.0; + myclass.SetBool("bEnd", false); + myclass.SetInt("iCurrent_node", 0); + myclass.SetHandle("lGrabbed_players", new ArrayList()); + myclass.speed = 35.0; + return view_as(myclass); + } + property bool end + { + public get() + { + return this.GetBool("bEnd"); + } + public set(bool val) + { + this.SetBool("bEnd", val); + } + } + property int current_node + { + public get() + { + return this.GetInt("iCurrent_node"); + } + public set(int val) + { + this.SetInt("iCurrent_node", val); + } + } + property ArrayList grabbed_players + { + public get() + { + return view_as(this.GetHandle("lGrabbed_players")); + } + public set(ArrayList list) + { + this.SetHandle("lGrabbed_players", list); + } + } + public void TeleportGrabbedPlayers(const float[3] position) + { + for (int i = 0; i < this.grabbed_players.Length; i++) + { + if (IsValidPlayer(this.grabbed_players.Get(i))) + { + if(GetClientTeam(this.grabbed_players.Get(i)) == 3) + SetOrigin(this.grabbed_players.Get(i), position); + } + } + } + + public void KillFly() + { + delete this.grabbed_players; + delete this; + } + + public void Start() + { + EntFireByIndex(this.entity, "SetAnimation", "fly", "0.00", -1); + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + public void Tick() + { + float flyPos[3], flyPos_copy[3]; + GetOrigin(this.entity, flyPos); + GetOrigin(this.entity, flyPos_copy); + float targetNode[3]; + MakeVectorFromPoints( { 0.0, 0.0, 0.0 }, TARGET_NODES[this.current_node], targetNode); + int playerNear; + float point[3], fwd[3]; + GetForwardVector(this.entity, fwd); + ScaleVector(fwd, 80.0); + AddVectors(flyPos, fwd, point); + + /*** Kill nearby physboxes ***/ + int physbox; + if ((physbox = FindEntityByClassnameWithin(physbox, "func_physbox", flyPos, 350.0)) != -1) + { + EntFireByIndex(physbox, "FireUser2", "", "0.00", -1); + } + + /*** Grab a near player ***/ + if((playerNear = FindEntityByClassnameWithin(playerNear, "player", point, 100.0)) != -1) + { + if(GetClientTeam(playerNear) == 3) + { + if(!IsElementInArray(playerNear, this.grabbed_players)) + { + this.grabbed_players.Push(playerNear); + } + } + } + + if((playerNear = FindEntityByClassnameWithin(playerNear, "player", point, 100.0)) != -1) + { + if(GetClientTeam(playerNear) == 3) + { + if(!IsElementInArray(playerNear, this.grabbed_players)) + { + this.grabbed_players.Push(playerNear); + } + } + } + + /*** Teleport grabbed players ***/ + flyPos_copy[2] -= 40.0; + this.TeleportGrabbedPlayers(flyPos_copy); + + /*** Move towards the next node ***/ + // Fast approx of distance without needing sqrt + this.current_distance_to_target = FloatAbs(targetNode[0] - flyPos[0]) + FloatAbs(targetNode[1] - flyPos[1]); + + float distToTarget[3]; + SubtractVectors(flyPos, targetNode, distToTarget); + + if (FloatAbs(distToTarget[0]) < 80.0 && FloatAbs(distToTarget[1]) < 80.0 && FloatAbs(distToTarget[2]) < 80.0) + { + if (this.current_node < t_len - 1) + { + this.current_node++; + } + else + { + EntFireByIndex(this.entity, "SetAnimation", "idle", "0.00", -1); + EntFireByIndex(this.entity, "SetAnimation", "attack", "2.00", -1); + EntFire("boss_fly_sound_end", "StopSound", "", "0.00", -1); + //EntFire("4_fly_hovno", "FireUser1", "", "0.50", -1); + //EntFire("5_fly_hovno", "FireUser1", "", "0.50", -1); + //EntFire("fly_hovno_sound4", "PlaySound", "", "0.50", -1); + //EntFire("fly_hovno_sound5", "PlaySound", "", "0.50", -1); + flyPos_copy[2] += 200; + this.TeleportGrabbedPlayers(flyPos_copy); + this.grabbed_players.Clear(); + float angles[3]; + GetForwardVector(this.entity, angles); + angles[2] = 0.0; + SetForwardVector(this.entity, angles); + this.end = true; + return; + } + + this.previous_distance_to_target = -1.0; + } + else + { + this.MoveTowardsTarget(flyPos, targetNode); + this.previous_distance_to_target = this.current_distance_to_target; + } + + if (!this.end) + CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + +} + +//methodmap Fly_End_Hovno < Fly_End +//{ + //public Fly_End_Hovno(int entity) + //{ + //Fly_End myclass = new Fly_End(entity); + //myclass.type = eFlyEndHovno; + //myclass.rot_speed_acceleration = 0.16; + //myclass.rot_speed_max = 0.24; + //myclass.rot_speed_min = 0.16; + //myclass.max_speed = 120.0; + //myclass.speed_acceleration = 0.4; + //myclass.SetBool("bStop_on_last_node", true); + //myclass.SetInt("iPath", 0); + //return view_as(myclass); + //} + //property bool stop_on_last_node + //{ + //public get() + //{ + //return this.GetBool("bStop_on_last_node"); + //} + //public set(bool val) + //{ + //this.SetBool("bStop_on_last_node", val); + //} + //} + //property int path + //{ + //public get() + //{ + //return this.GetInt("iPath"); + //} + //public set(int val) + //{ + //this.SetInt("iPath", val); + //} + //} + //public void Start(int p, bool stop) + //{ + //this.path = p; + //this.stop_on_last_node = stop; + //EntFireByIndex(this.entity, "SetAnimation", "fly", "0.00", -1); + //CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + //} + // + //public void Tick() + //{ + //float flyPos[3], flyPos_copy[3]; + //GetOrigin(this.entity, flyPos); + //GetOrigin(this.entity, flyPos_copy); + //float targetNode[3]; + //MakeVectorFromPoints( { 0.0, 0.0, 0.0 }, TARGET_NODES2[this.path][this.current_node], targetNode); + //flyPos_copy[2] -= 40; + + + /*** Teleport grabbed players ***/ + //this.TeleportGrabbedPlayers(flyPos_copy); + + /*** Move towards the next node ***/ + // Fast approx of distance without needing sqrt + //this.current_distance_to_target = FloatAbs(targetNode[0] - flyPos[0]) + FloatAbs(targetNode[1] - flyPos[1]); + + //float distToTarget[3]; + //SubtractVectors(flyPos, targetNode, distToTarget); + + //if (FloatAbs(distToTarget[0]) < 80.0 && FloatAbs(distToTarget[1]) < 80.0 && FloatAbs(distToTarget[2]) < 80.0) + //{ + //this.previous_distance_to_target = -1.0; + //int len = (this.path == 0) ? t_len_0:t_len_1; + //if (this.current_node < len - 1) + //{ + //this.current_node++; + //} + //else if (this.stop_on_last_node) + //{ + //EntFireByIndex(this.entity, "SetAnimation", "idle", "0.00", -1); + //flyPos_copy[2] += 200.0; + //this.TeleportGrabbedPlayers(flyPos_copy); + //float angles[3]; + //GetForwardVector(this.entity, angles); + //angles[2] = 0.0; + //SetForwardVector(this.entity, angles); + //this.end = true; + //return; + //} + //} + //if (!this.end) + //{ + //this.MoveTowardsTarget(flyPos, targetNode); + //this.previous_distance_to_target = this.current_distance_to_target; + //CreateTimer(0.0, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + //} + //} +//} + + +public void ChasePlayer(Fly_Small fly, const float[3] flyPos) +{ + + fly.retarget -= 0.01; + float targetPos[3]; + GetOrigin(fly.target, targetPos); + targetPos[2] += 48; + + // Fast approx of distance without needing sqrt + fly.current_distance_to_target = FloatAbs(targetPos[0] - flyPos[0]) + FloatAbs(targetPos[1] - flyPos[1]); + if(fly.retarget <= 0.0 || !IsTargetInSight(fly.entity, flyPos, targetPos)) + { + fly.target = -1; + } + else + { + fly.MoveTowardsTarget(flyPos, targetPos); + fly.previous_distance_to_target = fly.current_distance_to_target; + } + +} + +public bool IsTargetInSight(int entity, const float[3] flyPos, const float[3] targetPos) +{ + return TraceLine(flyPos, targetPos, entity) >= 1.0; +} + + +public int GetNewTarget(Fly_Small fly) +{ + + if(!IsValidPlayer(fly.target)) + { + fly.target = -1; + } + + int player = -1; + ArrayList playerArr = new ArrayList(); + + while(-1 != (player = FindEntityByClassname(player, "player"))) + { + if(GetClientTeam(player) == 3) + { + float playerPos[3], selfPos[3]; + GetOrigin(fly.entity, selfPos); + GetOrigin(player, playerPos); + playerPos[2] += 48; + if(IsTargetInSight(fly.entity, selfPos, playerPos)) + playerArr.Push(player); + } + } + if(playerArr.Length > 0) + { + fly.retarget = 8; + int target = playerArr.Get(GetRandomInt(0, playerArr.Length - 1)); + delete playerArr; + + return target; + } + else + { + delete playerArr; + + return -1; + } +} + +public void MoveForward(Fly_base fly, float blocker1, float blocker2) +{ + if(!IsValidEntity(fly.entity)) + return; + + float pos1[3], pos2[3], selfPos[3], selfFwd[3]; + GetOrigin(fly.entity, selfPos); + GetForwardVector(fly.entity, selfFwd); + ScaleVector(selfFwd, blocker1); + AddVectors(selfPos, selfFwd, pos1); + GetForwardVector(fly.entity, selfFwd); + ScaleVector(selfFwd, blocker2); + AddVectors(selfPos, selfFwd, pos2); + + if (TraceLine(pos1, pos2, fly.entity) < 1.0) + { + + fly.speed = 0.0; + } + else + { + float newpos[3]; + GetForwardVector(fly.entity, selfFwd); + ScaleVector(selfFwd, fly.speed); + AddVectors(selfPos, selfFwd, newpos); + SetOrigin(fly.entity, newpos); + } + +} + +public void MoveDir(Fly_base fly, float[3] dir) +{ + if(!IsValidEntity(fly.entity)) + return; + + if(fly.speed < fly.max_speed) fly.speed += fly.speed_acceleration; + float currentAngle[3], origin[3], newpos[3], dir_copy[3]; + dir_copy[0] = dir[0]; + dir_copy[1] = dir[1]; + dir_copy[2] = dir[2]; + GetForwardVector(fly.entity, currentAngle); + currentAngle[2] = 0.0; + SetForwardVector(fly.entity, currentAngle); + GetOrigin(fly.entity, origin); + ScaleVector(dir_copy, fly.speed / 4.0); + AddVectors(origin, dir_copy, newpos); + SetOrigin(fly.entity, newpos); + +} + +public void GetNewDir(Fly_base fly, const float[3] targetDir, const float[3] currentDir, float[3] newDir) +{ + if(!IsValidEntity(fly.entity)) + return; + + float rotDir = currentDir[0] * targetDir[1] - currentDir[1] * targetDir[0]; + if (FloatAbs(rotDir) > 0.3) + { + if (fly.speed > 0) + fly.speed -= 0.6 * fly.speed_acceleration; + if (fly.rotation_speed < fly.rot_speed_max) + fly.rotation_speed += fly.rot_speed_acceleration; + } + else + { + if (fly.speed < fly.max_speed) + fly.speed += fly.speed_acceleration; + if (fly.rotation_speed > fly.rot_speed_min) + fly.rotation_speed -= fly.rot_speed_acceleration; + } + + if (rotDir > fly.rot_err || rotDir >= 0 && fly.previous_distance_to_target < fly.current_distance_to_target) + { + Rotate2D(currentDir, fly.rotation_speed, newDir); + } + else if (rotDir < -fly.rot_err || rotDir < 0 && fly.previous_distance_to_target < fly.current_distance_to_target) + { + Rotate2D(currentDir, -fly.rotation_speed, newDir); + } + else + { + newDir[0] = currentDir[0]; + newDir[1] = currentDir[1]; + newDir[2] = currentDir[2]; + } + +} + +public void Rotate2D(const float[3] vector, const float angle, float[3] buffer) +{ + buffer[0] = vector[0] * Cosine(angle) - vector[1] * Sine(angle); + buffer[1] = vector[0] * Sine(angle) + vector[1] * Cosine(angle); +} + +public int GetRandomValue(const int max){ + return GetRandomInt(0, max + 1); +} + +public bool IsElementInArray(const any element, const ArrayList arr) +{ + for (int i = 0; i < arr.Length; i++) + { + if (element == arr.Get(i)) + return true; + } + return false; +} + +methodmap Microwave < Basic +{ + public Microwave(int entity) + { + Basic myclass = new Basic(); + myclass.SetInt("iEntity", entity); + myclass.SetBool("bDead", false); + myclass.SetBool("bStarted", false); + myclass.SetInt("iHealth", 69); + return view_as(myclass); + } + + property int entity + { + public get() + { + return this.GetInt("iEntity"); + } + public set(int val) + { + this.SetInt("iEntity", val); + } + } + + property bool dead + { + public get() + { + return this.GetBool("bDead"); + } + public set(bool val) + { + this.SetBool("bDead", val); + } + } + + property bool started + { + public get() + { + return this.GetBool("bStarted"); + } + public set(bool val) + { + this.SetBool("bStarted", val); + } + } + + property int health + { + public get() + { + return this.GetInt("iHealth"); + } + public set(int val) + { + this.SetInt("iHealth", val); + } + } + + public void Start() + { + this.started = true; + } + + public void AddHealth(int hp) + { + this.health += hp; + } + + public void Hit(int hp) + { + if (this.started && !this.dead) + { + this.health -= hp; + if (this.health < 0) + { + this.health = 0; + } + char msg[250]; + Format(msg, sizeof(msg), "message Microwave %d HP", this.health); + EntFire("fly_text", "AddOutput", msg, "0.0", -1); + EntFire("fly_text", "Display", "", "0.01", -1); + } + + if (this.health <= 0 && !this.dead) + { + EntFire("microwave_dead_relay", "Trigger", "", "0.0", -1); + this.dead = true; + } + } +} + +public Action Tick_Cb(Handle timer, Fly_base fly_base) +{ + KillTimer(timer); + if(fly_base) + { + switch(fly_base.type) + { + case eFlySmall: + { + Fly_Small fly = view_as(fly_base); + if(fly.doNextTick) + { + + fly.Tick(); + } + else + { + + delete fly; + } + } + case eFly: + { + Fly fly = view_as(fly_base); + if(fly.doNextTick) + { + + fly.Tick(); + } + else + { + + fly.KillFly(); + } + } + case eFlyEnd: + { + Fly_End fly = view_as(fly_base); + if(fly.doNextTick) + { + + fly.Tick(); + } + else + { + + fly.KillFly(); + } + } + //case eFlyEndHovno: + //{ + //Fly_End_Hovno fly = view_as(fly_base); + //if(fly.doNextTick) + //{ + // + //fly.Tick(); + //} + //else + //{ + // + //delete fly; + //} + //} + } + } + return Plugin_Stop; +} \ No newline at end of file diff --git a/VScripts/scripting/include/vscripts/JJBA.inc b/VScripts/scripting/include/vscripts/JJBA.inc new file mode 100644 index 00000000..442b8899 --- /dev/null +++ b/VScripts/scripting/include/vscripts/JJBA.inc @@ -0,0 +1,245 @@ +#if defined _JJBA_included + #endinput +#endif +#define _JJBA_included +#include +#include +#include + +#define TICKRATE 0.1 +#define TARGET_DISTANCE 5000.0 +#define RETARGET_TIME 7.5 +#define SPEED_FORWARD 1.0 +#define SPEED_TURNING 0.5 + +stock float FloatMod(float num, float denom) +{ + return num - denom * RoundToFloor(num / denom); +} + +stock float operator%(float oper1, float oper2) +{ + return FloatMod(oper1, oper2); +} + +public bool IsValidPlayer(int player) +{ + return player >= 1 && player <= 64 && IsValidEntity(player) && IsPlayerAlive(player); +} + +public float GetDistance(const float[3] v1, const float[3] v2) +{ + return SquareRoot((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]) + (v1[2] - v2[2]) * (v1[2] - v2[2])); +} + +methodmap MovingNpc < Basic +{ + public MovingNpc(int entity) + { + Basic myclass = new Basic(); + myclass.SetInt("iEntity", entity); + myclass.SetInt("iTarget", -1); + myclass.SetInt("iTf", -1); + myclass.SetInt("iTs", -1); + myclass.SetFloat("fTtime", 0.0); + myclass.SetBool("bTicking", false); + return view_as(myclass); + } + property int entity + { + public get() + { + return this.GetInt("iEntity"); + } + public set(int val) + { + this.SetInt("iEntity", val); + } + } + property int target + { + public get() + { + return this.GetInt("iTarget"); + } + public set(int val) + { + this.SetInt("iTarget", val); + } + } + property int tf + { + public get() + { + return this.GetInt("iTf"); + } + public set(int val) + { + this.SetInt("iTf", val); + } + } + property int ts + { + public get() + { + return this.GetInt("iTs"); + } + public set(int val) + { + this.SetInt("iTs", val); + } + } + property float ttime + { + public get() + { + return this.GetFloat("fTtime"); + } + public set(float val) + { + this.SetFloat("fTtime", val); + } + } + property bool ticking + { + public get() + { + return this.GetBool("bTicking"); + } + public set(bool val) + { + this.SetBool("bTicking", val); + } + } + + public void Start() + { + + if(!this.ticking) + { + this.ticking = true; + CreateTimer(TICKRATE, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } + } + + public void Stop() + { + if(this.ticking) + { + this.ticking = false; + } + } + + public float GetTargetYaw(const float[3] start, const float[3] target) + { + + float yaw = 0.00; + float v[3]; + SubtractVectors(start, target, v); + float vl = SquareRoot(v[0] * v[0] + v[1] * v[1]); + yaw = 180.0 * ArcCosine(v[0] / vl) / 3.14159; + if (v[1] < 0.0) + yaw = -yaw; + + return yaw; + } + + public void SetThruster(bool fwd, int caller) + { + if(fwd) + this.tf = caller; + else + this.ts = caller; + } + + public void SearchTarget() + { + + this.ttime = 0.00; + this.target = -1; + int h = -1; + ArrayList candidates = new ArrayList(); + float orig[3]; + GetOrigin(this.entity, orig); + while (-1 != (h = FindEntityByClassnameWithin(h, "player", orig, TARGET_DISTANCE))) + { + //check if target is a valid player + CT team(3) + health above 0 (not dead) + if (GetClientTeam(h) == 3 && IsPlayerAlive(h)) + { + //check if the target is in sight of the npc (this physbox origin+48 height) + float t_orig[3]; + GetOrigin(this.entity, orig); + orig[2] += 40.0; + GetOrigin(h, t_orig); + t_orig[2] += 48.0; + if (TraceLine(orig, t_orig, this.entity) == 1.00) + candidates.Push(h); //if everything required is OK, add the target to the list of candidates + } + } + if(candidates.Length == 0) + { + delete candidates; + return; + } + this.target = candidates.Get(GetRandomInt(0, candidates.Length - 1)); + + delete candidates; + + } + + public void Tick() + { + + EntFireByIndex(this.tf, "Deactivate", "", "0.00", -1); + EntFireByIndex(this.ts, "Deactivate", "", "0.00", -1); + if (!IsValidPlayer(this.target) || GetClientTeam(this.target) != 3 || this.ttime >= RETARGET_TIME) + { + this.SearchTarget(); + } + this.ttime+=TICKRATE; + EntFireByIndex(this.tf, "Activate", "", "0.02", -1); + EntFireByIndex(this.ts, "Activate", "", "0.02", -1); + float angl[3], s_orig[3], t_orig[3]; + GetAngles(this.entity, angl); + float sa = angl[1]; + GetOrigin(this.entity, s_orig); + GetOrigin(this.target, t_orig); + float ta = this.GetTargetYaw(s_orig, t_orig); + float ang = FloatAbs((sa - ta + 360.0) % 360.0); + if (ang >= 180.0) + EntFireByIndex(this.ts, "AddOutput", "angles 0 270 0", "0.00", -1); + else + EntFireByIndex(this.ts, "AddOutput", "angles 0 90 0", "0.00", -1); + float angdif = (sa - ta - 180.0); + while (angdif > 360.0) { angdif -= 180.0; } + while (angdif < -180.0) { angdif += 360.0; } + angdif = FloatAbs(angdif); + GetOrigin(this.entity, s_orig); + GetOrigin(this.target, t_orig); + //float tdist = GetDistance(s_orig, t_orig); + //float tdistz = (t_orig[2] - s_orig[2]); + char input[128]; + Format(input, sizeof(input), "force %.4f", 3000.0 * SPEED_FORWARD); + EntFireByIndex(this.tf, "AddOutput", input, "0.00", -1); + Format(input, sizeof(input), "force %.4f", (3.0 * SPEED_TURNING) * angdif); + EntFireByIndex(this.ts, "AddOutput", input, "0.00", -1); + CreateTimer(TICKRATE, Tick_Cb, this, TIMER_FLAG_NO_MAPCHANGE); + } +} + +public Action Tick_Cb(Handle timer, MovingNpc npc) +{ + KillTimer(timer); + if(npc.ticking) + { + + npc.Tick(); + } + else + { + EntFireByIndex(npc.tf, "Deactivate", "", "0.00", -1); + EntFireByIndex(npc.ts, "Deactivate", "", "0.00", -1); + delete npc; + } + return Plugin_Stop; +} diff --git a/VScripts/scripting/vscript_Aesthetic.sp b/VScripts/scripting/vscript_Aesthetic.sp new file mode 100644 index 00000000..4b929a6c --- /dev/null +++ b/VScripts/scripting/vscript_Aesthetic.sp @@ -0,0 +1,405 @@ +#pragma semicolon 1 + +#define DEBUG + +#define PLUGIN_AUTHOR "Cloud Strife" +#define PLUGIN_VERSION "1.00" +#define MAP_NAME "ze_a_e_s_t_h_e_t_i_c_v1_1s" + +#include +#include +#include + +#pragma newdecls required + +bool bValidMap = false; +Chess g_Chess = null; +ArrayList g_aEyes = null; + +public Plugin myinfo = +{ + name = "Aesthetic vscripts", + author = PLUGIN_AUTHOR, + description = "", + version = PLUGIN_VERSION, + url = "https://steamcommunity.com/id/cloudstrifeua/" +}; + +public void OnMapStart() +{ + char sCurMap[256]; + GetCurrentMap(sCurMap, sizeof(sCurMap)); + bValidMap = (strcmp(sCurMap, MAP_NAME, false) == 0); + if(bValidMap) + { + HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); + HookEvent("round_end", OnRoundEnd, EventHookMode_PostNoCopy); + g_aEyes = new ArrayList(); + } + else + { + char sFilename[256]; + GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); + + ServerCommand("sm plugins unload %s", sFilename); + } +} + +public void OnRoundStart(Event event, const char[] name, bool dontBroadcast) +{ + if(!bValidMap) + return; + g_Chess = new Chess(GetEntityIndexByName("GreenStart", "path_track"), GetEntityIndexByName("GreenEnd", "path_track"), + GetEntityIndexByName("PurpleStart", "path_track"), GetEntityIndexByName("PurpleEnd", "path_track")); + int tmp = GetEntityIndexByName("GreenEnd", "path_track"); + + HookSingleEntityOutput(tmp, "OnPass", OnGreenEndPass); + tmp = GetEntityIndexByName("PurpleEnd", "path_track"); + + HookSingleEntityOutput(tmp, "OnPass", OnPurpleEndPass); + tmp = GetEntityIndexByHammerID(92835, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton1); + tmp = GetEntityIndexByHammerID(92838, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton2); + tmp = GetEntityIndexByHammerID(92841, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton3); + tmp = GetEntityIndexByHammerID(92844, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton4); + tmp = GetEntityIndexByHammerID(92850, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton5); + tmp = GetEntityIndexByHammerID(92847, "func_button"); + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton6); + tmp = GetEntityIndexByHammerID(92853, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton7); + tmp = GetEntityIndexByHammerID(92856, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPurpleButton8); + tmp = GetEntityIndexByHammerID(92013, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton1); + tmp = GetEntityIndexByHammerID(92084, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton2); + tmp = GetEntityIndexByHammerID(91906, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton3); + tmp = GetEntityIndexByHammerID(92081, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton4); + tmp = GetEntityIndexByHammerID(92016, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton5); + tmp = GetEntityIndexByHammerID(92075, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton6); + tmp = GetEntityIndexByHammerID(89814, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton7); + tmp = GetEntityIndexByHammerID(92046, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnGreenButton8); + tmp = GetEntityIndexByHammerID(89040, "func_button"); + + HookSingleEntityOutput(tmp, "OnPressed", OnPressedTrig, true); + tmp = GetEntityIndexByHammerID(490936, "trigger_push"); + + HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger); + tmp = GetEntityIndexByHammerID(445713, "trigger_push"); + + HookSingleEntityOutput(tmp, "OnStartTouch", OnPushTrigger2); +} + +public void OnPushTrigger2(const char[] output, int caller, int activator, float delay) +{ + + float tmp[3]; + GetOrigin(activator, tmp); + tmp[2] += 2.0; + SetOrigin(activator, tmp); +} + +public void OnPushTrigger(const char[] output, int caller, int activator, float delay) +{ + + float tmp[3]; + GetOrigin(activator, tmp); + tmp[2] += 4.0; + SetOrigin(activator, tmp); +} + +public void OnPressedTrig(const char[] output, int caller, int activator, float delay) +{ + delete g_Chess; +} + +public void OnGreenButton8(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(-1.0, -1.0); + } +} + +public void OnGreenButton7(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(0.0, -1.0); + } +} + +public void OnGreenButton6(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(1.0, -1.0); + } +} + +public void OnGreenButton5(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(1.0, 0.0); + } +} + +public void OnGreenButton4(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(1.0, 1.0); + } +} + +public void OnGreenButton3(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(0.0, 1.0); + } +} + +public void OnGreenButton2(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(-1.0, 1.0); + } +} + +public void OnGreenButton1(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveGreen(-1.0, 0.0); + } +} + +public void OnPurpleButton8(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(-1.0, -1.0); + } +} + +public void OnPurpleButton7(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(0.0, -1.0); + } +} + +public void OnPurpleButton6(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(1.0, -1.0); + } +} + +public void OnPurpleButton5(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(1.0, 0.0); + } +} + +public void OnPurpleButton4(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(1.0, 1.0); + } +} + +public void OnPurpleButton3(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(0.0, 1.0); + } +} + +public void OnPurpleButton2(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(-1.0, 1.0); + } +} + +public void OnPurpleButton1(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MovePurple(-1.0, 0.0); + } +} + +public void OnGreenEndPass(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveStartToEnd(g_Chess.greenStart, g_Chess.greenEnd); + g_Chess.CheckInLove(); + } +} + +public void OnPurpleEndPass(const char[] output, int caller, int activator, float delay) +{ + if(g_Chess) + { + + g_Chess.MoveStartToEnd(g_Chess.purpleStart, g_Chess.purpleEnd); + g_Chess.CheckInLove(); + } +} + +public void OnEntitySpawned(int entity, const char[] classname) +{ + if(!bValidMap) + return; + if(IsValidEntity(entity)) + { + if(strcmp(classname, "func_breakable") == 0) + { + char sName[128]; + GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName)); + if(!sName[0]) + return; + int pos = FindCharInString(sName, '&', true); + if(pos != -1) + { sName[pos] = 0; + if(strcmp(sName, "EyeBoss") == 0) + { + + Eye eye = new Eye(entity); + HookSingleEntityOutput(entity, "OnUser2", OnEyeMove); + g_aEyes.Push(eye); + } + } + } + } +} + +public void OnEyeMove(const char[] output, int caller, int activator, float delay) +{ + + for (int i = 0; i < g_aEyes.Length; i++) + { + Eye tmp = view_as(g_aEyes.Get(i)); + if(tmp.entity == caller) + { + + tmp.Move(); + } + } +} + +public void OnEntityDestroyed(int entity) +{ + if(!bValidMap) + return; + if(IsValidEntity(entity)) + { + char sClassname[64]; + GetEntityClassname(entity, sClassname, sizeof(sClassname)); + if(strcmp(sClassname, "func_breakable") == 0) + { + char sName[128]; + GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName)); + if(!sName[0]) + return; + if(StrContains(sName, "EyeBoss") != -1) + { + for (int i = 0; i < g_aEyes.Length; i++) + { + Eye tmp = view_as(g_aEyes.Get(i)); + if(entity == tmp.entity) + { + + delete tmp; + g_aEyes.Erase(i); + } + } + } + } + } +} + +public void Cleanup() +{ + if(!bValidMap) + return; + + delete g_Chess; + for (int i = 0; i < g_aEyes.Length; i++) + { + Eye tmp = view_as(g_aEyes.Get(i)); + delete tmp; + g_aEyes.Erase(i); + } +} + +public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast) +{ + Cleanup(); +} + +public void OnMapEnd() +{ + Cleanup(); + if(bValidMap) + { + UnhookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); + UnhookEvent("round_end", OnRoundEnd, EventHookMode_PostNoCopy); + } + bValidMap = false; +} \ No newline at end of file diff --git a/VScripts/scripting/vscript_JJBA.sp b/VScripts/scripting/vscript_JJBA.sp new file mode 100644 index 00000000..f2e1d72a --- /dev/null +++ b/VScripts/scripting/vscript_JJBA.sp @@ -0,0 +1,138 @@ +#pragma semicolon 1 + +#define DEBUG + +#define PLUGIN_AUTHOR "Cloud Strife" +#define PLUGIN_VERSION "1.00" +#define MAP_NAME "ze_jjba_v5fs" + +#include +#include +#include +#include + +#pragma newdecls required + +bool bValidMap = false; +ArrayList g_aMovingNpc; + +public Plugin myinfo = +{ + name = "JJBA vscripts", + author = PLUGIN_AUTHOR, + description = "JJBA vscripts", + version = PLUGIN_VERSION, + url = "https://steamcommunity.com/id/cloudstrifeua/" +}; + +public void OnMapStart() +{ + char sCurMap[256]; + GetCurrentMap(sCurMap, sizeof(sCurMap)); + bValidMap = (strcmp(MAP_NAME, sCurMap, false) == 0); + if(bValidMap) + { + g_aMovingNpc = new ArrayList(); + } + else + { + char sFilename[256]; + GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); + + ServerCommand("sm plugins unload %s", sFilename); + } +} + +public void OnEntitySpawned(int entity, const char[] classname) +{ + if(!bValidMap) + return; + if(IsValidEntity(entity)) + { + if(strcmp(classname, "phys_thruster") == 0) + { + char sTarget[128]; + GetOutputTarget(entity, "m_OnUser1", 0, sTarget, sizeof(sTarget)); + if(!sTarget[0]) + return; + + if (StrContains(sTarget, "npc_physbox") != -1) + { + int ent = GetEntityIndexByName(sTarget, "func_physbox"); + MovingNpc npc = null; + bool bAlreadyInList = false; + for (int i = 0; i < g_aMovingNpc.Length; i++) + { + MovingNpc tmp = view_as(g_aMovingNpc.Get(i)); + if(tmp.entity == ent) + { + npc = tmp; + bAlreadyInList = true; + } + } + if(!bAlreadyInList) + { + npc = new MovingNpc(ent); + } + GetEntPropString(entity, Prop_Data, "m_iName", sTarget, sizeof(sTarget)); + if(StrContains(sTarget, "npc_thruster_forward") != -1) + { + npc.SetThruster(true, entity); + } + else if(StrContains(sTarget, "npc_thruster_side") != -1) + { + npc.SetThruster(false, entity); + } + + if(bAlreadyInList) + { + npc.Start(); + + } + else + g_aMovingNpc.Push(npc); + } + } + } +} + +public void OnEntityDestroyed(int entity) +{ + if(!bValidMap) + return; + if(IsValidEntity(entity)) + { + char sClassname[128]; + GetEntityClassname(entity, sClassname, sizeof(sClassname)); + if(strcmp(sClassname, "func_physbox") == 0) + { + for (int i = 0; i < g_aMovingNpc.Length; i++) + { + MovingNpc npc = view_as(g_aMovingNpc.Get(i)); + if(npc.entity == entity) + { + + npc.Stop(); + g_aMovingNpc.Erase(i); + break; + } + } + } + } +} + + +public void OnMapEnd() +{ + if(bValidMap) + { + for (int i = 0; i < g_aMovingNpc.Length; i++) + { + MovingNpc npc = view_as(g_aMovingNpc.Get(i)); + npc.Stop(); + g_aMovingNpc.Erase(i); + } + delete g_aMovingNpc; + } + bValidMap = false; +} \ No newline at end of file diff --git a/VScripts/scripting/vscript_Kitchen.sp b/VScripts/scripting/vscript_Kitchen.sp new file mode 100644 index 00000000..177b1cb7 --- /dev/null +++ b/VScripts/scripting/vscript_Kitchen.sp @@ -0,0 +1,455 @@ +#pragma semicolon 1 + +#define PLUGIN_AUTHOR "Cloud Strife" +#define PLUGIN_VERSION "1.00" +#define MAP_NAME "ze_Kitchen_v2s" + +#include +#include +#include + +#pragma newdecls required + +bool bValidMap = false; +Fly g_Fly = null; +Fly_End g_FlyEnd = null; +//Fly_End_Hovno g_FlyEndHovno[5] = { null, ... }; +ArrayList g_aFlySmall = null; +Microwave g_Microwave = null; +StringMap g_iButton_players = null; + +public Plugin myinfo = +{ + name = "Kitchen vscripts", + author = PLUGIN_AUTHOR, + description = "", + version = PLUGIN_VERSION, + url = "https://steamcommunity.com/id/cloudstrifeua/" +}; + +public void OnPluginStart() +{ + HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); + HookEvent("round_end", OnRoundEnd, EventHookMode_PostNoCopy); +} + + +public void OnMapStart() +{ + + char sCurMap[256]; + GetCurrentMap(sCurMap, sizeof(sCurMap)); + bValidMap = (strcmp(sCurMap, MAP_NAME, false) == 0); + if(bValidMap) + { + g_aFlySmall = new ArrayList(); + g_iButton_players = new StringMap(); + } + else + { + char sFilename[256]; + GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); + + ServerCommand("sm plugins unload %s", sFilename); + } + + +} + +public void OnRoundStart(Event event, const char[] name, bool dontBroadcast) +{ + if(!bValidMap) + return; + int tmp = GetEntityIndexByHammerID(1208341, "trigger_multiple"); + + HookSingleEntityOutput(tmp, "OnUser1", OnFlyStart, true); + HookSingleEntityOutput(tmp, "OnUser2", OnAddFlyHP); + HookSingleEntityOutput(tmp, "OnStartTouch", OnFlyInit, true); + tmp = GetEntityIndexByHammerID(1564273, "prop_dynamic"); + + HookSingleEntityOutput(tmp, "OnUser1", OnFlyEndInit, true); + tmp = GetEntityIndexByHammerID(1416995, "prop_dynamic"); + + HookSingleEntityOutput(tmp, "OnUser1", OnFlyDeadTrigger, true); + tmp = GetEntityIndexByHammerID(1189814, "logic_relay"); + + HookSingleEntityOutput(tmp, "OnTrigger", OnMicrowaveInit, true); +} + +public void OnPlayerPickUp(const char[] output, int caller, int activator, float delay) +{ + char sButtonIndex[64]; + Format(sButtonIndex, sizeof(sButtonIndex), "%d", caller); + g_iButton_players.SetValue(sButtonIndex, activator, true); + +} + +public void OnButtonPressed(const char[] output, int caller, int activator, float delay) +{ + char sButtonKey[64]; + Format(sButtonKey, sizeof(sButtonKey), "%d", caller); + int val = -1; + g_iButton_players.GetValue(sButtonKey, val); + if(val == activator) + { + EntFireByIndex(caller, "FireUser1", "", "0.00", -1); + } + +} + +public void OnMicrowaveInit(const char[] output, int caller, int activator, float delay) +{ + int entity = GetEntityIndexByHammerID(1684029, "prop_dynamic"); + + g_Microwave = new Microwave(entity); + + HookSingleEntityOutput(entity, "OnUser1", OnMicrowaveAddHP); + HookSingleEntityOutput(entity, "OnTakeDamage", OnMicrowaveTakeDamage); + HookSingleEntityOutput(entity, "OnUser2", OnMicrowaveStart, true); + HookSingleEntityOutput(entity, "OnUser3", OnMicrowaveLaserHit1); + HookSingleEntityOutput(entity, "OnUser4", OnMicrowaveLaserHit2); +} + +public void OnMicrowaveLaserHit2(const char[] output, int caller, int activator, float delay) +{ + if(g_Microwave) + g_Microwave.Hit(80); + +} + +public void OnMicrowaveLaserHit1(const char[] output, int caller, int activator, float delay) +{ + if(g_Microwave) + { + g_Microwave.Hit(70); + + } +} + +public void OnMicrowaveStart(const char[] output, int caller, int activator, float delay) +{ + CreateTimer(1.0, Microwave_StartDelay,_, TIMER_FLAG_NO_MAPCHANGE); +} + +public Action Microwave_StartDelay(Handle timer) +{ + KillTimer(timer); + g_Microwave.Start(); + return Plugin_Stop; +} + +public void OnMicrowaveTakeDamage(const char[] output, int caller, int activator, float delay) +{ + if(g_Microwave) + { + g_Microwave.Hit(1); + } +} + +public void OnMicrowaveAddHP(const char[] output, int caller, int activator, float delay) +{ + g_Microwave.AddHealth(200); + +} + +public void OnFlyDeadTrigger(const char[] output, int caller, int activator, float delay) +{ + float orig[3], angles[3]; + GetOrigin(g_Fly.entity, orig); + GetAngles(g_Fly.entity, angles); + SetOrigin(caller, orig); + SetAngles(caller, angles); + g_Fly.KillFly(); + g_Fly = null; + EntFireByIndex(caller, "SetAnimation", "dead", "0.0", -1); + EntFireByIndex(caller, "SetAnimation", "dead_loop", "2.0", -1); + +} + +//public void OnFlyEndHovnoInit1(const char[] output, int caller, int activator, float delay) +//{ + //g_FlyEndHovno[0] = new Fly_End_Hovno(caller); + //g_FlyEndHovno[0].Start(1, false); + // +//} + +//public void OnFlyEndHovnoInit2(const char[] output, int caller, int activator, float delay) +//{ + //g_FlyEndHovno[1] = new Fly_End_Hovno(caller); + //g_FlyEndHovno[1].Start(1, false); + // +//} + +//public void OnFlyEndHovnoInit3(const char[] output, int caller, int activator, float delay) +//{ + //g_FlyEndHovno[2] = new Fly_End_Hovno(caller); + //g_FlyEndHovno[2].Start(1, false); + // +//} + +//public void OnFlyEndHovnoInit4(const char[] output, int caller, int activator, float delay) +//{ + //g_FlyEndHovno[3] = new Fly_End_Hovno(caller); + //g_FlyEndHovno[3].Start(1, false); + // +//} + +//public void OnFlyEndHovnoInit5(const char[] output, int caller, int activator, float delay) +//{ + //g_FlyEndHovno[4] = new Fly_End_Hovno(caller); + //g_FlyEndHovno[4].Start(1, false); + // +//} + +public void OnFlyEndInit(const char[] output, int caller, int activator, float delay) +{ + g_FlyEnd = new Fly_End(caller); + g_FlyEnd.Start(); + +} + +public void OnFlyInit(const char[] output, int caller, int activator, float delay) +{ + int fly = GetEntityIndexByHammerID(1199348, "prop_dynamic"); + + g_Fly = new Fly(fly); + + HookSingleEntityOutput(fly, "OnUser1", OnChangeEggsCount); + HookSingleEntityOutput(fly, "OnTakeDamage", OnFlyTakeDamage); +} + +public void OnFlyTakeDamage(const char[] output, int caller, int activator, float delay) +{ + if(g_Fly) + { + g_Fly.Hit(); + + } +} + +public void OnFlyStart(const char[] output, int caller, int activator, float delay) +{ + g_Fly.Start(); + +} + +public void OnAddFlyHP(const char[] output, int caller, int activator, float delay) +{ + g_Fly.AddHealth(415); + +} + +public void OnChangeEggsCount(const char[] output, int caller, int activator, float delay) +{ + if(g_Fly) + { + g_Fly.IncrementEggCount(-1); + + } +} + +public void OnEntitySpawned(int entity, const char[] classname) +{ + if(!bValidMap) + return; + if(IsValidEntity(entity)) + { + if(strcmp(classname, "prop_dynamic") == 0) + { + char sName[128]; + GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName)); + if(!sName[0]) + return; + if(StrContains(sName, "fly_small_model") != -1) + { + Fly_Small fly_small = new Fly_Small(entity); + g_aFlySmall.Push(fly_small); + if(StrContains(sName, "fly_small_model_map") != -1) + { + + CreateTimer(5.0, StartDelay, fly_small); + } + else + { + + fly_small.Start(); + } + HookSingleEntityOutput(entity, "OnUser1", OnFlySmallDie, true); + } + //else if(strcmp(sName, "1_fly_hovno") == 0) + //{ + // + //HookSingleEntityOutput(entity, "OnUser1", OnFlyEndHovnoInit1, true); + //} + //else if(strcmp(sName, "2_fly_hovno") == 0) + //{ + // + //HookSingleEntityOutput(entity, "OnUser1", OnFlyEndHovnoInit2, true); + //} + //else if(strcmp(sName, "3_fly_hovno") == 0) + //{ + // + //HookSingleEntityOutput(entity, "OnUser1", OnFlyEndHovnoInit3, true); + //} + //else if(strcmp(sName, "4_fly_hovno") == 0) + //{ + // + //HookSingleEntityOutput(entity, "OnUser1", OnFlyEndHovnoInit4, true); + //} + //else if(strcmp(sName, "5_fly_hovno") == 0) + //{ + // + //HookSingleEntityOutput(entity, "OnUser1", OnFlyEndHovnoInit5, true); + //} + } + else if(strcmp(classname, "func_button") == 0) + { + char sName[128]; + GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName)); + if(!sName[0]) + return; + if(StrContains(sName, "george_cades_syr_button") != -1) + { + + HookSingleEntityOutput(entity, "OnUser2", OnPlayerPickUp); + HookSingleEntityOutput(entity, "OnPressed", OnButtonPressed); + } + else if(StrContains(sName, "george_cades_toast_button") != -1) + { + + HookSingleEntityOutput(entity, "OnUser2", OnPlayerPickUp); + HookSingleEntityOutput(entity, "OnPressed", OnButtonPressed); + } + else if(StrContains(sName, "george_cades_sunka_button") != -1) + { + + HookSingleEntityOutput(entity, "OnUser2", OnPlayerPickUp); + HookSingleEntityOutput(entity, "OnPressed", OnButtonPressed); + } + else if(StrContains(sName, "george_cades_korenka_button") != -1) + { + + HookSingleEntityOutput(entity, "OnUser2", OnPlayerPickUp); + HookSingleEntityOutput(entity, "OnPressed", OnButtonPressed); + } + else if(StrContains(sName, "george_cades_houba_button") != -1) + { + + HookSingleEntityOutput(entity, "OnUser2", OnPlayerPickUp); + HookSingleEntityOutput(entity, "OnPressed", OnButtonPressed); + } + } + } +} + +public Action StartDelay(Handle timer, Fly_Small fly) +{ + KillTimer(timer); + if(fly) + { + + fly.Start(); + } + return Plugin_Stop; +} + +public void OnFlySmallDie(const char[] output, int caller, int activator, float delay) +{ + for (int i = 0; i < g_aFlySmall.Length; i++) + { + Fly_Small fly = view_as(g_aFlySmall.Get(i)); + if(fly.entity == caller) + { + + fly.Die(); + g_aFlySmall.Erase(i); + } + } +} + +public void OnEntityDestroyed(int entity) +{ + if(!IsValidEntity(entity) || !bValidMap) + return; + char sClassname[64]; + GetEntityClassname(entity, sClassname, sizeof(sClassname)); + if(strcmp(sClassname, "prop_dynamic") == 0) + { + char sName[128]; + GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName)); + if(!sName[0]) + return; + if(StrContains(sName, "fly_small_model") != -1) + { + for (int i = 0; i < g_aFlySmall.Length; i++) + { + Fly_Small fly = view_as(g_aFlySmall.Get(i)); + if(fly.entity == entity) + { + + fly.doNextTick = false; + g_aFlySmall.Erase(i); + } + } + } + else if(strcmp(sName, "mikrovlnka_model") == 0) + { + if(g_Microwave) + { + + delete g_Microwave; + } + } + } +} + +public void Cleanup() +{ + if(!bValidMap) + return; + + if(g_Microwave) + delete g_Microwave; + + if(g_Fly) + { + g_Fly.doNextTick = false; + g_Fly = null; + } + if(g_FlyEnd) + { + g_FlyEnd.doNextTick = false; + g_FlyEnd = null; + } + //for (int i = 0; i < 5; i++) + //{ + //if(g_FlyEndHovno[i]) + //{ + //g_FlyEndHovno[i].doNextTick = false; + //g_FlyEndHovno[i] = null; + //} + //} + for (int i = 0; i < g_aFlySmall.Length; i++) + { + Fly_Small fly = view_as(g_aFlySmall.Get(i)); + fly.doNextTick = false; + g_aFlySmall.Erase(i); + } + g_iButton_players.Clear(); +} + +public void OnRoundEnd(Event event, const char[] name, bool dontBroadcast) +{ + Cleanup(); +} + +public void OnMapEnd() +{ + Cleanup(); + if(bValidMap) + { + delete g_aFlySmall; + delete g_iButton_players; + } + bValidMap = false; +} \ No newline at end of file diff --git a/VScripts/scripting/vscript_ze_dreamin.sp b/VScripts/scripting/vscript_ze_dreamin_v2.sp similarity index 99% rename from VScripts/scripting/vscript_ze_dreamin.sp rename to VScripts/scripting/vscript_ze_dreamin_v2.sp index e222d011..f7711ef5 100644 --- a/VScripts/scripting/vscript_ze_dreamin.sp +++ b/VScripts/scripting/vscript_ze_dreamin_v2.sp @@ -41,7 +41,7 @@ public void VerifyMap() char sCurrentMap[64]; GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); - if (strncmp(sCurrentMap, "ze_dreamin_", 11, false) != 0) + if (strncmp(sCurrentMap, "ze_dreamin_v2", 13, false) != 0) { char sFilename[256]; GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); diff --git a/VScripts/scripting/vscript_ze_dreamin_v3.sp b/VScripts/scripting/vscript_ze_dreamin_v3.sp new file mode 100644 index 00000000..2a7c0dd5 --- /dev/null +++ b/VScripts/scripting/vscript_ze_dreamin_v3.sp @@ -0,0 +1,924 @@ +#include +#include +#include + +#pragma semicolon 1 +#pragma newdecls required + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "ze_dreamin VScript", + author = "Neon", + description = "", + version = "1.0", + url = "https://steamcommunity.com/id/n3ontm" +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + HookEvent("round_start", OnRoundStart); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnMapStart() +{ + VerifyMap(); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void VerifyMap() +{ + char sCurrentMap[64]; + GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); + + if (strncmp(sCurrentMap, "ze_dreamin_v3", 12, false) != 0) + { + char sFilename[256]; + GetPluginFilename(INVALID_HANDLE, sFilename, sizeof(sFilename)); + + ServerCommand("sm plugins unload %s", sFilename); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) +{ + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("reflect_logic"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnFalse", st3_hitbox_reflect, false); + + iEntity = FindEntityByTargetName("upline_timer"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnTimer", upline_maker_upline, false); + + iEntity = FindEntityByTargetName("explo_timer"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnTimer", explo_maker_setan, false); + + iEntity = FindEntityByTargetName("rtv_laser_timer"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnTimer", rtv_laser_timer, false); + + iEntity = FindEntityByTargetName("rtv_th_timer"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnTimer", rtv_th_timer, false); + + iEntity = FindEntityByTargetName("linelaser_random"); + if (iEntity != INVALID_ENT_REFERENCE) + { + HookSingleEntityOutput(iEntity, "OnCase01", linelaser_maker_left, false); + HookSingleEntityOutput(iEntity, "OnCase02", linelaser_maker_right, false); + } + + iEntity = FindEntityByTargetName("case_1"); + if (iEntity != INVALID_ENT_REFERENCE) + { + HookSingleEntityOutput(iEntity, "OnCase01", sbomb_1_Case01, false); + HookSingleEntityOutput(iEntity, "OnCase02", sbomb_1_Case02, false); + HookSingleEntityOutput(iEntity, "OnCase03", sbomb_1_Case03, false); + HookSingleEntityOutput(iEntity, "OnCase04", sbomb_1_Case04, false); + } + + iEntity = FindEntityByTargetName("case_2"); + if (iEntity != INVALID_ENT_REFERENCE) + { + HookSingleEntityOutput(iEntity, "OnCase01", sbomb_2_Case01, false); + HookSingleEntityOutput(iEntity, "OnCase02", sbomb_2_Case02, false); + HookSingleEntityOutput(iEntity, "OnCase03", sbomb_2_Case03, false); + HookSingleEntityOutput(iEntity, "OnCase04", sbomb_2_Case04, false); + } + + iEntity = FindEntityByTargetName("case_3"); + if (iEntity != INVALID_ENT_REFERENCE) + { + HookSingleEntityOutput(iEntity, "OnCase01", sbomb_3_Case01, false); + HookSingleEntityOutput(iEntity, "OnCase02", sbomb_3_Case02, false); + HookSingleEntityOutput(iEntity, "OnCase03", sbomb_3_Case03, false); + HookSingleEntityOutput(iEntity, "OnCase04", sbomb_3_Case04, false); + } + + iEntity = FindEntityByTargetName("totem_random"); + if (iEntity != INVALID_ENT_REFERENCE) + { + HookSingleEntityOutput(iEntity, "OnCase01", push_maker_setrandom, false); + HookSingleEntityOutput(iEntity, "OnCase02", heal_maker_setrandom, false); + HookSingleEntityOutput(iEntity, "OnCase03", stable_maker_setrandom, false); + HookSingleEntityOutput(iEntity, "OnCase04", rotate_maker_setrandom, false); + } + + iEntity = FindEntityByTargetName("spike_timer"); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnTimer", spike_maker_top, false); + + iEntity = FindEntityByHammerID(389450); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_389450_display, false); + + iEntity = FindEntityByHammerID(385777); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_385777_display, false); + + iEntity = FindEntityByHammerID(385886); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_385886_display, false); + + iEntity = FindEntityByHammerID(386004); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_386004_display, false); + + iEntity = FindEntityByHammerID(381463); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_381463_display, false); + + iEntity = FindEntityByHammerID(381581); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_381581_display, false); + + iEntity = FindEntityByHammerID(381648); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_381648_display, false); + + iEntity = FindEntityByHammerID(378212); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_378212_display, false); + + iEntity = FindEntityByHammerID(375007); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_375007_display, false); + + iEntity = FindEntityByHammerID(241061); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnPressed", func_button_241061_display, false); + + iEntity = FindEntityByHammerID(213033); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_213033_display, false); + + iEntity = FindEntityByHammerID(142829); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_142829_display, false); + + iEntity = FindEntityByHammerID(95608); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_95608_display, false); + + iEntity = FindEntityByHammerID(95733); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_95733_display, false); + + iEntity = FindEntityByHammerID(95823); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_95823_display, false); + + iEntity = FindEntityByHammerID(77927); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnPressed", func_button_77927_display, false); + + iEntity = FindEntityByHammerID(23408); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_23408_display, false); + + iEntity = FindEntityByHammerID(23452); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_23452_display, false); + + iEntity = FindEntityByHammerID(23474); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_23474_display, false); + + iEntity = FindEntityByHammerID(579052); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnStartTouch", trigger_once_579052_display, false); + + iEntity = FindEntityByHammerID(23551); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnBreak", func_breakable_23551_display, false); + + iEntity = FindEntityByHammerID(21950); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnPressed", func_button_21950_display, false); + + iEntity = FindEntityByHammerID(22017); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnPressed", func_button_22017_display, false); + + iEntity = FindEntityByHammerID(3664); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnBreak", func_breakable_3664_display, false); + + iEntity = FindEntityByHammerID(11288); + if (iEntity != INVALID_ENT_REFERENCE) + HookSingleEntityOutput(iEntity, "OnHitMin", math_counter_11288_display, false); + + CreateTimer(12.0, Credits, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Credits(Handle timer) +{ + CPrintToChatAll("{pink}[VScripts] {white}Map using VScripts ported by Neon™"); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void st3_hitbox_reflect(const char[] output, int caller, int activator, float delay) +{ + if (!IsValidClient(activator)) + return; + + int iHealth = GetClientHealth(activator); + + if(iHealth > 10) + { + SetEntityHealth(activator, iHealth - 10); + } + else + { + SetEntityHealth(activator, 1); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void upline_maker_upline(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(-1280.0, 1280.0); + fOrigin[1] = GetRandomFloat(-1280.0, 1280.0); + fOrigin[2] = -2780.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("upline_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void explo_maker_setan(const char[] output, int caller, int activator, float delay) +{ + float fAngles[3]; + fAngles[0] = 0.0; + fAngles[1] = GetRandomFloat(0.0, 359.0); + fAngles[2] = 0.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("explo_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, NULL_VECTOR, fAngles, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void linelaser_maker_left(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = 0.0; + fOrigin[1] = GetRandomFloat(-640.0, 640.0); + fOrigin[2] = -1780.0; + + float fAngles[3]; + fAngles[0] = 0.0; + fAngles[1] = 0.0; + fAngles[2] = 0.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("linelaser_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, fAngles, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void linelaser_maker_right(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = 0.0; + fOrigin[1] = GetRandomFloat(-640.0, 640.0); + fOrigin[2] = -1820.0; + + float fAngles[3]; + fAngles[0] = 0.0; + fAngles[1] = 90.0; + fAngles[2] = 0.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("linelaser_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, fAngles, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void push_maker_setrandom(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(-768.0, 768.0); + fOrigin[1] = GetRandomFloat(-768.0, 768.0); + fOrigin[2] = -2720.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("push_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void heal_maker_setrandom(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(-768.0, 768.0); + fOrigin[1] = GetRandomFloat(-768.0, 768.0); + fOrigin[2] = -2720.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("heal_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void stable_maker_setrandom(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(-768.0, 768.0); + fOrigin[1] = GetRandomFloat(-768.0, 768.0); + fOrigin[2] = -2720.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("stable_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void rotate_maker_setrandom(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(-768.0, 768.0); + fOrigin[1] = GetRandomFloat(-768.0, 768.0); + fOrigin[2] = -2720.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("rotate_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void spike_maker_top(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(12090.0, 14363.0); + fOrigin[1] = GetRandomFloat(1280.0, 3560.0); + fOrigin[2] = 1500.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("spike_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + { + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); + AcceptEntityInput(iEntity, "ForceSpawn"); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void rtv_laser_timer(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(6300.0, 8350.0); + fOrigin[1] = GetRandomFloat(-1850.0, 220.0); + fOrigin[2] = -610.0; + + float fAngles[3]; + fAngles[0] = 0.0; + fAngles[1] = GetRandomFloat(0.0, 359.0); + fAngles[2] = 0.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("rtv_laser_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + { + TeleportEntity(iEntity, fOrigin, fAngles, NULL_VECTOR); + AcceptEntityInput(iEntity, "ForceSpawn"); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void rtv_th_timer(const char[] output, int caller, int activator, float delay) +{ + float fOrigin[3]; + fOrigin[0] = GetRandomFloat(6300.0, 8350.0); + fOrigin[1] = GetRandomFloat(-1850.0, 220.0); + fOrigin[2] = -610.0; + + int iEntity = INVALID_ENT_REFERENCE; + + iEntity = FindEntityByTargetName("rtv_th_maker"); + if (iEntity != INVALID_ENT_REFERENCE) + { + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); + AcceptEntityInput(iEntity, "ForceSpawn"); + } +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_1_Case01(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_1"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_1_Case02(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_1"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, -300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_1_Case03(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_1"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, 300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_1_Case04(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_1"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, -300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_2_Case01(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_2"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_2_Case02(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_2"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, -300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_2_Case03(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_2"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, 300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_2_Case04(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_2"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, -300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_3_Case01(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_3"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_3_Case02(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_3"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, -300.0, 0.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_3_Case03(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_3"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, 300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void sbomb_3_Case04(const char[] output, int caller, int activator, float delay) +{ + int iEntity = INVALID_ENT_REFERENCE; + iEntity = FindEntityByTargetName("sbomb_3"); + + if (iEntity != INVALID_ENT_REFERENCE) + run(iEntity, 0.0, -300.0); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_389450_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_385777_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_385886_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_386004_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_381463_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_381581_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_381648_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_378212_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_375007_display(const char[] output, int caller, int activator, float delay) +{ + Display(15); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_button_241061_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_213033_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_142829_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_95608_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_95733_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_95823_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_button_77927_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_23408_display(const char[] output, int caller, int activator, float delay) +{ + Display(35); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_23452_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_23474_display(const char[] output, int caller, int activator, float delay) +{ + Display(25); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void trigger_once_579052_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_breakable_23551_display(const char[] output, int caller, int activator, float delay) +{ + Display(20); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_button_21950_display(const char[] output, int caller, int activator, float delay) +{ + Display(30); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_button_22017_display(const char[] output, int caller, int activator, float delay) +{ + Display(10); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void func_breakable_3664_display(const char[] output, int caller, int activator, float delay) +{ + Display(45); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void math_counter_11288_display(const char[] output, int caller, int activator, float delay) +{ + Display(51); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void Display(int iTimer) +{ + int iRelay = CreateEntityByName("logic_relay"); + DispatchKeyFormat(iRelay, "targetname", "vscript_countdown_relay"); + DispatchKeyFormat(iRelay, "spawnflags", "0"); + DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,AddOutput,message seconds left,0,-1"); + DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message %d,0,-1", iTimer - 1); + + int iBackup = iTimer; + for (int j = 0; j <= iTimer; j++) + { + iBackup--; + DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message %d,%d,-1", iBackup, j); + DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,Display,,%d,-1", j); + DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,Display,,%d,-1", j); + } + + DispatchKeyFormat(iRelay, "OnSpawn", "seconds_left,AddOutput,message ,%d,-1", iTimer + 1); + DispatchKeyFormat(iRelay, "OnSpawn", "text_sec,AddOutput,message ,%d,-1", iTimer + 1); + DispatchKeyFormat(iRelay, "OnSpawn", "!self,Kill,,%d,-1", iTimer + 2); + SpawnAndActivate(iRelay); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void run(int iEntity, float fX1, float fY1) +{ + float fOrigin[3]; + GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fOrigin); + fOrigin[0] += fX1; + fOrigin[1] += fY1; + + if (fOrigin[0] > 8300.0 || fOrigin[1] > 150.0 || fOrigin[0] < -1800.0 || fOrigin[1] < -5194.0) + { + fOrigin[0] = 7312.0; + fOrigin[1] = -816.0; + fOrigin[2] = -634.0; + } + + TeleportEntity(iEntity, fOrigin, NULL_VECTOR, NULL_VECTOR); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int FindEntityByTargetName(const char[] sTargetnameToFind) +{ + int iEntity = INVALID_ENT_REFERENCE; + while((iEntity = FindEntityByClassname(iEntity, "*")) != INVALID_ENT_REFERENCE) + { + char sTargetname[64]; + GetEntPropString(iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname)); + + if (strcmp(sTargetnameToFind, sTargetname, false) == 0) + { + return iEntity; + } + } + + PrintToChatAll("[VScripts] Error! Could not find entity: %s", sTargetnameToFind); + return INVALID_ENT_REFERENCE; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int FindEntityByHammerID(int iHammerID) +{ + int iEntity = INVALID_ENT_REFERENCE; + while((iEntity = FindEntityByClassname(iEntity, "*")) != INVALID_ENT_REFERENCE) + { + if(GetEntProp(iEntity, Prop_Data, "m_iHammerID") == iHammerID) + { + return iEntity; + } + } + + PrintToChatAll("[VScripts] Error! Could not find entity: #%d", iHammerID); + return INVALID_ENT_REFERENCE; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +stock bool DispatchKeyFormat(int entity, const char[] key, const char[] value, any ...) +{ + char buffer[1024]; + VFormat(buffer, sizeof(buffer), value, 4); + + DispatchKeyValue(entity, key, buffer); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +stock void SpawnAndActivate(int entity) +{ + DispatchSpawn(entity); + ActivateEntity(entity); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +stock bool IsValidClient(int client) +{ + return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client)); +} \ No newline at end of file