4ªU|nutscripts/vscriptsdirector_base_addonî„”WÿÿÿdashingP@gsÿFÖÿÿtxt addoninfo—†‰ÿFÿÿ"AddonInfo" { "addonSteamAppID" "550" "addonTitle" "Dashing" "addonVersion" "1.0" "addonTagLine" "Dashing" "addonAuthor" "Respire" "addonAuthorSteamID" "notrespire" "addonContent_Script" "1" "addonDescription" "Dashing" }if (!Entities.FindByName(null, "survivor_dash_timer")) { SpawnEntityFromTable("logic_timer", { targetname = "survivor_dash_timer", RefireTime = 0.05, OnTimer = "!self,RunScriptCode,RespireSurvivorDash.Think()" }); } ::RespireSurvivorDash <- { Config = { SOUND = { DASH = [ "player/footsteps/survivor/shoe_scuff1.wav", "player/footsteps/survivor/shoe_scuff2.wav", "player/footsteps/survivor/shoe_scuff3.wav", "player/footsteps/survivor/shoe_scuff4.wav" ] }, DASH_SETTINGS = { FORCE = 400, GROUND_LIFT_HEIGHT = 251 }, TIMING = { THINK_INTERVAL = 0.05, RECHARGE_TIME = 2.5, MAX_CHARGES = 4 }, DEBUG = { ENABLED = true } }, CONSTANTS = { MOVEMENT_BUTTONS = 8 | 16 | 512 | 1024, IN_SPEED = 131072, INVALID_GROUND_ENTITY = -1 }, PLAYER_STATE = {}, function Log(msg, level = "debug") { if (this.Config.DEBUG.ENABLED || level != "debug") { printl("[dash " + level + "] " + msg); } }, function OnGameEvent_player_spawn(params) { local player = GetPlayerFromUserID(params.userid); if (player && player.IsSurvivor()) { this.InitPlayerState(params.userid); } }, function OnGameEvent_player_death(params) { if ("userid" in params) { this.CleanupPlayerState(params.userid); } }, function InitPlayerState(userid) { this.PLAYER_STATE[userid] <- { lastButtonMask = 0, dashCharges = this.Config.TIMING.MAX_CHARGES, rechargeAccumulator = 0.0, lastThinkTime = Time() }; }, function CleanupPlayerState(userid) { if (userid in this.PLAYER_STATE) { delete this.PLAYER_STATE[userid]; } }, function CanPlayerDash(player, state) { if (state.dashCharges <= 0) return false; return !( NetProps.GetPropInt(player, "m_hGroundEntity") == this.CONSTANTS.INVALID_GROUND_ENTITY || NetProps.GetPropInt(player, "m_isIncapacitated") != 0 || NetProps.GetPropEntity(player, "m_pounceAttacker") != null || NetProps.GetPropEntity(player, "m_tongueOwner") != null || NetProps.GetPropEntity(player, "m_jockeyAttacker") != null || NetProps.GetPropEntity(player, "m_pummelAttacker") != null || NetProps.GetPropEntity(player, "m_carryAttacker") != null || (NetProps.GetPropFloat(player, "m_flProgressBarStartTime") > 0.0 && NetProps.GetPropFloat(player, "m_flProgressBarDuration") > 0.0) ); }, function Think() { local now = Time(); local players = this.GetHumanSurvivors(); foreach (player in players) { local userid = player.GetPlayerUserId(); if (!(userid in this.PLAYER_STATE)) { this.InitPlayerState(userid); } local state = this.PLAYER_STATE[userid]; local delta = now - state.lastThinkTime; state.lastThinkTime = now; if (state.dashCharges < this.Config.TIMING.MAX_CHARGES) { state.rechargeAccumulator += delta; while ( state.rechargeAccumulator >= this.Config.TIMING.RECHARGE_TIME && state.dashCharges < this.Config.TIMING.MAX_CHARGES ) { state.dashCharges++; state.rechargeAccumulator -= this.Config.TIMING.RECHARGE_TIME; } } local buttons = player.GetButtonMask(); local moveMask = buttons & this.CONSTANTS.MOVEMENT_BUTTONS; local shiftNow = (buttons & this.CONSTANTS.IN_SPEED); local shiftBefore = (state.lastButtonMask & this.CONSTANTS.IN_SPEED); local shiftPressed = shiftNow && !shiftBefore; if ( shiftPressed && moveMask && this.CanPlayerDash(player, state) ) { this.PerformDash(player, state, buttons); state.dashCharges--; } state.lastButtonMask = buttons; } }, function PerformDash(player, state, buttons) { local dir = this.GetDashVector(player, buttons); if (dir.Length() <= 0) return; local vel = player.GetVelocity(); vel.x = dir.x * this.Config.DASH_SETTINGS.FORCE; vel.y = dir.y * this.Config.DASH_SETTINGS.FORCE; vel.z = this.Config.DASH_SETTINGS.GROUND_LIFT_HEIGHT; player.SetVelocity(vel); NetProps.SetPropFloat(player, "localdata.m_Local.m_flFallVelocity", 0.0); local sounds = this.Config.SOUND.DASH; local snd = sounds[RandomInt(0, sounds.len() - 1)]; EmitSoundOn(snd, player); }, function GetDashVector(player, buttons) { local yaw = player.EyeAngles().y * PI / 180; local fwd = Vector(cos(yaw), sin(yaw), 0); local right = Vector(sin(yaw), -cos(yaw), 0); local v = Vector(0, 0, 0); if (buttons & 8) v += fwd; if (buttons & 16) v -= fwd; if (buttons & 512) v -= right; if (buttons & 1024) v += right; v.Norm(); return v; }, function GetHumanSurvivors() { local out = []; local ent = null; while (ent = Entities.FindByClassname(ent, "player")) { if ( ent.IsSurvivor() && NetProps.GetPropInt(ent, "m_iTeamNum") == 2 && NetProps.GetPropInt(ent, "m_survivorCharacter") != -1 ) { out.append(ent); } } return out; } }; RespireSurvivorDash.Init <- function() { foreach (snd in this.Config.SOUND.DASH) { PrecacheSound(snd); } __CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener); this.Log("Respire's Survivor Dash Loaded", "info"); }; RespireSurvivorDash.Init(); // :3 // Coockle Doodle Doo! IncludeScript( "dashing" );