SHOW:
|
|
- or go back to the newest paste.
1 | if SERVER then | |
2 | AddCSLuaFile("shared.lua") | |
3 | end | |
4 | ||
5 | ||
6 | ENT.Type = "anim" | |
7 | ENT.Model = Model("models/Items/combine_rifle_ammo01.mdl") | |
8 | ||
9 | ENT.Stuck = false | |
10 | ENT.Weaponised = false | |
11 | ||
12 | ENT.PunchMax = 6 | |
13 | ENT.PunchRemaining = 6 | |
14 | ||
15 | ||
16 | function ENT:Initialize() | |
17 | ||
18 | self.Entity:SetHealth(50) | |
19 | self.Entity:SetModel("models/Items/combine_rifle_ammo01.mdl") | |
20 | self.Entity:PhysicsInit(SOLID_VPHYSICS) | |
21 | self.Entity:SetMoveType(MOVETYPE_VPHYSICS) | |
22 | self.Entity:SetSolid(SOLID_VPHYSICS) | |
23 | self.Entity:DrawShadow(false) | |
24 | self.Entity:SetCollisionGroup(COLLISION_GROUP_WORLD) | |
25 | ||
26 | local phys = self.Entity:GetPhysicsObject():EnableMotion(false) | |
27 | self:SetColor(Color(25, 122, 21, 255)) | |
28 | ||
29 | --self:StartEffects() | |
30 | --self:Explosive() | |
31 | self.Entity:EmitSound("C4.Plant") | |
32 | ||
33 | ||
34 | end | |
35 | ||
36 | local matTripmineLaser = Material( "sprites/bluelaser1" ) | |
37 | local matLight = Material( "models/roller/rollermine_glow" ) | |
38 | local colBeam = Color( 100, 100, 210, 30 ) | |
39 | local colLaser = Color( 100, 100, 240, 30 ) | |
40 | ||
41 | function ENT:Think() | |
42 | ||
43 | ||
44 | ||
45 | - | if not self.endpos then |
45 | + | |
46 | local t = {} | |
47 | t.start = self:GetPos() | |
48 | t.endpos = t.start + self:GetUp() * 4096 | |
49 | t.filter = self | |
50 | local tr = util.TraceLine(t) | |
51 | self.endpos = tr.HitPos | |
52 | - | if tr.HitNonWorld then |
52 | + | --[[if tr.HitNonWorld then |
53 | ||
54 | if SERVER then | |
55 | local ply = self.Owner | |
56 | local ignore = {ply, self} | |
57 | if not IsValid(ply) then return end | |
58 | for k, v in pairs(player.GetAll()) do | |
59 | - | if v:IsActiveTraitor() or v:IsSpec() then |
59 | + | if v:GetRole() == ROLE_TRAITOR then |
60 | table.insert(ignore, v) | |
61 | end | |
62 | - | if not table.HasValue(ignore,tr.Entity) and tr.Entity:IsPlayer() then |
62 | + | if (not table.HasValue(ignore,tr.Entity)) and tr.Entity:IsPlayer() then |
63 | self:Explosive() | |
64 | self:Remove() | |
65 | end | |
66 | ||
67 | ||
68 | end | |
69 | end | |
70 | - | end |
70 | + | end --]] |
71 | end | |
72 | ||
73 | ENT.OurHealth = 50 | |
74 | ||
75 | function ENT:OnTakeDamage(dmg) | |
76 | self:TakePhysicsDamage(dmg) | |
77 | ||
78 | if(self.OurHealth <= 0) then return; end | |
79 | ||
80 | self.OurHealth = self.OurHealth - dmg:GetDamage() | |
81 | ||
82 | if(self.OurHealth <= 0) then | |
83 | - | if not self.endpos then |
83 | + | self:Explosive() |
84 | self:Remove() | |
85 | end | |
86 | end | |
87 | ||
88 | function ENT:Draw() | |
89 | - | // offset the texture coords so it looks like it is scrolling |
89 | + | |
90 | ||
91 | ||
92 | - | // Make the texture coords relative to distance so they are always a nice size |
92 | + | if not self.endpos then |
93 | return | |
94 | end | |
95 | - | // Draw the beam |
95 | + | |
96 | render.SetMaterial( matTripmineLaser ) | |
97 | local TexOffset = 6 | |
98 | local Distance = self.endpos:Distance( self:GetPos() ) | |
99 | - | // Draw a quad at the hitpoint to fake the laser hitting it |
99 | + | |
100 | render.DrawBeam( self.endpos, self.Entity:GetPos(), 3, TexOffset, TexOffset+Distance, colBeam ) | |
101 | render.SetMaterial( matLight ) | |
102 | local Size = math.Rand( 3, 5 ) | |
103 | local Normal = (self.Entity:GetPos()-self.endpos):GetNormal() * 0.1 | |
104 | render.DrawQuadEasy( self.endpos + Normal, Normal, Size, Size, colLaser, 0 ) | |
105 | self.Entity:DrawModel() | |
106 | ||
107 | end | |
108 | function ENT:StartTouch( ent ) | |
109 | if (ent:IsPlayer()) then | |
110 | - | function ENT:StartEffects() |
110 | + | if (ent:GetRole() != ROLE_TRAITOR) then |
111 | - | local sprite = ents.Create( "env_sprite" ) |
111 | + | self:Explosive() |
112 | - | if IsValid(sprite) then |
112 | + | self:Remove() |
113 | - | -- local angpos = self:GetAttachment(ball) |
113 | + | end |
114 | - | -- sometimes attachments don't work (Lua-side) on dedicated servers, |
114 | + | |
115 | - | -- so have to fudge it |
115 | + | |
116 | - | local ang = self:GetAngles() |
116 | + | |
117 | - | local pos = self:GetPos() + self:GetAngles():Up() * 6 |
117 | + | |
118 | - | sprite:SetPos(pos) |
118 | + | |
119 | - | sprite:SetAngles(ang) |
119 | + | |
120 | - | sprite:SetParent(self.Entity) |
120 | + | |
121 | - | sprite:SetKeyValue("spawnflags", "1") |
121 | + | |
122 | - | sprite:SetKeyValue("scale", "0.25") |
122 | + | |
123 | - | sprite:SetKeyValue("rendermode", "5") |
123 | + | |
124 | - | sprite:SetKeyValue("renderfx", "7") |
124 | + | |
125 | phexp:Spawn() | |
126 | - | sprite:Spawn() |
126 | + | |
127 | - | sprite:Activate() |
127 | + | |
128 | local phyexp = ents.Create("env_physexplosion") | |
129 | - | self.BallSprite = sprite |
129 | + | |
130 | phyexp:SetPos(self:GetPos()) | |
131 | phyexp:SetKeyValue("magnitude", 100) | |
132 | - | local effect = EffectData() |
132 | + | |
133 | - | effect:SetStart(self:GetPos()) |
133 | + | |
134 | - | effect:SetOrigin(self:GetPos()) |
134 | + | |
135 | - | effect:SetNormal(self:GetAngles():Up()) |
135 | + | |
136 | - | util.Effect("ManhackSparks", effect, true, true) |
136 | + | |
137 | local norm = self:GetAngles():Up() * -1 | |
138 | - | if SERVER then |
138 | + | |
139 | - | local ball = self:LookupAttachment("attach_ball") |
139 | + | |
140 | - | util.SpriteTrail(self.Entity, ball, Color(250, 250, 250), false, 30, 0, 1, 0.07, "trails/physbeam.vmt") |
140 | + | local effect = EffectData() |
141 | effect:SetStart(self:GetPos()) | |
142 | effect:SetOrigin(self:GetPos()) | |
143 | effect:SetNormal(norm * -1) | |
144 | effect:SetRadius(16) | |
145 | effect:SetScale(1) | |
146 | util.Effect("ManhackSparks", effect, true, true) | |
147 | end |