Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various additions to PointShop items #298

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions lua/pointshop/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ function PS:ShowColorChooser(item, modifications)
self:SendModifications(item.ID, modifications)
end
end
function PS:ShowPlyColorChooser(item, modifications)
-- TODO: Do this
local chooser = vgui.Create('DPointShopColorChooser')
chooser:SetColor(modifications.plycolor)

chooser.OnChoose = function(color)
modifications.plycolor = color
self:SendModifications(item.ID, modifications)
end
end

function PS:SendModifications(item_id, modifications)
net.Start('PS_ModifyItem')
Expand Down
6 changes: 5 additions & 1 deletion lua/pointshop/items/weapons/357.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_357'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(6, "357", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
8 changes: 6 additions & 2 deletions lua/pointshop/items/weapons/ar2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_ar2'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(60, "AR2", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
8 changes: 6 additions & 2 deletions lua/pointshop/items/weapons/crossbow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_crossbow'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(5, "XBowBolt", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
8 changes: 6 additions & 2 deletions lua/pointshop/items/weapons/grenade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_frag'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(1, "Grenade", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
8 changes: 6 additions & 2 deletions lua/pointshop/items/weapons/pistol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_pistol'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(18, "Pistol", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
8 changes: 6 additions & 2 deletions lua/pointshop/items/weapons/rpg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_rpg'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(3, "RPG_Round", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
6 changes: 5 additions & 1 deletion lua/pointshop/items/weapons/shotgun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_shotgun'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(70, "Buckshot", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
6 changes: 5 additions & 1 deletion lua/pointshop/items/weapons/smg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ITEM.WeaponClass = 'weapon_smg1'
ITEM.SingleUse = true

function ITEM:OnBuy(ply)
if (!ply:HasWeapon(self.WeaponClass)) then
ply:Give(self.WeaponClass)
else
ply:GiveAmmo(180, "SMG1", false)
end
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
end
22 changes: 22 additions & 0 deletions lua/pointshop/vgui/DPointShopItem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local PANEL = {}
local adminicon = Material("icon16/shield.png")
local equippedicon = Material("icon16/eye.png")
local groupicon = Material("icon16/group.png")
local modifyicon = Material("icon16/color_wheel.png")
local bodygroupicon = Material("icon16/cog.png")

local canbuycolor = Color(0, 100, 0, 125)
local cantbuycolor = Color(100, 0, 0, 125)
Expand Down Expand Up @@ -58,6 +60,14 @@ function PANEL:DoClick()
PS.Items[self.Data.ID]:Modify(LocalPlayer().PS_Items[self.Data.ID].Modifiers)
end)
end

if LocalPlayer():PS_HasItemEquipped(self.Data.ID) and self.Data.BodyGroup then
menu:AddSpacer()

menu:AddOption('Body Groups...', function()
PS.Items[self.Data.ID]:BodyGroup(LocalPlayer().PS_Items[self.Data.ID].Modifiers)
end)
end
end

menu:Open()
Expand Down Expand Up @@ -155,6 +165,18 @@ function PANEL:PaintOver()
surface.SetDrawColor(Color(255, 255, 255, 255))
surface.DrawTexturedRect(5, self:GetTall() - self.InfoHeight - 5 - 16, 16, 16)
end

if self.Data.Modify then
surface.SetMaterial(modifyicon)
surface.SetDrawColor(Color(255, 255, 255, 255))
surface.DrawTexturedRect(5, 5, 16, 16)
end

if self.Data.BodyGroup then
surface.SetMaterial(bodygroupicon)
surface.SetDrawColor(Color(255, 255, 255, 255))
surface.DrawTexturedRect(5, 26, 16, 16)
end

local points = PS.Config.CalculateBuyPrice(LocalPlayer(), self.Data)

Expand Down
16 changes: 13 additions & 3 deletions lua/pointshop/vgui/DPointShopPreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local PANEL = {}

function PANEL:Init()
self:SetModel(LocalPlayer():GetModel())

local PrevMins, PrevMaxs = self.Entity:GetRenderBounds()
self:SetCamPos(PrevMins:Distance(PrevMaxs) * Vector(0.30, 0.30, 0.25) + Vector(0, 0, 15))
self:SetLookAt((PrevMaxs + PrevMins) / 2)
Expand All @@ -14,8 +14,18 @@ function PANEL:Paint()
local x, y = self:LocalToScreen( 0, 0 )

self:LayoutEntity( self.Entity )

local ang = self.aLookAngle
function self.Entity:GetPlayerColor() return LocalPlayer():GetPlayerColor() end

self.Entity:SetSkin(LocalPlayer():GetSkin())
for i = 0, 20 do
if LocalPlayer():GetBodygroup(i) ~= nil then
self.Entity:SetBodygroup(i, LocalPlayer():GetBodygroup(i))
else
self.Entity:SetBodygroup(i, 0)
end
end

local ang = self.aLookAngle
if ( !ang ) then
ang = (self.vLookatPos-self.vCamPos):Angle()
end
Expand Down