Editing Module:Test/data/virtual
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | + | local DefInfo = DefInfo or require "DefInfo" | |
− | + | ||
− | |||
local VF = {} | local VF = {} | ||
− | VF. | + | VF.vfields = {} |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | } | ||
− | -- | + | --------------- |
− | -- | + | -- tools.DPS -- |
− | -- | + | --------------- |
− | -- | + | function VF.vfields.unarmedDPS(def) |
− | -- | + | if not def.tools then return nil end |
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | -- | ||
− | |||
− | |||
− | + | for _,tool in ipairs(def.tools) do | |
− | + | local dps = tool.power / tool.cooldownTime | |
− | + | if dps then tool.DPS = Util.round(dps, 3) end | |
− | + | end | |
− | + | end | |
− | |||
− | |||
− | |||
− | + | --------------- | |
− | + | -- verbs.DPS -- | |
− | + | --------------- | |
− | + | function VF.vfields.verbsDPS(def) | |
− | + | local filters = { | |
− | + | {'verbs', 1, 'defaultProjectile'}, | |
− | if not def | + | {'verbs', 1, 'warmupTime'}, |
+ | {'statBases', 'RangedWeapon_Cooldown'} | ||
+ | } | ||
+ | if not Util.table.checkMultiple(def, filters) then return nil end | ||
− | + | local projectile = DefInfo.getDef(def.verbs[1].defaultProjectile) | |
− | + | local warmup = def.verbs[1].warmupTime | |
− | + | local cooldown = def.statBases.RangedWeapon_Cooldown | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | if not projectile then return nil end | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | local burst = def.verbs[1].burstShotCount | |
− | local | + | local pause = def.verbs[1].ticksBetweenBurstShots |
+ | local damage = Util.table.check(projectile, 'projectile', 'damageAmountBase') and projectile.projectile.damageAmountBase | ||
+ | local dps | ||
− | + | if burst and pause then | |
− | + | dps = damage * burst / (warmup + cooldown + burst*(pause/60)) | |
− | + | else | |
− | + | dps = damage / (warmup + cooldown) | |
− | + | end | |
− | |||
− | + | if dps then | |
− | + | def.verbs[1].DPS = Util.round(dps, 3) | |
− | + | end | |
− | + | end | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ------------------------------------- | |
− | + | -- naturally lives in these biomes -- | |
− | + | ------------------------------------- | |
− | + | function VF.vfields.raceLivesIn(def) | |
− | + | if def.thingClass ~= 'Pawn' then return nil end | |
− | + | local biomes = {} | |
− | |||
− | |||
− | |||
− | |||
− | + | for biomeK,biome in pairs(Data) do | |
− | + | if Util.table.check(biome, 'wildAnimals') then | |
− | + | for animalK,animal in pairs(biome.wildAnimals) do | |
− | + | if animalK == def.defName then | |
− | + | table.insert(biomes, biome.defName) | |
− | |||
− | |||
− | |||
end | end | ||
end | end | ||
end | end | ||
+ | end | ||
− | + | if #biomes > 0 then | |
− | + | def._.livesIn = biomes | |
− | + | end | |
− | + | end | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ------------------------ | |
− | + | -- module entry point -- | |
− | + | ------------------------ | |
− | + | function VF.expand(mergedDef) | |
− | + | for k,func in pairs(VF.vfields) do | |
− | + | func(mergedDef) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
+ | end | ||
− | + | return VF | |
− |