Skip to content

Commit

Permalink
Merge pull request #6 from rafraser/gamemode-prototypes
Browse files Browse the repository at this point in the history
1.1 Update Implementation
  • Loading branch information
Robert Fraser authored Dec 20, 2018
2 parents 86813db + 58a6c7c commit c600a15
Show file tree
Hide file tree
Showing 107 changed files with 2,477 additions and 2,701 deletions.
19 changes: 9 additions & 10 deletions fluffy_balls/entities/entities/mg_ball_drop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENT.PrintName = "Ball"

ENT.MinSize = 24
ENT.MaxSize = 64
ENT.LifeTime = 15

function ENT:SetupDataTables()
self:NetworkVar( "Float", 0, "BallSize", { KeyName = "ballsize", Edit = { type = "Float", min = self.MinSize, max = self.MaxSize, order = 1 } } )
Expand All @@ -20,16 +21,23 @@ function ENT:Initialize()
self:SetModel("models/Combine_Helicopter/helicopter_bomb01.mdl")
self:RebuildPhysics()

-- Should be overriden in the gamemode
self:SetBallColor( table.Random( {
Vector( 1, 0.3, 0.3 ),
Vector( 0.3, 1, 0.3 ),
Vector( 1, 1, 0.3 ),
Vector( 0.2, 0.3, 1 ),
} ) )

-- Remove balls that have lived for too long
timer.Simple(self.LifeTime, function()
if IsValid(self) then
self:Remove()
end
end)
end

function ENT:RebuildPhysics( value )

-- This is necessary so that the vphysics.dll will not crash when attaching constraints to the new PhysObj after old one was destroyed
-- TODO: Somehow figure out why it happens and/or move this code/fix to the constraint library
self.ConstraintSystem = nil
Expand All @@ -39,22 +47,18 @@ function ENT:RebuildPhysics( value )
self:SetCollisionBounds( Vector( -size, -size, -size ), Vector( size, size, size ) )

self:PhysWake()

end

function ENT:OnBallSizeChanged( varname, oldvalue, newvalue )

-- Do not rebuild if the size wasn't changed
if ( oldvalue == newvalue ) then return end

self:RebuildPhysics( newvalue )

end

local BounceSound = Sound( "garrysmod/balloon_pop_cute.wav" )

function ENT:PhysicsCollide( data, physobj )

-- Play sound on bounce
if ( data.Speed > 60 && data.DeltaTime > 0.2 ) then

Expand All @@ -73,14 +77,11 @@ function ENT:PhysicsCollide( data, physobj )
local TargetVelocity = NewVelocity * LastSpeed * 0.9

physobj:SetVelocity( TargetVelocity )

end

function ENT:OnTakeDamage( dmginfo )

-- React physically when shot/getting blown
self:TakePhysicsDamage( dmginfo )

end

function ENT:Use( activator, caller )
Expand All @@ -96,7 +97,6 @@ if ( SERVER ) then return end -- We do NOT want to execute anything below in thi
local matBall = Material( "sprites/sent_ball" )

function ENT:Draw()

render.SetMaterial( matBall )

local pos = self:GetPos()
Expand All @@ -109,5 +109,4 @@ function ENT:Draw()

local size = math.Clamp( self:GetBallSize(), self.MinSize, self.MaxSize )
render.DrawSprite( pos, size, size, Color( lcolor.x, lcolor.y, lcolor.z, 255 ) )

end
42 changes: 0 additions & 42 deletions fluffy_btest/gamemode/init.lua

This file was deleted.

56 changes: 0 additions & 56 deletions fluffy_castlecrash/entities/flag_blue.lua

This file was deleted.

56 changes: 0 additions & 56 deletions fluffy_castlecrash/entities/flag_red.lua

This file was deleted.

5 changes: 0 additions & 5 deletions fluffy_castlecrash/fluffy_castlecrash.txt

This file was deleted.

10 changes: 0 additions & 10 deletions fluffy_castlecrash/gamemode/init.lua

This file was deleted.

12 changes: 0 additions & 12 deletions fluffy_castlecrash/gamemode/shared.lua

This file was deleted.

5 changes: 0 additions & 5 deletions fluffy_crossbow_battle/fluffy_crossbow.txt

This file was deleted.

12 changes: 0 additions & 12 deletions fluffy_crossbow_battle/gamemode/init.lua

This file was deleted.

14 changes: 0 additions & 14 deletions fluffy_crossbow_battle/gamemode/shared.lua

This file was deleted.

25 changes: 25 additions & 0 deletions fluffy_ctf/entities/entities/ctf_blue_marker.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AddCSLuaFile()
ENT.Base = "base_point"
ENT.Type = "point"
if CLIENT then
ENT.Icon = Material('icon16/flag_blue.png')
end

function ENT:UpdateTransmitState()
return TRANSMIT_ALWAYS
end

function ENT:Draw()
if not LocalPlayer():Alive() or LocalPlayer().Spectating then return end

local center = self:GetPos()
local p = center:ToScreen()

surface.SetDrawColor(color_white)
surface.SetMaterial(self.Icon)
surface.DrawTexturedRect(p.x - 8, p.y - 8, 16, 16)

if LocalPlayer():Team() == TEAM_BLUE then
draw.SimpleTextOutlined('Capture here!', 'DermaDefault', p.x, p.y + 16, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color(0, 0, 0))
end
end
Loading

0 comments on commit c600a15

Please sign in to comment.