-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
# Assistance Terminals | ||
|
||
![Idle State](https://cdn.discordapp.com/attachments/439006819722067968/869649803737460747/gm_construct0074.jpg "Idle State") | ||
|
||
![Alert State](https://cdn.discordapp.com/attachments/439006819722067968/869649801443172472/gm_construct0075.jpg "Alert State") | ||
|
||
The Assistance Terminals are essentially glorified request devices. Their function is the same - to allow citizens and other human factions to request a Combine officer to their location. | ||
|
||
The plugin comes with native support for the [Waypoints plugin](https://plugins.gethelix.co/waypoints/) by [Gr4Ss](http:https://steamcommunity.com/profiles/76561197997384060). When a request is made, a waypoint will appear at the location of the terminal. | ||
|
||
Finally, the plugin makes use of the Areas plugin that comes with Helix by default - meaning you will need to set up some areas around the map, if you wish to make use of the location feature of the terminals, otherwise the terminal location will default to "Unknown Location". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
surface.CreateFont( "terminal_title", { | ||
font = "Roboto", | ||
size = 35, | ||
weight = 0, | ||
scanlines = 2, | ||
antialias = true | ||
} ) | ||
|
||
surface.CreateFont( "terminal_requestText", { | ||
font = "Roboto", | ||
size = 30, | ||
weight = 0, | ||
scanlines = 2, | ||
antialias = true | ||
} ) | ||
|
||
surface.CreateFont( "terminal_location", { | ||
font = "Lucida Console", | ||
size = 20, | ||
weight = 20, | ||
scanlines = 2, | ||
shadow = true, | ||
antialias = true | ||
} ) | ||
|
||
surface.CreateFont( "terminal_infoText", { | ||
font = "Lucida Console", | ||
size = 30, | ||
weight = 20, | ||
scanlines = 2, | ||
antialias = true | ||
} ) |
142 changes: 142 additions & 0 deletions
142
assistance_terminal/entities/entities/ix_assistance_terminal/cl_init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
|
||
include( "shared.lua" ) | ||
|
||
local noise = Material( "overlays/camcorder_noise" ) | ||
local overlay = Material( "effects/combine_binocoverlay" ) | ||
|
||
function ENT:Think( ) | ||
if ( self:GetNetVar( "alarmLights" ) ) then | ||
local dynamicLight = DynamicLight( self:EntIndex( ) ) | ||
|
||
if (dynamicLight) then | ||
dynamicLight.pos = self:GetPos( ) + self:GetForward( ) * 50 | ||
|
||
dynamicLight.r = 200 | ||
dynamicLight.g = 0 | ||
dynamicLight.b = 0 | ||
|
||
dynamicLight.brightness = 1 | ||
dynamicLight.Decay = 900 | ||
dynamicLight.DieTime = CurTime( ) | ||
dynamicLight.Size = 750 | ||
end | ||
end | ||
end | ||
|
||
local combineLogoParts = { | ||
{ | ||
{ x = 200, y = 77.5 }, | ||
{ x = 370, y = 164.5 }, | ||
{ x = 278, y = 160 } | ||
}, | ||
{ | ||
{ x = 126, y = 151.5 }, | ||
{ x = 205.3, y = 230 }, | ||
{ x = 212, y = 322.6 } | ||
}, | ||
{ | ||
{ x = 200, y = 293 }, | ||
{ x = 370, y = 293 }, | ||
{ x = 370, y = 322.6 }, | ||
{ x = 212, y = 322.6 } | ||
}, | ||
{ | ||
{ x = 338, y = 162 }, | ||
{ x = 370, y = 164.5 }, | ||
{ x = 370, y = 300 }, | ||
{ x = 338, y = 300 } | ||
}, | ||
{ | ||
{ x = 200, y = 77.5 }, | ||
{ x = 282, y = 164 }, | ||
{ x = 235, y = 175 }, | ||
{ x = 207, y = 232 }, | ||
{ x = 126, y = 151.5 } | ||
} | ||
} | ||
|
||
-- Helper function from the wiki. | ||
local function draw_Circle( x, y, radius, seg ) | ||
local cir = { } | ||
|
||
table.insert( cir, { x = x, y = y, u = 0.5, v = 0.5 } ) | ||
for i = 0, seg do | ||
local a = math.rad( ( i / seg ) * -360 ) | ||
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } ) | ||
end | ||
|
||
local a = math.rad( 0 ) -- This is needed for non absolute segment counts | ||
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } ) | ||
|
||
surface.DrawPoly( cir ) | ||
end | ||
|
||
function ENT:Draw( ) | ||
self:DrawModel( ) | ||
|
||
if ( LocalPlayer( ):GetPos( ):Distance( self:GetPos( ) ) > 1000 ) then return end | ||
|
||
local area = LocalPlayer( ):GetArea( ) | ||
|
||
if ( !area or area == "" ) then | ||
area = "Unknown Location" | ||
end | ||
|
||
local angle = self:GetAngles( ) | ||
angle:RotateAroundAxis( angle:Right( ), -90 ) | ||
angle:RotateAroundAxis( angle:Up( ), 90 ) | ||
|
||
cam.Start3D2D( self:GetPos( ) + self:GetForward( ) * 13 + self:GetRight( ) * 8.5 + self:GetUp( ) * 20, angle, 0.0364 ) | ||
|
||
surface.SetDrawColor( 50, 50, 50, 255 ) | ||
surface.DrawRect( 0, 0, 496, 502 ) | ||
|
||
surface.SetDrawColor( 0, 0, 255, 75 ) | ||
surface.DrawRect( 0, 0, 496, 40 ) | ||
|
||
draw.SimpleText( "ASSISTANCE TERMINAL", "terminal_title", 248, 20, Color( 255, 255, 225, 50 + math.abs( math.sin( CurTime( ) ) ) * 300 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
surface.SetDrawColor( 44, 44, 44, 255 ) | ||
|
||
surface.SetDrawColor( 0, 0, 0, 200 ) | ||
surface.DrawRect( 0, 452, 496, 50 ) | ||
draw.SimpleText( area, "terminal_location", 248, 477, Color( 255, 255, 225, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
|
||
if ( self:GetNetVar( "alarm" ) ) then | ||
surface.SetDrawColor( 255, 0, 0, 255 ) | ||
surface.DrawRect( 0, 80, 496, 120 ) | ||
draw.SimpleText( "OFFICERS HAVE BEEN DISPATCHED", "terminal_requestText", 248, 105, Color( 0, 25, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
draw.SimpleText( "REQUESTER: #" .. self:GetNetVar( "requester", 0 ), "terminal_requestText", 248, 140, Color( 255, 255, 0, 50 + math.abs( math.sin( CurTime( ) ) ) * 300 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
draw.SimpleText( "REMAIN IN PLACE", "terminal_requestText", 248, 175, Color( 255, 255, 0, 50 + math.abs( math.sin( CurTime( ) ) ) * 300 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
else | ||
-- Combine Logo. If you want to put a non-solid color background here, you need to change the logo to a material. | ||
surface.SetDrawColor( 176, 124, 32, 255 ) | ||
draw.NoTexture( ) | ||
surface.DrawPoly( combineLogoParts[1] ) | ||
surface.DrawPoly( combineLogoParts[2] ) | ||
surface.DrawPoly( combineLogoParts[3] ) | ||
surface.DrawPoly( combineLogoParts[4] ) | ||
|
||
draw_Circle( 271.5, 227.3, 94, 100 ) | ||
|
||
surface.SetDrawColor( 50, 50, 50, 255 ) | ||
draw_Circle( 271.5, 227.3, 65, 100 ) | ||
|
||
surface.SetDrawColor( 176, 124, 32, 255 ) | ||
draw_Circle( 271.5, 227.3, 52, 100 ) | ||
|
||
surface.SetDrawColor( 50, 50, 50, 255 ) | ||
surface.DrawPoly( combineLogoParts[5] ) | ||
|
||
draw.SimpleText( "INSERT ID CARD TO", "terminal_infoText", 248, 375, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
draw.SimpleText( "REQUEST ASSISTANCE", "terminal_infoText", 248, 405, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) | ||
end | ||
|
||
surface.SetDrawColor( 255, 255, 255, 255 ) | ||
surface.SetMaterial( noise ) | ||
surface.DrawTexturedRect( 0, 0, 496, 502 ) | ||
|
||
surface.SetDrawColor( 0, 0, 0, 255 ) | ||
surface.SetMaterial( overlay ) | ||
surface.DrawTexturedRect( 0, 0, 496, 502 ) | ||
cam.End3D2D( ) | ||
end |
100 changes: 100 additions & 0 deletions
100
assistance_terminal/entities/entities/ix_assistance_terminal/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
include( "shared.lua" ) | ||
|
||
AddCSLuaFile( "cl_init.lua" ) | ||
AddCSLuaFile( "shared.lua" ) | ||
|
||
function ENT:Initialize( ) | ||
self:SetModel( "models/props_combine/combine_smallmonitor001.mdl" ) | ||
self:SetMoveType( MOVETYPE_VPHYSICS ) | ||
self:PhysicsInit( SOLID_VPHYSICS ) | ||
self:SetUseType( SIMPLE_USE ) | ||
self:SetSolid( SOLID_VPHYSICS ) | ||
|
||
self:SetNetVar( "alarm", false ) | ||
end | ||
|
||
function ENT:Use( client ) | ||
local combineAvailable | ||
|
||
for _, player in ipairs( player.GetAll( ) ) do | ||
if ( player:IsCombine( ) ) then | ||
combineAvailable = true | ||
|
||
break | ||
end | ||
end | ||
|
||
if ( combineAvailable ) then | ||
if ( !client:IsCombine( ) ) then | ||
local card = client:GetCharacter( ):GetInventory( ):HasItem( "cid" ) | ||
|
||
if ( card ) then | ||
local cid = card:GetData( "id", 0 ) | ||
local area = client:GetArea( ) | ||
|
||
if ( !area or area == "" ) then | ||
area = "Unknown Location" | ||
end | ||
|
||
self:SetNetVar( "alarm", true ) | ||
self:SetNetVar( "requester", cid ) | ||
|
||
ix.chat.Send( client, "terminal_request", tostring(cid), false, nil, {area} ) | ||
|
||
-- Waypoint support. | ||
local waypointPlugin = ix.plugin.Get( "waypoints" ) | ||
|
||
if ( waypointPlugin ) then | ||
local waypoint = { | ||
pos = self:GetPos( ), | ||
text = "Terminal Request - #" .. tostring(cid) .. " | " .. area, | ||
color = Color( 175, 125, 100 ), | ||
addedBy = client, | ||
time = CurTime( ) + 300 | ||
} | ||
|
||
self:SetNetVar( "waypoint", #waypointPlugin.waypoints ) -- Save the waypoint index for easy access later. | ||
|
||
waypointPlugin:AddWaypoint( waypoint ) | ||
end | ||
else | ||
client:Notify( "You need an Identification Card to use the Assistance Terminal!" ) | ||
end | ||
elseif ( self:GetNetVar( "alarm", false ) ) then | ||
self:SetNetVar( "alarm", false ) | ||
self:SetNetVar( "requester", nil ) | ||
|
||
local waypointIndex = self:GetNetVar( "waypoint" ) | ||
|
||
if ( waypointIndex ) then | ||
local waypointPlugin = ix.plugin.Get( "waypoints" ) | ||
|
||
if ( waypointPlugin ) then | ||
waypointPlugin:UpdateWaypoint(waypointIndex, nil) | ||
end | ||
|
||
self:SetNetVar( "waypoint", nil) | ||
end | ||
end | ||
else | ||
client:Notify( "There are no officers available at this time!" ) | ||
end | ||
end | ||
|
||
function ENT:Think( ) | ||
if ( ( self.NextAlert or 0 ) <= CurTime( ) and self:GetNetVar( "alarm" ) ) then | ||
self.NextAlert = CurTime( ) + 3 | ||
|
||
self:EmitSound( "ambient/alarms/klaxon1.wav", 80, 70 ) | ||
self:EmitSound( "ambient/alarms/klaxon1.wav", 80, 80 ) | ||
|
||
self:SetNetVar( "alarmLights", true ) | ||
|
||
timer.Simple( 2, function( ) | ||
self:SetNetVar( "alarmLights", false ) | ||
end ) | ||
end | ||
|
||
self:NextThink( CurTime( ) + 2 ) | ||
end |
7 changes: 7 additions & 0 deletions
7
assistance_terminal/entities/entities/ix_assistance_terminal/shared.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
ENT.Type = "anim" | ||
ENT.Author = "VictorK" | ||
ENT.Category = "HL2 RP" | ||
ENT.PrintName = "Assistance Terminal" | ||
ENT.AdminSpawnable = true | ||
ENT.Spawnable = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
PLUGIN.name = "Assistance Terminals" | ||
PLUGIN.description = "Adds assistance terminals that citizens can use to request Combine officers to their location." | ||
PLUGIN.author = "VictorK" | ||
|
||
ix.util.Include( "cl_plugin.lua" ) | ||
ix.util.Include( "sv_hooks.lua" ) | ||
|
||
function PLUGIN:InitializedChatClasses( ) | ||
local CLASS = { } | ||
CLASS.format = "Incoming Assistance Terminal request: #%s | %s" | ||
|
||
function CLASS:CanHear( speaker, listener ) | ||
return listener:IsCombine( ) | ||
end | ||
|
||
function CLASS:OnChatAdd( speaker, text, bAnonymous, data ) | ||
chat.AddText( Color( 175, 125, 100 ), string.format( self.format, text, data[1] ) ) | ||
end | ||
|
||
ix.chat.Register( "terminal_request", CLASS ) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
function PLUGIN:SaveData( ) | ||
local data = { } | ||
|
||
for _, v in ipairs( ents.FindByClass( "ix_assistance_terminal" ) ) do | ||
data[#data + 1] = { | ||
v:GetPos( ), | ||
v:GetAngles( ) | ||
} | ||
end | ||
|
||
ix.data.Set( "assistanceTerminals", data ) | ||
end | ||
|
||
function PLUGIN:LoadData( ) | ||
for _, v in ipairs( ix.data.Get( "assistanceTerminals" ) or {} ) do | ||
local entity = ents.Create( "ix_assistance_terminal" ) | ||
|
||
entity:SetPos( v[1] ) | ||
entity:SetAngles( v[2] ) | ||
entity:Spawn( ) | ||
|
||
local physicsObject = entity:GetPhysicsObject( ) | ||
|
||
if ( IsValid( physicsObject ) ) then | ||
physicsObject:EnableMotion( false ) | ||
end | ||
end | ||
end |