From 09438fc7910a5ada13e4ba63cd55d2c4f11a291e Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Fri, 23 Aug 2019 04:09:47 +0200 Subject: [PATCH 1/7] Fixed some errors and updated to latest sf standards --- lua/starfall/libs_sv/acffunctions.lua | 1456 +++++++++++++++++++++---- 1 file changed, 1249 insertions(+), 207 deletions(-) diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua index d0a3d1a16..a325476e9 100644 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -21,31 +21,31 @@ -- [ Helper Functions ] -- local function isEngine ( ent ) - if not validPhysics( ent ) then return false end - if ( ent:GetClass() == "acf_engine" ) then return true else return false end + if not validPhysics( ent ) then return false end + if ( ent:GetClass() == "acf_engine" ) then return true else return false end end local function isGearbox ( ent ) - if not validPhysics( ent ) then return false end - if ( ent:GetClass() == "acf_gearbox" ) then return true else return false end + if not validPhysics( ent ) then return false end + if ( ent:GetClass() == "acf_gearbox" ) then return true else return false end end local function isGun ( ent ) - if not validPhysics( ent ) then return false end - if ( ent:GetClass() == "acf_gun" ) then return true else return false end + if not validPhysics( ent ) then return false end + if ( ent:GetClass() == "acf_gun" ) then return true else return false end end local function isAmmo ( ent ) - if not validPhysics( ent ) then return false end - if ( ent:GetClass() == "acf_ammo" ) then return true else return false end + if not validPhysics( ent ) then return false end + if ( ent:GetClass() == "acf_ammo" ) then return true else return false end end local function isFuel ( ent ) - if not validPhysics(ent) then return false end - if ( ent:GetClass() == "acf_fueltank" ) then return true else return false end + if not validPhysics(ent) then return false end + if ( ent:GetClass() == "acf_fueltank" ) then return true else return false end end -local function reloadTime(ent) +local function reloadTime( ent ) if ent.CurrentShot and ent.CurrentShot > 0 then return ent.ReloadTime end return ent.MagReload end @@ -54,41 +54,815 @@ local propProtectionInstalled = FindMetaTable("Entity").CPPIGetOwner and true local function restrictInfo ( ent ) if not propProtectionInstalled then return false end - if GetConVar("sbox_acf_restrictinfo"):GetInt() ~= 0 then - if ent:CPPIGetOwner() ~= SF.instance.player then return true else return false end - end - return false + if GetConVar("sbox_acf_restrictinfo"):GetInt() ~= 0 then + if ent:CPPIGetOwner() ~= SF.instance.player then return true else return false end + end + return false +end + +---------------------------------------- +-- ACF Library + +local acf_library = SF.RegisterLibrary("acf") + +local checktype = SF.CheckType +local checkluatype = SF.CheckLuaType +local checkpermission = SF.Permissions.check + +local ents_metatable, ents_methods, vec_meta, ang_meta, wrap, unwrap, vwrap, vunwrap, awrap, aunwrap + +SF.Permissions.registerPrivilege("acf.createMobility", "Create acf engine", "Allows the user to create ACF engines and gearboxes") +SF.Permissions.registerPrivilege("acf.createFuelTank", "Create acf fuel tank", "Allows the user to create ACF fuel tanks") +SF.Permissions.registerPrivilege("acf.createGun", "Create acf gun", "Allows the user to create ACF guns") +SF.Permissions.registerPrivilege("acf.createAmmo", "Create acf ammo", "Allows the user to create ACF ammoboxes") +SF.Permissions.registerPrivilege("entities.acf", "ACF", "Allows the user to control ACF components", { entities = {} }) + +local plyCount = SF.LimitObject("acf_components", "acf_components", -1, "The number of ACF components allowed to spawn via Starfall") +local plyBurst = SF.BurstObject("acf_components", "acf_components", 4, 4, "Rate ACF components can be spawned per second.", "Number of ACF components that can be spawned in a short time.") + +local function propOnDestroy(ent, instance) + local ply = instance.player + plyCount:free(ply, 1) + instance.data.props.props[ent] = nil +end + +local function register(ent, instance) + ent:CallOnRemove("starfall_prop_delete", propOnDestroy, instance) + plyCount:free(instance.player, -1) + instance.data.props.props[ent] = true +end + +--- Returns true if functions returning sensitive info are restricted to owned props +-- @server +-- @return True if restriced, False if not +function acf_library.infoRestricted() + return GetConVar("sbox_acf_restrictinfo"):GetInt() ~= 0 +end + +--- Returns current ACF drag divisor +-- @server +-- @return The current drag divisor +function acf_library.dragDivisor() + return ACF.DragDiv +end + +--- Returns the effective armor given an armor value and hit angle +-- @server +-- @return The effective armor +function acf_library.effectiveArmor(armor, angle) + checkluatype(armor, TYPE_NUMBER) + checkluatype(angle, TYPE_NUMBER) + + return math.Round(armor / math.abs(math.cos(math.rad(math.min(angle, 89.999)))), 1) +end + +-- Dont create a cache on init because maby a new entity get registered later on? +local id_name_cache = {} +local function idFromName(list, name) + id_name_cache[list] = id_name_cache[list] or {} + + if id_name_cache[list][name] then return id_name_cache[list][name] end + + for id, data in pairs(list) do + if data.name == name then + id_name_cache[list][name] = id + + return id + end + end +end + +--- Creates a engine or gearbox given the id or name +-- @param pos Position of created engine or gearbox +-- @param ang Angle of created engine or gearbox +-- @param id id or name of the engine or gearbox to create +-- @param frozen True to spawn frozen +-- @param gear_ratio A table containing the gear ratios, only applied if the mobility is a gearbox. -1 is final drive +-- @server +-- @return The created engine or gearbox +function acf_library.createMobility(pos, ang, id, frozen, gear_ratio) + checkpermission(SF.instance, nil, "acf.createMobility") + + local instance = SF.instance + local ply = instance.player + + if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end + + checktype(pos, vec_meta) + checktype(ang, ang_meta) + checkluatype(id, TYPE_STRING) + frozen = frozen and true or false + gear_ratio = type(gear_ratio) == "table" and gear_ratio or {} + + local pos = vunwrap(pos) + local ang = aunwrap(ang) + + local list_entries = ACF.Weapons.Mobility + + -- Not a valid id, try name + if not list_entries[id] then + id = idFromName(list_entries, id) + + -- Name is also invalid, error + if not id or not list_entries[id] then + SF.Throw("Invalid id or name", 2) + end + end + + local type_id = list_entries[id] + local dupe_class = duplicator.FindEntityClass(type_id.ent) + + if not dupe_class then SF.Throw("Didn't find entity duplicator records", 2) end + + plyBurst:use(ply, 1) + plyCount:checkuse(ply, 1) + + local args_table = { + SF.clampPos(pos), + ang, + id + } + + if type_id.ent == "acf_gearbox" then + for i = 1, 9 do + args_table[3 + i] = type(gear_ratio[i]) == "number" and gear_ratio[i] or (i < type_id.gears and i / 10 or -0.1) + end + + args_table[13] = gear_ratio[-1] or 0.5 + end + + local ent = dupe_class.Func(ply, unpack(args_table)) + ent:Activate() + + local phys = ent:GetPhysicsObject() + if phys:IsValid() then + phys:EnableMotion(not frozen) + end + + if instance.data.props.undo then + undo.Create("ACF Mobility") + undo.SetPlayer(ply) + undo.AddEntity(ent) + undo.Finish("ACF Mobility (" .. tostring(id) .. ")") + end + + ply:AddCleanup("props", ent) + register(ent, instance) + + return SF.WrapObject(ent) +end + +--- Returns the specs of the engine or gearbox +-- @param id id or name of the engine or gearbox +-- @server +-- @return The specs table +function acf_library.getMobilitySpecs(id) + checkluatype(id, TYPE_STRING) + + local list_entries = ACF.Weapons.Mobility + + -- Not a valid id, try name + if not list_entries[id] then + id = idFromName(list_entries, id) + + -- Name is also invalid, error + if not id or not list_entries[id] then + SF.Throw("Invalid id or name", 2) + end + end + + local specs = table.Copy(list_entries[id]) + specs.BaseClass = nil + + return specs +end + +--- Returns a list of all mobility components +-- @server +-- @return The mobility component list +function acf_library.getAllMobility() + local list = {} + + for id, _ in pairs(ACF.Weapons.Mobility) do + table.insert(list, id) + end + + return list +end + +--- Returns a list of all engines +-- @server +-- @return The engine list +function acf_library.getAllEngines() + local list = {} + + for id, d in pairs(ACF.Weapons.Mobility) do + if d.ent == "acf_engine" then + table.insert(list, id) + end + end + + return list +end + +--- Returns a list of all gearboxes +-- @server +-- @return The gearbox list +function acf_library.getAllGearboxes() + local list = {} + + for id, d in pairs(ACF.Weapons.Mobility) do + if d.ent == "acf_gearbox" then + table.insert(list, id) + end + end + + return list +end + +--- Creates a fuel tank given the id +-- @param pos Position of created fuel tank +-- @param ang Angle of created fuel tank +-- @param id id of the fuel tank to create +-- @param frozen True to spawn frozen +-- @param fueltype The type of fuel to use (Diesel, Electric, Petrol) +-- @server +-- @return The created fuel tank +function acf_library.createFuelTank(pos, ang, id, fueltype, frozen) + checkpermission(SF.instance, nil, "acf.createFuelTank") + + local instance = SF.instance + local ply = instance.player + + if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end + + checktype(pos, vec_meta) + checktype(ang, ang_meta) + checkluatype(id, TYPE_STRING) + frozen = frozen and true or false + fueltype = fueltype or "Diesel" + checkluatype(fueltype, TYPE_STRING) + + local pos = vunwrap(pos) + local ang = aunwrap(ang) + + if fueltype ~= "Diesel" and fueltype ~= "Electric" and fueltype ~= "Petrol" then SF.Throw("Invalid fuel type") end + + local list_entries = ACF.Weapons.FuelTanks + if not list_entries[id] then SF.Throw("Invalid id", 2) end + + local type_id = list_entries[id] + local dupe_class = duplicator.FindEntityClass(type_id.ent) + + if not dupe_class then SF.Throw("Didn't find entity duplicator records", 2) end + + plyBurst:use(ply, 1) + plyCount:checkuse(ply, 1) + + local ent = dupe_class.Func(ply, SF.clampPos(pos), ang, "Basic_FuelTank", id, fueltype) + ent:Activate() + + local phys = ent:GetPhysicsObject() + if phys:IsValid() then + phys:EnableMotion(not frozen) + end + + if instance.data.props.undo then + undo.Create("ACF Fuel Tank") + undo.SetPlayer(ply) + undo.AddEntity(ent) + undo.Finish("ACF Fuel Tank (" .. tostring(id) .. ")") + end + + ply:AddCleanup("props", ent) + register(ent, instance) + + return SF.WrapObject(ent) +end + +--- Returns the specs of the fuel tank +-- @param id id of the engine or gearbox +-- @server +-- @return The specs table +function acf_library.getFuelTankSpecs(id) + checkluatype(id, TYPE_STRING) + + local list_entries = ACF.Weapons.FuelTanks + if not list_entries[id] then SF.Throw("Invalid id", 2) end + + local specs = table.Copy(list_entries[id]) + specs.BaseClass = nil + + return specs +end + +--- Returns a list of all fuel tanks +-- @server +-- @return The fuel tank list +function acf_library.getAllFuelTanks() + local list = {} + + for id, _ in pairs(ACF.Weapons.FuelTanks) do + table.insert(list, id) + end + + return list +end + +--- Creates a fun given the id or name +-- @param pos Position of created gun +-- @param ang Angle of created gun +-- @param id id or name of the gun to create +-- @param frozen True to spawn frozen +-- @server +-- @return The created gun +function acf_library.createGun(pos, ang, id, frozen) + checkpermission(SF.instance, nil, "acf.createGun") + + local instance = SF.instance + local ply = instance.player + + if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end + + checktype(pos, vec_meta) + checktype(ang, ang_meta) + checkluatype(id, TYPE_STRING) + frozen = frozen and true or false + + local pos = vunwrap(pos) + local ang = aunwrap(ang) + + local list_entries = ACF.Weapons.Guns + + -- Not a valid id, try name + if not list_entries[id] then + id = idFromName(list_entries, id) + + -- Name is also invalid, error + if not id or not list_entries[id] then + SF.Throw("Invalid id or name", 2) + end + end + + local type_id = list_entries[id] + local dupe_class = duplicator.FindEntityClass(type_id.ent) + + if not dupe_class then SF.Throw("Didn't find entity duplicator records", 2) end + + plyBurst:use(ply, 1) + plyCount:checkuse(ply, 1) + + local ent = dupe_class.Func(ply, SF.clampPos(pos), ang, id) + ent:Activate() + + local phys = ent:GetPhysicsObject() + if phys:IsValid() then + phys:EnableMotion(not frozen) + end + + if instance.data.props.undo then + undo.Create("ACF Gun") + undo.SetPlayer(ply) + undo.AddEntity(ent) + undo.Finish("ACF Gun (" .. tostring(id) .. ")") + end + + ply:AddCleanup("props", ent) + register(ent, instance) + + return SF.WrapObject(ent) +end + +--- Returns the specs of gun +-- @param id id or name of the gun +-- @server +-- @return The specs table +function acf_library.getGunSpecs(id) + checkluatype(id, TYPE_STRING) + + local list_entries = ACF.Weapons.Guns + + -- Not a valid id, try name + if not list_entries[id] then + id = idFromName(list_entries, id) + + -- Name is also invalid, error + if not id or not list_entries[id] then + SF.Throw("Invalid id or name", 2) + end + end + + local specs = table.Copy(list_entries[id]) + specs.BaseClass = nil + + return specs +end + +--- Returns a list of all guns +-- @server +-- @return The guns list +function acf_library.getAllGuns() + local list = {} + + for id, _ in pairs(ACF.Weapons.Guns) do + table.insert(list, id) + end + + return list +end + +-- Set ammo properties +local ammo_properties = {} + +for id, data in pairs(list.Get("ACFRoundTypes")) do + ammo_properties[id] = { + name = data.name, + desc = data.desc, + model = data.model, + gun_blacklist = ACF.AmmoBlacklist[id], + create_data = {} + } +end + +-- No other way to get this so hardcoded here it is ;( +local ammo_property_data = { + propellantLength = { + type = "number", + default = 0.01, + data = 3, + convert = function(value) return value end + }, + + projectileLength = { + type = "number", + default = 15, + data = 4, + convert = function(value) return value end + }, + + heFillerVolume = { + type = "number", + default = 0, + data = 5, + convert = function(value) return value end + }, + + tracer = { + type = "boolean", + default = false, + data = 10, + convert = function(value) return value and 0.5 or 0 end + } +} + +ammo_properties.AP.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + tracer = ammo_property_data.tracer +} + +ammo_properties.APHE.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + heFillerVolume = ammo_property_data.heFillerVolume, + tracer = ammo_property_data.tracer +} + +ammo_properties.FL.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + flechettes = { + type = "number", + default = 6, + data = 5, + convert = function(value) return value end + }, + flechettesSpread = { + type = "number", + default = 10, + data = 6, + convert = function(value) return value end + }, + tracer = ammo_property_data.tracer +} + +ammo_properties.HE.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + heFillerVolume = ammo_property_data.heFillerVolume, + tracer = ammo_property_data.tracer +} + +ammo_properties.HEAT.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + heFillerVolume = ammo_property_data.heFillerVolume, + crushConeAngle = { + type = "number", + default = 0, + data = 6, + convert = function(value) return value end + }, + tracer = ammo_property_data.tracer +} + +ammo_properties.HP.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + heFillerVolume = ammo_property_data.heFillerVolume, + hollowPointCavityVolume = { + type = "number", + default = 0, + data = 5, + convert = function(value) return value end + }, + tracer = ammo_property_data.tracer +} + +ammo_properties.SM.create_data = { + propellantLength = ammo_property_data.propellantLength, + projectileLength = ammo_property_data.projectileLength, + smokeFillerVolume = ammo_property_data.heFillerVolume, + wpFillerVolume = { + type = "number", + default = 0, + data = 6, + convert = function(value) return value end + }, + fuseTime = { + type = "number", + default = 0, + data = 7, + convert = function(value) return value end + }, + tracer = ammo_property_data.tracer +} + +ammo_properties.Refill.create_data = {} + +--- Creates a ammo box given the id +-- @param pos Position of created ammo box +-- @param ang Angle of created ammo box +-- @param id id of the ammo box to create +-- @param ammo_id id of the ammo +-- @param frozen True to spawn frozen +-- @param ammo_data the ammo data +-- @server +-- @return The created ammo box +-- @usage +-- If ammo_data isn't provided default values will be used (same as in the ACF menu) +-- Possible values for ammo_data corresponding to ammo_id: +-- +-- AP: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- tracer (bool) +-- +-- APHE: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- heFillerVolume (number) +-- \- tracer (bool) +-- +-- FL: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- flechettes (number) +-- \- flechettesSpread (number) +-- \- tracer (bool) +-- +-- HE: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- heFillerVolume (number) +-- \- tracer (bool) +-- +-- HEAT: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- heFillerVolume (number) +-- \- crushConeAngle (number) +-- \- tracer (bool) +-- +-- HP: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- heFillerVolume (number) +-- \- hollowPointCavityVolume (number) +-- \- tracer (bool) +-- +-- SM: +-- \- propellantLength (number) +-- \- projectileLength (number) +-- \- smokeFillerVolume (number) +-- \- wpFillerVolume (number) +-- \- fuseTime (number) +-- \- tracer (bool) +-- +-- Refil: +function acf_library.createAmmo(pos, ang, id, gun_id, ammo_id, frozen, ammo_data) + checkpermission(SF.instance, nil, "acf.createAmmo") + + local instance = SF.instance + local ply = instance.player + + if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end + + checktype(pos, vec_meta) + checktype(ang, ang_meta) + checkluatype(id, TYPE_STRING) + checkluatype(ammo_id, TYPE_STRING) + checkluatype(gun_id, TYPE_STRING) + frozen = frozen and true or false + ammo_data = type(ammo_data) == "table" and ammo_data or {} + + local pos = vunwrap(pos) + local ang = aunwrap(ang) + + local list_entries = ACF.Weapons.Ammo + local type_id = list_entries[id] + if not type_id then SF.Throw("Invalid id", 2) end + + local ammo = ammo_properties[ammo_id] + if not ammo then SF.Throw("Invalid ammo id", 2) end + + local gun_list_entries = ACF.Weapons.Guns + if not gun_list_entries[gun_id] then + gun_id = idFromName(gun_list_entries, gun_id) + + if not gun_id or not gun_list_entries[gun_id] then + SF.Throw("Invalid gun id or name", 2) + end + end + + local dupe_class = duplicator.FindEntityClass(type_id.ent) + if not dupe_class then SF.Throw("Didn't find entity duplicator records", 2) end + + plyBurst:use(ply, 1) + plyCount:checkuse(ply, 1) + + local args_table = { + SF.clampPos(pos), + ang, + id, + gun_id, + ammo_id, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + } + + for k, v in pairs(ammo.create_data) do + local value = ammo_data[k] + + if value then + if type(value) == v.type then + args_table[3 + v.data] = v.convert(value) + else + args_table[3 + v.data] = v.convert(v.default) + end + else + args_table[3 + v.data] = v.convert(v.default) + end + end + + local ent = dupe_class.Func(ply, unpack(args_table)) + ent:Activate() + + local phys = ent:GetPhysicsObject() + if phys:IsValid() then + phys:EnableMotion(not frozen) + end + + if instance.data.props.undo then + undo.Create("ACF Ammo") + undo.SetPlayer(ply) + undo.AddEntity(ent) + undo.Finish("ACF Ammo (" .. tostring(id) .. ")") + end + + ply:AddCleanup("props", ent) + register(ent, instance) + + return SF.WrapObject(ent) +end + +--- Returns the specs of the ammo +-- @param id id of the ammo +-- @server +-- @return The specs table +function acf_library.getAmmoSpecs(id) + checkluatype(id, TYPE_STRING) + + local data = ammo_properties[id] + if not data then SF.Throw("Invalid id", 2) end + + local properties = {} + for name, d in pairs(data.create_data) do + properties[name] = { + type = d.type, + default = d.default, + convert = d.convert + } + end + + return { + name = data.name, + desc = data.desc, + model = data.model, + properties = table.Copy(data.create_data)--properties + } end +--- Returns a list of all ammo types +-- @server +-- @return The ammo list +function acf_library.getAllAmmo() + local list = {} + + for id, _ in pairs(ammo_properties) do + table.insert(list, id) + end + + return list +end + +--- Returns a list of all ammo boxes +-- @server +-- @return The ammo box list +function acf_library.getAllAmmoBoxes() + local list = {} + + for id, _ in pairs(ACF.Weapons.Ammo) do + table.insert(list, id) + end + + return list +end + +---------------------------------------- +-- Entity Methods + SF.AddHook("postload", function() - local ents_metatable = SF.Entities.Metatable - local ents_methods = SF.Entities.Methods - local wrap, unwrap = SF.Entities.Wrap, SF.Entities.Unwrap + ents_metatable = SF.Entities.Metatable + ents_methods = SF.Entities.Methods + + vec_meta = SF.Vectors.Metatable + ang_meta = SF.Angles.Metatable + + wrap = SF.Entities.Wrap + unwrap = SF.Entities.Unwrap + vwrap = SF.Vectors.Wrap + vunwrap = SF.Vectors.Unwrap + awrap = SF.Angles.Wrap + aunwrap = SF.Angles.Unwrap -- [General Functions ] -- + -- Moved to acf lib -- Returns true if functions returning sensitive info are restricted to owned props - function ents_methods:acfInfoRestricted () + --[[function ents_methods:acfInfoRestricted () return GetConVar( "sbox_acf_restrictinfo" ):GetInt() ~= 0 + end]] + + -- Returns true if this entity contains sensitive info and is not accessable to us + function ents_methods:acfIsInfoRestricted () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return restrictInfo( this ) end -- Returns the short name of an ACF entity function ents_methods:acfNameShort () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isEngine( this ) then return this.Id or "" end if isGearbox( this ) then return this.Id or "" end if isGun( this ) then return this.Id or "" end if isAmmo( this ) then return this.RoundId or "" end if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end + + return "" end -- Returns the capacity of an acf ammo crate or fuel tank function ents_methods:acfCapacity () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isFuel( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return this.Capacity or 1 @@ -96,8 +870,10 @@ SF.AddHook("postload", function() -- Returns true if the acf engine, fuel tank, or ammo crate is active function ents_methods:acfGetActive () - SF.CheckType( self, ents_metatable ) - local this = unwrap( self ) + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return false end if restrictInfo( this ) then return false end @@ -111,34 +887,39 @@ SF.AddHook("postload", function() -- Turns an ACF engine, ammo crate, or fuel tank on or off function ents_methods:acfSetActive ( on ) - SF.CheckType( self, ents_metatable ) - local this = unwrap( self ) + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Active", on and 1 or 0 ) + this:TriggerInput( "Active", on and 1 or 0 ) end - --returns 1 if hitpos is on a clipped part of prop + --returns true if hitpos is on a clipped part of prop function ents_methods:acfHitClip( hitpos ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( hitpos, "vector" ) - local this = unwrap( self ) + checktype( self, ents_metatable ) + checktype( hitpos, vec_meta ) + local this = unwrap( self ) + local hitpos = vunwrap( hitpos ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) -- E2 has owner check so i guess having a check if the player has permission is sufficient enough? - if not isOwner( self, this ) then return false end if ACF_CheckClips( nil, nil, this, hitpos ) then return true else return false end end local linkTables = { -- link resources within each ent type. should point to an ent: true if adding link.Ent, false to add link itself - acf_engine = { GearLink = true, FuelLink = false }, - acf_gearbox = { WheelLink = true, Master = false }, - acf_fueltank = { Master = false }, - acf_gun = { AmmoLink = false }, - acf_ammo = { Master = false } + acf_engine = { GearLink = true, FuelLink = false }, + acf_gearbox = { WheelLink = true, Master = false }, + acf_fueltank = { Master = false }, + acf_gun = { AmmoLink = false }, + acf_ammo = { Master = false } } - local function getLinks ( ent, enttype ) + local function getLinks ( ent, enttype ) local ret = {} -- find the link resources available for this ent type for entry, mode in pairs( linkTables[ enttype ] ) do @@ -174,10 +955,10 @@ SF.AddHook("postload", function() -- Returns the ACF links associated with the entity function ents_methods:acfLinks () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) - if not IsValid( this ) then return {} end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end local enttype = this:GetClass() @@ -185,14 +966,16 @@ SF.AddHook("postload", function() return searchForGearboxLinks( this ) end - return getLinks( this, enttype ) + return getLinks( this, enttype ) end -- Returns the full name of an ACF entity function ents_methods:acfName () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isAmmo( this ) then return ( this.RoundId .. " " .. this.RoundType) end if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end @@ -207,9 +990,11 @@ SF.AddHook("postload", function() -- Returns the type of ACF entity function ents_methods:acfType () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isEngine( this ) or isGearbox( this ) then local List = list.Get( "ACFEnts" ) return List[ "Mobility" ][ this.Id ][ "category" ] or "" @@ -223,127 +1008,210 @@ SF.AddHook("postload", function() return "" end - --perform ACF links + -- Perform ACF links function ents_methods:acfLinkTo ( target, notify ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( target, ents_metatable ) - SF.CheckType( notify, "number" ) + checktype( self, ents_metatable ) + checktype( target, ents_metatable ) + local this = unwrap( self ) local tar = unwrap( target ) - if not ( ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) and ( isOwner( self, this ) and isOwner( self, tar ) ) ) then - if notify > 0 then - ACF_SendNotify( self.player, 0, "Must be called on a gun, engine, or gearbox you own." ) - end - return 0 + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end + + checkpermission( SF.instance, this, "entities.acf" ) + checkpermission( SF.instance, tar, "entities.acf" ) + + if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then + SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) end - local success, msg = this:Link( tar ) - if notify > 0 then - ACF_SendNotify( self.player, success, msg ) - end - return success and 1 or 0 + local success, msg = this:Link( tar ) + if notify then + ACF_SendNotify( self.player, success, msg ) + end + return success, msg end - --perform ACF unlinks + -- Perform ACF unlinks function ents_methods:acfUnlinkFrom ( target, notify ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( target, ents_metatable ) - SF.CheckType( notify, "number" ) + checktype( self, ents_metatable ) + checktype( target, ents_metatable ) + local this = unwrap( self ) local tar = unwrap( target ) - if not ( ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) and ( isOwner( self, this ) and isOwner( self, tar ) ) ) then - if notify > 0 then - ACF_SendNotify( self.player, 0, "Must be called on a gun, engine, or gearbox you own." ) - end - return 0 + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end + + checkpermission( SF.instance, this, "entities.acf" ) + checkpermission( SF.instance, tar, "entities.acf" ) + + if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then + SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) end - local success, msg = this:Unlink( tar ) - if notify > 0 then - ACF_SendNotify( self.player, success, msg ) - end - return success and 1 or 0 + local success, msg = this:Unlink( tar ) + if notify then + ACF_SendNotify( self.player, success, msg ) + end + return success, msg end + -- returns any wheels linked to this engine/gearbox or child gearboxes + function ents_methods:acfGetLinkedWheels () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isEngine(this) or isGearbox(this) ) then SF.Throw( "Target must be a engine, or gearbox", 2 ) end + local wheels = {} + for k, ent in pairs( ACF_GetLinkedWheels( this ) ) do + table.insert( wheels, wrap( ent ) ) + end + + return wheels + end -- [ Engine Functions ] -- -- Returns true if the entity is an ACF engine function ents_methods:acfIsEngine () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return isEngine( this ) + end + + -- Returns true if an ACF engine is electric + function ents_methods:acfIsElectric () + checktype( self, ents_metatable ) local this = unwrap( self ) - if isEngine( this ) then return true else return false end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return this.iselec == true end -- Returns the torque in N/m of an ACF engine function ents_methods:acfMaxTorque () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end return this.PeakTorque or 0 end - -- Returns the power in kW of an ACF engine - function ents_methods:acfMaxPower () - SF.CheckType( self, ents_metatable ) + -- Returns the torque in N/m of an ACF engine with fuel + function ents_methods:acfMaxTorqueWithFuel () + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end + return (this.PeakTorque or 0) * (ACF.TorqueBoost or 0) + end + + local function getMaxPower( ent ) local peakpower - if this.iselec then - peakpower = math.floor( this.PeakTorque * this.LimitRPM / ( 4 * 9548.8 ) ) + + if ent.iselec then + peakpower = math.floor( ent.PeakTorque * ent.LimitRPM / ( 4 * 9548.8 ) ) else - peakpower = math.floor( this.PeakTorque * this.PeakMaxRPM / 9548.8 ) + peakpower = math.floor( ent.PeakTorque * ent.PeakMaxRPM / 9548.8 ) end + return peakpower or 0 end + -- Returns the power in kW of an ACF engine + function ents_methods:acfMaxPower () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return isEngine( this ) and getMaxPower( this ) or 0 + end + + -- Returns the power in kW of an ACF engine with fuel + function ents_methods:acfMaxPowerWithFuel () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return (isEngine( this ) and getMaxPower( this ) or 0) * (ACF.TorqueBoost or 0) + end + -- Returns the idle rpm of an ACF engine function ents_methods:acfIdleRPM () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end return this.IdleRPM or 0 end + -- Returns the powerband min and max of an ACF Engine + function ents_methods:acfPowerband () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if not isEngine( this ) then return 0, 0 end + return this.PeakMinRPM or 0, this.PeakMaxRPM or 0 + end + -- Returns the powerband min of an ACF engine function ents_methods:acfPowerbandMin () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end return this.PeakMinRPM or 0 end -- Returns the powerband max of an ACF engine function ents_methods:acfPowerbandMax () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end return this.PeakMaxRPM or 0 end -- Returns the redline rpm of an ACF engine function ents_methods:acfRedline () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end return this.LimitRPM or 0 end -- Returns the current rpm of an ACF engine function ents_methods:acfRPM () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end return math.floor( this.FlyRPM ) or 0 @@ -351,9 +1219,11 @@ SF.AddHook("postload", function() -- Returns the current torque of an ACF engine function ents_methods:acfTorque () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end return math.floor( this.Torque or 0 ) @@ -361,9 +1231,11 @@ SF.AddHook("postload", function() -- Returns the inertia of an ACF engine's flywheel function ents_methods:acfFlyInertia () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return nil end if restrictInfo( this ) then return 0 end return this.Inertia or 0 @@ -371,9 +1243,11 @@ SF.AddHook("postload", function() -- Returns the mass of an ACF engine's flywheel function ents_methods:acfFlyMass () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return nil end if restrictInfo( this ) then return 0 end return this.Inertia / ( 3.1416 )^2 or 0 @@ -381,9 +1255,11 @@ SF.AddHook("postload", function() --- Returns the current power of an ACF engine function ents_methods:acfPower () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end return math.floor( ( this.Torque or 0 ) * ( this.FlyRPM or 0 ) / 9548.8 ) @@ -391,20 +1267,25 @@ SF.AddHook("postload", function() -- Returns true if the RPM of an ACF engine is inside the powerband function ents_methods:acfInPowerband () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return false end if restrictInfo( this ) then return false end if ( this.FlyRPM < this.PeakMinRPM ) then return false end if ( this.FlyRPM > this.PeakMaxRPM ) then return false end + return true end function ents_methods:acfGetThrottle () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end return ( this.Throttle or 0 ) * 100 @@ -412,12 +1293,14 @@ SF.AddHook("postload", function() -- Sets the throttle value for an ACF engine function ents_methods:acfSetThrottle ( throttle ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( throttle, "number" ) + checktype( self, ents_metatable ) + checkluatype( throttle, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isEngine( this ) then return end - if restrictInfo( this ) then return end this:TriggerInput( "Throttle", throttle ) end @@ -426,17 +1309,21 @@ SF.AddHook("postload", function() -- Returns true if the entity is an ACF gearbox function ents_methods:acfIsGearbox () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) - if isGearbox( this ) then return true else return false end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return isGearbox( this ) end -- Returns the current gear for an ACF gearbox function ents_methods:acfGear () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end if restrictInfo( this ) then return 0 end return this.Gear or 0 @@ -444,9 +1331,11 @@ SF.AddHook("postload", function() -- Returns the number of gears for an ACF gearbox function ents_methods:acfNumGears () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end if restrictInfo( this ) then return 0 end return this.Gears or 0 @@ -454,9 +1343,11 @@ SF.AddHook("postload", function() -- Returns the final ratio for an ACF gearbox function ents_methods:acfFinalRatio () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end if restrictInfo( this ) then return 0 end return this.GearTable[ "Final" ] or 0 @@ -464,9 +1355,11 @@ SF.AddHook("postload", function() -- Returns the total ratio (current gear * final) for an ACF gearbox function ents_methods:acfTotalRatio () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end if restrictInfo( this ) then return 0 end return this.GearRatio or 0 @@ -474,51 +1367,60 @@ SF.AddHook("postload", function() -- Returns the max torque for an ACF gearbox function ents_methods:acfTorqueRating () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end return this.MaxTorque or 0 end -- Returns whether an ACF gearbox is dual clutch function ents_methods:acfIsDual () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return false end if restrictInfo( this ) then return false end - if this.Dual then return true end - return false + + return this.Dual end -- Returns the time in ms an ACF gearbox takes to change gears function ents_methods:acfShiftTime () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end return ( this.SwitchTime or 0 ) * 1000 end -- Returns true if an ACF gearbox is in gear function ents_methods:acfInGear () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return false end if restrictInfo( this ) then return false end - if this.InGear then return true end - return false + + return this.InGear end -- Returns the ratio for a specified gear of an ACF gearbox function ents_methods:acfGearRatio ( gear ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( gear, "number" ) - + checktype( self, ents_metatable ) + checkluatype( gear, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end if restrictInfo( this ) then return 0 end local g = math.Clamp( math.floor( gear ), 1, this.Gears ) @@ -527,20 +1429,24 @@ SF.AddHook("postload", function() -- Returns the current torque output for an ACF gearbox function ents_methods:acfTorqueOut () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGearbox( this ) then return 0 end return math.min( this.TotalReqTq or 0, this.MaxTorque or 0 ) / ( this.GearRatio or 1 ) end -- Sets the gear ratio of a CVT, set to 0 to use built-in algorithm function ents_methods:acfCVTRatio ( ratio ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( ratio, "number" ) - + checktype( self, ents_metatable ) + checkluatype( ratio, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.CVT then return end @@ -549,10 +1455,13 @@ SF.AddHook("postload", function() -- Sets the current gear for an ACF gearbox function ents_methods:acfShift ( gear ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( gear, "number" ) + checktype( self, ents_metatable ) + checkluatype( gear, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end this:TriggerInput( "Gear", gear ) @@ -560,9 +1469,12 @@ SF.AddHook("postload", function() -- Cause an ACF gearbox to shift up function ents_methods:acfShiftUp () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end this:TriggerInput( "Gear Up", 1 ) --doesn't need to be toggled off @@ -570,9 +1482,12 @@ SF.AddHook("postload", function() -- Cause an ACF gearbox to shift down function ents_methods:acfShiftDown () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end this:TriggerInput( "Gear Down", 1 ) --doesn't need to be toggled off @@ -580,21 +1495,27 @@ SF.AddHook("postload", function() -- Sets the brakes for an ACF gearbox function ents_methods:acfBrake ( brake ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( brake, "number" ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end - this:TriggerInput("Brake", brake) + this:TriggerInput( "Brake", brake ) end -- Sets the left brakes for an ACF gearbox function ents_methods:acfBrakeLeft ( brake ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( brake, "number" ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Dual then return end @@ -603,10 +1524,13 @@ SF.AddHook("postload", function() -- Sets the right brakes for an ACF gearbox function ents_methods:acfBrakeRight ( brake ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( brake, "number" ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Dual then return end @@ -615,10 +1539,13 @@ SF.AddHook("postload", function() -- Sets the clutch for an ACF gearbox function ents_methods:acfClutch ( clutch ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( clutch, "number" ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end this:TriggerInput( "Clutch", clutch ) @@ -626,10 +1553,13 @@ SF.AddHook("postload", function() -- Sets the left clutch for an ACF gearbox function ents_methods:acfClutchLeft( clutch ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( clutch, "number" ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Dual then return end @@ -638,10 +1568,13 @@ SF.AddHook("postload", function() -- Sets the right clutch for an ACF gearbox function ents_methods:acfClutchRight ( clutch ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( clutch, "number" ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Dual then return end @@ -650,10 +1583,13 @@ SF.AddHook("postload", function() -- Sets the steer ratio for an ACF gearbox function ents_methods:acfSteerRate ( rate ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( rate, "number" ) + checktype( self, ents_metatable ) + checkluatype( rate, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.DoubleDiff then return end @@ -662,10 +1598,13 @@ SF.AddHook("postload", function() -- Applies gear hold for an automatic ACF gearbox function ents_methods:acfHoldGear( hold ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( hold, "number" ) + checktype( self, ents_metatable ) + checkluatype( hold, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Auto then return end @@ -674,10 +1613,13 @@ SF.AddHook("postload", function() -- Sets the shift point scaling for an automatic ACF gearbox function ents_methods:acfShiftPointScale( scale ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( scale, "number" ) + checktype( self, ents_metatable ) + checkluatype( scale, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end if restrictInfo( this ) then return end if not this.Auto then return end @@ -689,17 +1631,21 @@ SF.AddHook("postload", function() -- Returns true if the entity is an ACF gun function ents_methods:acfIsGun () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isGun( this ) and not restrictInfo( this ) then return true else return false end end -- Returns true if the ACF gun is ready to fire function ents_methods:acfReady () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return false end if restrictInfo( this ) then return false end if ( this.Ready ) then return true end @@ -708,18 +1654,22 @@ SF.AddHook("postload", function() -- Returns the magazine size for an ACF gun function ents_methods:acfMagSize () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return 0 end return this.MagSize or 1 end -- Returns the spread for an ACF gun or flechette ammo function ents_methods:acfSpread () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) or isAmmo( this ) then return 0 end local Spread = this.GetInaccuracy and this:GetInaccuracy() or this.Inaccuracy or 0 if this.BulletData[ "Type" ] == "FL" then @@ -731,9 +1681,11 @@ SF.AddHook("postload", function() -- Returns true if an ACF gun is reloading function ents_methods:acfIsReloading () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return false end if restrictInfo( this ) then return false end if (this.Reloading) then return true end @@ -742,18 +1694,22 @@ SF.AddHook("postload", function() -- Returns the rate of fire of an acf gun function ents_methods:acfFireRate () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return 0 end return math.Round( this.RateOfFire or 0, 3 ) end -- Returns the number of rounds left in a magazine for an ACF gun function ents_methods:acfMagRounds () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return 0 end if restrictInfo( this ) then return 0 end if this.MagSize > 1 then @@ -765,40 +1721,51 @@ SF.AddHook("postload", function() -- Sets the firing state of an ACF weapon function ents_methods:acfFire ( fire ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( fire, "number" ) + checktype( self, ents_metatable ) + checkluatype( fire, TYPE_NUMBER ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGun( this ) then return end - if restrictInfo( this ) then return end + this:TriggerInput( "Fire", fire ) end -- Causes an ACF weapon to unload function ents_methods:acfUnload () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGun( this ) then return end - if restrictInfo( this ) then return end + this:UnloadAmmo() end -- Causes an ACF weapon to reload function ents_methods:acfReload () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isGun( this ) then return end - if restrictInfo( this ) then return end + this.Reloading = true end --Returns the number of rounds in active ammo crates linked to an ACF weapon function ents_methods:acfAmmoCount () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return 0 end if restrictInfo( this ) then return 0 end local Ammo = 0 @@ -812,9 +1779,11 @@ SF.AddHook("postload", function() --Returns the number of rounds in all ammo crates linked to an ACF weapon function ents_methods:acfTotalAmmoCount () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return 0 end if restrictInfo( this ) then return 0 end local Ammo = 0 @@ -826,48 +1795,58 @@ SF.AddHook("postload", function() return Ammo end - -- Returns time to next shot of an ACF weapon - function ents_methods:acfReloadTime () - SF.CheckType( self, ents_metatable ) + -- Returns time to next shot of an ACF weapon + function ents_methods:acfReloadTime () + checktype( self, ents_metatable ) local this = unwrap( self ) - if restrictInfo( this ) or not isGun( this ) or this.Ready then return 0 end - return reloadTime( this ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - -- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars - function ents_methods:acfReloadProgress () - SF.CheckType( self, ents_metatable ) + if restrictInfo( this ) or not isGun( this ) or this.Ready then return 0 end + return reloadTime( this ) + end + + -- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars + function ents_methods:acfReloadProgress () + checktype( self, ents_metatable ) local this = unwrap( self ) - if restrictInfo( this ) or not isGun( this ) or this.Ready then return 1 end - return math.Clamp( 1 - (this.NextFire - CurTime()) / reloadTime( this ), 0, 1 ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if restrictInfo( this ) or not isGun( this ) or this.Ready then return 1 end + return math.Clamp( 1 - (this.NextFire - CurTime()) / reloadTime( this ), 0, 1 ) + end - -- Returns time it takes for an ACF weapon to reload magazine - function ents_methods:acfMagReloadTime () - SF.CheckType( self, ents_metatable ) + -- Returns time it takes for an ACF weapon to reload magazine + function ents_methods:acfMagReloadTime () + checktype( self, ents_metatable ) local this = unwrap( self ) - if restrictInfo( SF.instance.player , this ) or not isGun( this ) or not this.MagReload then return 0 end - return this.MagReload - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if restrictInfo( SF.instance.player , this ) or not isGun( this ) or not this.MagReload then return 0 end + return this.MagReload + end -- [ Ammo Functions ] -- -- Returns true if the entity is an ACF ammo crate function ents_methods:acfIsAmmo () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) - if isAmmo( this ) and not restrictInfo( this ) then return true else return false end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return isAmmo( this ) and not restrictInfo( this ) end -- Returns the rounds left in an acf ammo crate function ents_methods:acfRounds () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isAmmo( this ) then return 0 end if restrictInfo( this ) then return 0 end return this.Ammo or 0 @@ -875,19 +1854,24 @@ SF.AddHook("postload", function() -- Returns the type of weapon the ammo in an ACF ammo crate loads into function ents_methods:acfRoundType () --cartridge? - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isAmmo( this ) then return "" end if restrictInfo( this ) then return "" end - return this.RoundId or "" + --return this.RoundId or "" + return this.RoundType or "" -- E2 uses this one now end -- Returns the type of ammo in a crate or gun function ents_methods:acfAmmoType () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isAmmo( this ) or isGun( this ) then return "" end if restrictInfo( this ) then return "" end return this.BulletData[ "Type" ] or "" @@ -895,9 +1879,11 @@ SF.AddHook("postload", function() -- Returns the caliber of an ammo or gun function ents_methods:acfCaliber () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return ( this.Caliber or 0 ) * 10 @@ -905,9 +1891,11 @@ SF.AddHook("postload", function() -- Returns the muzzle velocity of the ammo in a crate or gun function ents_methods:acfMuzzleVel () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return math.Round( ( this.BulletData[ "MuzzleVel" ] or 0 ) * ACF.VelScale, 3 ) @@ -915,9 +1903,11 @@ SF.AddHook("postload", function() -- Returns the mass of the projectile in a crate or gun function ents_methods:acfProjectileMass () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return math.Round( this.BulletData[ "ProjMass" ] or 0, 3 ) @@ -925,9 +1915,11 @@ SF.AddHook("postload", function() -- Returns the number of projectiles in a flechette round function ents_methods:acfFLSpikes () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end if not this.BulletData[ "Type" ] == "FL" then return 0 end @@ -936,9 +1928,11 @@ SF.AddHook("postload", function() -- Returns the mass of a single spike in a FL round in a crate or gun function ents_methods:acfFLSpikeMass () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end if not this.BulletData[ "Type" ] == "FL" then return 0 end @@ -947,9 +1941,11 @@ SF.AddHook("postload", function() -- Returns the radius of the spikes in a flechette round in mm function ents_methods:acfFLSpikeRadius () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end if not this.BulletData[ "Type" ] == "FL" then return 0 end @@ -958,14 +1954,17 @@ SF.AddHook("postload", function() -- Returns the penetration of an AP, APHE, or HEAT round function ents_methods:acfPenetration () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end local Type = this.BulletData[ "Type" ] or "" local Energy - if Type == "AP" or Type == "APHE" then + + --[[if Type == "AP" or Type == "APHE" then Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37, this.BulletData[ "ProjMass" ] - ( this.BulletData[ "FillerMass" ] or 0 ), this.BulletData[ "LimitVel" ] ) return math.Round( ( Energy.Penetration / this.BulletData[ "PenAera" ] ) * ACF.KEtoRHA, 3 ) elseif Type == "HEAT" then @@ -974,15 +1973,31 @@ SF.AddHook("postload", function() elseif Type == "FL" then Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37 , this.BulletData[ "FlechetteMass" ], this.BulletData[ "LimitVel" ] ) return math.Round( ( Energy.Penetration / this.BulletData[ "FlechettePenArea" ] ) * ACF.KEtoRHA, 3 ) + end]] + + if Type == "AP" or Type == "APHE" then + Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37, this.BulletData["ProjMass"] - (this.BulletData["FillerMass"] or 0), this.BulletData["LimitVel"] ) + return math.Round((Energy.Penetration/this.BulletData["PenAera"])*ACF.KEtoRHA,3) + elseif Type == "HEAT" then + local Crushed, HEATFillerMass, BoomFillerMass = ACF.RoundTypes["HEAT"].CrushCalc(this.BulletData.MuzzleVel, this.BulletData.FillerMass) + if Crushed == 1 then return 0 end -- no HEAT jet to fire off, it was all converted to HE + Energy = ACF_Kinetic(ACF.RoundTypes["HEAT"].CalcSlugMV( this.BulletData, HEATFillerMass )*39.37, this.BulletData["SlugMass"], 9999999 ) + return math.Round((Energy.Penetration/this.BulletData["SlugPenAera"])*ACF.KEtoRHA,3) + elseif Type == "FL" then + Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37 , this.BulletData["FlechetteMass"], this.BulletData["LimitVel"] ) + return math.Round((Energy.Penetration/this.BulletData["FlechettePenArea"])*ACF.KEtoRHA, 3) end + return 0 end -- Returns the blast radius of an HE, APHE, or HEAT round function ents_methods:acfBlastRadius () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end local Type = this.BulletData[ "Type" ] or "" @@ -995,22 +2010,27 @@ SF.AddHook("postload", function() end -- Returns the drag coef of the ammo in a crate or gun - function ents_methods:acfDragCoef() - SF.CheckType( self, ents_metatable ) + -- E2 doesnt have this function (anymore), no clue why but i guess i will comment it out + --[[function ents_methods:acfDragCoef() + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return ( this.BulletData[ "DragCoef" ] or 0 ) / ACF.DragDiv - end + end]] -- [ Armor Functions ] -- -- Returns the current health of an entity function ents_methods:acfPropHealth () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not validPhysics( this ) then return 0 end if restrictInfo( this ) then return 0 end if not ACF_Check( this ) then return 0 end @@ -1019,9 +2039,11 @@ SF.AddHook("postload", function() -- Returns the current armor of an entity function ents_methods:acfPropArmor () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not validPhysics( this ) then return 0 end if restrictInfo( this ) then return 0 end if not ACF_Check( this ) then return 0 end @@ -1030,9 +2052,11 @@ SF.AddHook("postload", function() -- Returns the max health of an entity function ents_methods:acfPropHealthMax () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not validPhysics( this ) then return 0 end if restrictInfo( this ) then return 0 end if not ACF_Check( this ) then return 0 end @@ -1041,9 +2065,11 @@ SF.AddHook("postload", function() -- Returns the max armor of an entity function ents_methods:acfPropArmorMax () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not validPhysics( this ) then return 0 end if restrictInfo( this ) then return 0 end if not ACF_Check( this ) then return 0 end @@ -1052,9 +2078,11 @@ SF.AddHook("postload", function() -- Returns the ductility of an entity function ents_methods:acfPropDuctility () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not validPhysics( this ) then return 0 end if restrictInfo( this ) then return 0 end if not ACF_Check( this ) then return 0 end @@ -1065,17 +2093,21 @@ SF.AddHook("postload", function() -- Returns true if the entity is an ACF fuel tank function ents_methods:acfIsFuel () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) - if isFuel( this ) and not restrictInfo( this ) then return true else return false end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + return isFuel( this ) and not restrictInfo( this ) end -- Returns true if the current engine requires fuel to run function ents_methods:acfFuelRequired () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return false end if restrictInfo( this ) then return false end return ( this.RequiresFuel and true ) or false @@ -1083,25 +2115,29 @@ SF.AddHook("postload", function() -- Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks function ents_methods:acfRefuelDuty ( on ) - SF.CheckType( self, ents_metatable ) - SF.CheckType( on, "boolean" ) + checktype( self, ents_metatable ) + checktype( on, "boolean" ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( SF.instance, this, "entities.acf" ) + if not isFuel( this ) then return end - if restrictInfo( this ) then return end + this:TriggerInput( "Refuel Duty", on ) end -- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine function ents_methods:acfFuel () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if restrictInfo( this ) then return 0 end if isFuel( this ) then - if restrictInfo( this ) then return 0 end return math.Round( this.Fuel, 3 ) elseif isEngine( this ) then - if restrictInfo( this ) then return 0 end if not #(this.FuelLink) then return 0 end --if no tanks, return 0 local liters = 0 @@ -1118,9 +2154,11 @@ SF.AddHook("postload", function() -- Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity function ents_methods:acfFuelLevel () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isFuel( this ) then if restrictInfo( this ) then return 0 end return math.Round( this.Fuel / this.Capacity, 3 ) @@ -1145,9 +2183,11 @@ SF.AddHook("postload", function() -- Returns the current fuel consumption in liters per minute or kilowatts of an engine function ents_methods:acfFuelUse () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 @@ -1173,9 +2213,11 @@ SF.AddHook("postload", function() -- Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using function ents_methods:acfPeakFuelUse () - SF.CheckType( self, ents_metatable ) + checktype( self, ents_metatable ) local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end if restrictInfo( this ) then return 0 end if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 From 3b1ad416c957b334c283cb7a0284514e9b6c1444 Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Fri, 23 Aug 2019 06:05:50 +0200 Subject: [PATCH 2/7] Added starfall docs --- lua/starfall/libs_cl/docs.lua | 285 ++++++++++++++++++++++++++ lua/starfall/libs_sv/acffunctions.lua | 281 ++++++++++++++++--------- 2 files changed, 474 insertions(+), 92 deletions(-) create mode 100644 lua/starfall/libs_cl/docs.lua mode change 100644 => 100755 lua/starfall/libs_sv/acffunctions.lua diff --git a/lua/starfall/libs_cl/docs.lua b/lua/starfall/libs_cl/docs.lua new file mode 100644 index 000000000..2722186a7 --- /dev/null +++ b/lua/starfall/libs_cl/docs.lua @@ -0,0 +1,285 @@ +-- Load Docs, nothing else +-- Sadly we cant have it in the fancy helper but it will work in the old one and syntax highlighting + +table.Merge(SF.Docs, {["classes"]={[1]="Entity";["Entity"]={["class"]="class";["classForced"]=true;["description"]="\ +Entity type";["fields"]={};["methods"]={[1]="acfAmmoCount";[10]="acfClutch";[11]="acfClutchLeft";[12]="acfClutchRight";[13]="acfFLSpikeMass";[14]="acfFLSpikeRadius";[15]="acfFLSpikes";[16]="acfFinalRatio";[17]="acfFire";[18]="acfFireRate";[19]="acfFlyInertia";[2]="acfAmmoType";[20]="acfFlyMass";[21]="acfFuel";[22]="acfFuelLevel";[23]="acfFuelRequired";[24]="acfFuelUse";[25]="acfGear";[26]="acfGearRatio";[27]="acfGetActive";[28]="acfGetLinkedWheels";[29]="acfGetThrottle";[3]="acfBlastRadius";[30]="acfHitClip";[31]="acfHoldGear";[32]="acfIdleRPM";[33]="acfInGear";[34]="acfInPowerband";[35]="acfIsAmmo";[36]="acfIsDual";[37]="acfIsElectric";[38]="acfIsEngine";[39]="acfIsFuel";[4]="acfBrake";[40]="acfIsGearbox";[41]="acfIsGun";[42]="acfIsInfoRestricted";[43]="acfIsReloading";[44]="acfLinkTo";[45]="acfLinks";[46]="acfMagReloadTime";[47]="acfMagRounds";[48]="acfMagSize";[49]="acfMaxPower";[5]="acfBrakeLeft";[50]="acfMaxPowerWithFuel";[51]="acfMaxTorque";[52]="acfMaxTorqueWithFuel";[53]="acfMuzzleVel";[54]="acfName";[55]="acfNameShort";[56]="acfNumGears";[57]="acfPeakFuelUse";[58]="acfPenetration";[59]="acfPower";[6]="acfBrakeRight";[60]="acfPowerband";[61]="acfPowerbandMax";[62]="acfPowerbandMin";[63]="acfProjectileMass";[64]="acfPropArmor";[65]="acfPropArmorMax";[66]="acfPropDuctility";[67]="acfPropHealth";[68]="acfPropHealthMax";[69]="acfRPM";[7]="acfCVTRatio";[70]="acfReady";[71]="acfRedline";[72]="acfRefuelDuty";[73]="acfReload";[74]="acfReloadProgress";[75]="acfReloadTime";[76]="acfRoundType";[77]="acfRounds";[78]="acfSetActive";[79]="acfSetThrottle";[8]="acfCaliber";[80]="acfShift";[81]="acfShiftDown";[82]="acfShiftPointScale";[83]="acfShiftTime";[84]="acfShiftUp";[85]="acfSpread";[86]="acfSteerRate";[87]="acfTorque";[88]="acfTorqueOut";[89]="acfTorqueRating";[9]="acfCapacity";[90]="acfTotalAmmoCount";[91]="acfTotalRatio";[92]="acfType";[93]="acfUnlinkFrom";[94]="acfUnload";["acfAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the number of rounds in active ammo crates linked to an ACF weapon";["fname"]="acfAmmoCount";["name"]="ents_methods:acfAmmoCount";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the number of rounds in active ammo crates linked to an ACF weapon ";};["acfAmmoType"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the type of ammo in a crate or gun";["fname"]="acfAmmoType";["name"]="ents_methods:acfAmmoType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the type of ammo in a crate or gun ";};["acfBlastRadius"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the blast radius of an HE, APHE, or HEAT round";["fname"]="acfBlastRadius";["name"]="ents_methods:acfBlastRadius";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the blast radius of an HE, APHE, or HEAT round ";};["acfBrake"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the brakes for an ACF gearbox";["fname"]="acfBrake";["name"]="ents_methods:acfBrake";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the brakes for an ACF gearbox ";};["acfBrakeLeft"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the left brakes for an ACF gearbox";["fname"]="acfBrakeLeft";["name"]="ents_methods:acfBrakeLeft";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the left brakes for an ACF gearbox ";};["acfBrakeRight"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the right brakes for an ACF gearbox";["fname"]="acfBrakeRight";["name"]="ents_methods:acfBrakeRight";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the right brakes for an ACF gearbox ";};["acfCVTRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the gear ratio of a CVT, set to 0 to use built-in algorithm";["fname"]="acfCVTRatio";["name"]="ents_methods:acfCVTRatio";["param"]={[1]="ratio";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the gear ratio of a CVT, set to 0 to use built-in algorithm ";};["acfCaliber"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the caliber of an ammo or gun";["fname"]="acfCaliber";["name"]="ents_methods:acfCaliber";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the caliber of an ammo or gun ";};["acfCapacity"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the capacity of an acf ammo crate or fuel tank";["fname"]="acfCapacity";["name"]="ents_methods:acfCapacity";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the capacity of an acf ammo crate or fuel tank ";};["acfClutch"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the clutch for an ACF gearbox";["fname"]="acfClutch";["name"]="ents_methods:acfClutch";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the clutch for an ACF gearbox ";};["acfClutchLeft"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the left clutch for an ACF gearbox";["fname"]="acfClutchLeft";["name"]="ents_methods:acfClutchLeft";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the left clutch for an ACF gearbox ";};["acfClutchRight"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the right clutch for an ACF gearbox";["fname"]="acfClutchRight";["name"]="ents_methods:acfClutchRight";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the right clutch for an ACF gearbox ";};["acfFLSpikeMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the mass of a single spike in a FL round in a crate or gun";["fname"]="acfFLSpikeMass";["name"]="ents_methods:acfFLSpikeMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the mass of a single spike in a FL round in a crate or gun ";};["acfFLSpikeRadius"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the radius of the spikes in a flechette round in mm";["fname"]="acfFLSpikeRadius";["name"]="ents_methods:acfFLSpikeRadius";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the radius of the spikes in a flechette round in mm ";};["acfFLSpikes"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the number of projectiles in a flechette round";["fname"]="acfFLSpikes";["name"]="ents_methods:acfFLSpikes";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the number of projectiles in a flechette round ";};["acfFinalRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the final ratio for an ACF gearbox";["fname"]="acfFinalRatio";["name"]="ents_methods:acfFinalRatio";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the final ratio for an ACF gearbox ";};["acfFire"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the firing state of an ACF weapon";["fname"]="acfFire";["name"]="ents_methods:acfFire";["param"]={[1]="fire";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the firing state of an ACF weapon ";};["acfFireRate"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the rate of fire of an acf gun";["fname"]="acfFireRate";["name"]="ents_methods:acfFireRate";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the rate of fire of an acf gun ";};["acfFlyInertia"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the inertia of an ACF engine's flywheel";["fname"]="acfFlyInertia";["name"]="ents_methods:acfFlyInertia";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the inertia of an ACF engine's flywheel ";};["acfFlyMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the mass of an ACF engine's flywheel";["fname"]="acfFlyMass";["name"]="ents_methods:acfFlyMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the mass of an ACF engine's flywheel ";};["acfFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine";["fname"]="acfFuel";["name"]="ents_methods:acfFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine ";};["acfFuelLevel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity";["fname"]="acfFuelLevel";["name"]="ents_methods:acfFuelLevel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity ";};["acfFuelRequired"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the current engine requires fuel to run";["fname"]="acfFuelRequired";["name"]="ents_methods:acfFuelRequired";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the current engine requires fuel to run ";};["acfFuelUse"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current fuel consumption in liters per minute or kilowatts of an engine";["fname"]="acfFuelUse";["name"]="ents_methods:acfFuelUse";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current fuel consumption in liters per minute or kilowatts of an engine ";};["acfGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current gear for an ACF gearbox";["fname"]="acfGear";["name"]="ents_methods:acfGear";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current gear for an ACF gearbox ";};["acfGearRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the ratio for a specified gear of an ACF gearbox";["fname"]="acfGearRatio";["name"]="ents_methods:acfGearRatio";["param"]={[1]="gear";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the ratio for a specified gear of an ACF gearbox ";};["acfGetActive"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the acf engine, fuel tank, or ammo crate is active";["fname"]="acfGetActive";["name"]="ents_methods:acfGetActive";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the acf engine, fuel tank, or ammo crate is active ";};["acfGetLinkedWheels"]={["class"]="function";["classlib"]="Entity";["description"]="\ +returns any wheels linked to this engine/gearbox or child gearboxes";["fname"]="acfGetLinkedWheels";["name"]="ents_methods:acfGetLinkedWheels";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +returns any wheels linked to this engine/gearbox or child gearboxes ";};["acfGetThrottle"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the throttle value";["fname"]="acfGetThrottle";["name"]="ents_methods:acfGetThrottle";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the throttle value ";};["acfHitClip"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if hitpos is on a clipped part of prop";["fname"]="acfHitClip";["name"]="ents_methods:acfHitClip";["param"]={[1]="hitpos";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if hitpos is on a clipped part of prop ";};["acfHoldGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Applies gear hold for an automatic ACF gearbox";["fname"]="acfHoldGear";["name"]="ents_methods:acfHoldGear";["param"]={[1]="hold";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Applies gear hold for an automatic ACF gearbox ";};["acfIdleRPM"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the idle rpm of an ACF engine";["fname"]="acfIdleRPM";["name"]="ents_methods:acfIdleRPM";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the idle rpm of an ACF engine ";};["acfInGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if an ACF gearbox is in gear";["fname"]="acfInGear";["name"]="ents_methods:acfInGear";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if an ACF gearbox is in gear ";};["acfInPowerband"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the RPM of an ACF engine is inside the powerband";["fname"]="acfInPowerband";["name"]="ents_methods:acfInPowerband";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the RPM of an ACF engine is inside the powerband ";};["acfIsAmmo"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the entity is an ACF ammo crate";["fname"]="acfIsAmmo";["name"]="ents_methods:acfIsAmmo";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the entity is an ACF ammo crate ";};["acfIsDual"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns whether an ACF gearbox is dual clutch";["fname"]="acfIsDual";["name"]="ents_methods:acfIsDual";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns whether an ACF gearbox is dual clutch ";};["acfIsElectric"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if an ACF engine is electric";["fname"]="acfIsElectric";["name"]="ents_methods:acfIsElectric";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if an ACF engine is electric ";};["acfIsEngine"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the entity is an ACF engine";["fname"]="acfIsEngine";["name"]="ents_methods:acfIsEngine";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the entity is an ACF engine ";};["acfIsFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the entity is an ACF fuel tank";["fname"]="acfIsFuel";["name"]="ents_methods:acfIsFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the entity is an ACF fuel tank ";};["acfIsGearbox"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the entity is an ACF gearbox";["fname"]="acfIsGearbox";["name"]="ents_methods:acfIsGearbox";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the entity is an ACF gearbox ";};["acfIsGun"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the entity is an ACF gun";["fname"]="acfIsGun";["name"]="ents_methods:acfIsGun";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the entity is an ACF gun ";};["acfIsInfoRestricted"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if this entity contains sensitive info and is not accessable to us";["fname"]="acfIsInfoRestricted";["name"]="ents_methods:acfIsInfoRestricted";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if this entity contains sensitive info and is not accessable to us ";};["acfIsReloading"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if an ACF gun is reloading";["fname"]="acfIsReloading";["name"]="ents_methods:acfIsReloading";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if an ACF gun is reloading ";};["acfLinkTo"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Perform ACF links";["fname"]="acfLinkTo";["name"]="ents_methods:acfLinkTo";["param"]={[1]="target";[2]="notify";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Perform ACF links ";};["acfLinks"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the ACF links associated with the entity";["fname"]="acfLinks";["name"]="ents_methods:acfLinks";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the ACF links associated with the entity ";};["acfMagReloadTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns time it takes for an ACF weapon to reload magazine";["fname"]="acfMagReloadTime";["name"]="ents_methods:acfMagReloadTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns time it takes for an ACF weapon to reload magazine ";};["acfMagRounds"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the number of rounds left in a magazine for an ACF gun";["fname"]="acfMagRounds";["name"]="ents_methods:acfMagRounds";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the number of rounds left in a magazine for an ACF gun ";};["acfMagSize"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the magazine size for an ACF gun";["fname"]="acfMagSize";["name"]="ents_methods:acfMagSize";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the magazine size for an ACF gun ";};["acfMaxPower"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the power in kW of an ACF engine";["fname"]="acfMaxPower";["name"]="ents_methods:acfMaxPower";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the power in kW of an ACF engine ";};["acfMaxPowerWithFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the power in kW of an ACF engine with fuel";["fname"]="acfMaxPowerWithFuel";["name"]="ents_methods:acfMaxPowerWithFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the power in kW of an ACF engine with fuel ";};["acfMaxTorque"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the torque in N/m of an ACF engine";["fname"]="acfMaxTorque";["name"]="ents_methods:acfMaxTorque";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the torque in N/m of an ACF engine ";};["acfMaxTorqueWithFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the torque in N/m of an ACF engine with fuel";["fname"]="acfMaxTorqueWithFuel";["name"]="ents_methods:acfMaxTorqueWithFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the torque in N/m of an ACF engine with fuel ";};["acfMuzzleVel"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the muzzle velocity of the ammo in a crate or gun";["fname"]="acfMuzzleVel";["name"]="ents_methods:acfMuzzleVel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the muzzle velocity of the ammo in a crate or gun ";};["acfName"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the full name of an ACF entity";["fname"]="acfName";["name"]="ents_methods:acfName";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the full name of an ACF entity ";};["acfNameShort"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the short name of an ACF entity";["fname"]="acfNameShort";["name"]="ents_methods:acfNameShort";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the short name of an ACF entity ";};["acfNumGears"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the number of gears for an ACF gearbox";["fname"]="acfNumGears";["name"]="ents_methods:acfNumGears";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the number of gears for an ACF gearbox ";};["acfPeakFuelUse"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using";["fname"]="acfPeakFuelUse";["name"]="ents_methods:acfPeakFuelUse";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using ";};["acfPenetration"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the penetration of an AP, APHE, or HEAT round";["fname"]="acfPenetration";["name"]="ents_methods:acfPenetration";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the penetration of an AP, APHE, or HEAT round ";};["acfPower"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current power of an ACF engine";["fname"]="acfPower";["name"]="ents_methods:acfPower";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current power of an ACF engine ";};["acfPowerband"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the powerband min and max of an ACF Engine";["fname"]="acfPowerband";["name"]="ents_methods:acfPowerband";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the powerband min and max of an ACF Engine ";};["acfPowerbandMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the powerband max of an ACF engine";["fname"]="acfPowerbandMax";["name"]="ents_methods:acfPowerbandMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the powerband max of an ACF engine ";};["acfPowerbandMin"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the powerband min of an ACF engine";["fname"]="acfPowerbandMin";["name"]="ents_methods:acfPowerbandMin";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the powerband min of an ACF engine ";};["acfProjectileMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the mass of the projectile in a crate or gun";["fname"]="acfProjectileMass";["name"]="ents_methods:acfProjectileMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the mass of the projectile in a crate or gun ";};["acfPropArmor"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current armor of an entity";["fname"]="acfPropArmor";["name"]="ents_methods:acfPropArmor";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current armor of an entity ";};["acfPropArmorMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the max armor of an entity";["fname"]="acfPropArmorMax";["name"]="ents_methods:acfPropArmorMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the max armor of an entity ";};["acfPropDuctility"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the ductility of an entity";["fname"]="acfPropDuctility";["name"]="ents_methods:acfPropDuctility";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the ductility of an entity ";};["acfPropHealth"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current health of an entity";["fname"]="acfPropHealth";["name"]="ents_methods:acfPropHealth";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current health of an entity ";};["acfPropHealthMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the max health of an entity";["fname"]="acfPropHealthMax";["name"]="ents_methods:acfPropHealthMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the max health of an entity ";};["acfRPM"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current rpm of an ACF engine";["fname"]="acfRPM";["name"]="ents_methods:acfRPM";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current rpm of an ACF engine ";};["acfReady"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns true if the ACF gun is ready to fire";["fname"]="acfReady";["name"]="ents_methods:acfReady";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns true if the ACF gun is ready to fire ";};["acfRedline"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the redline rpm of an ACF engine";["fname"]="acfRedline";["name"]="ents_methods:acfRedline";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the redline rpm of an ACF engine ";};["acfRefuelDuty"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks";["fname"]="acfRefuelDuty";["name"]="ents_methods:acfRefuelDuty";["param"]={[1]="on";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks ";};["acfReload"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Causes an ACF weapon to reload";["fname"]="acfReload";["name"]="ents_methods:acfReload";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Causes an ACF weapon to reload ";};["acfReloadProgress"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars";["fname"]="acfReloadProgress";["name"]="ents_methods:acfReloadProgress";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns number between 0 and 1 which represents reloading progress of an ACF weapon.";};["acfReloadTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns time to next shot of an ACF weapon";["fname"]="acfReloadTime";["name"]="ents_methods:acfReloadTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns time to next shot of an ACF weapon ";};["acfRoundType"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the type of weapon the ammo in an ACF ammo crate loads into";["fname"]="acfRoundType";["name"]="ents_methods:acfRoundType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the type of weapon the ammo in an ACF ammo crate loads into ";};["acfRounds"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the rounds left in an acf ammo crate";["fname"]="acfRounds";["name"]="ents_methods:acfRounds";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the rounds left in an acf ammo crate ";};["acfSetActive"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Turns an ACF engine, ammo crate, or fuel tank on or off";["fname"]="acfSetActive";["name"]="ents_methods:acfSetActive";["param"]={[1]="on";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Turns an ACF engine, ammo crate, or fuel tank on or off ";};["acfSetThrottle"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the throttle value for an ACF engine";["fname"]="acfSetThrottle";["name"]="ents_methods:acfSetThrottle";["param"]={[1]="throttle";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the throttle value for an ACF engine ";};["acfShift"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the current gear for an ACF gearbox";["fname"]="acfShift";["name"]="ents_methods:acfShift";["param"]={[1]="gear";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the current gear for an ACF gearbox ";};["acfShiftDown"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Cause an ACF gearbox to shift down";["fname"]="acfShiftDown";["name"]="ents_methods:acfShiftDown";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Cause an ACF gearbox to shift down ";};["acfShiftPointScale"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the shift point scaling for an automatic ACF gearbox";["fname"]="acfShiftPointScale";["name"]="ents_methods:acfShiftPointScale";["param"]={[1]="scale";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the shift point scaling for an automatic ACF gearbox ";};["acfShiftTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the time in ms an ACF gearbox takes to change gears";["fname"]="acfShiftTime";["name"]="ents_methods:acfShiftTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the time in ms an ACF gearbox takes to change gears ";};["acfShiftUp"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Cause an ACF gearbox to shift up";["fname"]="acfShiftUp";["name"]="ents_methods:acfShiftUp";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Cause an ACF gearbox to shift up ";};["acfSpread"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the spread for an ACF gun or flechette ammo";["fname"]="acfSpread";["name"]="ents_methods:acfSpread";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the spread for an ACF gun or flechette ammo ";};["acfSteerRate"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the steer ratio for an ACF gearbox";["fname"]="acfSteerRate";["name"]="ents_methods:acfSteerRate";["param"]={[1]="rate";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Sets the steer ratio for an ACF gearbox ";};["acfTorque"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current torque of an ACF engine";["fname"]="acfTorque";["name"]="ents_methods:acfTorque";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current torque of an ACF engine ";};["acfTorqueOut"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the current torque output for an ACF gearbox";["fname"]="acfTorqueOut";["name"]="ents_methods:acfTorqueOut";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the current torque output for an ACF gearbox ";};["acfTorqueRating"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the max torque for an ACF gearbox";["fname"]="acfTorqueRating";["name"]="ents_methods:acfTorqueRating";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the max torque for an ACF gearbox ";};["acfTotalAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the number of rounds in all ammo crates linked to an ACF weapon";["fname"]="acfTotalAmmoCount";["name"]="ents_methods:acfTotalAmmoCount";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the number of rounds in all ammo crates linked to an ACF weapon ";};["acfTotalRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the total ratio (current gear * final) for an ACF gearbox";["fname"]="acfTotalRatio";["name"]="ents_methods:acfTotalRatio";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the total ratio (current gear * final) for an ACF gearbox ";};["acfType"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the type of ACF entity";["fname"]="acfType";["name"]="ents_methods:acfType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the type of ACF entity ";};["acfUnlinkFrom"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Perform ACF unlinks";["fname"]="acfUnlinkFrom";["name"]="ents_methods:acfUnlinkFrom";["param"]={[1]="target";[2]="notify";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Perform ACF unlinks ";};["acfUnload"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Causes an ACF weapon to unload";["fname"]="acfUnload";["name"]="ents_methods:acfUnload";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Causes an ACF weapon to unload ";};};["name"]="Entity";["param"]={};["summary"]="\ +Entity type ";["typtbl"]="ents_methods";};};["directives"]={};["hooks"]={};["libraries"]={[1]="acf";["acf"]={["class"]="library";["description"]="\ + \ +ACF Library";["fields"]={};["functions"]={[1]="createAmmo";[10]="getAllFuelTanks";[11]="getAllGearboxes";[12]="getAllGuns";[13]="getAllMobility";[14]="getAmmoSpecs";[15]="getFuelTankSpecs";[16]="getGunSpecs";[17]="getMobilitySpecs";[18]="infoRestricted";[2]="createFuelTank";[3]="createGun";[4]="createMobility";[5]="dragDivisor";[6]="effectiveArmor";[7]="getAllAmmo";[8]="getAllAmmoBoxes";[9]="getAllEngines";["createAmmo"]={["class"]="function";["description"]="\ +Creates a ammo box given the id";["fname"]="createAmmo";["library"]="acf";["name"]="acf_library.createAmmo";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="gun_id";[5]="ammo_id";[6]="frozen";[7]="ammo_data";["ammo_data"]="the ammo data";["ammo_id"]="id of the ammo";["ang"]="Angle of created ammo box";["frozen"]="True to spawn frozen";["gun_id"]="id of the gun";["id"]="id of the ammo box to create";["pos"]="Position of created ammo box";};["private"]=false;["realm"]="sv";["ret"]="The created ammo box";["server"]=true;["summary"]="\ +Creates a ammo box given the id ";["usage"]="\ +If ammo_data isn't provided default values will be used (same as in the ACF menu) \ +Possible values for ammo_data corresponding to ammo_id: \ + \ +AP: \ +- propellantLength (number) \ +- projectileLength (number) \ +- tracer (bool) \ + \ +APHE: \ +- propellantLength (number) \ +- projectileLength (number) \ +- heFillerVolume (number) \ +- tracer (bool) \ + \ +FL: \ +- propellantLength (number) \ +- projectileLength (number) \ +- flechettes (number) \ +- flechettesSpread (number) \ +- tracer (bool) \ + \ +HE: \ +- propellantLength (number) \ +- projectileLength (number) \ +- heFillerVolume (number) \ +- tracer (bool) \ + \ +HEAT: \ +- propellantLength (number) \ +- projectileLength (number) \ +- heFillerVolume (number) \ +- crushConeAngle (number) \ +- tracer (bool) \ + \ +HP: \ +- propellantLength (number) \ +- projectileLength (number) \ +- heFillerVolume (number) \ +- hollowPointCavityVolume (number) \ +- tracer (bool) \ + \ +SM: \ +- propellantLength (number) \ +- projectileLength (number) \ +- smokeFillerVolume (number) \ +- wpFillerVolume (number) \ +- fuseTime (number) \ +- tracer (bool) \ + \ +Refil: \ +";};["createFuelTank"]={["class"]="function";["description"]="\ +Creates a fuel tank given the id";["fname"]="createFuelTank";["library"]="acf";["name"]="acf_library.createFuelTank";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="fueltype";[5]="frozen";["ang"]="Angle of created fuel tank";["frozen"]="True to spawn frozen";["fueltype"]="The type of fuel to use (Diesel, Electric, Petrol)";["id"]="id of the fuel tank to create";["pos"]="Position of created fuel tank";};["private"]=false;["realm"]="sv";["ret"]="The created fuel tank";["server"]=true;["summary"]="\ +Creates a fuel tank given the id ";};["createGun"]={["class"]="function";["description"]="\ +Creates a fun given the id or name";["fname"]="createGun";["library"]="acf";["name"]="acf_library.createGun";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="frozen";["ang"]="Angle of created gun";["frozen"]="True to spawn frozen";["id"]="id or name of the gun to create";["pos"]="Position of created gun";};["private"]=false;["realm"]="sv";["ret"]="The created gun";["server"]=true;["summary"]="\ +Creates a fun given the id or name ";};["createMobility"]={["class"]="function";["description"]="\ +Creates a engine or gearbox given the id or name";["fname"]="createMobility";["library"]="acf";["name"]="acf_library.createMobility";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="frozen";[5]="gear_ratio";["ang"]="Angle of created engine or gearbox";["frozen"]="True to spawn frozen";["gear_ratio"]="A table containing the gear ratios, only applied if the mobility is a gearbox. -1 is final drive";["id"]="id or name of the engine or gearbox to create";["pos"]="Position of created engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The created engine or gearbox";["server"]=true;["summary"]="\ +Creates a engine or gearbox given the id or name ";};["dragDivisor"]={["class"]="function";["description"]="\ +Returns current ACF drag divisor";["fname"]="dragDivisor";["library"]="acf";["name"]="acf_library.dragDivisor";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The current drag divisor";["server"]=true;["summary"]="\ +Returns current ACF drag divisor ";};["effectiveArmor"]={["class"]="function";["description"]="\ +Returns the effective armor given an armor value and hit angle";["fname"]="effectiveArmor";["library"]="acf";["name"]="acf_library.effectiveArmor";["param"]={[1]="armor";[2]="angle";};["private"]=false;["realm"]="sv";["ret"]="The effective armor";["server"]=true;["summary"]="\ +Returns the effective armor given an armor value and hit angle ";};["getAllAmmo"]={["class"]="function";["description"]="\ +Returns a list of all ammo types";["fname"]="getAllAmmo";["library"]="acf";["name"]="acf_library.getAllAmmo";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The ammo list";["server"]=true;["summary"]="\ +Returns a list of all ammo types ";};["getAllAmmoBoxes"]={["class"]="function";["description"]="\ +Returns a list of all ammo boxes";["fname"]="getAllAmmoBoxes";["library"]="acf";["name"]="acf_library.getAllAmmoBoxes";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The ammo box list";["server"]=true;["summary"]="\ +Returns a list of all ammo boxes ";};["getAllEngines"]={["class"]="function";["description"]="\ +Returns a list of all engines";["fname"]="getAllEngines";["library"]="acf";["name"]="acf_library.getAllEngines";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The engine list";["server"]=true;["summary"]="\ +Returns a list of all engines ";};["getAllFuelTanks"]={["class"]="function";["description"]="\ +Returns a list of all fuel tanks";["fname"]="getAllFuelTanks";["library"]="acf";["name"]="acf_library.getAllFuelTanks";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The fuel tank list";["server"]=true;["summary"]="\ +Returns a list of all fuel tanks ";};["getAllGearboxes"]={["class"]="function";["description"]="\ +Returns a list of all gearboxes";["fname"]="getAllGearboxes";["library"]="acf";["name"]="acf_library.getAllGearboxes";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The gearbox list";["server"]=true;["summary"]="\ +Returns a list of all gearboxes ";};["getAllGuns"]={["class"]="function";["description"]="\ +Returns a list of all guns";["fname"]="getAllGuns";["library"]="acf";["name"]="acf_library.getAllGuns";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The guns list";["server"]=true;["summary"]="\ +Returns a list of all guns ";};["getAllMobility"]={["class"]="function";["description"]="\ +Returns a list of all mobility components";["fname"]="getAllMobility";["library"]="acf";["name"]="acf_library.getAllMobility";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The mobility component list";["server"]=true;["summary"]="\ +Returns a list of all mobility components ";};["getAmmoSpecs"]={["class"]="function";["description"]="\ +Returns the specs of the ammo";["fname"]="getAmmoSpecs";["library"]="acf";["name"]="acf_library.getAmmoSpecs";["param"]={[1]="id";["id"]="id of the ammo";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ +Returns the specs of the ammo ";};["getFuelTankSpecs"]={["class"]="function";["description"]="\ +Returns the specs of the fuel tank";["fname"]="getFuelTankSpecs";["library"]="acf";["name"]="acf_library.getFuelTankSpecs";["param"]={[1]="id";["id"]="id of the engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ +Returns the specs of the fuel tank ";};["getGunSpecs"]={["class"]="function";["description"]="\ +Returns the specs of gun";["fname"]="getGunSpecs";["library"]="acf";["name"]="acf_library.getGunSpecs";["param"]={[1]="id";["id"]="id or name of the gun";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ +Returns the specs of gun ";};["getMobilitySpecs"]={["class"]="function";["description"]="\ +Returns the specs of the engine or gearbox";["fname"]="getMobilitySpecs";["library"]="acf";["name"]="acf_library.getMobilitySpecs";["param"]={[1]="id";["id"]="id or name of the engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ +Returns the specs of the engine or gearbox ";};["infoRestricted"]={["class"]="function";["description"]="\ +Returns true if functions returning sensitive info are restricted to owned props";["fname"]="infoRestricted";["library"]="acf";["name"]="acf_library.infoRestricted";["param"]={};["private"]=false;["realm"]="sv";["ret"]="True if restriced, False if not";["server"]=true;["summary"]="\ +Returns true if functions returning sensitive info are restricted to owned props ";};};["libtbl"]="acf_library";["name"]="acf";["summary"]="\ + \ +ACF Library ";["tables"]={};};};}) \ No newline at end of file diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua old mode 100644 new mode 100755 index a325476e9..2261eecd6 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -604,6 +604,7 @@ ammo_properties.Refill.create_data = {} -- @param pos Position of created ammo box -- @param ang Angle of created ammo box -- @param id id of the ammo box to create +-- @param gun_id id of the gun -- @param ammo_id id of the ammo -- @param frozen True to spawn frozen -- @param ammo_data the ammo data @@ -660,6 +661,7 @@ ammo_properties.Refill.create_data = {} -- \- tracer (bool) -- -- Refil: +-- function acf_library.createAmmo(pos, ang, id, gun_id, ammo_id, frozen, ammo_data) checkpermission(SF.instance, nil, "acf.createAmmo") @@ -830,7 +832,8 @@ SF.AddHook("postload", function() return GetConVar( "sbox_acf_restrictinfo" ):GetInt() ~= 0 end]] - -- Returns true if this entity contains sensitive info and is not accessable to us + --- Returns true if this entity contains sensitive info and is not accessable to us + -- @server function ents_methods:acfIsInfoRestricted () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -840,7 +843,8 @@ SF.AddHook("postload", function() return restrictInfo( this ) end - -- Returns the short name of an ACF entity + --- Returns the short name of an ACF entity + -- @server function ents_methods:acfNameShort () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -856,7 +860,8 @@ SF.AddHook("postload", function() return "" end - -- Returns the capacity of an acf ammo crate or fuel tank + --- Returns the capacity of an acf ammo crate or fuel tank + -- @server function ents_methods:acfCapacity () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -868,7 +873,8 @@ SF.AddHook("postload", function() return this.Capacity or 1 end - -- Returns true if the acf engine, fuel tank, or ammo crate is active + --- Returns true if the acf engine, fuel tank, or ammo crate is active + -- @server function ents_methods:acfGetActive () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -885,7 +891,8 @@ SF.AddHook("postload", function() return false end - -- Turns an ACF engine, ammo crate, or fuel tank on or off + --- Turns an ACF engine, ammo crate, or fuel tank on or off + -- @server function ents_methods:acfSetActive ( on ) checktype( self, ents_metatable ) local this = unwrap( self ) @@ -897,7 +904,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Active", on and 1 or 0 ) end - --returns true if hitpos is on a clipped part of prop + --- Returns true if hitpos is on a clipped part of prop + -- @server function ents_methods:acfHitClip( hitpos ) checktype( self, ents_metatable ) checktype( hitpos, vec_meta ) @@ -953,7 +961,8 @@ SF.AddHook("postload", function() return ret end - -- Returns the ACF links associated with the entity + --- Returns the ACF links associated with the entity + -- @server function ents_methods:acfLinks () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -969,7 +978,8 @@ SF.AddHook("postload", function() return getLinks( this, enttype ) end - -- Returns the full name of an ACF entity + --- Returns the full name of an ACF entity + -- @server function ents_methods:acfName () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -988,7 +998,8 @@ SF.AddHook("postload", function() return List[ acftype ][ this.Id ][ "name" ] or "" end - -- Returns the type of ACF entity + --- Returns the type of ACF entity + -- @server function ents_methods:acfType () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1008,7 +1019,8 @@ SF.AddHook("postload", function() return "" end - -- Perform ACF links + --- Perform ACF links + -- @server function ents_methods:acfLinkTo ( target, notify ) checktype( self, ents_metatable ) checktype( target, ents_metatable ) @@ -1033,7 +1045,8 @@ SF.AddHook("postload", function() return success, msg end - -- Perform ACF unlinks + --- Perform ACF unlinks + -- @server function ents_methods:acfUnlinkFrom ( target, notify ) checktype( self, ents_metatable ) checktype( target, ents_metatable ) @@ -1058,7 +1071,8 @@ SF.AddHook("postload", function() return success, msg end - -- returns any wheels linked to this engine/gearbox or child gearboxes + --- returns any wheels linked to this engine/gearbox or child gearboxes + -- @server function ents_methods:acfGetLinkedWheels () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1076,7 +1090,8 @@ SF.AddHook("postload", function() -- [ Engine Functions ] -- - -- Returns true if the entity is an ACF engine + --- Returns true if the entity is an ACF engine + -- @server function ents_methods:acfIsEngine () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1086,7 +1101,8 @@ SF.AddHook("postload", function() return isEngine( this ) end - -- Returns true if an ACF engine is electric + --- Returns true if an ACF engine is electric + -- @server function ents_methods:acfIsElectric () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1096,7 +1112,8 @@ SF.AddHook("postload", function() return this.iselec == true end - -- Returns the torque in N/m of an ACF engine + --- Returns the torque in N/m of an ACF engine + -- @server function ents_methods:acfMaxTorque () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1107,7 +1124,8 @@ SF.AddHook("postload", function() return this.PeakTorque or 0 end - -- Returns the torque in N/m of an ACF engine with fuel + --- Returns the torque in N/m of an ACF engine with fuel + -- @server function ents_methods:acfMaxTorqueWithFuel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1130,7 +1148,8 @@ SF.AddHook("postload", function() return peakpower or 0 end - -- Returns the power in kW of an ACF engine + --- Returns the power in kW of an ACF engine + -- @server function ents_methods:acfMaxPower () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1140,7 +1159,8 @@ SF.AddHook("postload", function() return isEngine( this ) and getMaxPower( this ) or 0 end - -- Returns the power in kW of an ACF engine with fuel + --- Returns the power in kW of an ACF engine with fuel + -- @server function ents_methods:acfMaxPowerWithFuel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1150,7 +1170,8 @@ SF.AddHook("postload", function() return (isEngine( this ) and getMaxPower( this ) or 0) * (ACF.TorqueBoost or 0) end - -- Returns the idle rpm of an ACF engine + --- Returns the idle rpm of an ACF engine + -- @server function ents_methods:acfIdleRPM () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1161,7 +1182,8 @@ SF.AddHook("postload", function() return this.IdleRPM or 0 end - -- Returns the powerband min and max of an ACF Engine + --- Returns the powerband min and max of an ACF Engine + -- @server function ents_methods:acfPowerband () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1172,7 +1194,8 @@ SF.AddHook("postload", function() return this.PeakMinRPM or 0, this.PeakMaxRPM or 0 end - -- Returns the powerband min of an ACF engine + --- Returns the powerband min of an ACF engine + -- @server function ents_methods:acfPowerbandMin () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1183,7 +1206,8 @@ SF.AddHook("postload", function() return this.PeakMinRPM or 0 end - -- Returns the powerband max of an ACF engine + --- Returns the powerband max of an ACF engine + -- @server function ents_methods:acfPowerbandMax () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1194,7 +1218,8 @@ SF.AddHook("postload", function() return this.PeakMaxRPM or 0 end - -- Returns the redline rpm of an ACF engine + --- Returns the redline rpm of an ACF engine + -- @server function ents_methods:acfRedline () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1205,7 +1230,8 @@ SF.AddHook("postload", function() return this.LimitRPM or 0 end - -- Returns the current rpm of an ACF engine + --- Returns the current rpm of an ACF engine + -- @server function ents_methods:acfRPM () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1217,7 +1243,8 @@ SF.AddHook("postload", function() return math.floor( this.FlyRPM ) or 0 end - -- Returns the current torque of an ACF engine + --- Returns the current torque of an ACF engine + -- @server function ents_methods:acfTorque () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1229,7 +1256,8 @@ SF.AddHook("postload", function() return math.floor( this.Torque or 0 ) end - -- Returns the inertia of an ACF engine's flywheel + --- Returns the inertia of an ACF engine's flywheel + -- @server function ents_methods:acfFlyInertia () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1241,7 +1269,8 @@ SF.AddHook("postload", function() return this.Inertia or 0 end - -- Returns the mass of an ACF engine's flywheel + --- Returns the mass of an ACF engine's flywheel + -- @server function ents_methods:acfFlyMass () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1254,6 +1283,7 @@ SF.AddHook("postload", function() end --- Returns the current power of an ACF engine + -- @server function ents_methods:acfPower () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1265,7 +1295,8 @@ SF.AddHook("postload", function() return math.floor( ( this.Torque or 0 ) * ( this.FlyRPM or 0 ) / 9548.8 ) end - -- Returns true if the RPM of an ACF engine is inside the powerband + --- Returns true if the RPM of an ACF engine is inside the powerband + -- @server function ents_methods:acfInPowerband () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1280,6 +1311,8 @@ SF.AddHook("postload", function() return true end + --- Returns the throttle value + -- @server function ents_methods:acfGetThrottle () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1291,7 +1324,8 @@ SF.AddHook("postload", function() return ( this.Throttle or 0 ) * 100 end - -- Sets the throttle value for an ACF engine + --- Sets the throttle value for an ACF engine + -- @server function ents_methods:acfSetThrottle ( throttle ) checktype( self, ents_metatable ) checkluatype( throttle, TYPE_NUMBER ) @@ -1307,7 +1341,8 @@ SF.AddHook("postload", function() -- [ Gearbox Functions ] -- - -- Returns true if the entity is an ACF gearbox + --- Returns true if the entity is an ACF gearbox + -- @server function ents_methods:acfIsGearbox () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1317,7 +1352,8 @@ SF.AddHook("postload", function() return isGearbox( this ) end - -- Returns the current gear for an ACF gearbox + --- Returns the current gear for an ACF gearbox + -- @server function ents_methods:acfGear () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1329,7 +1365,8 @@ SF.AddHook("postload", function() return this.Gear or 0 end - -- Returns the number of gears for an ACF gearbox + --- Returns the number of gears for an ACF gearbox + -- @server function ents_methods:acfNumGears () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1341,7 +1378,8 @@ SF.AddHook("postload", function() return this.Gears or 0 end - -- Returns the final ratio for an ACF gearbox + --- Returns the final ratio for an ACF gearbox + -- @server function ents_methods:acfFinalRatio () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1353,7 +1391,8 @@ SF.AddHook("postload", function() return this.GearTable[ "Final" ] or 0 end - -- Returns the total ratio (current gear * final) for an ACF gearbox + --- Returns the total ratio (current gear * final) for an ACF gearbox + -- @server function ents_methods:acfTotalRatio () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1365,7 +1404,8 @@ SF.AddHook("postload", function() return this.GearRatio or 0 end - -- Returns the max torque for an ACF gearbox + --- Returns the max torque for an ACF gearbox + -- @server function ents_methods:acfTorqueRating () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1376,7 +1416,8 @@ SF.AddHook("postload", function() return this.MaxTorque or 0 end - -- Returns whether an ACF gearbox is dual clutch + --- Returns whether an ACF gearbox is dual clutch + -- @server function ents_methods:acfIsDual () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1389,7 +1430,8 @@ SF.AddHook("postload", function() return this.Dual end - -- Returns the time in ms an ACF gearbox takes to change gears + --- Returns the time in ms an ACF gearbox takes to change gears + -- @server function ents_methods:acfShiftTime () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1400,7 +1442,8 @@ SF.AddHook("postload", function() return ( this.SwitchTime or 0 ) * 1000 end - -- Returns true if an ACF gearbox is in gear + --- Returns true if an ACF gearbox is in gear + -- @server function ents_methods:acfInGear () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1413,7 +1456,8 @@ SF.AddHook("postload", function() return this.InGear end - -- Returns the ratio for a specified gear of an ACF gearbox + --- Returns the ratio for a specified gear of an ACF gearbox + -- @server function ents_methods:acfGearRatio ( gear ) checktype( self, ents_metatable ) checkluatype( gear, TYPE_NUMBER ) @@ -1427,7 +1471,8 @@ SF.AddHook("postload", function() return this.GearTable[ g ] or 0 end - -- Returns the current torque output for an ACF gearbox + --- Returns the current torque output for an ACF gearbox + -- @server function ents_methods:acfTorqueOut () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1438,7 +1483,8 @@ SF.AddHook("postload", function() return math.min( this.TotalReqTq or 0, this.MaxTorque or 0 ) / ( this.GearRatio or 1 ) end - -- Sets the gear ratio of a CVT, set to 0 to use built-in algorithm + --- Sets the gear ratio of a CVT, set to 0 to use built-in algorithm + -- @server function ents_methods:acfCVTRatio ( ratio ) checktype( self, ents_metatable ) checkluatype( ratio, TYPE_NUMBER ) @@ -1453,7 +1499,8 @@ SF.AddHook("postload", function() this.CVTRatio = math.Clamp( ratio, 0, 1 ) end - -- Sets the current gear for an ACF gearbox + --- Sets the current gear for an ACF gearbox + -- @server function ents_methods:acfShift ( gear ) checktype( self, ents_metatable ) checkluatype( gear, TYPE_NUMBER ) @@ -1467,7 +1514,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Gear", gear ) end - -- Cause an ACF gearbox to shift up + --- Cause an ACF gearbox to shift up + -- @server function ents_methods:acfShiftUp () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1480,7 +1528,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Gear Up", 1 ) --doesn't need to be toggled off end - -- Cause an ACF gearbox to shift down + --- Cause an ACF gearbox to shift down + -- @server function ents_methods:acfShiftDown () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1493,7 +1542,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Gear Down", 1 ) --doesn't need to be toggled off end - -- Sets the brakes for an ACF gearbox + --- Sets the brakes for an ACF gearbox + -- @server function ents_methods:acfBrake ( brake ) checktype( self, ents_metatable ) checkluatype( brake, TYPE_NUMBER ) @@ -1507,7 +1557,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Brake", brake ) end - -- Sets the left brakes for an ACF gearbox + --- Sets the left brakes for an ACF gearbox + -- @server function ents_methods:acfBrakeLeft ( brake ) checktype( self, ents_metatable ) checkluatype( brake, TYPE_NUMBER ) @@ -1522,7 +1573,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Left Brake", brake ) end - -- Sets the right brakes for an ACF gearbox + --- Sets the right brakes for an ACF gearbox + -- @server function ents_methods:acfBrakeRight ( brake ) checktype( self, ents_metatable ) checkluatype( brake, TYPE_NUMBER ) @@ -1537,7 +1589,8 @@ SF.AddHook("postload", function() this:TriggerInput("Right Brake", brake ) end - -- Sets the clutch for an ACF gearbox + --- Sets the clutch for an ACF gearbox + -- @server function ents_methods:acfClutch ( clutch ) checktype( self, ents_metatable ) checkluatype( clutch, TYPE_NUMBER ) @@ -1551,7 +1604,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Clutch", clutch ) end - -- Sets the left clutch for an ACF gearbox + --- Sets the left clutch for an ACF gearbox + -- @server function ents_methods:acfClutchLeft( clutch ) checktype( self, ents_metatable ) checkluatype( clutch, TYPE_NUMBER ) @@ -1566,7 +1620,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Left Clutch", clutch ) end - -- Sets the right clutch for an ACF gearbox + --- Sets the right clutch for an ACF gearbox + -- @server function ents_methods:acfClutchRight ( clutch ) checktype( self, ents_metatable ) checkluatype( clutch, TYPE_NUMBER ) @@ -1581,7 +1636,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Right Clutch", clutch ) end - -- Sets the steer ratio for an ACF gearbox + --- Sets the steer ratio for an ACF gearbox + -- @server function ents_methods:acfSteerRate ( rate ) checktype( self, ents_metatable ) checkluatype( rate, TYPE_NUMBER ) @@ -1596,7 +1652,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Steer Rate", rate ) end - -- Applies gear hold for an automatic ACF gearbox + --- Applies gear hold for an automatic ACF gearbox + -- @server function ents_methods:acfHoldGear( hold ) checktype( self, ents_metatable ) checkluatype( hold, TYPE_NUMBER ) @@ -1611,7 +1668,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Hold Gear", hold ) end - -- Sets the shift point scaling for an automatic ACF gearbox + --- Sets the shift point scaling for an automatic ACF gearbox + -- @server function ents_methods:acfShiftPointScale( scale ) checktype( self, ents_metatable ) checkluatype( scale, TYPE_NUMBER ) @@ -1629,7 +1687,8 @@ SF.AddHook("postload", function() -- [ Gun Functions ] -- - -- Returns true if the entity is an ACF gun + --- Returns true if the entity is an ACF gun + -- @server function ents_methods:acfIsGun () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1639,7 +1698,8 @@ SF.AddHook("postload", function() if isGun( this ) and not restrictInfo( this ) then return true else return false end end - -- Returns true if the ACF gun is ready to fire + --- Returns true if the ACF gun is ready to fire + -- @server function ents_methods:acfReady () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1652,7 +1712,8 @@ SF.AddHook("postload", function() return false end - -- Returns the magazine size for an ACF gun + --- Returns the magazine size for an ACF gun + -- @server function ents_methods:acfMagSize () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1663,7 +1724,8 @@ SF.AddHook("postload", function() return this.MagSize or 1 end - -- Returns the spread for an ACF gun or flechette ammo + --- Returns the spread for an ACF gun or flechette ammo + -- @server function ents_methods:acfSpread () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1679,7 +1741,8 @@ SF.AddHook("postload", function() return Spread end - -- Returns true if an ACF gun is reloading + --- Returns true if an ACF gun is reloading + -- @server function ents_methods:acfIsReloading () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1692,7 +1755,8 @@ SF.AddHook("postload", function() return false end - -- Returns the rate of fire of an acf gun + --- Returns the rate of fire of an acf gun + -- @server function ents_methods:acfFireRate () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1703,7 +1767,8 @@ SF.AddHook("postload", function() return math.Round( this.RateOfFire or 0, 3 ) end - -- Returns the number of rounds left in a magazine for an ACF gun + --- Returns the number of rounds left in a magazine for an ACF gun + -- @server function ents_methods:acfMagRounds () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1719,7 +1784,8 @@ SF.AddHook("postload", function() return 0 end - -- Sets the firing state of an ACF weapon + --- Sets the firing state of an ACF weapon + -- @server function ents_methods:acfFire ( fire ) checktype( self, ents_metatable ) checkluatype( fire, TYPE_NUMBER ) @@ -1733,7 +1799,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Fire", fire ) end - -- Causes an ACF weapon to unload + --- Causes an ACF weapon to unload + -- @server function ents_methods:acfUnload () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1746,7 +1813,8 @@ SF.AddHook("postload", function() this:UnloadAmmo() end - -- Causes an ACF weapon to reload + --- Causes an ACF weapon to reload + -- @server function ents_methods:acfReload () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1759,7 +1827,8 @@ SF.AddHook("postload", function() this.Reloading = true end - --Returns the number of rounds in active ammo crates linked to an ACF weapon + --- Returns the number of rounds in active ammo crates linked to an ACF weapon + -- @server function ents_methods:acfAmmoCount () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1777,7 +1846,8 @@ SF.AddHook("postload", function() return Ammo end - --Returns the number of rounds in all ammo crates linked to an ACF weapon + --- Returns the number of rounds in all ammo crates linked to an ACF weapon + -- @server function ents_methods:acfTotalAmmoCount () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1795,7 +1865,8 @@ SF.AddHook("postload", function() return Ammo end - -- Returns time to next shot of an ACF weapon + --- Returns time to next shot of an ACF weapon + -- @server function ents_methods:acfReloadTime () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1806,7 +1877,8 @@ SF.AddHook("postload", function() return reloadTime( this ) end - -- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars + --- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars + -- @server function ents_methods:acfReloadProgress () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1817,7 +1889,8 @@ SF.AddHook("postload", function() return math.Clamp( 1 - (this.NextFire - CurTime()) / reloadTime( this ), 0, 1 ) end - -- Returns time it takes for an ACF weapon to reload magazine + --- Returns time it takes for an ACF weapon to reload magazine + -- @server function ents_methods:acfMagReloadTime () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1830,7 +1903,8 @@ SF.AddHook("postload", function() -- [ Ammo Functions ] -- - -- Returns true if the entity is an ACF ammo crate + --- Returns true if the entity is an ACF ammo crate + -- @server function ents_methods:acfIsAmmo () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1840,7 +1914,8 @@ SF.AddHook("postload", function() return isAmmo( this ) and not restrictInfo( this ) end - -- Returns the rounds left in an acf ammo crate + --- Returns the rounds left in an acf ammo crate + -- @server function ents_methods:acfRounds () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1852,7 +1927,8 @@ SF.AddHook("postload", function() return this.Ammo or 0 end - -- Returns the type of weapon the ammo in an ACF ammo crate loads into + --- Returns the type of weapon the ammo in an ACF ammo crate loads into + -- @server function ents_methods:acfRoundType () --cartridge? checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1865,7 +1941,8 @@ SF.AddHook("postload", function() return this.RoundType or "" -- E2 uses this one now end - -- Returns the type of ammo in a crate or gun + --- Returns the type of ammo in a crate or gun + -- @server function ents_methods:acfAmmoType () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1877,7 +1954,8 @@ SF.AddHook("postload", function() return this.BulletData[ "Type" ] or "" end - -- Returns the caliber of an ammo or gun + --- Returns the caliber of an ammo or gun + -- @server function ents_methods:acfCaliber () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1889,7 +1967,8 @@ SF.AddHook("postload", function() return ( this.Caliber or 0 ) * 10 end - -- Returns the muzzle velocity of the ammo in a crate or gun + --- Returns the muzzle velocity of the ammo in a crate or gun + -- @server function ents_methods:acfMuzzleVel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1901,7 +1980,8 @@ SF.AddHook("postload", function() return math.Round( ( this.BulletData[ "MuzzleVel" ] or 0 ) * ACF.VelScale, 3 ) end - -- Returns the mass of the projectile in a crate or gun + --- Returns the mass of the projectile in a crate or gun + -- @server function ents_methods:acfProjectileMass () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1913,7 +1993,8 @@ SF.AddHook("postload", function() return math.Round( this.BulletData[ "ProjMass" ] or 0, 3 ) end - -- Returns the number of projectiles in a flechette round + --- Returns the number of projectiles in a flechette round + -- @server function ents_methods:acfFLSpikes () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1926,7 +2007,8 @@ SF.AddHook("postload", function() return this.BulletData[ "Flechettes" ] or 0 end - -- Returns the mass of a single spike in a FL round in a crate or gun + --- Returns the mass of a single spike in a FL round in a crate or gun + -- @server function ents_methods:acfFLSpikeMass () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1939,7 +2021,8 @@ SF.AddHook("postload", function() return math.Round( this.BulletData[ "FlechetteMass" ] or 0, 3) end - -- Returns the radius of the spikes in a flechette round in mm + --- Returns the radius of the spikes in a flechette round in mm + -- @server function ents_methods:acfFLSpikeRadius () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1952,7 +2035,8 @@ SF.AddHook("postload", function() return math.Round( ( this.BulletData[ "FlechetteRadius" ] or 0 ) * 10, 3) end - -- Returns the penetration of an AP, APHE, or HEAT round + --- Returns the penetration of an AP, APHE, or HEAT round + -- @server function ents_methods:acfPenetration () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -1991,7 +2075,8 @@ SF.AddHook("postload", function() return 0 end - -- Returns the blast radius of an HE, APHE, or HEAT round + --- Returns the blast radius of an HE, APHE, or HEAT round + -- @server function ents_methods:acfBlastRadius () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2024,7 +2109,8 @@ SF.AddHook("postload", function() -- [ Armor Functions ] -- - -- Returns the current health of an entity + --- Returns the current health of an entity + -- @server function ents_methods:acfPropHealth () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2037,7 +2123,8 @@ SF.AddHook("postload", function() return math.Round( this.ACF.Health or 0, 3 ) end - -- Returns the current armor of an entity + --- Returns the current armor of an entity + -- @server function ents_methods:acfPropArmor () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2050,7 +2137,8 @@ SF.AddHook("postload", function() return math.Round( this.ACF.Armour or 0, 3 ) end - -- Returns the max health of an entity + --- Returns the max health of an entity + -- @server function ents_methods:acfPropHealthMax () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2063,7 +2151,8 @@ SF.AddHook("postload", function() return math.Round( this.ACF.MaxHealth or 0, 3 ) end - -- Returns the max armor of an entity + --- Returns the max armor of an entity + -- @server function ents_methods:acfPropArmorMax () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2076,7 +2165,8 @@ SF.AddHook("postload", function() return math.Round( this.ACF.MaxArmour or 0, 3 ) end - -- Returns the ductility of an entity + --- Returns the ductility of an entity + -- @server function ents_methods:acfPropDuctility () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2091,7 +2181,8 @@ SF.AddHook("postload", function() -- [ Fuel Functions ] -- - -- Returns true if the entity is an ACF fuel tank + --- Returns true if the entity is an ACF fuel tank + -- @server function ents_methods:acfIsFuel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2101,7 +2192,8 @@ SF.AddHook("postload", function() return isFuel( this ) and not restrictInfo( this ) end - -- Returns true if the current engine requires fuel to run + --- Returns true if the current engine requires fuel to run + -- @server function ents_methods:acfFuelRequired () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2113,7 +2205,8 @@ SF.AddHook("postload", function() return ( this.RequiresFuel and true ) or false end - -- Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks + --- Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks + -- @server function ents_methods:acfRefuelDuty ( on ) checktype( self, ents_metatable ) checktype( on, "boolean" ) @@ -2127,7 +2220,8 @@ SF.AddHook("postload", function() this:TriggerInput( "Refuel Duty", on ) end - -- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine + --- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine + -- @server function ents_methods:acfFuel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2152,7 +2246,8 @@ SF.AddHook("postload", function() return 0 end - -- Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity + --- Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity + -- @server function ents_methods:acfFuelLevel () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2181,7 +2276,8 @@ SF.AddHook("postload", function() return 0 end - -- Returns the current fuel consumption in liters per minute or kilowatts of an engine + --- Returns the current fuel consumption in liters per minute or kilowatts of an engine + -- @server function ents_methods:acfFuelUse () checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2211,7 +2307,8 @@ SF.AddHook("postload", function() return math.Round( Consumption, 3 ) end - -- Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using + --- Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using + -- @server function ents_methods:acfPeakFuelUse () checktype( self, ents_metatable ) local this = unwrap( self ) From 6403c80366969959e33d7a0b568b8c791cabb9d2 Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Fri, 23 Aug 2019 06:53:50 +0200 Subject: [PATCH 3/7] Fixed acfRefuelDuty --- lua/starfall/libs_sv/acffunctions.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua index 2261eecd6..83e04a089 100755 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -2209,7 +2209,6 @@ SF.AddHook("postload", function() -- @server function ents_methods:acfRefuelDuty ( on ) checktype( self, ents_metatable ) - checktype( on, "boolean" ) local this = unwrap( self ) if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end @@ -2217,7 +2216,7 @@ SF.AddHook("postload", function() if not isFuel( this ) then return end - this:TriggerInput( "Refuel Duty", on ) + this:TriggerInput( "Refuel Duty", on and true or false ) end --- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine From 0571534f54c4acb5eba7222abb76971169a1c4fd Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Sat, 24 Aug 2019 17:15:00 +0200 Subject: [PATCH 4/7] Reenabld acfDragCoef --- lua/starfall/libs_cl/docs.lua | 6 ++++-- lua/starfall/libs_sv/acffunctions.lua | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/starfall/libs_cl/docs.lua b/lua/starfall/libs_cl/docs.lua index 2722186a7..8beade794 100644 --- a/lua/starfall/libs_cl/docs.lua +++ b/lua/starfall/libs_cl/docs.lua @@ -2,7 +2,7 @@ -- Sadly we cant have it in the fancy helper but it will work in the old one and syntax highlighting table.Merge(SF.Docs, {["classes"]={[1]="Entity";["Entity"]={["class"]="class";["classForced"]=true;["description"]="\ -Entity type";["fields"]={};["methods"]={[1]="acfAmmoCount";[10]="acfClutch";[11]="acfClutchLeft";[12]="acfClutchRight";[13]="acfFLSpikeMass";[14]="acfFLSpikeRadius";[15]="acfFLSpikes";[16]="acfFinalRatio";[17]="acfFire";[18]="acfFireRate";[19]="acfFlyInertia";[2]="acfAmmoType";[20]="acfFlyMass";[21]="acfFuel";[22]="acfFuelLevel";[23]="acfFuelRequired";[24]="acfFuelUse";[25]="acfGear";[26]="acfGearRatio";[27]="acfGetActive";[28]="acfGetLinkedWheels";[29]="acfGetThrottle";[3]="acfBlastRadius";[30]="acfHitClip";[31]="acfHoldGear";[32]="acfIdleRPM";[33]="acfInGear";[34]="acfInPowerband";[35]="acfIsAmmo";[36]="acfIsDual";[37]="acfIsElectric";[38]="acfIsEngine";[39]="acfIsFuel";[4]="acfBrake";[40]="acfIsGearbox";[41]="acfIsGun";[42]="acfIsInfoRestricted";[43]="acfIsReloading";[44]="acfLinkTo";[45]="acfLinks";[46]="acfMagReloadTime";[47]="acfMagRounds";[48]="acfMagSize";[49]="acfMaxPower";[5]="acfBrakeLeft";[50]="acfMaxPowerWithFuel";[51]="acfMaxTorque";[52]="acfMaxTorqueWithFuel";[53]="acfMuzzleVel";[54]="acfName";[55]="acfNameShort";[56]="acfNumGears";[57]="acfPeakFuelUse";[58]="acfPenetration";[59]="acfPower";[6]="acfBrakeRight";[60]="acfPowerband";[61]="acfPowerbandMax";[62]="acfPowerbandMin";[63]="acfProjectileMass";[64]="acfPropArmor";[65]="acfPropArmorMax";[66]="acfPropDuctility";[67]="acfPropHealth";[68]="acfPropHealthMax";[69]="acfRPM";[7]="acfCVTRatio";[70]="acfReady";[71]="acfRedline";[72]="acfRefuelDuty";[73]="acfReload";[74]="acfReloadProgress";[75]="acfReloadTime";[76]="acfRoundType";[77]="acfRounds";[78]="acfSetActive";[79]="acfSetThrottle";[8]="acfCaliber";[80]="acfShift";[81]="acfShiftDown";[82]="acfShiftPointScale";[83]="acfShiftTime";[84]="acfShiftUp";[85]="acfSpread";[86]="acfSteerRate";[87]="acfTorque";[88]="acfTorqueOut";[89]="acfTorqueRating";[9]="acfCapacity";[90]="acfTotalAmmoCount";[91]="acfTotalRatio";[92]="acfType";[93]="acfUnlinkFrom";[94]="acfUnload";["acfAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Entity type";["fields"]={};["methods"]={[1]="acfAmmoCount";[10]="acfClutch";[11]="acfClutchLeft";[12]="acfClutchRight";[13]="acfDragCoef";[14]="acfFLSpikeMass";[15]="acfFLSpikeRadius";[16]="acfFLSpikes";[17]="acfFinalRatio";[18]="acfFire";[19]="acfFireRate";[2]="acfAmmoType";[20]="acfFlyInertia";[21]="acfFlyMass";[22]="acfFuel";[23]="acfFuelLevel";[24]="acfFuelRequired";[25]="acfFuelUse";[26]="acfGear";[27]="acfGearRatio";[28]="acfGetActive";[29]="acfGetLinkedWheels";[3]="acfBlastRadius";[30]="acfGetThrottle";[31]="acfHitClip";[32]="acfHoldGear";[33]="acfIdleRPM";[34]="acfInGear";[35]="acfInPowerband";[36]="acfIsAmmo";[37]="acfIsDual";[38]="acfIsElectric";[39]="acfIsEngine";[4]="acfBrake";[40]="acfIsFuel";[41]="acfIsGearbox";[42]="acfIsGun";[43]="acfIsInfoRestricted";[44]="acfIsReloading";[45]="acfLinkTo";[46]="acfLinks";[47]="acfMagReloadTime";[48]="acfMagRounds";[49]="acfMagSize";[5]="acfBrakeLeft";[50]="acfMaxPower";[51]="acfMaxPowerWithFuel";[52]="acfMaxTorque";[53]="acfMaxTorqueWithFuel";[54]="acfMuzzleVel";[55]="acfName";[56]="acfNameShort";[57]="acfNumGears";[58]="acfPeakFuelUse";[59]="acfPenetration";[6]="acfBrakeRight";[60]="acfPower";[61]="acfPowerband";[62]="acfPowerbandMax";[63]="acfPowerbandMin";[64]="acfProjectileMass";[65]="acfPropArmor";[66]="acfPropArmorMax";[67]="acfPropDuctility";[68]="acfPropHealth";[69]="acfPropHealthMax";[7]="acfCVTRatio";[70]="acfRPM";[71]="acfReady";[72]="acfRedline";[73]="acfRefuelDuty";[74]="acfReload";[75]="acfReloadProgress";[76]="acfReloadTime";[77]="acfRoundType";[78]="acfRounds";[79]="acfSetActive";[8]="acfCaliber";[80]="acfSetThrottle";[81]="acfShift";[82]="acfShiftDown";[83]="acfShiftPointScale";[84]="acfShiftTime";[85]="acfShiftUp";[86]="acfSpread";[87]="acfSteerRate";[88]="acfTorque";[89]="acfTorqueOut";[9]="acfCapacity";[90]="acfTorqueRating";[91]="acfTotalAmmoCount";[92]="acfTotalRatio";[93]="acfType";[94]="acfUnlinkFrom";[95]="acfUnload";["acfAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ Returns the number of rounds in active ammo crates linked to an ACF weapon";["fname"]="acfAmmoCount";["name"]="ents_methods:acfAmmoCount";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ Returns the number of rounds in active ammo crates linked to an ACF weapon ";};["acfAmmoType"]={["class"]="function";["classlib"]="Entity";["description"]="\ Returns the type of ammo in a crate or gun";["fname"]="acfAmmoType";["name"]="ents_methods:acfAmmoType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ @@ -26,7 +26,9 @@ Sets the clutch for an ACF gearbox ";};["acfClutchLeft"]={["class"]="function";[ Sets the left clutch for an ACF gearbox";["fname"]="acfClutchLeft";["name"]="ents_methods:acfClutchLeft";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ Sets the left clutch for an ACF gearbox ";};["acfClutchRight"]={["class"]="function";["classlib"]="Entity";["description"]="\ Sets the right clutch for an ACF gearbox";["fname"]="acfClutchRight";["name"]="ents_methods:acfClutchRight";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the right clutch for an ACF gearbox ";};["acfFLSpikeMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Sets the right clutch for an ACF gearbox ";};["acfDragCoef"]={["class"]="function";["classlib"]="Entity";["description"]="\ +Returns the drag coef of the ammo in a crate or gun";["fname"]="acfDragCoef";["name"]="ents_methods:acfDragCoef";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ +Returns the drag coef of the ammo in a crate or gun ";};["acfFLSpikeMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ Returns the mass of a single spike in a FL round in a crate or gun";["fname"]="acfFLSpikeMass";["name"]="ents_methods:acfFLSpikeMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ Returns the mass of a single spike in a FL round in a crate or gun ";};["acfFLSpikeRadius"]={["class"]="function";["classlib"]="Entity";["description"]="\ Returns the radius of the spikes in a flechette round in mm";["fname"]="acfFLSpikeRadius";["name"]="ents_methods:acfFLSpikeRadius";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua index 83e04a089..77761dd87 100755 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -188,7 +188,7 @@ function acf_library.createMobility(pos, ang, id, frozen, gear_ratio) args_table[3 + i] = type(gear_ratio[i]) == "number" and gear_ratio[i] or (i < type_id.gears and i / 10 or -0.1) end - args_table[13] = gear_ratio[-1] or 0.5 + args_table[13] = type(gear_ratio[-1]) == "number" and gear_ratio[-1] or 0.5 end local ent = dupe_class.Func(ply, unpack(args_table)) @@ -2094,9 +2094,9 @@ SF.AddHook("postload", function() return 0 end - -- Returns the drag coef of the ammo in a crate or gun - -- E2 doesnt have this function (anymore), no clue why but i guess i will comment it out - --[[function ents_methods:acfDragCoef() + --- Returns the drag coef of the ammo in a crate or gun + -- @server + function ents_methods:acfDragCoef() checktype( self, ents_metatable ) local this = unwrap( self ) @@ -2105,7 +2105,7 @@ SF.AddHook("postload", function() if not ( isAmmo( this ) or isGun( this ) ) then return 0 end if restrictInfo( this ) then return 0 end return ( this.BulletData[ "DragCoef" ] or 0 ) / ACF.DragDiv - end]] + end -- [ Armor Functions ] -- From 2d00ac8d2a1af9eb0838d0036ce1e2d2eaed10c1 Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Sat, 25 Jan 2020 19:32:19 +0100 Subject: [PATCH 5/7] Updated to newest version of StarfallEX --- lua/starfall/libs_cl/docs.lua | 4 +- lua/starfall/libs_sv/acffunctions.lua | 2461 ++++++++++++------------- 2 files changed, 1230 insertions(+), 1235 deletions(-) mode change 100755 => 100644 lua/starfall/libs_sv/acffunctions.lua diff --git a/lua/starfall/libs_cl/docs.lua b/lua/starfall/libs_cl/docs.lua index 8beade794..4c54e8f62 100644 --- a/lua/starfall/libs_cl/docs.lua +++ b/lua/starfall/libs_cl/docs.lua @@ -284,4 +284,6 @@ Returns the specs of the engine or gearbox ";};["infoRestricted"]={["class"]="fu Returns true if functions returning sensitive info are restricted to owned props";["fname"]="infoRestricted";["library"]="acf";["name"]="acf_library.infoRestricted";["param"]={};["private"]=false;["realm"]="sv";["ret"]="True if restriced, False if not";["server"]=true;["summary"]="\ Returns true if functions returning sensitive info are restricted to owned props ";};};["libtbl"]="acf_library";["name"]="acf";["summary"]="\ \ -ACF Library ";["tables"]={};};};}) \ No newline at end of file +ACF Library ";["tables"]={};};};}) + +return function() end diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua old mode 100755 new mode 100644 index 77761dd87..907fcc624 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -18,6 +18,19 @@ -- #fuel +local checkluatype = SF.CheckLuaType +local checkpermission = SF.Permissions.check +local registerprivilege = SF.Permissions.registerPrivilege + +registerprivilege("acf.createMobility", "Create acf engine", "Allows the user to create ACF engines and gearboxes") +registerprivilege("acf.createFuelTank", "Create acf fuel tank", "Allows the user to create ACF fuel tanks") +registerprivilege("acf.createGun", "Create acf gun", "Allows the user to create ACF guns") +registerprivilege("acf.createAmmo", "Create acf ammo", "Allows the user to create ACF ammoboxes") +registerprivilege("entities.acf", "ACF", "Allows the user to control ACF components", { entities = {} }) + +local plyCount = SF.LimitObject("acf_components", "acf_components", -1, "The number of ACF components allowed to spawn via Starfall") +local plyBurst = SF.BurstObject("acf_components", "acf_components", 4, 4, "Rate ACF components can be spawned per second.", "Number of ACF components that can be spawned in a short time.") + -- [ Helper Functions ] -- local function isEngine ( ent ) @@ -52,33 +65,29 @@ end local propProtectionInstalled = FindMetaTable("Entity").CPPIGetOwner and true -local function restrictInfo ( ent ) - if not propProtectionInstalled then return false end - if GetConVar("sbox_acf_restrictinfo"):GetInt() ~= 0 then - if ent:CPPIGetOwner() ~= SF.instance.player then return true else return false end - end - return false -end - ---------------------------------------- -- ACF Library +SF.RegisterLibrary("acf") -local acf_library = SF.RegisterLibrary("acf") +-- Local to each starfall +return function(instance) -- Called for library declarations -local checktype = SF.CheckType -local checkluatype = SF.CheckLuaType -local checkpermission = SF.Permissions.check -local ents_metatable, ents_methods, vec_meta, ang_meta, wrap, unwrap, vwrap, vunwrap, awrap, aunwrap +local checktype = instance.CheckType +local acf_library = instance.Libraries.acf +local owrap, ounwrap = instance.WrapObject, instance.UnwrapObject +local ents_methods, ent_meta, ewrap, eunwrap = instance.Types.Entity.Methods, instance.Types.Entity, instance.Types.Entity.Wrap, instance.Types.Entity.Unwrap +local ang_meta, awrap, aunwrap = instance.Types.Angle, instance.Types.Angle.Wrap, instance.Types.Angle.Unwrap +local vec_meta, vwrap, vunwrap = instance.Types.Vector, instance.Types.Vector.Wrap, instance.Types.Vector.Unwrap -SF.Permissions.registerPrivilege("acf.createMobility", "Create acf engine", "Allows the user to create ACF engines and gearboxes") -SF.Permissions.registerPrivilege("acf.createFuelTank", "Create acf fuel tank", "Allows the user to create ACF fuel tanks") -SF.Permissions.registerPrivilege("acf.createGun", "Create acf gun", "Allows the user to create ACF guns") -SF.Permissions.registerPrivilege("acf.createAmmo", "Create acf ammo", "Allows the user to create ACF ammoboxes") -SF.Permissions.registerPrivilege("entities.acf", "ACF", "Allows the user to control ACF components", { entities = {} }) -local plyCount = SF.LimitObject("acf_components", "acf_components", -1, "The number of ACF components allowed to spawn via Starfall") -local plyBurst = SF.BurstObject("acf_components", "acf_components", 4, 4, "Rate ACF components can be spawned per second.", "Number of ACF components that can be spawned in a short time.") +local function restrictInfo ( ent ) + if not propProtectionInstalled then return false end + if GetConVar("sbox_acf_restrictinfo"):GetInt() ~= 0 then + if ent:CPPIGetOwner() ~= instance.player then return true else return false end + end + return false +end local function propOnDestroy(ent, instance) local ply = instance.player @@ -92,6 +101,7 @@ local function register(ent, instance) instance.data.props.props[ent] = true end + --- Returns true if functions returning sensitive info are restricted to owned props -- @server -- @return True if restriced, False if not @@ -141,9 +151,8 @@ end -- @server -- @return The created engine or gearbox function acf_library.createMobility(pos, ang, id, frozen, gear_ratio) - checkpermission(SF.instance, nil, "acf.createMobility") + checkpermission(instance, nil, "acf.createMobility") - local instance = SF.instance local ply = instance.player if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end @@ -209,7 +218,7 @@ function acf_library.createMobility(pos, ang, id, frozen, gear_ratio) ply:AddCleanup("props", ent) register(ent, instance) - return SF.WrapObject(ent) + return owrap(ent) end --- Returns the specs of the engine or gearbox @@ -289,9 +298,8 @@ end -- @server -- @return The created fuel tank function acf_library.createFuelTank(pos, ang, id, fueltype, frozen) - checkpermission(SF.instance, nil, "acf.createFuelTank") + checkpermission(instance, nil, "acf.createFuelTank") - local instance = SF.instance local ply = instance.player if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end @@ -337,7 +345,7 @@ function acf_library.createFuelTank(pos, ang, id, fueltype, frozen) ply:AddCleanup("props", ent) register(ent, instance) - return SF.WrapObject(ent) + return owrap(ent) end --- Returns the specs of the fuel tank @@ -377,9 +385,8 @@ end -- @server -- @return The created gun function acf_library.createGun(pos, ang, id, frozen) - checkpermission(SF.instance, nil, "acf.createGun") + checkpermission(instance, nil, "acf.createGun") - local instance = SF.instance local ply = instance.player if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end @@ -430,7 +437,7 @@ function acf_library.createGun(pos, ang, id, frozen) ply:AddCleanup("props", ent) register(ent, instance) - return SF.WrapObject(ent) + return owrap(ent) end --- Returns the specs of gun @@ -663,9 +670,8 @@ ammo_properties.Refill.create_data = {} -- Refil: -- function acf_library.createAmmo(pos, ang, id, gun_id, ammo_id, frozen, ammo_data) - checkpermission(SF.instance, nil, "acf.createAmmo") + checkpermission(instance, nil, "acf.createAmmo") - local instance = SF.instance local ply = instance.player if not hook.Run("CanTool", ply, {Hit = true, Entity = game.GetWorld()}, "acfmenu") then SF.Throw("No permission to spawn ACF components", 2) end @@ -751,7 +757,7 @@ function acf_library.createAmmo(pos, ang, id, gun_id, ammo_id, frozen, ammo_data ply:AddCleanup("props", ent) register(ent, instance) - return SF.WrapObject(ent) + return owrap(ent) end --- Returns the specs of the ammo @@ -810,1528 +816,1515 @@ end ---------------------------------------- -- Entity Methods -SF.AddHook("postload", function() - ents_metatable = SF.Entities.Metatable - ents_methods = SF.Entities.Methods - - vec_meta = SF.Vectors.Metatable - ang_meta = SF.Angles.Metatable - - wrap = SF.Entities.Wrap - unwrap = SF.Entities.Unwrap - vwrap = SF.Vectors.Wrap - vunwrap = SF.Vectors.Unwrap - awrap = SF.Angles.Wrap - aunwrap = SF.Angles.Unwrap - - -- [General Functions ] -- +-- [General Functions ] -- - -- Moved to acf lib - -- Returns true if functions returning sensitive info are restricted to owned props - --[[function ents_methods:acfInfoRestricted () - return GetConVar( "sbox_acf_restrictinfo" ):GetInt() ~= 0 - end]] +-- Moved to acf lib +-- Returns true if functions returning sensitive info are restricted to owned props +--[[function ents_methods:acfInfoRestricted () + return GetConVar( "sbox_acf_restrictinfo" ):GetInt() ~= 0 +end]] - --- Returns true if this entity contains sensitive info and is not accessable to us - -- @server - function ents_methods:acfIsInfoRestricted () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if this entity contains sensitive info and is not accessable to us +-- @server +function ents_methods:acfIsInfoRestricted () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - return restrictInfo( this ) - end + return restrictInfo( this ) +end - --- Returns the short name of an ACF entity - -- @server - function ents_methods:acfNameShort () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the short name of an ACF entity +-- @server +function ents_methods:acfNameShort () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if isEngine( this ) then return this.Id or "" end - if isGearbox( this ) then return this.Id or "" end - if isGun( this ) then return this.Id or "" end - if isAmmo( this ) then return this.RoundId or "" end - if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end - - return "" - end + if isEngine( this ) then return this.Id or "" end + if isGearbox( this ) then return this.Id or "" end + if isGun( this ) then return this.Id or "" end + if isAmmo( this ) then return this.RoundId or "" end + if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end + + return "" +end - --- Returns the capacity of an acf ammo crate or fuel tank - -- @server - function ents_methods:acfCapacity () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the capacity of an acf ammo crate or fuel tank +-- @server +function ents_methods:acfCapacity () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isFuel( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.Capacity or 1 - end + if not ( isAmmo( this ) or isFuel( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.Capacity or 1 +end - --- Returns true if the acf engine, fuel tank, or ammo crate is active - -- @server - function ents_methods:acfGetActive () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if the acf engine, fuel tank, or ammo crate is active +-- @server +function ents_methods:acfGetActive () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return false end - if restrictInfo( this ) then return false end - if not isAmmo( this ) then - if this.Active then return true end - else - if this.Load then return true end - end - return false + if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return false end + if restrictInfo( this ) then return false end + if not isAmmo( this ) then + if this.Active then return true end + else + if this.Load then return true end end + return false +end - --- Turns an ACF engine, ammo crate, or fuel tank on or off - -- @server - function ents_methods:acfSetActive ( on ) - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Turns an ACF engine, ammo crate, or fuel tank on or off +-- @server +function ents_methods:acfSetActive ( on ) + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return end - this:TriggerInput( "Active", on and 1 or 0 ) - end + if not ( isEngine( this ) or isAmmo( this ) or isFuel( this ) ) then return end + this:TriggerInput( "Active", on and 1 or 0 ) +end - --- Returns true if hitpos is on a clipped part of prop - -- @server - function ents_methods:acfHitClip( hitpos ) - checktype( self, ents_metatable ) - checktype( hitpos, vec_meta ) - local this = unwrap( self ) - local hitpos = vunwrap( hitpos ) +--- Returns true if hitpos is on a clipped part of prop +-- @server +function ents_methods:acfHitClip( hitpos ) + checktype( self, ents_metatable ) + checktype( hitpos, vec_meta ) + local this = unwrap( self ) + local hitpos = vunwrap( hitpos ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) -- E2 has owner check so i guess having a check if the player has permission is sufficient enough? + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) -- E2 has owner check so i guess having a check if the player has permission is sufficient enough? - if ACF_CheckClips( nil, nil, this, hitpos ) then return true else return false end - end + if ACF_CheckClips( nil, nil, this, hitpos ) then return true else return false end +end - local linkTables = - { -- link resources within each ent type. should point to an ent: true if adding link.Ent, false to add link itself - acf_engine = { GearLink = true, FuelLink = false }, - acf_gearbox = { WheelLink = true, Master = false }, - acf_fueltank = { Master = false }, - acf_gun = { AmmoLink = false }, - acf_ammo = { Master = false } - } +local linkTables = +{ -- link resources within each ent type. should point to an ent: true if adding link.Ent, false to add link itself + acf_engine = { GearLink = true, FuelLink = false }, + acf_gearbox = { WheelLink = true, Master = false }, + acf_fueltank = { Master = false }, + acf_gun = { AmmoLink = false }, + acf_ammo = { Master = false } +} - local function getLinks ( ent, enttype ) - local ret = {} - -- find the link resources available for this ent type - for entry, mode in pairs( linkTables[ enttype ] ) do - if not ent[ entry ] then error( "Couldn't find link resource " .. entry .. " for entity " .. tostring( ent ) ) return end +local function getLinks ( ent, enttype ) + local ret = {} + -- find the link resources available for this ent type + for entry, mode in pairs( linkTables[ enttype ] ) do + if not ent[ entry ] then error( "Couldn't find link resource " .. entry .. " for entity " .. tostring( ent ) ) return end - -- find all the links inside the resources - for _, link in pairs( ent[ entry ] ) do - ret[ #ret + 1 ] = mode and wrap( link.Ent ) or link - end + -- find all the links inside the resources + for _, link in pairs( ent[ entry ] ) do + ret[ #ret + 1 ] = mode and wrap( link.Ent ) or link end - - return ret end - local function searchForGearboxLinks ( ent ) - local boxes = ents.FindByClass( "acf_gearbox" ) + return ret +end + +local function searchForGearboxLinks ( ent ) + local boxes = ents.FindByClass( "acf_gearbox" ) - local ret = {} + local ret = {} - for _, box in pairs( boxes ) do - if IsValid( box ) then - for _, link in pairs( box.WheelLink ) do - if link.Ent == ent then - ret[ #ret + 1 ] = wrap( box ) - break - end + for _, box in pairs( boxes ) do + if IsValid( box ) then + for _, link in pairs( box.WheelLink ) do + if link.Ent == ent then + ret[ #ret + 1 ] = wrap( box ) + break end end end - - return ret end - --- Returns the ACF links associated with the entity - -- @server - function ents_methods:acfLinks () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return ret +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the ACF links associated with the entity +-- @server +function ents_methods:acfLinks () + checktype( self, ents_metatable ) + local this = unwrap( self ) - local enttype = this:GetClass() + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not linkTables[ enttype ] then - return searchForGearboxLinks( this ) - end + local enttype = this:GetClass() - return getLinks( this, enttype ) + if not linkTables[ enttype ] then + return searchForGearboxLinks( this ) end - --- Returns the full name of an ACF entity - -- @server - function ents_methods:acfName () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - - if isAmmo( this ) then return ( this.RoundId .. " " .. this.RoundType) end - if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end + return getLinks( this, enttype ) +end - local acftype = "" - if isEngine( this ) then acftype = "Mobility" end - if isGearbox( this ) then acftype = "Mobility" end - if isGun( this ) then acftype = "Guns" end - if ( acftype == "" ) then return "" end - local List = list.Get( "ACFEnts" ) - return List[ acftype ][ this.Id ][ "name" ] or "" - end +--- Returns the full name of an ACF entity +-- @server +function ents_methods:acfName () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if isAmmo( this ) then return ( this.RoundId .. " " .. this.RoundType) end + if isFuel( this ) then return this.FuelType .. " " .. this.SizeId end + + local acftype = "" + if isEngine( this ) then acftype = "Mobility" end + if isGearbox( this ) then acftype = "Mobility" end + if isGun( this ) then acftype = "Guns" end + if ( acftype == "" ) then return "" end + local List = list.Get( "ACFEnts" ) + return List[ acftype ][ this.Id ][ "name" ] or "" +end - --- Returns the type of ACF entity - -- @server - function ents_methods:acfType () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the type of ACF entity +-- @server +function ents_methods:acfType () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if isEngine( this ) or isGearbox( this ) then - local List = list.Get( "ACFEnts" ) - return List[ "Mobility" ][ this.Id ][ "category" ] or "" - end - if isGun( this ) then - local Classes = list.Get( "ACFClasses" ) - return Classes[ "GunClass" ][ this.Class ][ "name" ] or "" - end - if isAmmo( this ) then return this.RoundType or "" end - if isFuel( this ) then return this.FuelType or "" end - return "" + if isEngine( this ) or isGearbox( this ) then + local List = list.Get( "ACFEnts" ) + return List[ "Mobility" ][ this.Id ][ "category" ] or "" end - - --- Perform ACF links - -- @server - function ents_methods:acfLinkTo ( target, notify ) - checktype( self, ents_metatable ) - checktype( target, ents_metatable ) - - local this = unwrap( self ) - local tar = unwrap( target ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end - - checkpermission( SF.instance, this, "entities.acf" ) - checkpermission( SF.instance, tar, "entities.acf" ) - - if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then - SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) - end - - local success, msg = this:Link( tar ) - if notify then - ACF_SendNotify( self.player, success, msg ) - end - return success, msg + if isGun( this ) then + local Classes = list.Get( "ACFClasses" ) + return Classes[ "GunClass" ][ this.Class ][ "name" ] or "" end + if isAmmo( this ) then return this.RoundType or "" end + if isFuel( this ) then return this.FuelType or "" end + return "" +end - --- Perform ACF unlinks - -- @server - function ents_methods:acfUnlinkFrom ( target, notify ) - checktype( self, ents_metatable ) - checktype( target, ents_metatable ) - - local this = unwrap( self ) - local tar = unwrap( target ) +--- Perform ACF links +-- @server +function ents_methods:acfLinkTo ( target, notify ) + checktype( self, ents_metatable ) + checktype( target, ents_metatable ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end + local this = unwrap( self ) + local tar = unwrap( target ) - checkpermission( SF.instance, this, "entities.acf" ) - checkpermission( SF.instance, tar, "entities.acf" ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end - if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then - SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) - end + checkpermission( instance, this, "entities.acf" ) + checkpermission( instance, tar, "entities.acf" ) - local success, msg = this:Unlink( tar ) - if notify then - ACF_SendNotify( self.player, success, msg ) - end - return success, msg + if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then + SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) end - --- returns any wheels linked to this engine/gearbox or child gearboxes - -- @server - function ents_methods:acfGetLinkedWheels () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isEngine(this) or isGearbox(this) ) then SF.Throw( "Target must be a engine, or gearbox", 2 ) end - - local wheels = {} - for k, ent in pairs( ACF_GetLinkedWheels( this ) ) do - table.insert( wheels, wrap( ent ) ) - end - - return wheels + local success, msg = this:Link( tar ) + if notify then + ACF_SendNotify( self.player, success, msg ) end + return success, msg +end - -- [ Engine Functions ] -- - - --- Returns true if the entity is an ACF engine - -- @server - function ents_methods:acfIsEngine () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Perform ACF unlinks +-- @server +function ents_methods:acfUnlinkFrom ( target, notify ) + checktype( self, ents_metatable ) + checktype( target, ents_metatable ) - return isEngine( this ) - end + local this = unwrap( self ) + local tar = unwrap( target ) - --- Returns true if an ACF engine is electric - -- @server - function ents_methods:acfIsElectric () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( tar and tar:IsValid() ) then SF.Throw( "Invalid Link Entity", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + checkpermission( instance, tar, "entities.acf" ) - return this.iselec == true + if not ( isGun( this ) or isEngine( this ) or isGearbox( this ) ) then + SF.Throw( "Target must be a gun, engine, or gearbox", 2 ) end - --- Returns the torque in N/m of an ACF engine - -- @server - function ents_methods:acfMaxTorque () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - - if not isEngine( this ) then return 0 end - return this.PeakTorque or 0 + local success, msg = this:Unlink( tar ) + if notify then + ACF_SendNotify( self.player, success, msg ) end + return success, msg +end - --- Returns the torque in N/m of an ACF engine with fuel - -- @server - function ents_methods:acfMaxTorqueWithFuel () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- returns any wheels linked to this engine/gearbox or child gearboxes +-- @server +function ents_methods:acfGetLinkedWheels () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( isEngine(this) or isGearbox(this) ) then SF.Throw( "Target must be a engine, or gearbox", 2 ) end - if not isEngine( this ) then return 0 end - return (this.PeakTorque or 0) * (ACF.TorqueBoost or 0) + local wheels = {} + for k, ent in pairs( ACF_GetLinkedWheels( this ) ) do + table.insert( wheels, wrap( ent ) ) end - local function getMaxPower( ent ) - local peakpower - - if ent.iselec then - peakpower = math.floor( ent.PeakTorque * ent.LimitRPM / ( 4 * 9548.8 ) ) - else - peakpower = math.floor( ent.PeakTorque * ent.PeakMaxRPM / 9548.8 ) - end - - return peakpower or 0 - end - - --- Returns the power in kW of an ACF engine - -- @server - function ents_methods:acfMaxPower () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return wheels +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +-- [ Engine Functions ] -- - return isEngine( this ) and getMaxPower( this ) or 0 - end +--- Returns true if the entity is an ACF engine +-- @server +function ents_methods:acfIsEngine () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the power in kW of an ACF engine with fuel - -- @server - function ents_methods:acfMaxPowerWithFuel () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + return isEngine( this ) +end - return (isEngine( this ) and getMaxPower( this ) or 0) * (ACF.TorqueBoost or 0) - end +--- Returns true if an ACF engine is electric +-- @server +function ents_methods:acfIsElectric () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the idle rpm of an ACF engine - -- @server - function ents_methods:acfIdleRPM () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + return this.iselec == true +end - if not isEngine( this ) then return 0 end - return this.IdleRPM or 0 - end +--- Returns the torque in N/m of an ACF engine +-- @server +function ents_methods:acfMaxTorque () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the powerband min and max of an ACF Engine - -- @server - function ents_methods:acfPowerband () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end + return this.PeakTorque or 0 +end - if not isEngine( this ) then return 0, 0 end - return this.PeakMinRPM or 0, this.PeakMaxRPM or 0 - end +--- Returns the torque in N/m of an ACF engine with fuel +-- @server +function ents_methods:acfMaxTorqueWithFuel () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the powerband min of an ACF engine - -- @server - function ents_methods:acfPowerbandMin () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end + return (this.PeakTorque or 0) * (ACF.TorqueBoost or 0) +end - if not isEngine( this ) then return 0 end - return this.PeakMinRPM or 0 +local function getMaxPower( ent ) + local peakpower + + if ent.iselec then + peakpower = math.floor( ent.PeakTorque * ent.LimitRPM / ( 4 * 9548.8 ) ) + else + peakpower = math.floor( ent.PeakTorque * ent.PeakMaxRPM / 9548.8 ) end + + return peakpower or 0 +end - --- Returns the powerband max of an ACF engine - -- @server - function ents_methods:acfPowerbandMax () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the power in kW of an ACF engine +-- @server +function ents_methods:acfMaxPower () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return 0 end - return this.PeakMaxRPM or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the redline rpm of an ACF engine - -- @server - function ents_methods:acfRedline () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return isEngine( this ) and getMaxPower( this ) or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the power in kW of an ACF engine with fuel +-- @server +function ents_methods:acfMaxPowerWithFuel () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return 0 end - return this.LimitRPM or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the current rpm of an ACF engine - -- @server - function ents_methods:acfRPM () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return (isEngine( this ) and getMaxPower( this ) or 0) * (ACF.TorqueBoost or 0) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the idle rpm of an ACF engine +-- @server +function ents_methods:acfIdleRPM () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return math.floor( this.FlyRPM ) or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the current torque of an ACF engine - -- @server - function ents_methods:acfTorque () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0 end + return this.IdleRPM or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the powerband min and max of an ACF Engine +-- @server +function ents_methods:acfPowerband () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return math.floor( this.Torque or 0 ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the inertia of an ACF engine's flywheel - -- @server - function ents_methods:acfFlyInertia () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0, 0 end + return this.PeakMinRPM or 0, this.PeakMaxRPM or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the powerband min of an ACF engine +-- @server +function ents_methods:acfPowerbandMin () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return nil end - if restrictInfo( this ) then return 0 end - return this.Inertia or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the mass of an ACF engine's flywheel - -- @server - function ents_methods:acfFlyMass () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0 end + return this.PeakMinRPM or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the powerband max of an ACF engine +-- @server +function ents_methods:acfPowerbandMax () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return nil end - if restrictInfo( this ) then return 0 end - return this.Inertia / ( 3.1416 )^2 or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the current power of an ACF engine - -- @server - function ents_methods:acfPower () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0 end + return this.PeakMaxRPM or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the redline rpm of an ACF engine +-- @server +function ents_methods:acfRedline () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return math.floor( ( this.Torque or 0 ) * ( this.FlyRPM or 0 ) / 9548.8 ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns true if the RPM of an ACF engine is inside the powerband - -- @server - function ents_methods:acfInPowerband () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0 end + return this.LimitRPM or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the current rpm of an ACF engine +-- @server +function ents_methods:acfRPM () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return false end - if restrictInfo( this ) then return false end - if ( this.FlyRPM < this.PeakMinRPM ) then return false end - if ( this.FlyRPM > this.PeakMaxRPM ) then return false end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - return true - end + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return math.floor( this.FlyRPM ) or 0 +end - --- Returns the throttle value - -- @server - function ents_methods:acfGetThrottle () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the current torque of an ACF engine +-- @server +function ents_methods:acfTorque () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return ( this.Throttle or 0 ) * 100 - end + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return math.floor( this.Torque or 0 ) +end - --- Sets the throttle value for an ACF engine - -- @server - function ents_methods:acfSetThrottle ( throttle ) - checktype( self, ents_metatable ) - checkluatype( throttle, TYPE_NUMBER ) - local this = unwrap( self ) +--- Returns the inertia of an ACF engine's flywheel +-- @server +function ents_methods:acfFlyInertia () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isEngine( this ) then return end - this:TriggerInput( "Throttle", throttle ) - end + if not isEngine( this ) then return nil end + if restrictInfo( this ) then return 0 end + return this.Inertia or 0 +end +--- Returns the mass of an ACF engine's flywheel +-- @server +function ents_methods:acfFlyMass () + checktype( self, ents_metatable ) + local this = unwrap( self ) - -- [ Gearbox Functions ] -- + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns true if the entity is an ACF gearbox - -- @server - function ents_methods:acfIsGearbox () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return nil end + if restrictInfo( this ) then return 0 end + return this.Inertia / ( 3.1416 )^2 or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the current power of an ACF engine +-- @server +function ents_methods:acfPower () + checktype( self, ents_metatable ) + local this = unwrap( self ) - return isGearbox( this ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the current gear for an ACF gearbox - -- @server - function ents_methods:acfGear () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return math.floor( ( this.Torque or 0 ) * ( this.FlyRPM or 0 ) / 9548.8 ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns true if the RPM of an ACF engine is inside the powerband +-- @server +function ents_methods:acfInPowerband () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.Gear or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the number of gears for an ACF gearbox - -- @server - function ents_methods:acfNumGears () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return false end + if restrictInfo( this ) then return false end + if ( this.FlyRPM < this.PeakMinRPM ) then return false end + if ( this.FlyRPM > this.PeakMaxRPM ) then return false end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + return true +end - if not isGearbox( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.Gears or 0 - end +--- Returns the throttle value +-- @server +function ents_methods:acfGetThrottle () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the final ratio for an ACF gearbox - -- @server - function ents_methods:acfFinalRatio () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return ( this.Throttle or 0 ) * 100 +end - if not isGearbox( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.GearTable[ "Final" ] or 0 - end +--- Sets the throttle value for an ACF engine +-- @server +function ents_methods:acfSetThrottle ( throttle ) + checktype( self, ents_metatable ) + checkluatype( throttle, TYPE_NUMBER ) + local this = unwrap( self ) - --- Returns the total ratio (current gear * final) for an ACF gearbox - -- @server - function ents_methods:acfTotalRatio () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isEngine( this ) then return end + this:TriggerInput( "Throttle", throttle ) +end - if not isGearbox( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.GearRatio or 0 - end - --- Returns the max torque for an ACF gearbox - -- @server - function ents_methods:acfTorqueRating () - checktype( self, ents_metatable ) - local this = unwrap( self ) +-- [ Gearbox Functions ] -- - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns true if the entity is an ACF gearbox +-- @server +function ents_methods:acfIsGearbox () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return 0 end - return this.MaxTorque or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns whether an ACF gearbox is dual clutch - -- @server - function ents_methods:acfIsDual () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return isGearbox( this ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the current gear for an ACF gearbox +-- @server +function ents_methods:acfGear () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return false end - if restrictInfo( this ) then return false end - - return this.Dual - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the time in ms an ACF gearbox takes to change gears - -- @server - function ents_methods:acfShiftTime () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.Gear or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the number of gears for an ACF gearbox +-- @server +function ents_methods:acfNumGears () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return 0 end - return ( this.SwitchTime or 0 ) * 1000 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns true if an ACF gearbox is in gear - -- @server - function ents_methods:acfInGear () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.Gears or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the final ratio for an ACF gearbox +-- @server +function ents_methods:acfFinalRatio () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return false end - if restrictInfo( this ) then return false end - - return this.InGear - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the ratio for a specified gear of an ACF gearbox - -- @server - function ents_methods:acfGearRatio ( gear ) - checktype( self, ents_metatable ) - checkluatype( gear, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.GearTable[ "Final" ] or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the total ratio (current gear * final) for an ACF gearbox +-- @server +function ents_methods:acfTotalRatio () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return 0 end - if restrictInfo( this ) then return 0 end - local g = math.Clamp( math.floor( gear ), 1, this.Gears ) - return this.GearTable[ g ] or 0 - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns the current torque output for an ACF gearbox - -- @server - function ents_methods:acfTorqueOut () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.GearRatio or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the max torque for an ACF gearbox +-- @server +function ents_methods:acfTorqueRating () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return 0 end - return math.min( this.TotalReqTq or 0, this.MaxTorque or 0 ) / ( this.GearRatio or 1 ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Sets the gear ratio of a CVT, set to 0 to use built-in algorithm - -- @server - function ents_methods:acfCVTRatio ( ratio ) - checktype( self, ents_metatable ) - checkluatype( ratio, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + return this.MaxTorque or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns whether an ACF gearbox is dual clutch +-- @server +function ents_methods:acfIsDual () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.CVT then return end - this.CVTRatio = math.Clamp( ratio, 0, 1 ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Sets the current gear for an ACF gearbox - -- @server - function ents_methods:acfShift ( gear ) - checktype( self, ents_metatable ) - checkluatype( gear, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return false end + if restrictInfo( this ) then return false end + + return this.Dual +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns the time in ms an ACF gearbox takes to change gears +-- @server +function ents_methods:acfShiftTime () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Gear", gear ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Cause an ACF gearbox to shift up - -- @server - function ents_methods:acfShiftUp () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + return ( this.SwitchTime or 0 ) * 1000 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns true if an ACF gearbox is in gear +-- @server +function ents_methods:acfInGear () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Gear Up", 1 ) --doesn't need to be toggled off - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Cause an ACF gearbox to shift down - -- @server - function ents_methods:acfShiftDown () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isGearbox( this ) then return false end + if restrictInfo( this ) then return false end + + return this.InGear +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns the ratio for a specified gear of an ACF gearbox +-- @server +function ents_methods:acfGearRatio ( gear ) + checktype( self, ents_metatable ) + checkluatype( gear, TYPE_NUMBER ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Gear Down", 1 ) --doesn't need to be toggled off - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Sets the brakes for an ACF gearbox - -- @server - function ents_methods:acfBrake ( brake ) - checktype( self, ents_metatable ) - checkluatype( brake, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + if restrictInfo( this ) then return 0 end + local g = math.Clamp( math.floor( gear ), 1, this.Gears ) + return this.GearTable[ g ] or 0 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns the current torque output for an ACF gearbox +-- @server +function ents_methods:acfTorqueOut () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Brake", brake ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Sets the left brakes for an ACF gearbox - -- @server - function ents_methods:acfBrakeLeft ( brake ) - checktype( self, ents_metatable ) - checkluatype( brake, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return 0 end + return math.min( this.TotalReqTq or 0, this.MaxTorque or 0 ) / ( this.GearRatio or 1 ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Sets the gear ratio of a CVT, set to 0 to use built-in algorithm +-- @server +function ents_methods:acfCVTRatio ( ratio ) + checktype( self, ents_metatable ) + checkluatype( ratio, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.CVT then return end + this.CVTRatio = math.Clamp( ratio, 0, 1 ) +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Dual then return end - this:TriggerInput( "Left Brake", brake ) - end +--- Sets the current gear for an ACF gearbox +-- @server +function ents_methods:acfShift ( gear ) + checktype( self, ents_metatable ) + checkluatype( gear, TYPE_NUMBER ) + local this = unwrap( self ) - --- Sets the right brakes for an ACF gearbox - -- @server - function ents_methods:acfBrakeRight ( brake ) - checktype( self, ents_metatable ) - checkluatype( brake, TYPE_NUMBER ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + this:TriggerInput( "Gear", gear ) +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Dual then return end - this:TriggerInput("Right Brake", brake ) - end +--- Cause an ACF gearbox to shift up +-- @server +function ents_methods:acfShiftUp () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Sets the clutch for an ACF gearbox - -- @server - function ents_methods:acfClutch ( clutch ) - checktype( self, ents_metatable ) - checkluatype( clutch, TYPE_NUMBER ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + this:TriggerInput( "Gear Up", 1 ) --doesn't need to be toggled off +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - this:TriggerInput( "Clutch", clutch ) - end +--- Cause an ACF gearbox to shift down +-- @server +function ents_methods:acfShiftDown () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Sets the left clutch for an ACF gearbox - -- @server - function ents_methods:acfClutchLeft( clutch ) - checktype( self, ents_metatable ) - checkluatype( clutch, TYPE_NUMBER ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + this:TriggerInput( "Gear Down", 1 ) --doesn't need to be toggled off +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Dual then return end - this:TriggerInput( "Left Clutch", clutch ) - end +--- Sets the brakes for an ACF gearbox +-- @server +function ents_methods:acfBrake ( brake ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) + local this = unwrap( self ) - --- Sets the right clutch for an ACF gearbox - -- @server - function ents_methods:acfClutchRight ( clutch ) - checktype( self, ents_metatable ) - checkluatype( clutch, TYPE_NUMBER ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + this:TriggerInput( "Brake", brake ) +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Dual then return end - this:TriggerInput( "Right Clutch", clutch ) - end +--- Sets the left brakes for an ACF gearbox +-- @server +function ents_methods:acfBrakeLeft ( brake ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Dual then return end + this:TriggerInput( "Left Brake", brake ) +end - --- Sets the steer ratio for an ACF gearbox - -- @server - function ents_methods:acfSteerRate ( rate ) - checktype( self, ents_metatable ) - checkluatype( rate, TYPE_NUMBER ) - local this = unwrap( self ) +--- Sets the right brakes for an ACF gearbox +-- @server +function ents_methods:acfBrakeRight ( brake ) + checktype( self, ents_metatable ) + checkluatype( brake, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Dual then return end + this:TriggerInput("Right Brake", brake ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Sets the clutch for an ACF gearbox +-- @server +function ents_methods:acfClutch ( clutch ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) + local this = unwrap( self ) - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.DoubleDiff then return end - this:TriggerInput( "Steer Rate", rate ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - --- Applies gear hold for an automatic ACF gearbox - -- @server - function ents_methods:acfHoldGear( hold ) - checktype( self, ents_metatable ) - checkluatype( hold, TYPE_NUMBER ) - local this = unwrap( self ) + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + this:TriggerInput( "Clutch", clutch ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Sets the left clutch for an ACF gearbox +-- @server +function ents_methods:acfClutchLeft( clutch ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Dual then return end + this:TriggerInput( "Left Clutch", clutch ) +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Auto then return end - this:TriggerInput( "Hold Gear", hold ) - end +--- Sets the right clutch for an ACF gearbox +-- @server +function ents_methods:acfClutchRight ( clutch ) + checktype( self, ents_metatable ) + checkluatype( clutch, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Dual then return end + this:TriggerInput( "Right Clutch", clutch ) +end - --- Sets the shift point scaling for an automatic ACF gearbox - -- @server - function ents_methods:acfShiftPointScale( scale ) - checktype( self, ents_metatable ) - checkluatype( scale, TYPE_NUMBER ) - local this = unwrap( self ) +--- Sets the steer ratio for an ACF gearbox +-- @server +function ents_methods:acfSteerRate ( rate ) + checktype( self, ents_metatable ) + checkluatype( rate, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.DoubleDiff then return end + this:TriggerInput( "Steer Rate", rate ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Applies gear hold for an automatic ACF gearbox +-- @server +function ents_methods:acfHoldGear( hold ) + checktype( self, ents_metatable ) + checkluatype( hold, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Auto then return end + this:TriggerInput( "Hold Gear", hold ) +end - if not isGearbox( this ) then return end - if restrictInfo( this ) then return end - if not this.Auto then return end - this:TriggerInput( "Shift Speed Scale", scale ) - end +--- Sets the shift point scaling for an automatic ACF gearbox +-- @server +function ents_methods:acfShiftPointScale( scale ) + checktype( self, ents_metatable ) + checkluatype( scale, TYPE_NUMBER ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) + + if not isGearbox( this ) then return end + if restrictInfo( this ) then return end + if not this.Auto then return end + this:TriggerInput( "Shift Speed Scale", scale ) +end - -- [ Gun Functions ] -- +-- [ Gun Functions ] -- - --- Returns true if the entity is an ACF gun - -- @server - function ents_methods:acfIsGun () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if the entity is an ACF gun +-- @server +function ents_methods:acfIsGun () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if isGun( this ) and not restrictInfo( this ) then return true else return false end - end + if isGun( this ) and not restrictInfo( this ) then return true else return false end +end - --- Returns true if the ACF gun is ready to fire - -- @server - function ents_methods:acfReady () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if the ACF gun is ready to fire +-- @server +function ents_methods:acfReady () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) then return false end - if restrictInfo( this ) then return false end - if ( this.Ready ) then return true end - return false - end + if not isGun( this ) then return false end + if restrictInfo( this ) then return false end + if ( this.Ready ) then return true end + return false +end - --- Returns the magazine size for an ACF gun - -- @server - function ents_methods:acfMagSize () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the magazine size for an ACF gun +-- @server +function ents_methods:acfMagSize () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) then return 0 end - return this.MagSize or 1 - end + if not isGun( this ) then return 0 end + return this.MagSize or 1 +end - --- Returns the spread for an ACF gun or flechette ammo - -- @server - function ents_methods:acfSpread () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the spread for an ACF gun or flechette ammo +-- @server +function ents_methods:acfSpread () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) or isAmmo( this ) then return 0 end - local Spread = this.GetInaccuracy and this:GetInaccuracy() or this.Inaccuracy or 0 - if this.BulletData[ "Type" ] == "FL" then - if restrictInfo( this ) then return Spread end - return Spread + ( this.BulletData[ "FlechetteSpread" ] or 0 ) - end - return Spread + if not isGun( this ) or isAmmo( this ) then return 0 end + local Spread = this.GetInaccuracy and this:GetInaccuracy() or this.Inaccuracy or 0 + if this.BulletData[ "Type" ] == "FL" then + if restrictInfo( this ) then return Spread end + return Spread + ( this.BulletData[ "FlechetteSpread" ] or 0 ) end + return Spread +end - --- Returns true if an ACF gun is reloading - -- @server - function ents_methods:acfIsReloading () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if an ACF gun is reloading +-- @server +function ents_methods:acfIsReloading () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) then return false end - if restrictInfo( this ) then return false end - if (this.Reloading) then return true end - return false - end + if not isGun( this ) then return false end + if restrictInfo( this ) then return false end + if (this.Reloading) then return true end + return false +end - --- Returns the rate of fire of an acf gun - -- @server - function ents_methods:acfFireRate () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the rate of fire of an acf gun +-- @server +function ents_methods:acfFireRate () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) then return 0 end - return math.Round( this.RateOfFire or 0, 3 ) - end + if not isGun( this ) then return 0 end + return math.Round( this.RateOfFire or 0, 3 ) +end - --- Returns the number of rounds left in a magazine for an ACF gun - -- @server - function ents_methods:acfMagRounds () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the number of rounds left in a magazine for an ACF gun +-- @server +function ents_methods:acfMagRounds () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isGun( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if this.MagSize > 1 then - return ( this.MagSize - this.CurrentShot ) or 1 - end - if this.Ready then return 1 end - return 0 + if not isGun( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if this.MagSize > 1 then + return ( this.MagSize - this.CurrentShot ) or 1 end + if this.Ready then return 1 end + return 0 +end - --- Sets the firing state of an ACF weapon - -- @server - function ents_methods:acfFire ( fire ) - checktype( self, ents_metatable ) - checkluatype( fire, TYPE_NUMBER ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) - - if not isGun( this ) then return end - - this:TriggerInput( "Fire", fire ) - end +--- Sets the firing state of an ACF weapon +-- @server +function ents_methods:acfFire ( fire ) + checktype( self, ents_metatable ) + checkluatype( fire, TYPE_NUMBER ) + local this = unwrap( self ) - --- Causes an ACF weapon to unload - -- @server - function ents_methods:acfUnload () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGun( this ) then return end + + this:TriggerInput( "Fire", fire ) +end - if not isGun( this ) then return end - - this:UnloadAmmo() - end +--- Causes an ACF weapon to unload +-- @server +function ents_methods:acfUnload () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Causes an ACF weapon to reload - -- @server - function ents_methods:acfReload () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) + if not isGun( this ) then return end + + this:UnloadAmmo() +end - if not isGun( this ) then return end - - this.Reloading = true - end +--- Causes an ACF weapon to reload +-- @server +function ents_methods:acfReload () + checktype( self, ents_metatable ) + local this = unwrap( self ) - --- Returns the number of rounds in active ammo crates linked to an ACF weapon - -- @server - function ents_methods:acfAmmoCount () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not isGun( this ) then return end + + this.Reloading = true +end - if not isGun( this ) then return 0 end - if restrictInfo( this ) then return 0 end - local Ammo = 0 - for Key, AmmoEnt in pairs( this.AmmoLink ) do - if AmmoEnt and AmmoEnt:IsValid() and AmmoEnt[ "Load" ] then - Ammo = Ammo + ( AmmoEnt.Ammo or 0 ) - end +--- Returns the number of rounds in active ammo crates linked to an ACF weapon +-- @server +function ents_methods:acfAmmoCount () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if not isGun( this ) then return 0 end + if restrictInfo( this ) then return 0 end + local Ammo = 0 + for Key, AmmoEnt in pairs( this.AmmoLink ) do + if AmmoEnt and AmmoEnt:IsValid() and AmmoEnt[ "Load" ] then + Ammo = Ammo + ( AmmoEnt.Ammo or 0 ) end - return Ammo end + return Ammo +end - --- Returns the number of rounds in all ammo crates linked to an ACF weapon - -- @server - function ents_methods:acfTotalAmmoCount () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - - if not isGun( this ) then return 0 end - if restrictInfo( this ) then return 0 end - local Ammo = 0 - for Key, AmmoEnt in pairs( this.AmmoLink ) do - if AmmoEnt and AmmoEnt:IsValid() then - Ammo = Ammo + ( AmmoEnt.Ammo or 0 ) - end +--- Returns the number of rounds in all ammo crates linked to an ACF weapon +-- @server +function ents_methods:acfTotalAmmoCount () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if not isGun( this ) then return 0 end + if restrictInfo( this ) then return 0 end + local Ammo = 0 + for Key, AmmoEnt in pairs( this.AmmoLink ) do + if AmmoEnt and AmmoEnt:IsValid() then + Ammo = Ammo + ( AmmoEnt.Ammo or 0 ) end - return Ammo end + return Ammo +end - --- Returns time to next shot of an ACF weapon - -- @server - function ents_methods:acfReloadTime () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns time to next shot of an ACF weapon +-- @server +function ents_methods:acfReloadTime () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if restrictInfo( this ) or not isGun( this ) or this.Ready then return 0 end - return reloadTime( this ) - end + if restrictInfo( this ) or not isGun( this ) or this.Ready then return 0 end + return reloadTime( this ) +end - --- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars - -- @server - function ents_methods:acfReloadProgress () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars +-- @server +function ents_methods:acfReloadProgress () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if restrictInfo( this ) or not isGun( this ) or this.Ready then return 1 end - return math.Clamp( 1 - (this.NextFire - CurTime()) / reloadTime( this ), 0, 1 ) - end + if restrictInfo( this ) or not isGun( this ) or this.Ready then return 1 end + return math.Clamp( 1 - (this.NextFire - CurTime()) / reloadTime( this ), 0, 1 ) +end - --- Returns time it takes for an ACF weapon to reload magazine - -- @server - function ents_methods:acfMagReloadTime () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns time it takes for an ACF weapon to reload magazine +-- @server +function ents_methods:acfMagReloadTime () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if restrictInfo( SF.instance.player , this ) or not isGun( this ) or not this.MagReload then return 0 end - return this.MagReload - end + if restrictInfo( instance.player , this ) or not isGun( this ) or not this.MagReload then return 0 end + return this.MagReload +end - -- [ Ammo Functions ] -- +-- [ Ammo Functions ] -- - --- Returns true if the entity is an ACF ammo crate - -- @server - function ents_methods:acfIsAmmo () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns true if the entity is an ACF ammo crate +-- @server +function ents_methods:acfIsAmmo () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - return isAmmo( this ) and not restrictInfo( this ) - end + return isAmmo( this ) and not restrictInfo( this ) +end - --- Returns the rounds left in an acf ammo crate - -- @server - function ents_methods:acfRounds () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the rounds left in an acf ammo crate +-- @server +function ents_methods:acfRounds () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isAmmo( this ) then return 0 end - if restrictInfo( this ) then return 0 end - return this.Ammo or 0 - end + if not isAmmo( this ) then return 0 end + if restrictInfo( this ) then return 0 end + return this.Ammo or 0 +end - --- Returns the type of weapon the ammo in an ACF ammo crate loads into - -- @server - function ents_methods:acfRoundType () --cartridge? - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the type of weapon the ammo in an ACF ammo crate loads into +-- @server +function ents_methods:acfRoundType () --cartridge? + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isAmmo( this ) then return "" end - if restrictInfo( this ) then return "" end - --return this.RoundId or "" - return this.RoundType or "" -- E2 uses this one now - end + if not isAmmo( this ) then return "" end + if restrictInfo( this ) then return "" end + --return this.RoundId or "" + return this.RoundType or "" -- E2 uses this one now +end - --- Returns the type of ammo in a crate or gun - -- @server - function ents_methods:acfAmmoType () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the type of ammo in a crate or gun +-- @server +function ents_methods:acfAmmoType () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isAmmo( this ) or isGun( this ) then return "" end - if restrictInfo( this ) then return "" end - return this.BulletData[ "Type" ] or "" - end + if not isAmmo( this ) or isGun( this ) then return "" end + if restrictInfo( this ) then return "" end + return this.BulletData[ "Type" ] or "" +end - --- Returns the caliber of an ammo or gun - -- @server - function ents_methods:acfCaliber () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the caliber of an ammo or gun +-- @server +function ents_methods:acfCaliber () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - return ( this.Caliber or 0 ) * 10 - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + return ( this.Caliber or 0 ) * 10 +end - --- Returns the muzzle velocity of the ammo in a crate or gun - -- @server - function ents_methods:acfMuzzleVel () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the muzzle velocity of the ammo in a crate or gun +-- @server +function ents_methods:acfMuzzleVel () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - return math.Round( ( this.BulletData[ "MuzzleVel" ] or 0 ) * ACF.VelScale, 3 ) - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + return math.Round( ( this.BulletData[ "MuzzleVel" ] or 0 ) * ACF.VelScale, 3 ) +end - --- Returns the mass of the projectile in a crate or gun - -- @server - function ents_methods:acfProjectileMass () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the mass of the projectile in a crate or gun +-- @server +function ents_methods:acfProjectileMass () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - return math.Round( this.BulletData[ "ProjMass" ] or 0, 3 ) - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + return math.Round( this.BulletData[ "ProjMass" ] or 0, 3 ) +end - --- Returns the number of projectiles in a flechette round - -- @server - function ents_methods:acfFLSpikes () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the number of projectiles in a flechette round +-- @server +function ents_methods:acfFLSpikes () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - if not this.BulletData[ "Type" ] == "FL" then return 0 end - return this.BulletData[ "Flechettes" ] or 0 - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + if not this.BulletData[ "Type" ] == "FL" then return 0 end + return this.BulletData[ "Flechettes" ] or 0 +end - --- Returns the mass of a single spike in a FL round in a crate or gun - -- @server - function ents_methods:acfFLSpikeMass () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the mass of a single spike in a FL round in a crate or gun +-- @server +function ents_methods:acfFLSpikeMass () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - if not this.BulletData[ "Type" ] == "FL" then return 0 end - return math.Round( this.BulletData[ "FlechetteMass" ] or 0, 3) - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + if not this.BulletData[ "Type" ] == "FL" then return 0 end + return math.Round( this.BulletData[ "FlechetteMass" ] or 0, 3) +end - --- Returns the radius of the spikes in a flechette round in mm - -- @server - function ents_methods:acfFLSpikeRadius () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the radius of the spikes in a flechette round in mm +-- @server +function ents_methods:acfFLSpikeRadius () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - if not this.BulletData[ "Type" ] == "FL" then return 0 end - return math.Round( ( this.BulletData[ "FlechetteRadius" ] or 0 ) * 10, 3) + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + if not this.BulletData[ "Type" ] == "FL" then return 0 end + return math.Round( ( this.BulletData[ "FlechetteRadius" ] or 0 ) * 10, 3) +end + +--- Returns the penetration of an AP, APHE, or HEAT round +-- @server +function ents_methods:acfPenetration () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + local Type = this.BulletData[ "Type" ] or "" + local Energy + + --[[if Type == "AP" or Type == "APHE" then + Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37, this.BulletData[ "ProjMass" ] - ( this.BulletData[ "FillerMass" ] or 0 ), this.BulletData[ "LimitVel" ] ) + return math.Round( ( Energy.Penetration / this.BulletData[ "PenAera" ] ) * ACF.KEtoRHA, 3 ) + elseif Type == "HEAT" then + Energy = ACF_Kinetic( this.BulletData[ "SlugMV" ] * 39.37, this.BulletData[ "SlugMass" ], 9999999 ) + return math.Round( ( Energy.Penetration / this.BulletData[ "SlugPenAera" ] ) * ACF.KEtoRHA, 3 ) + elseif Type == "FL" then + Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37 , this.BulletData[ "FlechetteMass" ], this.BulletData[ "LimitVel" ] ) + return math.Round( ( Energy.Penetration / this.BulletData[ "FlechettePenArea" ] ) * ACF.KEtoRHA, 3 ) + end]] + + if Type == "AP" or Type == "APHE" then + Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37, this.BulletData["ProjMass"] - (this.BulletData["FillerMass"] or 0), this.BulletData["LimitVel"] ) + return math.Round((Energy.Penetration/this.BulletData["PenAera"])*ACF.KEtoRHA,3) + elseif Type == "HEAT" then + local Crushed, HEATFillerMass, BoomFillerMass = ACF.RoundTypes["HEAT"].CrushCalc(this.BulletData.MuzzleVel, this.BulletData.FillerMass) + if Crushed == 1 then return 0 end -- no HEAT jet to fire off, it was all converted to HE + Energy = ACF_Kinetic(ACF.RoundTypes["HEAT"].CalcSlugMV( this.BulletData, HEATFillerMass )*39.37, this.BulletData["SlugMass"], 9999999 ) + return math.Round((Energy.Penetration/this.BulletData["SlugPenAera"])*ACF.KEtoRHA,3) + elseif Type == "FL" then + Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37 , this.BulletData["FlechetteMass"], this.BulletData["LimitVel"] ) + return math.Round((Energy.Penetration/this.BulletData["FlechettePenArea"])*ACF.KEtoRHA, 3) end + + return 0 +end - --- Returns the penetration of an AP, APHE, or HEAT round - -- @server - function ents_methods:acfPenetration () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the blast radius of an HE, APHE, or HEAT round +-- @server +function ents_methods:acfBlastRadius () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - local Type = this.BulletData[ "Type" ] or "" - local Energy - - --[[if Type == "AP" or Type == "APHE" then - Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37, this.BulletData[ "ProjMass" ] - ( this.BulletData[ "FillerMass" ] or 0 ), this.BulletData[ "LimitVel" ] ) - return math.Round( ( Energy.Penetration / this.BulletData[ "PenAera" ] ) * ACF.KEtoRHA, 3 ) - elseif Type == "HEAT" then - Energy = ACF_Kinetic( this.BulletData[ "SlugMV" ] * 39.37, this.BulletData[ "SlugMass" ], 9999999 ) - return math.Round( ( Energy.Penetration / this.BulletData[ "SlugPenAera" ] ) * ACF.KEtoRHA, 3 ) - elseif Type == "FL" then - Energy = ACF_Kinetic( this.BulletData[ "MuzzleVel" ] * 39.37 , this.BulletData[ "FlechetteMass" ], this.BulletData[ "LimitVel" ] ) - return math.Round( ( Energy.Penetration / this.BulletData[ "FlechettePenArea" ] ) * ACF.KEtoRHA, 3 ) - end]] - - if Type == "AP" or Type == "APHE" then - Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37, this.BulletData["ProjMass"] - (this.BulletData["FillerMass"] or 0), this.BulletData["LimitVel"] ) - return math.Round((Energy.Penetration/this.BulletData["PenAera"])*ACF.KEtoRHA,3) - elseif Type == "HEAT" then - local Crushed, HEATFillerMass, BoomFillerMass = ACF.RoundTypes["HEAT"].CrushCalc(this.BulletData.MuzzleVel, this.BulletData.FillerMass) - if Crushed == 1 then return 0 end -- no HEAT jet to fire off, it was all converted to HE - Energy = ACF_Kinetic(ACF.RoundTypes["HEAT"].CalcSlugMV( this.BulletData, HEATFillerMass )*39.37, this.BulletData["SlugMass"], 9999999 ) - return math.Round((Energy.Penetration/this.BulletData["SlugPenAera"])*ACF.KEtoRHA,3) - elseif Type == "FL" then - Energy = ACF_Kinetic(this.BulletData["MuzzleVel"]*39.37 , this.BulletData["FlechetteMass"], this.BulletData["LimitVel"] ) - return math.Round((Energy.Penetration/this.BulletData["FlechettePenArea"])*ACF.KEtoRHA, 3) - end - - return 0 + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + local Type = this.BulletData[ "Type" ] or "" + if Type == "HE" or Type == "APHE" then + return math.Round( this.BulletData[ "FillerMass" ]^0.33 * 8, 3 ) + elseif Type == "HEAT" then + return math.Round( ( this.BulletData[ "FillerMass" ] / 3)^0.33 * 8, 3 ) end + return 0 +end - --- Returns the blast radius of an HE, APHE, or HEAT round - -- @server - function ents_methods:acfBlastRadius () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the drag coef of the ammo in a crate or gun +-- @server +function ents_methods:acfDragCoef() + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - local Type = this.BulletData[ "Type" ] or "" - if Type == "HE" or Type == "APHE" then - return math.Round( this.BulletData[ "FillerMass" ]^0.33 * 8, 3 ) - elseif Type == "HEAT" then - return math.Round( ( this.BulletData[ "FillerMass" ] / 3)^0.33 * 8, 3 ) - end - return 0 - end + if not ( isAmmo( this ) or isGun( this ) ) then return 0 end + if restrictInfo( this ) then return 0 end + return ( this.BulletData[ "DragCoef" ] or 0 ) / ACF.DragDiv +end - --- Returns the drag coef of the ammo in a crate or gun - -- @server - function ents_methods:acfDragCoef() - checktype( self, ents_metatable ) - local this = unwrap( self ) +-- [ Armor Functions ] -- - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns the current health of an entity +-- @server +function ents_methods:acfPropHealth () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( isAmmo( this ) or isGun( this ) ) then return 0 end - if restrictInfo( this ) then return 0 end - return ( this.BulletData[ "DragCoef" ] or 0 ) / ACF.DragDiv - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - -- [ Armor Functions ] -- + if not validPhysics( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not ACF_Check( this ) then return 0 end + return math.Round( this.ACF.Health or 0, 3 ) +end - --- Returns the current health of an entity - -- @server - function ents_methods:acfPropHealth () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the current armor of an entity +-- @server +function ents_methods:acfPropArmor () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not validPhysics( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not ACF_Check( this ) then return 0 end - return math.Round( this.ACF.Health or 0, 3 ) - end + if not validPhysics( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not ACF_Check( this ) then return 0 end + return math.Round( this.ACF.Armour or 0, 3 ) +end - --- Returns the current armor of an entity - -- @server - function ents_methods:acfPropArmor () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the max health of an entity +-- @server +function ents_methods:acfPropHealthMax () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not validPhysics( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not ACF_Check( this ) then return 0 end - return math.Round( this.ACF.Armour or 0, 3 ) - end + if not validPhysics( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not ACF_Check( this ) then return 0 end + return math.Round( this.ACF.MaxHealth or 0, 3 ) +end - --- Returns the max health of an entity - -- @server - function ents_methods:acfPropHealthMax () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the max armor of an entity +-- @server +function ents_methods:acfPropArmorMax () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not validPhysics( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not ACF_Check( this ) then return 0 end - return math.Round( this.ACF.MaxHealth or 0, 3 ) - end + if not validPhysics( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not ACF_Check( this ) then return 0 end + return math.Round( this.ACF.MaxArmour or 0, 3 ) +end - --- Returns the max armor of an entity - -- @server - function ents_methods:acfPropArmorMax () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the ductility of an entity +-- @server +function ents_methods:acfPropDuctility () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not validPhysics( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not ACF_Check( this ) then return 0 end - return math.Round( this.ACF.MaxArmour or 0, 3 ) - end - - --- Returns the ductility of an entity - -- @server - function ents_methods:acfPropDuctility () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not validPhysics( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not ACF_Check( this ) then return 0 end + return ( this.ACF.Ductility or 0 ) * 100 +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +-- [ Fuel Functions ] -- - if not validPhysics( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not ACF_Check( this ) then return 0 end - return ( this.ACF.Ductility or 0 ) * 100 - end +--- Returns true if the entity is an ACF fuel tank +-- @server +function ents_methods:acfIsFuel () + checktype( self, ents_metatable ) + local this = unwrap( self ) - -- [ Fuel Functions ] -- + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns true if the entity is an ACF fuel tank - -- @server - function ents_methods:acfIsFuel () - checktype( self, ents_metatable ) - local this = unwrap( self ) + return isFuel( this ) and not restrictInfo( this ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Returns true if the current engine requires fuel to run +-- @server +function ents_methods:acfFuelRequired () + checktype( self, ents_metatable ) + local this = unwrap( self ) - return isFuel( this ) and not restrictInfo( this ) - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - --- Returns true if the current engine requires fuel to run - -- @server - function ents_methods:acfFuelRequired () - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isEngine( this ) then return false end + if restrictInfo( this ) then return false end + return ( this.RequiresFuel and true ) or false +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end +--- Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks +-- @server +function ents_methods:acfRefuelDuty ( on ) + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not isEngine( this ) then return false end - if restrictInfo( this ) then return false end - return ( this.RequiresFuel and true ) or false - end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + checkpermission( instance, this, "entities.acf" ) - --- Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks - -- @server - function ents_methods:acfRefuelDuty ( on ) - checktype( self, ents_metatable ) - local this = unwrap( self ) + if not isFuel( this ) then return end + + this:TriggerInput( "Refuel Duty", on and true or false ) +end - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - checkpermission( SF.instance, this, "entities.acf" ) +--- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine +-- @server +function ents_methods:acfFuel () + checktype( self, ents_metatable ) + local this = unwrap( self ) + + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + + if restrictInfo( this ) then return 0 end + if isFuel( this ) then + return math.Round( this.Fuel, 3 ) + elseif isEngine( this ) then + if not #(this.FuelLink) then return 0 end --if no tanks, return 0 + + local liters = 0 + for _, tank in pairs( this.FuelLink ) do + if validPhysics( tank ) and tank.Active then + liters = liters + tank.Fuel + end + end - if not isFuel( this ) then return end - - this:TriggerInput( "Refuel Duty", on and true or false ) + return math.Round( liters, 3 ) end + return 0 +end - --- Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine - -- @server - function ents_methods:acfFuel () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity +-- @server +function ents_methods:acfFuelLevel () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if isFuel( this ) then if restrictInfo( this ) then return 0 end - if isFuel( this ) then - return math.Round( this.Fuel, 3 ) - elseif isEngine( this ) then - if not #(this.FuelLink) then return 0 end --if no tanks, return 0 - - local liters = 0 - for _, tank in pairs( this.FuelLink ) do - if validPhysics( tank ) and tank.Active then - liters = liters + tank.Fuel - end - end - - return math.Round( liters, 3 ) - end - return 0 - end + return math.Round( this.Fuel / this.Capacity, 3 ) + elseif isEngine( this ) then + if restrictInfo( this ) then return 0 end + if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 - --- Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity - -- @server - function ents_methods:acfFuelLevel () - checktype( self, ents_metatable ) - local this = unwrap( self ) - - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - - if isFuel( this ) then - if restrictInfo( this ) then return 0 end - return math.Round( this.Fuel / this.Capacity, 3 ) - elseif isEngine( this ) then - if restrictInfo( this ) then return 0 end - if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 - - local liters = 0 - local capacity = 0 - for _, tank in pairs( this.FuelLink ) do - if validPhysics( tank ) and tank.Active then - capacity = capacity + tank.Capacity - liters = liters + tank.Fuel - end + local liters = 0 + local capacity = 0 + for _, tank in pairs( this.FuelLink ) do + if validPhysics( tank ) and tank.Active then + capacity = capacity + tank.Capacity + liters = liters + tank.Fuel end - if not capacity > 0 then return 0 end - - return math.Round( liters / capacity, 3 ) end - return 0 + if not capacity > 0 then return 0 end + + return math.Round( liters / capacity, 3 ) end + return 0 +end - --- Returns the current fuel consumption in liters per minute or kilowatts of an engine - -- @server - function ents_methods:acfFuelUse () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the current fuel consumption in liters per minute or kilowatts of an engine +-- @server +function ents_methods:acfFuelUse () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 - local tank - for _, fueltank in pairs( this.FuelLink ) do - if validPhysics( fueltank ) and fueltank.Fuel > 0 and fueltank.Active then - tank = fueltank - break - end + local tank + for _, fueltank in pairs( this.FuelLink ) do + if validPhysics( fueltank ) and fueltank.Fuel > 0 and fueltank.Active then + tank = fueltank + break end - if not tank then return 0 end + end + if not tank then return 0 end - local Consumption - if this.FuelType == "Electric" then - Consumption = 60 * ( this.Torque * this.FlyRPM / 9548.8 ) * this.FuelUse - else - local Load = 0.3 + this.Throttle * 0.7 - Consumption = 60 * Load * this.FuelUse * ( this.FlyRPM / this.PeakKwRPM ) / ACF.FuelDensity[ tank.FuelType ] - end - return math.Round( Consumption, 3 ) + local Consumption + if this.FuelType == "Electric" then + Consumption = 60 * ( this.Torque * this.FlyRPM / 9548.8 ) * this.FuelUse + else + local Load = 0.3 + this.Throttle * 0.7 + Consumption = 60 * Load * this.FuelUse * ( this.FlyRPM / this.PeakKwRPM ) / ACF.FuelDensity[ tank.FuelType ] end + return math.Round( Consumption, 3 ) +end - --- Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using - -- @server - function ents_methods:acfPeakFuelUse () - checktype( self, ents_metatable ) - local this = unwrap( self ) +--- Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using +-- @server +function ents_methods:acfPeakFuelUse () + checktype( self, ents_metatable ) + local this = unwrap( self ) - if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end + if not ( this and this:IsValid() ) then SF.Throw( "Entity is not valid", 2 ) end - if not isEngine( this ) then return 0 end - if restrictInfo( this ) then return 0 end - if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 + if not isEngine( this ) then return 0 end + if restrictInfo( this ) then return 0 end + if not #( this.FuelLink ) then return 0 end --if no tanks, return 0 - local fuel = "Petrol" - local tank - for _, fueltank in pairs( this.FuelLink ) do - if fueltank.Fuel > 0 and fueltank.Active then tank = fueltank break end - end - if tank then fuel = tank.Fuel end + local fuel = "Petrol" + local tank + for _, fueltank in pairs( this.FuelLink ) do + if fueltank.Fuel > 0 and fueltank.Active then tank = fueltank break end + end + if tank then fuel = tank.Fuel end - local Consumption - if this.FuelType == "Electric" then - Consumption = 60 * ( this.PeakTorque * this.LimitRPM / ( 4 * 9548.8 ) ) * this.FuelUse - else - local Load = 0.3 + this.Throttle * 0.7 - Consumption = 60 * this.FuelUse / ACF.FuelDensity[ fuel ] - end - return math.Round( Consumption, 3 ) + local Consumption + if this.FuelType == "Electric" then + Consumption = 60 * ( this.PeakTorque * this.LimitRPM / ( 4 * 9548.8 ) ) * this.FuelUse + else + local Load = 0.3 + this.Throttle * 0.7 + Consumption = 60 * this.FuelUse / ACF.FuelDensity[ fuel ] end -end) \ No newline at end of file + return math.Round( Consumption, 3 ) +end + +end From 48cfabd80aa5096bc6eb1594cb1320f176a7674f Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Sat, 1 Feb 2020 14:23:15 +0100 Subject: [PATCH 6/7] Updated to new doc system --- lua/starfall/libs_cl/docs.lua | 289 -------------------------- lua/starfall/libs_sv/acffunctions.lua | 8 +- 2 files changed, 5 insertions(+), 292 deletions(-) delete mode 100644 lua/starfall/libs_cl/docs.lua diff --git a/lua/starfall/libs_cl/docs.lua b/lua/starfall/libs_cl/docs.lua deleted file mode 100644 index 4c54e8f62..000000000 --- a/lua/starfall/libs_cl/docs.lua +++ /dev/null @@ -1,289 +0,0 @@ --- Load Docs, nothing else --- Sadly we cant have it in the fancy helper but it will work in the old one and syntax highlighting - -table.Merge(SF.Docs, {["classes"]={[1]="Entity";["Entity"]={["class"]="class";["classForced"]=true;["description"]="\ -Entity type";["fields"]={};["methods"]={[1]="acfAmmoCount";[10]="acfClutch";[11]="acfClutchLeft";[12]="acfClutchRight";[13]="acfDragCoef";[14]="acfFLSpikeMass";[15]="acfFLSpikeRadius";[16]="acfFLSpikes";[17]="acfFinalRatio";[18]="acfFire";[19]="acfFireRate";[2]="acfAmmoType";[20]="acfFlyInertia";[21]="acfFlyMass";[22]="acfFuel";[23]="acfFuelLevel";[24]="acfFuelRequired";[25]="acfFuelUse";[26]="acfGear";[27]="acfGearRatio";[28]="acfGetActive";[29]="acfGetLinkedWheels";[3]="acfBlastRadius";[30]="acfGetThrottle";[31]="acfHitClip";[32]="acfHoldGear";[33]="acfIdleRPM";[34]="acfInGear";[35]="acfInPowerband";[36]="acfIsAmmo";[37]="acfIsDual";[38]="acfIsElectric";[39]="acfIsEngine";[4]="acfBrake";[40]="acfIsFuel";[41]="acfIsGearbox";[42]="acfIsGun";[43]="acfIsInfoRestricted";[44]="acfIsReloading";[45]="acfLinkTo";[46]="acfLinks";[47]="acfMagReloadTime";[48]="acfMagRounds";[49]="acfMagSize";[5]="acfBrakeLeft";[50]="acfMaxPower";[51]="acfMaxPowerWithFuel";[52]="acfMaxTorque";[53]="acfMaxTorqueWithFuel";[54]="acfMuzzleVel";[55]="acfName";[56]="acfNameShort";[57]="acfNumGears";[58]="acfPeakFuelUse";[59]="acfPenetration";[6]="acfBrakeRight";[60]="acfPower";[61]="acfPowerband";[62]="acfPowerbandMax";[63]="acfPowerbandMin";[64]="acfProjectileMass";[65]="acfPropArmor";[66]="acfPropArmorMax";[67]="acfPropDuctility";[68]="acfPropHealth";[69]="acfPropHealthMax";[7]="acfCVTRatio";[70]="acfRPM";[71]="acfReady";[72]="acfRedline";[73]="acfRefuelDuty";[74]="acfReload";[75]="acfReloadProgress";[76]="acfReloadTime";[77]="acfRoundType";[78]="acfRounds";[79]="acfSetActive";[8]="acfCaliber";[80]="acfSetThrottle";[81]="acfShift";[82]="acfShiftDown";[83]="acfShiftPointScale";[84]="acfShiftTime";[85]="acfShiftUp";[86]="acfSpread";[87]="acfSteerRate";[88]="acfTorque";[89]="acfTorqueOut";[9]="acfCapacity";[90]="acfTorqueRating";[91]="acfTotalAmmoCount";[92]="acfTotalRatio";[93]="acfType";[94]="acfUnlinkFrom";[95]="acfUnload";["acfAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the number of rounds in active ammo crates linked to an ACF weapon";["fname"]="acfAmmoCount";["name"]="ents_methods:acfAmmoCount";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the number of rounds in active ammo crates linked to an ACF weapon ";};["acfAmmoType"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the type of ammo in a crate or gun";["fname"]="acfAmmoType";["name"]="ents_methods:acfAmmoType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the type of ammo in a crate or gun ";};["acfBlastRadius"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the blast radius of an HE, APHE, or HEAT round";["fname"]="acfBlastRadius";["name"]="ents_methods:acfBlastRadius";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the blast radius of an HE, APHE, or HEAT round ";};["acfBrake"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the brakes for an ACF gearbox";["fname"]="acfBrake";["name"]="ents_methods:acfBrake";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the brakes for an ACF gearbox ";};["acfBrakeLeft"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the left brakes for an ACF gearbox";["fname"]="acfBrakeLeft";["name"]="ents_methods:acfBrakeLeft";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the left brakes for an ACF gearbox ";};["acfBrakeRight"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the right brakes for an ACF gearbox";["fname"]="acfBrakeRight";["name"]="ents_methods:acfBrakeRight";["param"]={[1]="brake";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the right brakes for an ACF gearbox ";};["acfCVTRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the gear ratio of a CVT, set to 0 to use built-in algorithm";["fname"]="acfCVTRatio";["name"]="ents_methods:acfCVTRatio";["param"]={[1]="ratio";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the gear ratio of a CVT, set to 0 to use built-in algorithm ";};["acfCaliber"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the caliber of an ammo or gun";["fname"]="acfCaliber";["name"]="ents_methods:acfCaliber";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the caliber of an ammo or gun ";};["acfCapacity"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the capacity of an acf ammo crate or fuel tank";["fname"]="acfCapacity";["name"]="ents_methods:acfCapacity";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the capacity of an acf ammo crate or fuel tank ";};["acfClutch"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the clutch for an ACF gearbox";["fname"]="acfClutch";["name"]="ents_methods:acfClutch";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the clutch for an ACF gearbox ";};["acfClutchLeft"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the left clutch for an ACF gearbox";["fname"]="acfClutchLeft";["name"]="ents_methods:acfClutchLeft";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the left clutch for an ACF gearbox ";};["acfClutchRight"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the right clutch for an ACF gearbox";["fname"]="acfClutchRight";["name"]="ents_methods:acfClutchRight";["param"]={[1]="clutch";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the right clutch for an ACF gearbox ";};["acfDragCoef"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the drag coef of the ammo in a crate or gun";["fname"]="acfDragCoef";["name"]="ents_methods:acfDragCoef";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the drag coef of the ammo in a crate or gun ";};["acfFLSpikeMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the mass of a single spike in a FL round in a crate or gun";["fname"]="acfFLSpikeMass";["name"]="ents_methods:acfFLSpikeMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the mass of a single spike in a FL round in a crate or gun ";};["acfFLSpikeRadius"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the radius of the spikes in a flechette round in mm";["fname"]="acfFLSpikeRadius";["name"]="ents_methods:acfFLSpikeRadius";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the radius of the spikes in a flechette round in mm ";};["acfFLSpikes"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the number of projectiles in a flechette round";["fname"]="acfFLSpikes";["name"]="ents_methods:acfFLSpikes";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the number of projectiles in a flechette round ";};["acfFinalRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the final ratio for an ACF gearbox";["fname"]="acfFinalRatio";["name"]="ents_methods:acfFinalRatio";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the final ratio for an ACF gearbox ";};["acfFire"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the firing state of an ACF weapon";["fname"]="acfFire";["name"]="ents_methods:acfFire";["param"]={[1]="fire";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the firing state of an ACF weapon ";};["acfFireRate"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the rate of fire of an acf gun";["fname"]="acfFireRate";["name"]="ents_methods:acfFireRate";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the rate of fire of an acf gun ";};["acfFlyInertia"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the inertia of an ACF engine's flywheel";["fname"]="acfFlyInertia";["name"]="ents_methods:acfFlyInertia";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the inertia of an ACF engine's flywheel ";};["acfFlyMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the mass of an ACF engine's flywheel";["fname"]="acfFlyMass";["name"]="ents_methods:acfFlyMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the mass of an ACF engine's flywheel ";};["acfFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine";["fname"]="acfFuel";["name"]="ents_methods:acfFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the remaining liters or kilowatt hours of fuel in an ACF fuel tank or engine ";};["acfFuelLevel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity";["fname"]="acfFuelLevel";["name"]="ents_methods:acfFuelLevel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the amount of fuel in an ACF fuel tank or linked to engine as a percentage of capacity ";};["acfFuelRequired"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the current engine requires fuel to run";["fname"]="acfFuelRequired";["name"]="ents_methods:acfFuelRequired";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the current engine requires fuel to run ";};["acfFuelUse"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current fuel consumption in liters per minute or kilowatts of an engine";["fname"]="acfFuelUse";["name"]="ents_methods:acfFuelUse";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current fuel consumption in liters per minute or kilowatts of an engine ";};["acfGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current gear for an ACF gearbox";["fname"]="acfGear";["name"]="ents_methods:acfGear";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current gear for an ACF gearbox ";};["acfGearRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the ratio for a specified gear of an ACF gearbox";["fname"]="acfGearRatio";["name"]="ents_methods:acfGearRatio";["param"]={[1]="gear";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the ratio for a specified gear of an ACF gearbox ";};["acfGetActive"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the acf engine, fuel tank, or ammo crate is active";["fname"]="acfGetActive";["name"]="ents_methods:acfGetActive";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the acf engine, fuel tank, or ammo crate is active ";};["acfGetLinkedWheels"]={["class"]="function";["classlib"]="Entity";["description"]="\ -returns any wheels linked to this engine/gearbox or child gearboxes";["fname"]="acfGetLinkedWheels";["name"]="ents_methods:acfGetLinkedWheels";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -returns any wheels linked to this engine/gearbox or child gearboxes ";};["acfGetThrottle"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the throttle value";["fname"]="acfGetThrottle";["name"]="ents_methods:acfGetThrottle";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the throttle value ";};["acfHitClip"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if hitpos is on a clipped part of prop";["fname"]="acfHitClip";["name"]="ents_methods:acfHitClip";["param"]={[1]="hitpos";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if hitpos is on a clipped part of prop ";};["acfHoldGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Applies gear hold for an automatic ACF gearbox";["fname"]="acfHoldGear";["name"]="ents_methods:acfHoldGear";["param"]={[1]="hold";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Applies gear hold for an automatic ACF gearbox ";};["acfIdleRPM"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the idle rpm of an ACF engine";["fname"]="acfIdleRPM";["name"]="ents_methods:acfIdleRPM";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the idle rpm of an ACF engine ";};["acfInGear"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if an ACF gearbox is in gear";["fname"]="acfInGear";["name"]="ents_methods:acfInGear";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if an ACF gearbox is in gear ";};["acfInPowerband"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the RPM of an ACF engine is inside the powerband";["fname"]="acfInPowerband";["name"]="ents_methods:acfInPowerband";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the RPM of an ACF engine is inside the powerband ";};["acfIsAmmo"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the entity is an ACF ammo crate";["fname"]="acfIsAmmo";["name"]="ents_methods:acfIsAmmo";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the entity is an ACF ammo crate ";};["acfIsDual"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns whether an ACF gearbox is dual clutch";["fname"]="acfIsDual";["name"]="ents_methods:acfIsDual";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns whether an ACF gearbox is dual clutch ";};["acfIsElectric"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if an ACF engine is electric";["fname"]="acfIsElectric";["name"]="ents_methods:acfIsElectric";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if an ACF engine is electric ";};["acfIsEngine"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the entity is an ACF engine";["fname"]="acfIsEngine";["name"]="ents_methods:acfIsEngine";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the entity is an ACF engine ";};["acfIsFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the entity is an ACF fuel tank";["fname"]="acfIsFuel";["name"]="ents_methods:acfIsFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the entity is an ACF fuel tank ";};["acfIsGearbox"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the entity is an ACF gearbox";["fname"]="acfIsGearbox";["name"]="ents_methods:acfIsGearbox";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the entity is an ACF gearbox ";};["acfIsGun"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the entity is an ACF gun";["fname"]="acfIsGun";["name"]="ents_methods:acfIsGun";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the entity is an ACF gun ";};["acfIsInfoRestricted"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if this entity contains sensitive info and is not accessable to us";["fname"]="acfIsInfoRestricted";["name"]="ents_methods:acfIsInfoRestricted";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if this entity contains sensitive info and is not accessable to us ";};["acfIsReloading"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if an ACF gun is reloading";["fname"]="acfIsReloading";["name"]="ents_methods:acfIsReloading";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if an ACF gun is reloading ";};["acfLinkTo"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Perform ACF links";["fname"]="acfLinkTo";["name"]="ents_methods:acfLinkTo";["param"]={[1]="target";[2]="notify";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Perform ACF links ";};["acfLinks"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the ACF links associated with the entity";["fname"]="acfLinks";["name"]="ents_methods:acfLinks";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the ACF links associated with the entity ";};["acfMagReloadTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns time it takes for an ACF weapon to reload magazine";["fname"]="acfMagReloadTime";["name"]="ents_methods:acfMagReloadTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns time it takes for an ACF weapon to reload magazine ";};["acfMagRounds"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the number of rounds left in a magazine for an ACF gun";["fname"]="acfMagRounds";["name"]="ents_methods:acfMagRounds";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the number of rounds left in a magazine for an ACF gun ";};["acfMagSize"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the magazine size for an ACF gun";["fname"]="acfMagSize";["name"]="ents_methods:acfMagSize";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the magazine size for an ACF gun ";};["acfMaxPower"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the power in kW of an ACF engine";["fname"]="acfMaxPower";["name"]="ents_methods:acfMaxPower";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the power in kW of an ACF engine ";};["acfMaxPowerWithFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the power in kW of an ACF engine with fuel";["fname"]="acfMaxPowerWithFuel";["name"]="ents_methods:acfMaxPowerWithFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the power in kW of an ACF engine with fuel ";};["acfMaxTorque"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the torque in N/m of an ACF engine";["fname"]="acfMaxTorque";["name"]="ents_methods:acfMaxTorque";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the torque in N/m of an ACF engine ";};["acfMaxTorqueWithFuel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the torque in N/m of an ACF engine with fuel";["fname"]="acfMaxTorqueWithFuel";["name"]="ents_methods:acfMaxTorqueWithFuel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the torque in N/m of an ACF engine with fuel ";};["acfMuzzleVel"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the muzzle velocity of the ammo in a crate or gun";["fname"]="acfMuzzleVel";["name"]="ents_methods:acfMuzzleVel";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the muzzle velocity of the ammo in a crate or gun ";};["acfName"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the full name of an ACF entity";["fname"]="acfName";["name"]="ents_methods:acfName";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the full name of an ACF entity ";};["acfNameShort"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the short name of an ACF entity";["fname"]="acfNameShort";["name"]="ents_methods:acfNameShort";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the short name of an ACF entity ";};["acfNumGears"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the number of gears for an ACF gearbox";["fname"]="acfNumGears";["name"]="ents_methods:acfNumGears";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the number of gears for an ACF gearbox ";};["acfPeakFuelUse"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using";["fname"]="acfPeakFuelUse";["name"]="ents_methods:acfPeakFuelUse";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the peak fuel consumption in liters per minute or kilowatts of an engine at powerband max, for the current fuel type the engine is using ";};["acfPenetration"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the penetration of an AP, APHE, or HEAT round";["fname"]="acfPenetration";["name"]="ents_methods:acfPenetration";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the penetration of an AP, APHE, or HEAT round ";};["acfPower"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current power of an ACF engine";["fname"]="acfPower";["name"]="ents_methods:acfPower";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current power of an ACF engine ";};["acfPowerband"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the powerband min and max of an ACF Engine";["fname"]="acfPowerband";["name"]="ents_methods:acfPowerband";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the powerband min and max of an ACF Engine ";};["acfPowerbandMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the powerband max of an ACF engine";["fname"]="acfPowerbandMax";["name"]="ents_methods:acfPowerbandMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the powerband max of an ACF engine ";};["acfPowerbandMin"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the powerband min of an ACF engine";["fname"]="acfPowerbandMin";["name"]="ents_methods:acfPowerbandMin";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the powerband min of an ACF engine ";};["acfProjectileMass"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the mass of the projectile in a crate or gun";["fname"]="acfProjectileMass";["name"]="ents_methods:acfProjectileMass";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the mass of the projectile in a crate or gun ";};["acfPropArmor"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current armor of an entity";["fname"]="acfPropArmor";["name"]="ents_methods:acfPropArmor";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current armor of an entity ";};["acfPropArmorMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the max armor of an entity";["fname"]="acfPropArmorMax";["name"]="ents_methods:acfPropArmorMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the max armor of an entity ";};["acfPropDuctility"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the ductility of an entity";["fname"]="acfPropDuctility";["name"]="ents_methods:acfPropDuctility";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the ductility of an entity ";};["acfPropHealth"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current health of an entity";["fname"]="acfPropHealth";["name"]="ents_methods:acfPropHealth";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current health of an entity ";};["acfPropHealthMax"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the max health of an entity";["fname"]="acfPropHealthMax";["name"]="ents_methods:acfPropHealthMax";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the max health of an entity ";};["acfRPM"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current rpm of an ACF engine";["fname"]="acfRPM";["name"]="ents_methods:acfRPM";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current rpm of an ACF engine ";};["acfReady"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns true if the ACF gun is ready to fire";["fname"]="acfReady";["name"]="ents_methods:acfReady";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns true if the ACF gun is ready to fire ";};["acfRedline"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the redline rpm of an ACF engine";["fname"]="acfRedline";["name"]="ents_methods:acfRedline";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the redline rpm of an ACF engine ";};["acfRefuelDuty"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks";["fname"]="acfRefuelDuty";["name"]="ents_methods:acfRefuelDuty";["param"]={[1]="on";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the ACF fuel tank refuel duty status, which supplies fuel to other fuel tanks ";};["acfReload"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Causes an ACF weapon to reload";["fname"]="acfReload";["name"]="ents_methods:acfReload";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Causes an ACF weapon to reload ";};["acfReloadProgress"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns number between 0 and 1 which represents reloading progress of an ACF weapon. Useful for progress bars";["fname"]="acfReloadProgress";["name"]="ents_methods:acfReloadProgress";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns number between 0 and 1 which represents reloading progress of an ACF weapon.";};["acfReloadTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns time to next shot of an ACF weapon";["fname"]="acfReloadTime";["name"]="ents_methods:acfReloadTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns time to next shot of an ACF weapon ";};["acfRoundType"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the type of weapon the ammo in an ACF ammo crate loads into";["fname"]="acfRoundType";["name"]="ents_methods:acfRoundType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the type of weapon the ammo in an ACF ammo crate loads into ";};["acfRounds"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the rounds left in an acf ammo crate";["fname"]="acfRounds";["name"]="ents_methods:acfRounds";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the rounds left in an acf ammo crate ";};["acfSetActive"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Turns an ACF engine, ammo crate, or fuel tank on or off";["fname"]="acfSetActive";["name"]="ents_methods:acfSetActive";["param"]={[1]="on";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Turns an ACF engine, ammo crate, or fuel tank on or off ";};["acfSetThrottle"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the throttle value for an ACF engine";["fname"]="acfSetThrottle";["name"]="ents_methods:acfSetThrottle";["param"]={[1]="throttle";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the throttle value for an ACF engine ";};["acfShift"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the current gear for an ACF gearbox";["fname"]="acfShift";["name"]="ents_methods:acfShift";["param"]={[1]="gear";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the current gear for an ACF gearbox ";};["acfShiftDown"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Cause an ACF gearbox to shift down";["fname"]="acfShiftDown";["name"]="ents_methods:acfShiftDown";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Cause an ACF gearbox to shift down ";};["acfShiftPointScale"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the shift point scaling for an automatic ACF gearbox";["fname"]="acfShiftPointScale";["name"]="ents_methods:acfShiftPointScale";["param"]={[1]="scale";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the shift point scaling for an automatic ACF gearbox ";};["acfShiftTime"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the time in ms an ACF gearbox takes to change gears";["fname"]="acfShiftTime";["name"]="ents_methods:acfShiftTime";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the time in ms an ACF gearbox takes to change gears ";};["acfShiftUp"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Cause an ACF gearbox to shift up";["fname"]="acfShiftUp";["name"]="ents_methods:acfShiftUp";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Cause an ACF gearbox to shift up ";};["acfSpread"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the spread for an ACF gun or flechette ammo";["fname"]="acfSpread";["name"]="ents_methods:acfSpread";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the spread for an ACF gun or flechette ammo ";};["acfSteerRate"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Sets the steer ratio for an ACF gearbox";["fname"]="acfSteerRate";["name"]="ents_methods:acfSteerRate";["param"]={[1]="rate";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Sets the steer ratio for an ACF gearbox ";};["acfTorque"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current torque of an ACF engine";["fname"]="acfTorque";["name"]="ents_methods:acfTorque";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current torque of an ACF engine ";};["acfTorqueOut"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the current torque output for an ACF gearbox";["fname"]="acfTorqueOut";["name"]="ents_methods:acfTorqueOut";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the current torque output for an ACF gearbox ";};["acfTorqueRating"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the max torque for an ACF gearbox";["fname"]="acfTorqueRating";["name"]="ents_methods:acfTorqueRating";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the max torque for an ACF gearbox ";};["acfTotalAmmoCount"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the number of rounds in all ammo crates linked to an ACF weapon";["fname"]="acfTotalAmmoCount";["name"]="ents_methods:acfTotalAmmoCount";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the number of rounds in all ammo crates linked to an ACF weapon ";};["acfTotalRatio"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the total ratio (current gear * final) for an ACF gearbox";["fname"]="acfTotalRatio";["name"]="ents_methods:acfTotalRatio";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the total ratio (current gear * final) for an ACF gearbox ";};["acfType"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Returns the type of ACF entity";["fname"]="acfType";["name"]="ents_methods:acfType";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Returns the type of ACF entity ";};["acfUnlinkFrom"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Perform ACF unlinks";["fname"]="acfUnlinkFrom";["name"]="ents_methods:acfUnlinkFrom";["param"]={[1]="target";[2]="notify";};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Perform ACF unlinks ";};["acfUnload"]={["class"]="function";["classlib"]="Entity";["description"]="\ -Causes an ACF weapon to unload";["fname"]="acfUnload";["name"]="ents_methods:acfUnload";["param"]={};["private"]=false;["realm"]="sv";["server"]=true;["summary"]="\ -Causes an ACF weapon to unload ";};};["name"]="Entity";["param"]={};["summary"]="\ -Entity type ";["typtbl"]="ents_methods";};};["directives"]={};["hooks"]={};["libraries"]={[1]="acf";["acf"]={["class"]="library";["description"]="\ - \ -ACF Library";["fields"]={};["functions"]={[1]="createAmmo";[10]="getAllFuelTanks";[11]="getAllGearboxes";[12]="getAllGuns";[13]="getAllMobility";[14]="getAmmoSpecs";[15]="getFuelTankSpecs";[16]="getGunSpecs";[17]="getMobilitySpecs";[18]="infoRestricted";[2]="createFuelTank";[3]="createGun";[4]="createMobility";[5]="dragDivisor";[6]="effectiveArmor";[7]="getAllAmmo";[8]="getAllAmmoBoxes";[9]="getAllEngines";["createAmmo"]={["class"]="function";["description"]="\ -Creates a ammo box given the id";["fname"]="createAmmo";["library"]="acf";["name"]="acf_library.createAmmo";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="gun_id";[5]="ammo_id";[6]="frozen";[7]="ammo_data";["ammo_data"]="the ammo data";["ammo_id"]="id of the ammo";["ang"]="Angle of created ammo box";["frozen"]="True to spawn frozen";["gun_id"]="id of the gun";["id"]="id of the ammo box to create";["pos"]="Position of created ammo box";};["private"]=false;["realm"]="sv";["ret"]="The created ammo box";["server"]=true;["summary"]="\ -Creates a ammo box given the id ";["usage"]="\ -If ammo_data isn't provided default values will be used (same as in the ACF menu) \ -Possible values for ammo_data corresponding to ammo_id: \ - \ -AP: \ -- propellantLength (number) \ -- projectileLength (number) \ -- tracer (bool) \ - \ -APHE: \ -- propellantLength (number) \ -- projectileLength (number) \ -- heFillerVolume (number) \ -- tracer (bool) \ - \ -FL: \ -- propellantLength (number) \ -- projectileLength (number) \ -- flechettes (number) \ -- flechettesSpread (number) \ -- tracer (bool) \ - \ -HE: \ -- propellantLength (number) \ -- projectileLength (number) \ -- heFillerVolume (number) \ -- tracer (bool) \ - \ -HEAT: \ -- propellantLength (number) \ -- projectileLength (number) \ -- heFillerVolume (number) \ -- crushConeAngle (number) \ -- tracer (bool) \ - \ -HP: \ -- propellantLength (number) \ -- projectileLength (number) \ -- heFillerVolume (number) \ -- hollowPointCavityVolume (number) \ -- tracer (bool) \ - \ -SM: \ -- propellantLength (number) \ -- projectileLength (number) \ -- smokeFillerVolume (number) \ -- wpFillerVolume (number) \ -- fuseTime (number) \ -- tracer (bool) \ - \ -Refil: \ -";};["createFuelTank"]={["class"]="function";["description"]="\ -Creates a fuel tank given the id";["fname"]="createFuelTank";["library"]="acf";["name"]="acf_library.createFuelTank";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="fueltype";[5]="frozen";["ang"]="Angle of created fuel tank";["frozen"]="True to spawn frozen";["fueltype"]="The type of fuel to use (Diesel, Electric, Petrol)";["id"]="id of the fuel tank to create";["pos"]="Position of created fuel tank";};["private"]=false;["realm"]="sv";["ret"]="The created fuel tank";["server"]=true;["summary"]="\ -Creates a fuel tank given the id ";};["createGun"]={["class"]="function";["description"]="\ -Creates a fun given the id or name";["fname"]="createGun";["library"]="acf";["name"]="acf_library.createGun";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="frozen";["ang"]="Angle of created gun";["frozen"]="True to spawn frozen";["id"]="id or name of the gun to create";["pos"]="Position of created gun";};["private"]=false;["realm"]="sv";["ret"]="The created gun";["server"]=true;["summary"]="\ -Creates a fun given the id or name ";};["createMobility"]={["class"]="function";["description"]="\ -Creates a engine or gearbox given the id or name";["fname"]="createMobility";["library"]="acf";["name"]="acf_library.createMobility";["param"]={[1]="pos";[2]="ang";[3]="id";[4]="frozen";[5]="gear_ratio";["ang"]="Angle of created engine or gearbox";["frozen"]="True to spawn frozen";["gear_ratio"]="A table containing the gear ratios, only applied if the mobility is a gearbox. -1 is final drive";["id"]="id or name of the engine or gearbox to create";["pos"]="Position of created engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The created engine or gearbox";["server"]=true;["summary"]="\ -Creates a engine or gearbox given the id or name ";};["dragDivisor"]={["class"]="function";["description"]="\ -Returns current ACF drag divisor";["fname"]="dragDivisor";["library"]="acf";["name"]="acf_library.dragDivisor";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The current drag divisor";["server"]=true;["summary"]="\ -Returns current ACF drag divisor ";};["effectiveArmor"]={["class"]="function";["description"]="\ -Returns the effective armor given an armor value and hit angle";["fname"]="effectiveArmor";["library"]="acf";["name"]="acf_library.effectiveArmor";["param"]={[1]="armor";[2]="angle";};["private"]=false;["realm"]="sv";["ret"]="The effective armor";["server"]=true;["summary"]="\ -Returns the effective armor given an armor value and hit angle ";};["getAllAmmo"]={["class"]="function";["description"]="\ -Returns a list of all ammo types";["fname"]="getAllAmmo";["library"]="acf";["name"]="acf_library.getAllAmmo";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The ammo list";["server"]=true;["summary"]="\ -Returns a list of all ammo types ";};["getAllAmmoBoxes"]={["class"]="function";["description"]="\ -Returns a list of all ammo boxes";["fname"]="getAllAmmoBoxes";["library"]="acf";["name"]="acf_library.getAllAmmoBoxes";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The ammo box list";["server"]=true;["summary"]="\ -Returns a list of all ammo boxes ";};["getAllEngines"]={["class"]="function";["description"]="\ -Returns a list of all engines";["fname"]="getAllEngines";["library"]="acf";["name"]="acf_library.getAllEngines";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The engine list";["server"]=true;["summary"]="\ -Returns a list of all engines ";};["getAllFuelTanks"]={["class"]="function";["description"]="\ -Returns a list of all fuel tanks";["fname"]="getAllFuelTanks";["library"]="acf";["name"]="acf_library.getAllFuelTanks";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The fuel tank list";["server"]=true;["summary"]="\ -Returns a list of all fuel tanks ";};["getAllGearboxes"]={["class"]="function";["description"]="\ -Returns a list of all gearboxes";["fname"]="getAllGearboxes";["library"]="acf";["name"]="acf_library.getAllGearboxes";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The gearbox list";["server"]=true;["summary"]="\ -Returns a list of all gearboxes ";};["getAllGuns"]={["class"]="function";["description"]="\ -Returns a list of all guns";["fname"]="getAllGuns";["library"]="acf";["name"]="acf_library.getAllGuns";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The guns list";["server"]=true;["summary"]="\ -Returns a list of all guns ";};["getAllMobility"]={["class"]="function";["description"]="\ -Returns a list of all mobility components";["fname"]="getAllMobility";["library"]="acf";["name"]="acf_library.getAllMobility";["param"]={};["private"]=false;["realm"]="sv";["ret"]="The mobility component list";["server"]=true;["summary"]="\ -Returns a list of all mobility components ";};["getAmmoSpecs"]={["class"]="function";["description"]="\ -Returns the specs of the ammo";["fname"]="getAmmoSpecs";["library"]="acf";["name"]="acf_library.getAmmoSpecs";["param"]={[1]="id";["id"]="id of the ammo";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ -Returns the specs of the ammo ";};["getFuelTankSpecs"]={["class"]="function";["description"]="\ -Returns the specs of the fuel tank";["fname"]="getFuelTankSpecs";["library"]="acf";["name"]="acf_library.getFuelTankSpecs";["param"]={[1]="id";["id"]="id of the engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ -Returns the specs of the fuel tank ";};["getGunSpecs"]={["class"]="function";["description"]="\ -Returns the specs of gun";["fname"]="getGunSpecs";["library"]="acf";["name"]="acf_library.getGunSpecs";["param"]={[1]="id";["id"]="id or name of the gun";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ -Returns the specs of gun ";};["getMobilitySpecs"]={["class"]="function";["description"]="\ -Returns the specs of the engine or gearbox";["fname"]="getMobilitySpecs";["library"]="acf";["name"]="acf_library.getMobilitySpecs";["param"]={[1]="id";["id"]="id or name of the engine or gearbox";};["private"]=false;["realm"]="sv";["ret"]="The specs table";["server"]=true;["summary"]="\ -Returns the specs of the engine or gearbox ";};["infoRestricted"]={["class"]="function";["description"]="\ -Returns true if functions returning sensitive info are restricted to owned props";["fname"]="infoRestricted";["library"]="acf";["name"]="acf_library.infoRestricted";["param"]={};["private"]=false;["realm"]="sv";["ret"]="True if restriced, False if not";["server"]=true;["summary"]="\ -Returns true if functions returning sensitive info are restricted to owned props ";};};["libtbl"]="acf_library";["name"]="acf";["summary"]="\ - \ -ACF Library ";["tables"]={};};};}) - -return function() end diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua index 907fcc624..bfa88d2d5 100644 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -67,6 +67,9 @@ local propProtectionInstalled = FindMetaTable("Entity").CPPIGetOwner and true ---------------------------------------- -- ACF Library +-- @name acf +-- @class library +-- @libtbl acf_library SF.RegisterLibrary("acf") -- Local to each starfall @@ -608,6 +611,8 @@ ammo_properties.SM.create_data = { ammo_properties.Refill.create_data = {} --- Creates a ammo box given the id +-- If ammo_data isn't provided default values will be used (same as in the ACF menu) +-- Possible values for ammo_data corresponding to ammo_id: -- @param pos Position of created ammo box -- @param ang Angle of created ammo box -- @param id id of the ammo box to create @@ -617,9 +622,6 @@ ammo_properties.Refill.create_data = {} -- @param ammo_data the ammo data -- @server -- @return The created ammo box --- @usage --- If ammo_data isn't provided default values will be used (same as in the ACF menu) --- Possible values for ammo_data corresponding to ammo_id: -- -- AP: -- \- propellantLength (number) From b09ec41fe23dd510aa48025af1b540eb26e95a98 Mon Sep 17 00:00:00 2001 From: DaDamRival Date: Fri, 14 Feb 2020 00:25:12 +0100 Subject: [PATCH 7/7] fixed entity wrap and unwrap --- lua/starfall/libs_sv/acffunctions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/starfall/libs_sv/acffunctions.lua b/lua/starfall/libs_sv/acffunctions.lua index bfa88d2d5..19a6b5e3f 100644 --- a/lua/starfall/libs_sv/acffunctions.lua +++ b/lua/starfall/libs_sv/acffunctions.lua @@ -79,7 +79,7 @@ return function(instance) -- Called for library declarations local checktype = instance.CheckType local acf_library = instance.Libraries.acf local owrap, ounwrap = instance.WrapObject, instance.UnwrapObject -local ents_methods, ent_meta, ewrap, eunwrap = instance.Types.Entity.Methods, instance.Types.Entity, instance.Types.Entity.Wrap, instance.Types.Entity.Unwrap +local ents_methods, ent_meta, wrap, unwrap = instance.Types.Entity.Methods, instance.Types.Entity, instance.Types.Entity.Wrap, instance.Types.Entity.Unwrap local ang_meta, awrap, aunwrap = instance.Types.Angle, instance.Types.Angle.Wrap, instance.Types.Angle.Unwrap local vec_meta, vwrap, vunwrap = instance.Types.Vector, instance.Types.Vector.Wrap, instance.Types.Vector.Unwrap