Permalink
Browse files

horspeed= sets base horizontal speed, instead of max horizontal speed…

… now.
  • Loading branch information...
UnknownShadow200 committed Nov 30, 2017
1 parent 91a3ff2 commit 3bed91af85957303a6464859d55d72fae0099304
@@ -163,7 +163,7 @@ public class StatusScreen : Screen, IGameComponent {
if (fly) statusBuffer.Append(ref index, "Fly ON ");
bool speed = (speeding || halfSpeeding) &&
(hacks.CanSpeed || hacks.MaxSpeedMultiplier > 1);
(hacks.CanSpeed || hacks.BaseHorSpeed > 1);
if (speed) statusBuffer.Append(ref index, "Speed ON ");
if (noclip) statusBuffer.Append(ref index, "Noclip ON ");
hackStates.SetText(statusBuffer.ToString());
@@ -49,8 +49,8 @@ public sealed class HacksComponent {
public bool CanDoubleJump = true;
/// <summary> Whether the player can be pushed by other players. </summary>
public bool CanBePushed = true;
/// <summary> Maximum speed the entity can move at horizontally when CanSpeed is false. </summary>
public float MaxSpeedMultiplier = 1;
/// <summary> Base speed multiplier entity moves at horizontally. </summary>
public float BaseHorSpeed = 1;
/// <summary> Amount of jumps the player can perform. </summary>
public int MaxJumps = 1;
@@ -92,7 +92,7 @@ public sealed class HacksComponent {
float value = 0;
if (!Utils.TryParseDecimal(num, out value) || value <= 0) return;
MaxSpeedMultiplier = value;
BaseHorSpeed = value;
}
void ParseMultiJumps() {
@@ -160,7 +160,7 @@ public sealed class HacksComponent {
SetAllHacks(true);
if (HacksFlags == null) return;
MaxSpeedMultiplier = 1;
BaseHorSpeed = 1;
MaxJumps = 1;
CanBePushed = true;
@@ -108,11 +108,14 @@ public sealed class PhysicsComponent {
public void PhysicsTick(Vector3 vel) {
if (hacks.Noclip) entity.onGround = false;
float baseSpeed = GetBaseSpeed();
float verSpeed = baseSpeed * Math.Max(1, GetSpeed(hacks.CanSpeed, 8f) / 5);
float horSpeed = baseSpeed * GetSpeed(true, 8f/5);
float verSpeed = baseSpeed * Math.Max(1, GetSpeed(8f) / 5);
float horSpeed = baseSpeed * hacks.BaseHorSpeed * GetSpeed(8f/5);
// previously horSpeed used to be multiplied by factor of 0.02 in last case
// it's now multiplied by 0.1, so need to divide by 5 so user speed modifier comes out same
// TODO: this is a temp fix to avoid crashing for high horizontal speed
if (horSpeed > 75.0f) horSpeed = 75.0f;
bool womSpeedBoost = hacks.CanDoubleJump && hacks.WOMStyleHacks;
if (!hacks.Floating && womSpeedBoost) {
if (multiJumps == 1) { horSpeed *= 46.5f; verSpeed *= 7.5f; }
@@ -205,11 +208,11 @@ public sealed class PhysicsComponent {
entity.Velocity.Y -= gravity;
}
float GetSpeed(bool canSpeed, float speedMul) {
float GetSpeed(float speedMul) {
float factor = hacks.Floating ? speedMul : 1, speed = factor;
if (hacks.Speeding && canSpeed) speed += factor * hacks.SpeedMultiplier;
if (hacks.HalfSpeeding && canSpeed) speed += factor * hacks.SpeedMultiplier / 2;
return hacks.CanSpeed ? speed : Math.Min(speed, hacks.MaxSpeedMultiplier);
if (hacks.Speeding && hacks.CanSpeed) speed += factor * hacks.SpeedMultiplier;
if (hacks.HalfSpeeding && hacks.CanSpeed) speed += factor * hacks.SpeedMultiplier / 2;
return hacks.CanSpeed ? speed : Math.Min(speed, 1.0f);
}
const float inf = float.PositiveInfinity;
View
@@ -332,7 +332,7 @@ void HacksComp_Init(HacksComp* hacks) {
hacks->Enabled = true;
hacks->CanSeeAllNames = true;
hacks->CanDoubleJump = true;
hacks->MaxSpeedMultiplier = 1.0f;
hacks->BaseHorSpeed = 1.0f;
hacks->MaxJumps = 1;
hacks->NoclipSlide = true;
hacks->CanBePushed = true;
@@ -366,7 +366,7 @@ void HacksComp_ParseHorizontalSpeed(HacksComp* hacks) {
Real32 speed = 0.0f;
if (!Convert_TryParseReal32(&speedStr, &speed) || speed <= 0.0f) return;
hacks->MaxSpeedMultiplier = speed;
hacks->BaseHorSpeed = speed;
}
void HacksComp_ParseMultiSpeed(HacksComp* hacks) {
@@ -439,7 +439,7 @@ void HacksComp_UpdateState(HacksComp* hacks) {
HacksComp_SetAll(hacks, true);
if (hacks->HacksFlags.length == 0) return;
hacks->MaxSpeedMultiplier = 1;
hacks->BaseHorSpeed = 1;
hacks->MaxJumps = 1;
hacks->CanBePushed = true;
@@ -621,4 +621,178 @@ void LocalInterpComp_AdvanceState(InterpComp* interp) {
interp->Prev = interp->Next;
entity->Position = interp->Next.Pos;
InterpComp_AdvanceRotY(interp);
}
}
enum NameMode { Hovered, All, AllHovered, AllUnscaled }
enum EntityShadow { None, SnapToBlock, Circle, CircleAll, }
const int MaxCount = 256;
const byte SelfID = 255;
public Entity[] List = new Entity[MaxCount];
public EntityShadow ShadowMode = EntityShadow.None;
byte closestId;
NameMode NamesMode = NameMode.Hovered;
void Entities_Init(void) {
game.Graphics.ContextLost += ContextLost;
game.Graphics.ContextRecreated += ContextRecreated;
game.Events.ChatFontChanged += ChatFontChanged;
NamesMode = Options.GetEnum(OptionsKey.NamesMode, NameMode.Hovered);
if (game.ClassicMode) NamesMode = NameMode.Hovered;
ShadowMode = Options.GetEnum(OptionsKey.EntityShadow, EntityShadow.None);
if (game.ClassicMode) ShadowMode = EntityShadow.None;
}
void Entities_Tick(ScheduledTask* task) {
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
List[i].Tick(task.Interval);
}
}
void Entities_RenderModels(Real64 delta, Real32 t) {
gfx.Texturing = true;
gfx.AlphaTest = true;
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
List[i].RenderModel(delta, t);
}
gfx.Texturing = false;
gfx.AlphaTest = false;
}
bool hadFog;
void Entities_RenderNames(Real64 delta) {
closestId = GetClosetPlayer(game.LocalPlayer);
if (!game.LocalPlayer.Hacks.CanSeeAllNames || NamesMode != NameMode.All) return;
gfx.Texturing = true;
gfx.AlphaTest = true;
hadFog = gfx.Fog;
if (hadFog) gfx.Fog = false;
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
if (i != closestId || i == SelfID)
List[i].RenderName();
}
gfx.Texturing = false;
gfx.AlphaTest = false;
if (hadFog) gfx.Fog = true;
}
void Entities_RenderHoveredNames(Real64 delta) {
gfx.Texturing = true;
gfx.AlphaTest = true;
gfx.DepthTest = false;
hadFog = gfx.Fog;
if (hadFog) gfx.Fog = false;
bool allNames = !(NamesMode == NameMode.Hovered || NamesMode == NameMode.All)
&& game.LocalPlayer.Hacks.CanSeeAllNames;
for (int i = 0; i < List.Length; i++) {
bool hover = (i == closestId || allNames) && i != SelfID;
if (List[i] != null && hover)
List[i].RenderName();
}
gfx.Texturing = false;
gfx.AlphaTest = false;
gfx.DepthTest = true;
if (hadFog) gfx.Fog = true;
}
void Entities_ContextLost(void) {
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
List[i].ContextLost();
}
}
void Entities_ContextRecreated(void) {
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
List[i].ContextRecreated();
}
}
void Entities_ChatFontChanged(void) {
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
Player p = List[i] as Player;
if (p != null) p.UpdateName();
}
}
void Entities_Remove(EntityID id) {
game.EntityEvents.RaiseRemoved(id);
List[id].Despawn();
List[id] = null;
}
void Entities_Free(void) {
for (int i = 0; i < List.Length; i++) {
if (List[i] == null) continue;
RemoveEntity((byte)i);
}
game.Graphics.ContextLost -= ContextLost;
game.Graphics.ContextRecreated -= ContextRecreated;
game.Events.ChatFontChanged -= ChatFontChanged;
if (ShadowComponent.shadowTex > 0) {
game.Graphics.DeleteTexture(ref ShadowComponent.shadowTex);
}
}
EntityID Entities_GetClosetPlayer(Player* src) {
Vector3 eyePos = src.EyePosition;
Vector3 dir = Utils.GetDirVector(src.HeadYRadians, src.HeadXRadians);
float closestDist = float.PositiveInfinity;
byte targetId = SelfID;
for (int i = 0; i < List.Length - 1; i++) { // -1 because we don't want to pick against local player
Entity p = List[i];
if (p == null) continue;
float t0, t1;
if (Intersection.RayIntersectsRotatedBox(eyePos, dir, p, out t0, out t1) && t0 < closestDist) {
closestDist = t0;
targetId = (byte)i;
}
}
return targetId;
}
void Entities_DrawShadows(void) {
if (ShadowMode == EntityShadow.None) return;
ShadowComponent.boundShadowTex = false;
IGraphicsApi gfx = game.Graphics;
gfx.AlphaArgBlend = true;
gfx.DepthWrite = false;
gfx.AlphaBlending = true;
gfx.Texturing = true;
gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);
ShadowComponent.Draw(game, List[SelfID]);
if (ShadowMode == EntityShadow.CircleAll)
DrawOtherShadows();
gfx.AlphaArgBlend = false;
gfx.DepthWrite = true;
gfx.AlphaBlending = false;
gfx.Texturing = false;
}
void Entities_DrawOtherShadows(void) {
for (int i = 0; i < SelfID; i++) {
if (List[i] == null) continue;
Player p = List[i] as Player;
if (p != null) ShadowComponent.Draw(game, p);
}
}
Oops, something went wrong.

0 comments on commit 3bed91a

Please sign in to comment.