Code: Select all
wound_list = {}
function wound_list_global()
return wound_list
end
function checkWoundsEffectandHealing()
local medicSkill = cromlibrary.script.checkSkillLevel("medic")
if wound_list[1] == nil then
findEntity("woundevolution_timer").timer:stop()
return
end
for k,v in pairs(wound_list) do
local wound = wound_list[k]
if party.party:getChampion(wound.champion_number):isAlive() == false then
table.remove(wound_list,k)
end
local woundBandaged = wound.bandaged
local woundEvolution = math.random(1,12)
local bandageBonus = -1
local infection = 0
local vitalityStat = party.party:getChampion(wound.champion_number):getBaseStat("vitality")
if wound.infected then
local infectiondamage = math.min(4,math.random(2,6)-medicSkill)/2
party.party:getChampion(wound.champion_number):damage(infectiondamage,"poison")
party.party:getChampion(wound.champion_number):damage(infectiondamage,"physical")
crompermanentlog.script.addPermanentMessage(wound.champion_hit.." suffers from "..infectiondamage.." poison and physical damage from infected wound.",true)
elseif wound.infected == false then
local infectioncheck = math.random(1,100)
local infectionchance = 30-(medicSkill*3)-bandageBonus
if infectioncheck <= infectionchance then
wound.infected = true
crompermanentlog.script.addPermanentMessage("One of "..wound.champion_hit.."'s wound is now infected.",true)
end
end
if wound.infected then infection = -2 end
if woundBandaged then bandageBonus = 3 end
if woundEvolution<=4+medicSkill+bandageBonus+infection then
if wound.wound_attribute == "health" then
party.party:getChampion(wound.champion_number):modifyBaseStat(wound.wound_attribute,wound.attribute_damage)
end
if wound.wound_attribute == "energy" then
party.party:getChampion(wound.champion_number):modifyBaseStat(wound.wound_attribute,wound.attribute_damage)
end
party.party:getChampion(wound.champion_number):modifyBaseStat(wound.wound_attribute,wound.attribute_damage)
crompermanentlog.script.addPermanentMessage(wound.champion_hit.." heals from a "..wound.wound_severity.." "..wound.attribute_damage.." "..wound.wound_attribute.." wound.",true)
table.remove(wound_list,k)
end
end
end
function applyBandages(champion,bandagesBonus)
if wound_list[1] == nil then
findEntity("woundevolution_timer").timer:stop()
return
end
for k,v in pairs(wound_list) do
local wound = wound_list[k]
if champion == party.party:getChampion(wound.champion_number) then
if wound.bleeding >= 1 then
local bandage_bleeding_reduction = math.random(3,5)+bandagesBonus
wound.bleeding = math.max(0,wound.bleeding-bandage_bleeding_reduction)
if wound.bleeding == 0 then
hudPrint("A bleeding stops from bandaging")
end
return
end
end
end
for k,v in pairs(wound_list) do
local wound = wound_list[k]
if champion == party.party:getChampion(wound.champion_number) then
if wound.wound_severity == "critical" then
local woundBandaged = wound.bandaged
if woundBandaged == false then
wound.bandaged = true
break
end
return
end
end
end
for k,v in pairs(wound_list) do
local wound = wound_list[k]
if champion == party.party:getChampion(wound.champion_number) then
if wound.wound_severity == "severe" then
local woundBandaged = wound.bandaged
if woundBandaged == false then
wound.bandaged = true
break
end
end
end
end
end
function getWoundsNumbers(champion)
local severewounds = 0
local criticalwounds = 0
local lightwounds = 0
local bandagedwounds = 0
local infectedwounds = 0
local bleedingwounds = 0
for i = 1,#wound_list do
local wound = wound_list[i]
if wound.champion_hit == champion then
if wound.wound_severity == "severe" then severewounds = severewounds +1 end
if wound.wound_severity == "critical" then criticalwounds = criticalwounds +1 end
if wound.wound_severity == "light" then lightwounds = lightwounds +1 end
if wound.bandaged then bandagedwounds = bandagedwounds+1 end
if wound.infected then infectedwounds = infectedwounds+1 end
if wound.bleeding > 0 then bleedingwounds = bleedingwounds+1 end
end
end
return severewounds,criticalwounds,bandagedwounds,infectedwounds,bleedingwounds,lightwounds
end
--[[ )
spawn("counter", 1,26,1, "wounds_counter")
spawn("timer", 2,27,1, "wounds_timer")
:setTimerInterval(30)
:activate()
:addConnector("activate", "crom_wounds_script", "checkWoundsEffectandHealing")
spawn("timer", 4,27,0, "timer_28")
:setTimerInterval(10)
:activate()
:addConnector("activate", "crom_bleeding", "checkBleeding")
spawn("script_entity", 4,28,0, "crom_bleeding")
:setSource(" ]]
function checkBleeding()
--local wound_list_bleeding = crom_wounds_script.wound_list_global()
if wound_list[1] == nil then
findEntity("bleeding_timer").timer:stop()
findEntity("woundevolution_timer").timer:stop()
return
end
local bleedingOngoing = 0
for k,v in pairs(wound_list) do
local wound = wound_list[k]
if wound.bleeding then
if wound.bleeding > 0 then
bleedingOngoing = bleedingOngoing+1
party.party:getChampion(wound.champion_number):damage(wound.bleeding,"physical")
hudPrint(wound.champion_hit.." is bleeding for "..wound.bleeding.." points.")
local vitalityStat = party.party:getChampion(wound.champion_number):getBaseStat("vitality")/10
if math.random(1,6)+vitalityStat>=5 then
wound.bleeding = wound.bleeding-1
hudPrint(wound.champion_hit.."'s bleeding is reducing to "..wound.bleeding)
if wound.bleeding <= 0 then
bleedingOngoing = bleedingOngoing-1
hudPrint("A bleeding stops")
end
end
end
end
end
if bleedingOngoing<=0 then
findEntity("bleeding_timer").timer:stop()
end
end
--party damage
--[[ ]]
function checkChampDamage(party,champ,damamount,damtype)
local current_wound = {}
local slot = {1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,5,6,7,7,8,8,9,9,10}
local slotnumber = slot[math.random(1,#slot)]
local championName = champ:getName()
local championNumber = champ:getChampionByOrdinal()
local vitalityStat = champ:getBaseStat("vitality")
local typeOfWound = ""
local woundLocalisation = ""
local reducedAttribute = ""
local attribute_damage = 0
if slotnumber == 1 then woundLocalisation = "head" reducedAttribute = {4,4,4,4,4,4,5,6,6} end
if slotnumber == 2 then woundLocalisation = "torso" reducedAttribute = {1,1,1,3,3,3,5,5,5} end
if slotnumber == 3 then woundLocalisation = "legs" reducedAttribute = {1,1,1,1,3,3,5,5} end
if slotnumber == 4 then woundLocalisation = "feet" reducedAttribute = {1,1,1,1,3,3,5} end
if slotnumber == 5 then woundLocalisation = "back" reducedAttribute = {1,1,3,3,3,3,5,5} end
if slotnumber == 6 then woundLocalisation = "neck" reducedAttribute = {1,3,3,3,4,4,5,6} end
if slotnumber == 7 then woundLocalisation = "hand" reducedAttribute = {1,2,2,2,2,3} end
if slotnumber == 8 then woundLocalisation = "hand" reducedAttribute = {1,2,2,2,2,3} end
if slotnumber == 9 then woundLocalisation = "arm" reducedAttribute = {1,1,1,2,3,3} end
if slotnumber == 10 then woundLocalisation = "arm" reducedAttribute = {1,1,1,2,3,3} end
local reducedAttributePrenumber = reducedAttribute[math.random(1,#reducedAttribute)]
if reducedAttributePrenumber == 1 then reducedAttributenumber = "strength" end
if reducedAttributePrenumber == 2 then reducedAttributenumber = "dexterity" end
if reducedAttributePrenumber == 3 then reducedAttributenumber = "vitality" end
if reducedAttributePrenumber == 4 then reducedAttributenumber = "willpower" end
if reducedAttributePrenumber == 5 then reducedAttributenumber = "health" end
if reducedAttributePrenumber == 6 then reducedAttributenumber = "energy" end
if damamount>=(math.max(10,vitalityStat)) and damamount<(math.max(20,vitalityStat*2)) then
findEntity("woundevolution_timer").timer:start()
local bleedingDamage = 0
if damtype == "physical" then
if math.random()<=0.3 then
bleedingDamage = math.random(2,5)
end
end
current_wound["bleeding"] = bleedingDamage
attribute_damage = math.random(2,4)
current_wound["champion_hit"] = championName
current_wound["wound_attribute"] = reducedAttributenumber
if reducedAttributenumber == "health" then attribute_damage = attribute_damage*3 end
if reducedAttributenumber == "energy" then attribute_damage = attribute_damage*3 end
current_wound["attribute_damage"] = attribute_damage
current_wound["champion_number"] = championNumber
current_wound["bandaged"] = false
current_wound["infected"] = false
current_wound["wound_severity"] = "severe"
current_wound["damamount"] = damamount
typeOfWound = "severe wound"
table.insert(wound_list,current_wound)
elseif damamount>=(math.max(20,vitalityStat*2)) then
findEntity("woundevolution_timer").timer:start()
local bleedingDamage = 0
if damtype == "physical" then
if math.random()<=0.3 then
bleedingDamage = math.random(4,7)
end
end
current_wound["bleeding"] = bleedingDamage
attribute_damage = math.random(4,7)
current_wound["champion_hit"] = championName
current_wound["wound_attribute"] = reducedAttributenumber
if reducedAttributenumber == "health" then attribute_damage = attribute_damage*3 end
if reducedAttributenumber == "energy" then attribute_damage = attribute_damage*3 end
current_wound["attribute_damage"] = attribute_damage
current_wound["champion_number"] = championNumber
current_wound["bandaged"] = false
current_wound["infected"] = false
current_wound["wound_severity"] = "critical"
current_wound["damamount"] = damamount
typeOfWound = "CRITICAL wound"
table.insert(wound_list,current_wound)
-- else
-- current_wound["wound_severity"] = "light"
-- current_wound["champion_number"] = championNumber
-- current_wound["damamount"] = damamount
-- table.insert(wound_list,current_wound)
-- hudPrint(championName.." suffers minor bruises and cuts.")
end
if reducedAttributenumber == "health" then champ:modifyBaseStat(reducedAttributenumber,(attribute_damage*-1)) end
if reducedAttributenumber == "energy" then champ:modifyBaseStat(reducedAttributenumber,(attribute_damage*-1)) end
champ:modifyBaseStat(reducedAttributenumber,(attribute_damage*-1))
if damamount>=(math.max(10,vitalityStat)) then
hudPrint(championName.." suffers a "..typeOfWound.." in the "..woundLocalisation.." for "..attribute_damage.." "..reducedAttributenumber.." points.")
else
hudPrint(championName.." suffers minor bruises and cuts.")
end
if bleeding>0 then
findEntity("bleeding_timer").timer:start()
hudPrint("This wound is bleeding for "..bleeding.." HPs.")
end
end
Code: Select all
defineObject{name = "bandages",
class = "Item",
uiName = "bandages",
model = "assets/models/items/scroll.fbx",
gfxAtlas = "mod_assets/textures/TLC_items.tga",
gfxIndex = 45,
weight = 0.3,
stackable = true,
onUseItem =
function(self,champion)
local quality,qualityPriceBonus,qualityName,toolBonus = cromlibrary.script.renewedQualityBonus(string.sub(self.go.id,1,4))
local result,resultType,message = checkSkillSuccess("medic","dexterity","willpower",0,toolBonus,2,0,true,true,0.5,0,"")
local baseHealing = math.random(5,8)*(1+toolBonus)
if result < -10 then
local increasedDamage = math.modf(math.random(4,8)*(result*0.1))
champion:regainHealth(increasedDamage)
hudPrint("Bandaging critical failure. "..champion:getName().." suffers from "..increasedDamage.." increased damage.")
elseif result <= 0 then
hudPrint("Bandaging failure. "..champion:getName().." recovers only : "..baseHealing.." Hit points.")
champion:regainHealth(baseHealing)
elseif result > 0 then
cromwoundsystem.script.applyBandages(champion,toolBonus)
local skillBonusHealing = math.modf(0.1*result*baseHealing*3)
local finalHealing = (baseHealing*3)+skillBonusHealing
champion:regainHealth(finalHealing)
hudPrint("Bandaging success. "..champion:getName().." recovers "..finalHealing.." Hit points (base:"..(baseHealing*3)..";skill bonus:"..skillBonusHealing..").")
end
end,
}
Both are tied to other custom systems, notably my skill systems.
This is a work in progress (from the old log1 script I am porting to Log2, some function defintions are probably wrong, I need to test it), I might add a "first aid" skill, for bandaging, and light heals.
Medic is used as basic skill, and long term healing.