AddCSLuaFile("shared.lua") include("shared.lua") ENT.MODEL = "models/props_c17/briefcase001a.mdl" ENT.LASTINGEFFECT = 30; ENT.HASHIGH = true ENT.MULTIPLY = 1 ENT.LACED = {} ENT.SPEED_SCALE = 1 --console commands CreateConVar( "durgz_witty_sayings", "1", { FCVAR_REPLICATED, FCVAR_ARCHIVE } ) --0 for no witty sayings when you take the drug CreateConVar( "durgz_roleplay", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE } ) --set to 1 for none of those "special" side effects (like ultimate speed and really low gravity) function ENT:SpawnFunction( ply, tr, Classname) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal local ent = ents.Create(Classname) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() self:SetModel( self.MODEL ) --self:SetNWFloat( "SprintSpeed" self:PhysicsInit( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end self.LACED = {}; if( self.MASS )then self.Entity:GetPhysicsObject():SetMass( self.MASS ); end end function ENT:OnTakeDamage( dmginfo ) self.Entity:TakePhysicsDamage( dmginfo ) end local function DoHigh(activator, caller, class, lastingeffect, transition_time, overdosephrase, nicknames) --if you're transitioning to the end and you take another, smoothen it out if activator:GetNWFloat(class.."_high_end") && activator:GetNWFloat(class.."_high_end") > CurTime() && activator:GetNWFloat(class.."_high_end") - transition_time < CurTime() then --set the high start in such a way to where it doesn't snap to the start time, goes smoooothly. local set = CurTime() - ( activator:GetNWFloat(class.."_high_end") - CurTime() ); activator:SetNWFloat(class.."_high_start", set); --if you're not high at all elseif( !activator:GetNWFloat(class.."_high_start") || activator:GetNWFloat(class.."_high_end") < CurTime() )then activator:SetNWFloat(class.."_high_start", CurTime()); end --high is done local ctime; if( !activator:GetNWFloat(class.."_high_end") || activator:GetNWFloat(class.."_high_end") < CurTime() )then ctime = CurTime(); --you're already high on the drug, add more highness else ctime = activator:GetNWFloat(class.."_high_end") - lastingeffect/3; end activator:SetNWFloat(class.."_high_end", ctime + lastingeffect); if( activator:GetNWFloat(class.."_high_end") && activator:GetNWFloat(class.."_high_end") - lastingeffect*5 > CurTime() )then --kill em activator.DURGZ_MOD_DEATH = class; activator.DURGZ_MOD_OVERDOSE = overdosephrase[math.random(1, #overdosephrase)]; activator.DURGZ_MOD_NICKNAMES = nicknames[math.random(1, #nicknames)]; activator:Kill(); end end hook.Add("PlayerDeath", "durgz_death_notice", function(victim, inflictor, attacker) if( victim.DURGZ_MOD_DEATH )then --add shmexy killicon umsg.Start( "PlayerKilledByDrug" ) umsg.Entity( victim ); umsg.String( victim.DURGZ_MOD_DEATH ); umsg.End() local s = victim.DURGZ_MOD_OVERRIDE or victim:Nick().." "..victim.DURGZ_MOD_OVERDOSE.." "..victim.DURGZ_MOD_NICKNAMES.." and died."; /*for id,pl in pairs(player.GetAll())do pl:PrintMessage(HUD_PRINTTALK, s); end*/ MsgAll(s); victim.DURGZ_MOD_DEATH = nil; victim.DURGZ_MOD_OVERDOSE = nil; victim.DURGZ_MOD_NICKNAMES = nil; victim.DURGZ_MOD_OVERRIDE = nil; return true end end) function ENT:Use(activator,caller) umsg.Start("durgz_lose_virginity", activator) umsg.End() self:High(activator,caller); if( self.HASHIGH )then DoHigh( activator, caller, self:GetClass(), self.LASTINGEFFECT, self.TRANSITION_TIME, self.OverdosePhrase, self.Nicknames ); end self:AfterHigh(activator, caller); for k,v in pairs(self.LACED)do local drug = ents.Create(v); drug:Spawn(); drug:High(activator,caller); DoHigh( activator, caller, drug:GetClass(), drug.LASTINGEFFECT, drug.TRANSITION_TIME, drug.OverdosePhrase, drug.Nicknames ); drug:AfterHigh(activator,caller); drug:Remove(); end self.Entity:Remove() end --this is pretty much a function you call if you want the person taking the drug to say something, all this function does is check if the console command is a ok. function ENT:Say(pl, str) local should_say = GetConVar("durgz_witty_sayings", 0):GetBool() local is_empty = type(str) == "string" and str == "" or type(str) == "table" and #str == 0 or str == nil if should_say and !is_empty then if type(str) == "table" then str = str[math.random(1, #str)] end pl:ConCommand("say "..str) end return should_say end function ENT:Realistic() return GetConVar("durgz_roleplay", 0):GetBool() end function ENT:High(activator, caller) end function ENT:AfterHigh(activator, caller) end local function SoberUp(pl, x, y, z, ndeath, didntdie) --would be nice to have this be dynamically fetched instead of caked in with fixed values --besides , it would be helpful to completely kill renderspace effects on playerspawn --make a smooth transition and not a instant soberization if not (DEFAULT_WALK_SPEED or DEFAULT_RUN_SPEED or DEFAULT_JUMP_POWER or DEFAULT_GRAVITY) and pl:Alive() then DEFAULT_WALK_SPEED=pl:GetWalkSpeed();DEFAULT_RUN_SPEED=pl:GetRunSpeed() DEFAULT_JUMP_POWER=pl:GetJumpPower();DEFAULT_GRAVITY=pl:GetGravity() end local drugs = { "weed", "codeine", "cocaine", "cigarette", "alcohol", "mushroom", "meth", "ecstasy", "caffeine", "pcp", "lsd", "lsd_classic", "opium", "ketamine", } local ttime = { 6, 6, 5, 4, 6, 6, 3, 3, 3, 3, 6, 6, 3, 3, } --you can't get out of the heroine high because you die when the high ends if( !didntdie )then table.insert(ttime, 5) table.insert(drugs, "heroine") end for i = 1, #drugs do local tend = 0 if( pl:GetNWFloat("durgz_"..drugs[i].."_high_start") + ttime[i] > CurTime() )then tend = ( CurTime() - pl:GetNWFloat("durgz_"..drugs[i].."_high_start") ) + CurTime() elseif !( pl:GetNWFloat("durgz_"..drugs[i].."_high_end") - ttime[i] < CurTime() )then tend = CurTime() + ttime[i] elseif( pl:GetNWFloat("durgz_"..drugs[i].."_high_end") > CurTime() )then tend = pl:GetNWFloat("durgz_"..drugs[i].."_high_end") end pl:SetNWFloat("durgz_"..drugs[i].."_high_start", 0) pl:SetNWFloat("durgz_"..drugs[i].."_high_end", tend) end pl:SetWalkSpeed(DEFAULT_WALK_SPEED) --set speed back to normal pl:SetRunSpeed(DEFAULT_RUN_SPEED) --set speed back to normal pl:SetGravity(DEFAULT_GRAVITY) --no more floating pl:SetJumpPower(DEFAULT_JUMP_POWER) --no more big jump pl:SetDSP(1, false) --set sound to normal if( ndeath )then pl:EmitSound(Sound("vo/npc/male01/moan0"..math.random(4,5)..".wav")) end end hook.Add("DoPlayerDeath", "durgz_sober_up_cmd_death", SoberUp) hook.Add("PlayerSpawn", "durgz_sober_up_cmd_spawn", SoberUp) function ENT:Soberize(pl) SoberUp(pl, true, true, true, true, true);end hook.Add("PlayerSpawn", "durgz_getwalkrunspeed", function(pl) timer.Simple(0, function() if not (IsValid(pl) and pl:Alive()) then return end DEFAULT_WALK_SPEED = pl:GetWalkSpeed() DEFAULT_RUN_SPEED = pl:GetRunSpeed() DEFAULT_JUMP_POWER = pl:GetJumpPower() DEFAULT_GRAVITY = pl:GetGravity() end) end)