Skip to content

Commit

Permalink
Maj Bates
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhem-Pech committed Aug 6, 2018
1 parent 2569152 commit 2765852
Show file tree
Hide file tree
Showing 15 changed files with 738 additions and 50 deletions.
12 changes: 12 additions & 0 deletions entities/entities/batesmum/cl_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Utopia Games - Slashers
--
-- @Author: Vyn
-- @Date: 2017-07-26 00:53:59
-- @Last modified by: Guilhem PECH
-- @Last modified time: 2018-01-09 17:05:52

include('shared.lua')

function ENT:Draw()
self:DrawModel()
end
93 changes: 93 additions & 0 deletions entities/entities/batesmum/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- @Author: Guilhem PECH <Daryl_Winters>
-- @Date: 2018-01-09 11:09:22
-- @Email: guilhempech@gmail.com
-- @Project: Slashers
-- @Last modified by: Guilhem PECH
-- @Last modified time: 2018-01-11 16:59:23
local GM = GM or GAMEMODE
AddCSLuaFile("cl_init.lua") -- Make sure clientside
AddCSLuaFile("shared.lua") -- and shared scripts are sent.
include("shared.lua")
util.AddNetworkString("slash_mother_bates")
local timer = 0

local radiusFar = 500
local radiusMedium = 400
local radiusClose = 200

local function getDistanceNearestPlayer(table, origin)
local result = false

for k, v in ipairs(table) do
if v:IsValid() and v:IsPlayer() and v:Team() ~= TEAM_KILLER and (not result or v:GetPos():Distance(origin) < result) then
result = v:GetPos():Distance(origin)
end
end

return result
end

function ENT:Think()
local status = 0
if not GM.ROUND.Active then return end
if (timer + 0.5) < CurTime() then
timer = CurTime()

proximityPlayers = getDistanceNearestPlayer(ents.FindInSphere(self:GetPos(), radiusFar or 500), self:GetPos())

if not proximityPlayers then
print("Not")
GM.ROUND.Killer:SetWalkSpeed( GM.MAP.Killer.WalkSpeed )
GM.ROUND.Killer:SetRunSpeed(GM.MAP.Killer.RunSpeed )
status = 0
elseif proximityPlayers <= radiusClose then
print("Supplosed =", GM.MAP.Killer.WalkSpeed * 1.8)
GM.ROUND.Killer:SetWalkSpeed( GM.MAP.Killer.WalkSpeed * 1.8 )
GM.ROUND.Killer:SetRunSpeed(GM.MAP.Killer.RunSpeed * 1.8)
status = 3
elseif proximityPlayers <= radiusMedium then
print("Supplosed =", GM.MAP.Killer.WalkSpeed * 1.3)
GM.ROUND.Killer:SetWalkSpeed( GM.MAP.Killer.WalkSpeed * 1.3 )
GM.ROUND.Killer:SetRunSpeed(GM.MAP.Killer.RunSpeed * 1.3)
status = 2
else
print("Supplosed =", GM.MAP.Killer.WalkSpeed * 1.1)
GM.ROUND.Killer:SetWalkSpeed( GM.MAP.Killer.WalkSpeed * 1.1 )
GM.ROUND.Killer:SetRunSpeed(GM.MAP.Killer.RunSpeed * 1.1)
status = 1
end

net.Start("slash_mother_bates")
net.WriteUInt(status, 3)
net.Broadcast()
end
end

local ragdoll = ents.Create("prop_ragdoll")

function ENT:Initialize()
if ConVarExists("slashers_bates_far_radius") and ConVarExists("slashers_bates_medium_radius") and ConVarExists("slashers_bates_close_radius") then
radiusFar = GetConVar("slashers_bates_far_radius"):GetInt()
radiusMedium = GetConVar("slashers_bates_medium_radius"):GetInt()
radiusClose = GetConVar("slashers_bates_close_radius"):GetInt()
end
for k,v in pairs(ents.GetAll()) do
if v:GetName() == "slash_bates_points" then
v:Remove()
end
end
if (not IsValid(ragdoll)) then
ragdoll = ents.Create("prop_ragdoll")
end
ragdoll:SetModel("models/skeleton/skeleton_whole_noskins.mdl")
ragdoll:PhysicsInit(SOLID_VPHYSICS)
ragdoll:GetPhysicsObject():EnableDrag(true)
ragdoll:SetPos(self:GetPos())
self:SetParent(ragdoll)
ragdoll:Spawn()
ragdoll:SetName("slash_bates_mother")
self:SetName("slash_bates_points")
end

function ENT:Touch(ent)
end
15 changes: 15 additions & 0 deletions entities/entities/batesmum/shared.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- @Author: Guilhem PECH <Daryl_Winters>
-- @Date: 2018-01-09 11:09:22
-- @Email: guilhempech@gmail.com
-- @Project: Slashers
-- @Last modified by: Guilhem PECH
-- @Last modified time: 2018-01-09 17:05:43


ENT.Type = "point"
ENT.Author = "Daryl Winters"
ENT.PrintName = "Bates Mother"
ENT.Spawnable = true
--ENT.AutomaticFrameAdvance = true

slashers_batesmum_maxtap = 1
66 changes: 66 additions & 0 deletions entities/entities/sls_motherbates/cl_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
-- Utopia Games - Slashers
--
-- @Author: Guilhem PECH
-- @Date: 2017-07-26T13:54:42+02:00
-- @Last modified by: Guilhem PECH
-- @Last modified time: 15-Apr-2018

include("shared.lua")


local GM = GM or GAMEMODE


GM.oldLevel = null
GM.SoundPlayed = null

ENT.RenderGroup = RENDERGROUP_BOTH

GM.MommyEntity = nil

function ENT:Initialize()
GM.MommyEntity = self
end

function ENT:Draw()
self.Entity:DrawModel()
end

local function HUDPaintBackground()
if LocalPlayer():Team() != TEAM_KILLER || !GM.ROUND.Active || !IsValid(GM.MommyEntity) then return end

local pos = GM.MommyEntity:GetPos():ToScreen()
local color = Color(255,255,255)
if GM.oldLevel == 3 then
color = Color(255,0,0)
elseif GM.oldLevel == 1 then
color = Color(0,255,0)
elseif GM.oldLevel == 2 then
color = Color(255, 239, 0)
else
color = Color(255, 255, 255)
end

surface.SetDrawColor(color)
surface.SetMaterial(Material("icons/icon_mother.png"))
surface.DrawTexturedRect(pos.x - 50, pos.y -100, 64, 64)
end
hook.Add("HUDPaintBackground", "sls_kability_HUDPaintBackground", HUDPaintBackground)

function ENT:DrawTranslucent()
if LocalPlayer():IsLineOfSightClear( self.Entity ) and self.Entity:GetPos():Distance( LocalPlayer():GetPos()) < 150 and LocalPlayer():Team() != TEAM_KILLER then
DrawIndicator(self.Entity)
end
end

function ENT:Think()

end

function ENT:OnRemove()
if IsValid(GM.SoundPlayed) then
GM.SoundPlayed:Stop()
end
GM.oldLevel = null
GM.MommyEntity = null
end
151 changes: 151 additions & 0 deletions entities/entities/sls_motherbates/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
-- Utopia Games - Slashers
--
-- @Author: Guilhem PECH
-- @Date: 2017-07-26T13:54:42+02:00
-- @Last modified by: Guilhem PECH
-- @Last modified time: 15-Apr-2018



local GM = GAMEMODE

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')

util.AddNetworkString("sls_motherradar")

function endMusic(victim)
net.Start("sls_motherradar",true)
net.WriteUInt(0,2)
net.Send(victim)
end
hook.Add("PlayerDeath","slash_deathmusicend",'endMusic')

function ENT:Initialize()

self.Active = false
self:SetModel("models/poly_wheelchair.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetNWBool('activated',false)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType( SIMPLE_USE )

local bones = ents.Create( "prop_physics" )
bones:SetModel( "models/skeleton/skeleton_torso.mdl" )
bones:SetPos( self:GetPos() + Vector(-4.116044,0.400906,37.009029) )
bones:SetAngles(self:GetAngles() + Angle(-22.855,-15.711,9.402))
bones:SetMoveType(MOVETYPE_NONE)
bones:SetParent(self)
bones:Spawn()


local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:EnableMotion(true)
phys:Wake()
end

timer.Simple( 1, function()
if(IsValid(self)) then
self:SetMoveType(MOVETYPE_NONE)
end
end )
end

function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local ent = ents.Create("sls_motherbates")
ent:SetPos( tr.HitPos + tr.HitNormal )
ent:Spawn()

return ent
end
ents.Create("prop_physics")


function sendInfo (ply,DistSqr)
if(!IsValid(ply)) then return end
net.Start("sls_motherradar",true)
net.WriteUInt(howFar (DistSqr),2)
net.Send(ply)
end

function howFar (pos)
if (pos) < ( 500*500 ) then
return 3
elseif (pos) < ( 1000*1000 ) then
return 2
elseif (pos) < ( 1500*1500 ) then
return 1
else
return 0
end
end


function ENT:FindAroundPlayers(radius)
local entsNearby = ents.FindInSphere( self:GetPos() , radius )
local plyNearby = {}
for i,v in pairs(entsNearby) do
if (v:IsValid() and v:IsPlayer() and v:Team() ~= TEAM_KILLER and v.ClassID != CLASS_SURV_SHY) then
plyNearby[v] = v:GetPos():DistToSqr( self:GetPos() )
sendInfo(v,plyNearby[v])
end
end
return plyNearby
end

function ApplyModifications(ply,pos)
if(!IsValid(ply)) then return end
if (!ply.normWalk) then ply.normWalk = ply:GetWalkSpeed() end

if (pos) < ( 500*500 ) then
ply:SetWalkSpeed(ply.normWalk * 1.6)
ply:SetRunSpeed(ply.normWalk * 1.6)
elseif (pos) < ( 1000*1000 ) then
ply:SetWalkSpeed(ply.normWalk * 1.4)
ply:SetRunSpeed(ply.normWalk * 1.4)
elseif (pos) < ( 1500*1500 ) then
ply:SetWalkSpeed(ply.normWalk * 1.2)
ply:SetRunSpeed(ply.normWalk * 1.2)
else
ply:SetWalkSpeed(ply.normWalk)
ply:SetRunSpeed(ply.normWalk)

end
end


function ENT:Think()
local plyNearby = self:FindAroundPlayers(3000)
local last = 5000*5000
for k,v in pairs(plyNearby) do
if v < last then
sendInfo (GM.ROUND.Killer,v)
ApplyModifications(GM.ROUND.Killer,v)
last = v
end
end
self:NextThink( CurTime() + 1 )
return true
end

function ENT:OnTakeDamage(dmg)

end

function ENT:Use( activator, caller )
if ( activator:IsPlayer() && activator ~= GM.ROUND.Killer && !GM.ROUND.WaitingPolice) then
CurrentObjective = "wainting_police"
objectifComplete()
GM.ROUND:StartWaitingPolice()
end
end

function ENT:OnRemove()
if self:IsPlayer() then
self:GetOwner():SetWalkSpeed(ply.normWalk)
end
end
17 changes: 17 additions & 0 deletions entities/entities/sls_motherbates/shared.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Utopia Games - Slashers
--
-- @Author: Guilhem PECH
-- @Date: 2017-07-26T13:54:42+02:00
-- @Last modified by: Guilhem PECH
-- @Last modified time: 15-Apr-2018



ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "Mother"
ENT.Author = "Daryl Winters"
ENT.Information = " To Call the Police"
ENT.Category = "Slashers"
ENT.Spawnable = true
ENT.AdminSpawnable = false
Loading

1 comment on commit 2765852

@Garrus2142
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

Please sign in to comment.