Advertisement
RedDeadlyCreeper

ACF Fixed AmmoVolume

Jul 1st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.10 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. DEFINE_BASECLASS( "base_wire_entity" )
  5.  
  6. ENT.PrintName = "ACF Ammo Crate"
  7. ENT.WireDebugName = "ACF Ammo Crate"
  8.  
  9. if CLIENT then
  10.  
  11. /*-------------------------------------
  12. Shamefully stolen from lua rollercoaster. I'M SO SORRY. I HAD TO.
  13. -------------------------------------*/
  14.  
  15. local function Bezier( a, b, c, d, t )
  16. local ab,bc,cd,abbc,bccd
  17.  
  18. ab = LerpVector(t, a, b)
  19. bc = LerpVector(t, b, c)
  20. cd = LerpVector(t, c, d)
  21. abbc = LerpVector(t, ab, bc)
  22. bccd = LerpVector(t, bc, cd)
  23. dest = LerpVector(t, abbc, bccd)
  24.  
  25. return dest
  26. end
  27.  
  28.  
  29. local function BezPoint(perc, Table)
  30. perc = perc or self.Perc
  31.  
  32. local vec = Vector(0, 0, 0)
  33.  
  34. vec = Bezier(Table[1], Table[2], Table[3], Table[4], perc)
  35.  
  36. return vec
  37. end
  38.  
  39. function ACF_DrawRefillAmmo( Table )
  40.  
  41. for k,v in pairs( Table ) do
  42. local St, En = v.EntFrom:LocalToWorld(v.EntFrom:OBBCenter()), v.EntTo:LocalToWorld(v.EntTo:OBBCenter())
  43. local Distance = (En - St):Length()
  44. local Amount = math.Clamp((Distance/50),2,100)
  45. local Time = (SysTime() - v.StTime)
  46. local En2, St2 = En + Vector(0,0,100), St + ((En-St):GetNormalized() * 10)
  47. local vectab = { St, St2, En2, En}
  48. local center = (St+En)/2
  49. for I = 1, Amount do
  50. local point = BezPoint(((((I+Time)%Amount))/Amount), vectab)
  51. local ang = (point - center):Angle()
  52. local MdlTbl = {
  53. model = v.Model,
  54. pos = point,
  55. angle = ang
  56. }
  57. render.Model( MdlTbl )
  58. end
  59. end
  60.  
  61. end
  62.  
  63. function ACF_TrimInvalidRefillEffects(effectsTbl)
  64.  
  65. local effect
  66.  
  67. for i=1, #effectsTbl do
  68. effect = effectsTbl[i]
  69.  
  70. if not (IsValid(effect.EntFrom) and IsValid(effect.EntTo)) then
  71. effectsTbl[i] = nil
  72. end
  73. end
  74.  
  75. end
  76.  
  77. local ACF_AmmoInfoWhileSeated = CreateClientConVar("ACF_AmmoInfoWhileSeated", 0, true, false)
  78.  
  79. function ENT:Draw()
  80.  
  81. local lply = LocalPlayer()
  82. local hideBubble = not GetConVar("ACF_AmmoInfoWhileSeated"):GetBool() and IsValid(lply) and lply:InVehicle()
  83.  
  84. self.BaseClass.DoNormalDraw(self, false, hideBubble)
  85. Wire_Render(self)
  86.  
  87. if self.GetBeamLength and (not self.GetShowBeam or self:GetShowBeam()) then
  88. -- Every SENT that has GetBeamLength should draw a tracer. Some of them have the GetShowBeam boolean
  89. Wire_DrawTracerBeam( self, 1, self.GetBeamHighlight and self:GetBeamHighlight() or false )
  90. end
  91. --self.BaseClass.Draw( self )
  92.  
  93. if self.RefillAmmoEffect then
  94. ACF_TrimInvalidRefillEffects(self.RefillAmmoEffect)
  95. ACF_DrawRefillAmmo( self.RefillAmmoEffect )
  96. end
  97.  
  98. end
  99.  
  100. usermessage.Hook("ACF_RefillEffect", function( msg )
  101. local EntFrom, EntTo, Weapon = ents.GetByIndex( msg:ReadFloat() ), ents.GetByIndex( msg:ReadFloat() ), msg:ReadString()
  102. if not IsValid( EntFrom ) or not IsValid( EntTo ) then return end
  103. //local List = list.Get( "ACFRoundTypes")
  104. -- local Mdl = ACF.Weapons.Guns[Weapon].round.model or "models/munitions/round_100mm_shot.mdl"
  105. local Mdl = "models/munitions/round_100mm_shot.mdl"
  106. EntFrom.RefillAmmoEffect = EntFrom.RefillAmmoEffect or {}
  107. table.insert( EntFrom.RefillAmmoEffect, {EntFrom = EntFrom, EntTo = EntTo, Model = Mdl, StTime = SysTime()} )
  108. end)
  109.  
  110. usermessage.Hook("ACF_StopRefillEffect", function( msg )
  111. local EntFrom, EntTo = ents.GetByIndex( msg:ReadFloat() ), ents.GetByIndex( msg:ReadFloat() )
  112. //print("stop", EntFrom, EntTo)
  113. if not IsValid( EntFrom ) or not IsValid( EntTo )or not EntFrom.RefillAmmoEffect then return end
  114. for k,v in pairs( EntFrom.RefillAmmoEffect ) do
  115. if v.EntTo == EntTo then
  116. if #EntFrom.RefillAmmoEffect<=1 then
  117. EntFrom.RefillAmmoEffect = nil
  118. return
  119. end
  120. table.remove(EntFrom.RefillAmmoEffect, k)
  121. end
  122. end
  123. end)
  124.  
  125. return
  126.  
  127. end
  128.  
  129. function ENT:Initialize()
  130.  
  131. self.SpecialHealth = true --If true needs a special ACF_Activate function
  132. self.SpecialDamage = true --If true needs a special ACF_OnDamage function
  133. self.IsExplosive = true
  134. self.Exploding = false
  135. self.Damaged = false
  136. self.CanUpdate = true
  137. self.Load = false
  138. self.EmptyMass = 0
  139. self.NextMassUpdate = 0
  140. self.Ammo = 0
  141.  
  142. self.Master = {}
  143. self.Sequence = 0
  144.  
  145. self.Inputs = Wire_CreateInputs( self, { "Active" } ) --, "Fuse Length"
  146. self.Outputs = Wire_CreateOutputs( self, { "Munitions", "On Fire" } )
  147.  
  148. self.NextThink = CurTime() + 1
  149.  
  150. ACF.AmmoCrates = ACF.AmmoCrates or {}
  151.  
  152. end
  153.  
  154. function ENT:ACF_Activate( Recalc )
  155.  
  156. local EmptyMass = math.max(self.EmptyMass, self:GetPhysicsObject():GetMass() - self:AmmoMass())
  157.  
  158. self.ACF = self.ACF or {}
  159.  
  160. local PhysObj = self:GetPhysicsObject()
  161. if not self.ACF.Aera then
  162. self.ACF.Aera = PhysObj:GetSurfaceArea() * 6.45
  163. end
  164. if not self.ACF.Volume then
  165. self.ACF.Volume = PhysObj:GetVolume() * 16.38
  166. end
  167.  
  168. local Armour = EmptyMass*1000 / self.ACF.Aera / 0.78 --So we get the equivalent thickness of that prop in mm if all it's weight was a steel plate
  169. local Health = self.ACF.Volume/ACF.Threshold --Setting the threshold of the prop aera gone
  170. local Percent = 1
  171.  
  172. if Recalc and self.ACF.Health and self.ACF.MaxHealth then
  173. Percent = self.ACF.Health/self.ACF.MaxHealth
  174. end
  175.  
  176. self.ACF.Health = Health * Percent
  177. self.ACF.MaxHealth = Health
  178. self.ACF.Armour = Armour * (0.5 + Percent/2)
  179. self.ACF.MaxArmour = Armour
  180. self.ACF.Type = nil
  181. self.ACF.Mass = self.Mass
  182. self.ACF.Density = (self:GetPhysicsObject():GetMass()*1000) / self.ACF.Volume
  183. self.ACF.Type = "Prop"
  184.  
  185. end
  186.  
  187. function ENT:ACF_OnDamage( Entity, Energy, FrAera, Angle, Inflictor, Bone, Type ) --This function needs to return HitRes
  188.  
  189. local Mul = ((Type == "HEAT" and ACF.HEATMulAmmo) or 1) --Heat penetrators deal bonus damage to ammo
  190. local HitRes = ACF_PropDamage( Entity, Energy, FrAera * Mul, Angle, Inflictor ) --Calling the standard damage prop function
  191.  
  192. if self.Exploding or not self.IsExplosive then return HitRes end
  193.  
  194. if HitRes.Kill then
  195. if hook.Run("ACF_AmmoExplode", self, self.BulletData ) == false then return HitRes end
  196. self.Exploding = true
  197. if( Inflictor and Inflictor:IsValid() and Inflictor:IsPlayer() ) then
  198. self.Inflictor = Inflictor
  199. end
  200. if self.Ammo > 1 then
  201. ACF_ScaledExplosion( self )
  202. else
  203. ACF_HEKill( self, VectorRand() )
  204. end
  205. end
  206.  
  207. if self.Damaged then return HitRes end
  208. local Ratio = (HitRes.Damage/self.BulletData.RoundVolume)^0.2
  209. --print(Ratio)
  210. if ( Ratio * self.Capacity/self.Ammo ) > math.Rand(0,1) then
  211. self.Inflictor = Inflictor
  212. self.Damaged = CurTime() + (5 - Ratio*3)
  213. Wire_TriggerOutput(self, "On Fire", 1)
  214. end
  215.  
  216. return HitRes --This function needs to return HitRes
  217. end
  218.  
  219. function MakeACF_Ammo(Owner, Pos, Angle, Id, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10)
  220.  
  221. if not Owner:CheckLimit("_acf_ammo") then return false end
  222.  
  223. local Ammo = ents.Create("acf_ammo")
  224. if not Ammo:IsValid() then return false end
  225. Ammo:SetAngles(Angle)
  226. Ammo:SetPos(Pos)
  227. Ammo:Spawn()
  228. Ammo:SetPlayer(Owner)
  229. Ammo.Owner = Owner
  230.  
  231. Ammo.Model = ACF.Weapons.Ammo[Id].model
  232. Ammo:SetModel( Ammo.Model )
  233.  
  234. Ammo:PhysicsInit( SOLID_VPHYSICS )
  235. Ammo:SetMoveType( MOVETYPE_VPHYSICS )
  236. Ammo:SetSolid( SOLID_VPHYSICS )
  237.  
  238. Ammo.Id = Id
  239. Ammo:CreateAmmo(Id, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10)
  240.  
  241. Ammo.Ammo = Ammo.Capacity
  242. Ammo.EmptyMass = ACF.Weapons.Ammo[Ammo.Id].weight
  243. Ammo.Mass = Ammo.EmptyMass + Ammo:AmmoMass()
  244. Ammo.LastMass = 1
  245.  
  246. Ammo:UpdateMass()
  247.  
  248. Owner:AddCount( "_acf_ammo", Ammo )
  249. Owner:AddCleanup( "acfmenu", Ammo )
  250.  
  251. table.insert(ACF.AmmoCrates, Ammo)
  252.  
  253.  
  254. return Ammo
  255. end
  256. list.Set( "ACFCvars", "acf_ammo", {"id", "data1", "data2", "data3", "data4", "data5", "data6", "data7", "data8", "data9", "data10"} )
  257. duplicator.RegisterEntityClass("acf_ammo", MakeACF_Ammo, "Pos", "Angle", "Id", "RoundId", "RoundType", "RoundPropellant", "RoundProjectile", "RoundData5", "RoundData6", "RoundData7", "RoundData8", "RoundData9", "RoundData10" )
  258.  
  259. function ENT:Update( ArgsTable )
  260.  
  261. -- That table is the player data, as sorted in the ACFCvars above, with player who shot,
  262. -- and pos and angle of the tool trace inserted at the start
  263.  
  264. local msg = "Ammo crate updated successfully!"
  265.  
  266. if ArgsTable[1] ~= self.Owner then -- Argtable[1] is the player that shot the tool
  267. return false, "You don't own that ammo crate!"
  268. end
  269.  
  270. if ArgsTable[6] == "Refill" then -- Argtable[6] is the round type. If it's refill it shouldn't be loaded into guns, so we refuse to change to it
  271. return false, "Refill ammo type is only avaliable for new crates!"
  272. end
  273.  
  274. if ArgsTable[5] ~= self.RoundId then -- Argtable[5] is the weapon ID the new ammo loads into
  275. for Key, Gun in pairs( self.Master ) do
  276. if IsValid( Gun ) then
  277. Gun:Unlink( self )
  278. end
  279. end
  280. msg = "New ammo type loaded, crate unlinked."
  281. else -- ammotype wasn't changed, but let's check if new roundtype is blacklisted
  282. local Blacklist = ACF.AmmoBlacklist[ ArgsTable[6] ] or {}
  283.  
  284. for Key, Gun in pairs( self.Master ) do
  285. if IsValid( Gun ) and table.HasValue( Blacklist, Gun.Class ) then
  286. Gun:Unlink( self )
  287. msg = "New round type cannot be used with linked gun, crate unlinked."
  288. end
  289. end
  290. end
  291.  
  292. local AmmoPercent = self.Ammo/math.max(self.Capacity,1)
  293.  
  294. self:CreateAmmo(ArgsTable[4], ArgsTable[5], ArgsTable[6], ArgsTable[7], ArgsTable[8], ArgsTable[9], ArgsTable[10], ArgsTable[11], ArgsTable[12], ArgsTable[13], ArgsTable[14])
  295.  
  296. self.Ammo = math.floor(self.Capacity*AmmoPercent)
  297.  
  298. self:UpdateMass()
  299.  
  300. return true, msg
  301.  
  302. end
  303.  
  304. function ENT:UpdateOverlayText()
  305.  
  306. local roundType = self.RoundType
  307.  
  308. if self.BulletData.Tracer and self.BulletData.Tracer > 0 then
  309. roundType = roundType .. "-T"
  310. end
  311.  
  312. local text = roundType .. " - " .. self.Ammo .. " / " .. self.Capacity
  313. --text = text .. "\nRound Type: " .. self.RoundType
  314.  
  315. local RoundData = ACF.RoundTypes[ self.RoundType ]
  316.  
  317. if RoundData and RoundData.cratetxt then
  318. text = text .. "\n" .. RoundData.cratetxt( self.BulletData, self )
  319. end
  320.  
  321. self:SetOverlayText( text )
  322.  
  323. end
  324.  
  325. function ENT:CreateAmmo(Id, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10)
  326.  
  327. local GunData = list.Get("ACFEnts").Guns[Data1]
  328. if not GunData then
  329. self:Remove()
  330. return
  331. end
  332.  
  333. --Data 1 to 4 are should always be Round ID, Round Type, Propellant lenght, Projectile lenght
  334. self.RoundId = Data1 --Weapon this round loads into, ie 140mmC, 105mmH ...
  335. self.RoundType = Data2 --Type of round, IE AP, HE, HEAT ...
  336. self.RoundPropellant = Data3--Lenght of propellant
  337. self.RoundProjectile = Data4--Lenght of the projectile
  338. self.RoundData5 = ( Data5 or 0 )
  339. self.RoundData6 = ( Data6 or 0 )
  340. self.RoundData7 = ( Data7 or 0 )
  341. self.RoundData8 = ( Data8 or 0 )
  342. self.RoundData9 = ( Data9 or 0 )
  343. self.RoundData10 = ( Data10 or 0 )
  344.  
  345. local PlayerData = {}
  346. PlayerData.Id = self.RoundId
  347. PlayerData.Type = self.RoundType
  348. PlayerData.PropLength = self.RoundPropellant
  349. PlayerData.ProjLength = self.RoundProjectile
  350. PlayerData.Data5 = self.RoundData5
  351. PlayerData.Data6 = self.RoundData6
  352. PlayerData.Data7 = self.RoundData7
  353. PlayerData.Data8 = self.RoundData8
  354. PlayerData.Data9 = self.RoundData9
  355. PlayerData.Data10 = self.RoundData10
  356. self.ConvertData = ACF.RoundTypes[self.RoundType].convert
  357. self.BulletData = self:ConvertData( PlayerData )
  358. local PhysObj = self:GetPhysicsObject()
  359. local Efficiency = 0.11 * ACF.AmmoMod --This is the part of space that's actually useful, the rest is wasted on interround gaps, loading systems ..
  360. local vol = PhysObj:GetVolume()
  361. self.Volume = vol*Efficiency
  362.  
  363. self.Capacity = math.floor(self.Volume*16.38/self.BulletData.RoundVolume)
  364. -- self.Capacity = math.floor(self.Volume)
  365.  
  366. self.Caliber = GunData.caliber
  367. self.RoFMul = (vol > 46000) and (1-(math.log(vol*0.00066)/math.log(2)-4)*0.05) or 1 --*0.0625 for 25% @ 4x8x8, 0.025 10%, 0.0375 15%, 0.05 20%
  368.  
  369. self:SetNWString( "Ammo", self.Ammo )
  370. self:SetNWString( "WireName", GunData.name .. " Ammo" )
  371.  
  372. self.NetworkData = ACF.RoundTypes[self.RoundType].network
  373. self:NetworkData( self.BulletData )
  374.  
  375. self:UpdateOverlayText()
  376.  
  377. end
  378.  
  379. function ENT:AmmoMass() --Returns what the ammo mass would be if the crate was full
  380. return math.floor( (self.BulletData.ProjMass + self.BulletData.PropMass) * self.Capacity * 2 )
  381. end
  382.  
  383. function ENT:UpdateMass()
  384. self.Mass = self.EmptyMass + self:AmmoMass()*(self.Ammo/math.max(self.Capacity,1))
  385.  
  386. --reduce superflous engine calls, update crate mass every 5 kgs change or every 10s-15s
  387. if math.abs(self.LastMass - self.Mass) > 5 or CurTime() > self.NextMassUpdate then
  388. self.LastMass = self.Mass
  389. self.NextMassUpdate = CurTime()+math.Rand(10,15)
  390. local phys = self:GetPhysicsObject()
  391. if (phys:IsValid()) then
  392. phys:SetMass( self.Mass )
  393. end
  394. end
  395.  
  396. end
  397.  
  398.  
  399.  
  400. function ENT:GetInaccuracy()
  401. local SpreadScale = ACF.SpreadScale
  402. local inaccuracy = 0
  403. local Gun = list.Get("ACFEnts").Guns[self.RoundId]
  404.  
  405. if Gun then
  406. local Classes = list.Get("ACFClasses")
  407. inaccuracy = (Classes.GunClass[Gun.gunclass] or {spread = 0}).spread
  408. end
  409.  
  410. local coneAng = inaccuracy * ACF.GunInaccuracyScale
  411. return coneAng
  412. end
  413.  
  414.  
  415.  
  416. function ENT:TriggerInput( iname, value )
  417.  
  418. if (iname == "Active") then
  419. if value > 0 then
  420. self.Load = true
  421. self:FirstLoad()
  422. else
  423. self.Load = false
  424. end
  425. elseif (iname == "Fuse Length" and value > 0 and (self.BulletData.RoundType == "HE" or self.BulletData.RoundType == "APHE")) then
  426. end
  427.  
  428. end
  429.  
  430. function ENT:FirstLoad()
  431.  
  432. for Key,Value in pairs(self.Master) do
  433. if self.Master[Key] and self.Master[Key]:IsValid() and self.Master[Key].BulletData.Type == "Empty" then
  434. --print("Send FirstLoad")
  435. self.Master[Key]:UnloadAmmo()
  436. end
  437. end
  438.  
  439. end
  440.  
  441. function ENT:Think()
  442. if not self:IsSolid() then self.Ammo = 0 end
  443.  
  444. self:UpdateMass()
  445.  
  446. if self.Ammo ~= self.AmmoLast then
  447. self:UpdateOverlayText()
  448. self.AmmoLast = self.Ammo
  449. end
  450.  
  451. local color = self:GetColor()
  452. self:SetNWVector("TracerColour", Vector( color.r, color.g, color.b ) )
  453.  
  454. local cvarGrav = GetConVar("sv_gravity")
  455. local vec = Vector(0,0,cvarGrav:GetInt()*-1)
  456. if( self.sitp_inspace ) then
  457. vec = Vector(0, 0, 0)
  458. end
  459.  
  460. self:SetNWVector("Accel", vec)
  461.  
  462. self:NextThink( CurTime() + 1 )
  463.  
  464. if self.Damaged then
  465. if self.Damaged < CurTime() then
  466. ACF_ScaledExplosion( self )
  467. else
  468. if not (self.BulletData.Type == "Refill") then
  469. if math.Rand(0,150) > self.BulletData.RoundVolume^0.5 and math.Rand(0,1) < self.Ammo/math.max(self.Capacity,1) and ACF.RoundTypes[self.BulletData.Type] then
  470. self:EmitSound( "ambient/explosions/explode_4.wav", 350, math.max(255 - self.BulletData.PropMass*100,60) )
  471. local MuzzlePos = self:GetPos()
  472. local MuzzleVec = VectorRand()
  473. local Speed = ACF_MuzzleVelocity( self.BulletData.PropMass, self.BulletData.ProjMass/2, self.Caliber )
  474.  
  475. self.BulletData.Pos = MuzzlePos
  476. self.BulletData.Flight = (MuzzleVec):GetNormalized() * Speed * 39.37 + self:GetVelocity()
  477. self.BulletData.Owner = self.Inflictor or self.Owner
  478. self.BulletData.Gun = self
  479. self.BulletData.Crate = self:EntIndex()
  480. self.CreateShell = ACF.RoundTypes[self.BulletData.Type].create
  481. self:CreateShell( self.BulletData )
  482.  
  483. self.Ammo = self.Ammo - 1
  484.  
  485. end
  486. end
  487. self:NextThink( CurTime() + 0.01 + self.BulletData.RoundVolume^0.5/100 )
  488. end
  489. elseif self.RoundType == "Refill" and self.Ammo > 0 then // Completely new, fresh, genius, beautiful, flawless refill system.
  490. if self.Load then
  491. for _,Ammo in pairs( ACF.AmmoCrates ) do
  492. if Ammo.RoundType ~= "Refill" then
  493. local dist = self:GetPos():Distance(Ammo:GetPos())
  494. if dist < ACF.RefillDistance then
  495.  
  496. if Ammo.Capacity > Ammo.Ammo then
  497. self.SupplyingTo = self.SupplyingTo or {}
  498. if not table.HasValue( self.SupplyingTo, Ammo:EntIndex() ) then
  499. table.insert(self.SupplyingTo, Ammo:EntIndex())
  500. self:RefillEffect( Ammo )
  501. end
  502.  
  503. local Supply = math.ceil((50000/((Ammo.BulletData.ProjMass+Ammo.BulletData.PropMass)*1000))/dist)
  504. --Msg(tostring(50000).."/"..((Ammo.BulletData.ProjMass+Ammo.BulletData.PropMass)*1000).."/"..dist.."="..Supply.."\n")
  505. local Transfert = math.min(Supply, Ammo.Capacity - Ammo.Ammo)
  506. Ammo.Ammo = Ammo.Ammo + Transfert
  507. self.Ammo = self.Ammo - Transfert
  508.  
  509. Ammo.Supplied = true
  510. Ammo.Entity:EmitSound( "items/ammo_pickup.wav", 350, 80, 0.30 )
  511. end
  512. end
  513. end
  514. end
  515. end
  516. end
  517.  
  518. if self.SupplyingTo then
  519. for k, EntID in pairs( self.SupplyingTo ) do
  520. local Ammo = ents.GetByIndex(EntID)
  521. if not IsValid( Ammo ) then
  522. table.remove(self.SupplyingTo, k)
  523. self:StopRefillEffect( EntID )
  524. else
  525. local dist = self:GetPos():Distance(Ammo:GetPos())
  526. if dist > ACF.RefillDistance or Ammo.Capacity <= Ammo.Ammo or self.Damaged or not self.Load then // If ammo crate is out of refill max distance or is full or our refill crate is damaged or just in-active then stop refiliing it.
  527. table.remove(self.SupplyingTo, k)
  528. self:StopRefillEffect( EntID )
  529. end
  530. end
  531. end
  532. end
  533.  
  534. Wire_TriggerOutput(self, "Munitions", self.Ammo)
  535. return true
  536.  
  537. end
  538.  
  539. function ENT:RefillEffect( Target )
  540. umsg.Start("ACF_RefillEffect")
  541. umsg.Float( self:EntIndex() )
  542. umsg.Float( Target:EntIndex() )
  543. umsg.String( Target.RoundType )
  544. umsg.End()
  545. end
  546.  
  547. function ENT:StopRefillEffect( TargetID )
  548. umsg.Start("ACF_StopRefillEffect")
  549. umsg.Float( self:EntIndex() )
  550. umsg.Float( TargetID )
  551. umsg.End()
  552. end
  553.  
  554. function ENT:ConvertData()
  555. --You overwrite this with your own function, defined in the ammo definition file
  556. end
  557.  
  558. function ENT:NetworkData()
  559. --You overwrite this with your own function, defined in the ammo definition file
  560. end
  561.  
  562. function ENT:OnRemove()
  563.  
  564. for Key,Value in pairs(self.Master) do
  565. if self.Master[Key] and self.Master[Key]:IsValid() then
  566. self.Master[Key]:Unlink( self )
  567. self.Ammo = 0
  568. end
  569. end
  570. for k,v in pairs(ACF.AmmoCrates) do
  571. if v == self then
  572. table.remove(ACF.AmmoCrates,k)
  573. end
  574. end
  575.  
  576. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement