Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- KiraScripts = KiraScripts or {}
- include( "kira_modules.lua" )
- function RaPD_MakeTimedHookBeforeDead(name, user, target, limb, endTime, tickTime, tickFunc, endFunc, conditionFunc)
- local hookName = target:EntIndex().."_"..limb.."_Bandage_Think"
- local limbName = limb
- local endVarName = "RaPD_"..name.."_EndTime_"..limb
- local tickVarName = "RaPD_"..name.."_TickTime_"..limb
- target[endVarName] = CurTime() + endTime
- target[tickVarName] = CurTime() + tickTime
- hook.Add( "Think", hookName, function()
- local isValid = IsValid(target)
- if !isValid or !target:Alive() or (target[endVarName] and target[endVarName] <= CurTime()) or (isfunction(conditionFunc) and conditionFunc()) then
- if isfunction(endFunc) then endFunc() end
- hook.Remove( "Think", hookName)
- target[endVarName] = nil
- target[tickVarName] = nil
- elseif target[tickVarName] and target[tickVarName] <= CurTime() then
- if isfunction(tickFunc) then tickFunc() end
- target[tickVarName] = CurTime() + tickTime
- end
- end )
- end
- local function healBandages(mult, target, limb)
- target:RaPD_HealDamageLimb(2*mult, "piercing", limb)
- target:RaPD_HealDamageLimb(1*mult, "slash", limb)
- target:RaPD_HealDamageLimb(0.25*mult, "burn", limb)
- target:RaPD_HealDamageLimb(1.5*mult, "blast", limb)
- target:RaPD_HealDamageLimb(2*mult, "blunt", limb)
- end
- local function healBurns(mult, target, limb)
- target:RaPD_HealDamageLimb(1*mult, "burn", limb)
- end
- local function injectReagentFromContainer(item, count, target, reagent)
- local reagents = target.RaPD_Organism.Stats.reagents
- local count = count + (math.min(item.reagentCount - count, 0))
- item.reagentCount = item.reagentCount - count
- KiraScripts.RaPD_Reagents_FastCalc(reagents.Circulatory, reagent, count)
- end
- local function eatReagentFromContainer(item, count, target, reagent)
- local reagents = target.RaPD_Organism.Stats.reagents
- local count = count + (math.min(item.reagentCount - count, 0))
- //print("В предмете вычтется: ", count)
- //print("В предмете до: ", item.reagentCount)
- item.reagentCount = item.reagentCount - count
- //print("------")
- //print("В предмете после: ", item.reagentCount)
- //print("В организме до: ", reagents.Stomach[reagent])
- KiraScripts.RaPD_Reagents_FastCalc(reagents.Stomach, reagent, count)
- //print("В организме после: ", reagents.Stomach[reagent])
- //print("---------------------------")
- end
- local function takeOutItem(ply, item)
- if SERVER then
- local pos = util.TraceLine( {
- start = ply:EyePos(),
- endpos = ply:EyePos() + ply:EyeAngles():Forward()*60,
- filter = function( ent ) return ent == ply end
- } ).HitPos
- local ent = ents.Create( item.entityForDrop or "rapd_inventory_item" )
- ent:SetPos( pos )
- item.owner = ent
- ent.item = item
- ent:SetAngles( Angle(0, ply:EyeAngles().y + 180,0) )
- ent:Spawn()
- ent:Activate()
- end
- end
- local function surgeryOpen(target, org, limb)
- target:EmitSound("physics/flesh/flesh_squishy_impact_hard1.wav")
- if !org[limb].surgeryOpenedScar then
- target:RaPD_HealDamageLimb(-org[limb].MaxHP*0.25, "slash", limb)
- org[limb].surgeryOpenedScar = true
- end
- end
- local function surgeryClose(target, org, limb)
- target:EmitSound("physics/flesh/flesh_squishy_impact_hard4.wav")
- if org[limb].surgeryOpenedScar then
- target:RaPD_HealDamageLimb(org[limb].MaxHP*0.25, "slash", limb)
- org[limb].surgeryOpenedScar = false
- end
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- end
- RaPD_UniversalUses = {
- TakeOut = {
- Queue = 100,
- Limbs = "All",
- UseTime = 0.5,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- takeOutItem(user, item)
- return true
- end,
- },
- BloodSample = {
- Queue = 2,
- Limbs = {"RightArm", "LeftArm"},
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- local org = target.RaPD_Organism
- local data = org[limb]
- target:RaPD_TakeDamageLimb(1, "piercing", limb)
- target:EmitSound("garrysmod/ui_click.wav")
- target:EmitSound("physics/flesh/flesh_impact_bullet1.wav")
- target:RaPD_SetBleeding(limb, true, 8, 20)
- item.scanResultsMode = "Circulatory"
- item.scanResultsLimb = limb
- item.scanResults = table.Copy(org.Stats.reagents)
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- return false
- end,
- },
- SalivaSample = {
- Queue = 3,
- Limbs = "Head",
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- local org = target.RaPD_Organism
- local data = org[limb]
- target:EmitSound("garrysmod/ui_click.wav")
- item.scanResultsMode = "Stomach"
- item.scanResultsLimb = limb
- item.scanResults = table.Copy(org.Stats.reagents)
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- return false
- end,
- },
- ScanLimbs = {
- Queue = 1,
- Limbs = "All",
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- local org = target.RaPD_Organism
- local data = org[limb]
- target:EmitSound("garrysmod/ui_click.wav")
- item.scanResultsMode = "Limbs"
- item.scanResultsLimb = limb
- item.scanResults = table.Copy(data)
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- return false
- end,
- },
- ScanOrgans = {
- Queue = 8,
- Limbs = "All",
- UseTime = 2,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- local data = org[limb]
- return data.Organs
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- local org = target.RaPD_Organism
- local data = org[limb]
- target:EmitSound("garrysmod/ui_click.wav")
- item.scanResultsMode = "Organs"
- item.scanResultsLimb = limb
- item.scanResults = table.Copy(data.Organs)
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- return false
- end,
- },
- }
- RaPD_Items = {
- ["kira_bandage"] = {
- model = "models/props_junk/PopCan01a.mdl",
- material = "phoenix_storms/fender_white",
- model_color = Color(255,200,130),
- icon = "materials/kira_rapd/items/bandage.png",
- icon_color = Color(255,200,130),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["ApplyBandage"] = {
- Queue = 1,
- Limbs = "All",
- UseTime = 1.8,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- if !org then return end
- local limbData = org[limb]
- return true//!limbData.bandaged
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- if !item.uses then
- item.uses = 3
- end
- local org = target.RaPD_Organism
- if !org then return end
- local limbData = org[limb]
- if limbData.bleeding then limbData.bleeding = false end
- healBandages(2, target, limb)
- item.uses = item.uses - 1
- limbData.bandaged = true
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- RaPD_MakeTimedHookBeforeDead("BandageHealing", user, target, limb, 30, 1, function()
- healBandages(0.5, target, limb)
- // print("Исцеление от ",user," на ",target, "с конечностью ", limb)
- end, function()
- // print("Завершение исцеления от ",user," на ",target, "с конечностью ", limb)
- limbData.bandaged = false
- target:RaPD_UpdateHealthInfoOnClientsNOW()
- end)
- return item.uses <= 0
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_burn_ointment"] = {
- model = "models/props_lab/jar01b.mdl",
- model_color = Color(255,255,130),
- icon = "materials/kira_rapd/items/ointment.png",
- icon_color = Color(255,255,130),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["ApplyOintment"] = {
- Queue = 1,
- Limbs = "All",
- UseTime = 2,
- conditions = function(user, target, limb)
- return !target:GetNW2Bool("Limb_BurnCure_"..limb, false)
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- if !item.uses then
- item.uses = 5
- end
- local org = target.RaPD_Organism
- if !org then return end
- local limbData = org[limb]
- if limbData.bleeding then limbData.bleeding = false end
- healBurns(2, target, limb)
- item.uses = item.uses - 1
- target:SetNW2Bool("Limb_BurnCure_"..limb, true)
- RaPD_MakeTimedHookBeforeDead("OintmentHealing", user, target, limb, 20, 1, function()
- healBurns(0.5, target, limb)
- // print("Исцеление от ",user," на ",target, "с конечностью ", limb)
- end, function()
- // print("Завершение исцеления от ",user," на ",target, "с конечностью ", limb)
- target:SetNW2Bool("Limb_BurnCure_"..limb, false)
- end)
- return item.uses <= 0
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_syringe"] = {
- model = "models/props_c17/TrapPropeller_Lever.mdl",
- model_color = Color(0,0,0),
- icon = "materials/kira_rapd/items/syringe.png",
- reagentsContainer = true,
- reagentsLimit = 80,
- icon_color = Color(180,180,200),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["Inject10"] = {
- Queue = 1,
- Limbs = "All",
- UseTime = 1.5,
- conditions = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- end
- end,
- onUseEnd = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- injectReagentFromContainer(item, 10, target, item.reagent)
- end
- return false
- end,
- },
- ["Inject20"] = {
- Queue = 2,
- Limbs = "All",
- UseTime = 2,
- conditions = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- end
- end,
- onUseEnd = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- injectReagentFromContainer(item, 20, target, item.reagent)
- end
- return false
- end,
- },
- ["Inject40"] = {
- Queue = 3,
- Limbs = "All",
- UseTime = 3,
- conditions = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- end
- end,
- onUseEnd = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- injectReagentFromContainer(item, 40, target, item.reagent)
- end
- return false
- end,
- },
- ["Inject80"] = {
- Queue = 4,
- Limbs = "All",
- UseTime = 6,
- conditions = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- end
- end,
- onUseEnd = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 then
- injectReagentFromContainer(item, 80, target, item.reagent)
- end
- return false
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_bloodbag"] = {
- model = "models/Items/HealthKit.mdl",
- model_color = Color(200,70,70),
- icon = "materials/kira_rapd/items/bloodbagbig.png",
- reagentsContainer = true,
- reagentsLimit = 1000,
- icon_color = Color(180,180,200),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["BloodBagInject"] = {
- Queue = 1,
- Limbs = "All",
- UseTime = 1.2,
- conditions = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 and !target.RaPD_Organism[limb].bloodbagAttached and !item.opened then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- end,
- onUseEnd = function(user, target, limb, item)
- if item.reagent and item.reagentCount and item.reagentCount > 0 and !item.opened then
- target.RaPD_Organism[limb].bloodbagAttached = true
- item.opened = true
- local endInjection
- RaPD_MakeTimedHookBeforeDead("BloodBagInjectionThink_"..tostring(item), user, target, limb, 100, 0.4, function()
- if item.owner and IsValid(item.owner) and item.owner:GetPos():Distance(target:GetPos()) < 250 then
- injectReagentFromContainer(item, 5, target, item.reagent)
- if item.owner:IsPlayer() then item.owner:RaPD_UpdateInventory(2) end
- // print("Исцеление от ",user," на ",target, "с конечностью ", limb)
- else
- endInjection = true
- target:RaPD_TakeDamageLimb(6, "piercing", limb)
- target:EmitSound("physics/flesh/flesh_impact_bullet1.wav")
- target:RaPD_SetBleeding(limb, true, 25, 65)
- net.Start( "RaPD_SpreadBlood" )
- net.WriteEntity(target)
- net.WriteFloat( 1 )
- net.Broadcast()
- // print("Экстренное завершение исцеления от ",user," на ",target, "с конечностью ", limb)
- end
- end, function()
- // print("Завершение исцеления от ",user," на ",target, "с конечностью ", limb)
- target.RaPD_Organism[limb].bloodbagAttached = false
- item.opened = false
- end, function()
- return endInjection or !item.opened or (!item.reagent or !item.reagentCount or item.reagentCount <= 0)
- end)
- end
- end,
- },
- ["BloodBagClose"] = {
- Queue = 2,
- Limbs = "All",
- UseTime = 0.7,
- conditions = function(user, target, limb, item)
- if item.opened then
- return true
- end
- return false
- end,
- onUseStart = function(user, target, limb, item)
- end,
- onUseEnd = function(user, target, limb, item)
- if item.opened then
- item.opened = false
- end
- end,
- },
- ["Drink"] = {
- Queue = 3,
- Limbs = "Head",
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb, item)
- local org = target.RaPD_Organism
- local stom = org.Stats.reagents.Stomach
- eatReagentFromContainer(item, 150, target, item.reagent)
- return false
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_pill_charcoal"] = {
- model = "models/props_lab/jar01b.mdl",
- model_color = Color(80,155,80),
- icon = "materials/kira_rapd/items/pill.png",
- icon_color = Color(80,155,80),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["Eat"] = {
- Queue = 1,
- Limbs = "Head",
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb)
- local org = target.RaPD_Organism
- local stom = org.Stats.reagents.Stomach
- stom.charcoal = (stom.charcoal or 0) + 20
- /*
- local org = target.RaPD_Organism
- local stom = org.Stats.reagents.Stomach
- target:SetNW2Bool("Limb_CharcoalCure_"..limb, true)
- RaPD_MakeTimedHookBeforeDead("CharcoalHealing", user, target, limb, 30, 1, function()
- target:RaPD_HealDamageAllLimbsPercent(0.005, "toxin")
- print("Исцеление от ",user," на ",target, "с конечностью ", limb)
- end, function()
- print("Завершение исцеления от ",user," на ",target, "с конечностью ", limb)
- target:SetNW2Bool("Limb_CharcoalCure_"..limb, false)
- end)
- */
- return true
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_splint"] = {
- model = "models/props_junk/garbage_bag001a.mdl",
- material = "phoenix_storms/fender_white",
- icon = "materials/kira_rapd/items/splint.png",
- useMethods = {
- ["ApplySplint"] = {
- Queue = 1,
- Limbs = {"LeftArm","LeftLeg","RightArm","RightLeg",},
- UseTime = 10,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- return org and org[limb] and org[limb].fracture
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb)
- local org = target.RaPD_Organism
- if !org then return end
- if org[limb].fracture then
- org[limb].fracture = false
- target:RaPD_UpdateHealthInfoOnClients()
- return true
- end
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_surgery_kit"] = {
- model = "models/props_c17/BriefCase001a.mdl",
- icon = "materials/kira_rapd/items/medkit_surgery.png",
- icon_color = Color(130,130,180),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["Surgery_FixOrgans"] = {
- Queue = 1,
- Limbs = {"Chest", "Head"},
- UseTime = 15,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- local data = org[limb]
- return data.Organs
- end,
- onUseStart = function(user, target, limb)
- local org = target.RaPD_Organism
- target:RaPD_UpdateHealthInfoOnClients()
- target:RaPD_SetBleeding(limb, true, 30, 120)
- surgeryOpen(target, org, limb)
- end,
- onUseEnd = function(user, target, limb)
- if (!target.RaPD_Organism) or !limb or !target.RaPD_Organism[limb] or !target.RaPD_Organism[limb].Organs then return end
- local organs = target.RaPD_Organism[limb].Organs
- for organ, data in pairs(organs) do
- if data.MaxHP and data.DMG and data.DMG > 0 then
- data.DMG = 0
- user:RaPD_Thought_Localized({"HealingOrgans", organ}, Color(250,250,250), 4, 1, 1, 1, 5, 8)
- end
- end
- local org = target.RaPD_Organism
- target:RaPD_SetBleeding(limb, false)
- surgeryClose(target, org, limb)
- target:RaPD_UpdateHealthInfoOnClients()
- end,
- },
- ["Surgery_FixBones"] = {
- Queue = 2,
- Limbs = {"LeftArm", "LeftLeg", "RightArm", "RightLeg", "Chest", "Head"},
- UseTime = 15,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- return org and org[limb] and org[limb].fracture
- end,
- onUseStart = function(user, target, limb)
- local org = target.RaPD_Organism
- target:RaPD_SetBleeding(limb, true, 30, 120)
- surgeryOpen(target, org, limb)
- end,
- onUseEnd = function(user, target, limb)
- local org = target.RaPD_Organism
- target:RaPD_SetBleeding(limb, false)
- surgeryClose(target, org, limb)
- if !org then return end
- if org[limb].fracture then
- org[limb].fracture = false
- end
- end,
- },
- ["Surgery_Close"] = {
- Queue = 3,
- Limbs = "All",
- UseTime = 2,
- conditions = function(user, target, limb)
- local org = target.RaPD_Organism
- return org and org[limb] and org[limb].surgeryOpenedScar
- end,
- onUseStart = function(user, target, limb)
- local org = target.RaPD_Organism
- end,
- onUseEnd = function(user, target, limb)
- local org = target.RaPD_Organism
- target:RaPD_SetBleeding(limb, false)
- surgeryClose(target, org, limb)
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_scanner_lite"] = {
- model = "models/Items/battery.mdl",
- model_color = Color(65,155,222),
- icon = "materials/kira_rapd/items/scanner_lite.png",
- icon_color = Color(65,155,222),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["ScanReagents"] = RaPD_UniversalUses.BloodSample,
- ["ScanReagentsStomach"] = RaPD_UniversalUses.SalivaSample,
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- ["kira_scanner_full"] = {
- model = "models/Items/battery.mdl",
- model_color = Color(222,100,167),
- icon = "materials/kira_rapd/items/scanner.png",
- icon_color = Color(222,100,167),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["ScanReagents"] = RaPD_UniversalUses.BloodSample,
- ["ScanReagentsStomach"] = RaPD_UniversalUses.SalivaSample,
- ["ScanLimbs"] = RaPD_UniversalUses.ScanLimbs,
- ["ScanOrgans"] = RaPD_UniversalUses.ScanOrgans,
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },
- --------------------------------------------------
- ---------------------- Food ----------------------
- --------------------------------------------------
- /*["kira_burger"] = {
- model = "models/food/burger.mdl",
- model_color = Color(255,255,255),
- icon = "materials/kira_rapd/items/burger.png",
- icon_color = Color(210,172,87),
- icon_color_back = Color(0,0,0),
- useMethods = {
- ["Eat"] = {
- Queue = 1,
- Limbs = "Head",
- UseTime = 1,
- conditions = function(user, target, limb)
- return true
- end,
- onUseStart = function(user, target, limb)
- end,
- onUseEnd = function(user, target, limb)
- local org = target.RaPD_Organism
- local stom = org.Stats.reagents.Stomach
- stom.nutrients = (stom.nutrients or 0) + 1200
- return true
- end,
- },
- ["TakeOut"] = RaPD_UniversalUses.TakeOut,
- },
- },*/
- }
- function KiraScripts.RaPD_AddItem(name, data)
- if !name or !data then
- print("[RaPD] Error! Item ( "..tostring(name).." ) can not be added!")
- return end
- RaPD_Items[name] = data
- print("[RaPD] Item "..tostring(name).." succesfully added.")
- end
- print("[RaPD] - Items are loaded.")
- KiraExpansions.InitializeAddons("RaPD_Items")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement