Page 1 of 1

wound and wound management system

Posted: Tue Sep 01, 2015 9:28 pm
by cromcrom
Hi all,

I open this thread to gather ideas about a semi realistic wound and wound management system for the party, that would replace the native one.

I already had a wound system back in log1, and would like to try to do almost the same on log2, but sexier, thanks to the GrimTK.

Really more a brainstorming than anythings...

body parts:
head
body
upper legs
lower legs
right arm
left arm

Type of wounds (depending on received damages):
light
medium
severe
critical
a combination of wounds could lead to the disabling of the body part (same as native effect maybe)

wounds effects:
bleeding
attributes loss
infection

skill used:
first aid using bandages on each wounds, to prevent infection, stop bleeding, and give back a very few HP immediately
chirurgy on the most severe wounds, to help healing and reduce attributes loss.
maybe medicine, to reduce infection chance.

some most terrible wounds could leave some permanent or very very long lasting sequels...

Any other ideas ?

Re: wound and wound management system

Posted: Tue Oct 06, 2015 10:03 am
by akroma222
Hey Crom Crom,

I gave Head injury a 15% chance to cause blindness onStart
My chest injury causes bleeding damage over time (which will eventually kill) + also a 15% chance to cause Weakness (condition that drops Vitality, Health and Health regen)
Leg and Feet injuries have a 15% chance to cause Slow condition

I am also introducing a system that records how long each champ has been afflicted with each condition so that-
Some conditions will advance to more serious states if not dealt with
EG - Disease (does not abate with time, can NOT be cured by simply sleeping)
will begin to cause secondary conditions over time (like Fever, Blind, Weakened etc)
will begin to spread to other champions if not cured in time.

I have also ensured that some conditions will remove others, EG - Slow removes Haste, Frozen removes Burning

Also even some of the benficial conditions will have -ve effects if used too much...
Too much Haste all the time leads to periods of champion being Slowed afterwards
Too much Rage all the time leads to Insanity etc etc

I have a question though!
Seems Heal Party and using healing crystals will only cure vanilla harmful conditions like poison, paralysis... but not custom conditions even when
SpoilerShow

Code: Select all

beneficial = false,
   	harmful = true,
are added to the definition

Does anyone know how to manage or hack around this????
Easy for Healing Crystals I know (onClick > check > cure)
Thought there might be something im missing in the definition

Akroma

Re: wound and wound management system

Posted: Tue Oct 06, 2015 10:03 am
by akroma222
Also, yes, bandages/ first aid kits needed for injuries, not healing potions....

Re: wound and wound management system

Posted: Tue Oct 06, 2015 2:45 pm
by cromcrom
I am right now in the process of porting my log1 wound system into log2.
It does what I described in the first post: severe/critical wounds; localisation, attributes loss, bleeding, infection.
I do not use conditions for now.
I really like your disease ideas, having a basic "disease" condition inducing other conditions, and possibly transmitting to other champions is great ^^.

For now, only severe and critical wounds are recorded.
However, I would also like to record "cuts and bruises" (less than 10hp hits, globally), to create a new healing system (after some times, all these minor wounds would disappear, thus increasing vastly the health of the champion. However, the champion's health would slowly decrease anyways, especially from severe wounds not healing so fast.)
However, the check is set in the "onDamage" party hook.
And I also have a bleeding system, that inflicts some light damages to the champion. But this damage would also be recorded as "cut and bruises" (<10hp damage), but it shouldn't, so it shouldn't heal so easily...
Just some thought, I will stick to my severe/critical wounds system, until I can think of something.

As for conditions, I am afraid I can't help you, because I haven't set my nose into that at all, yet.

Re: wound and wound management system

Posted: Tue Oct 06, 2015 2:54 pm
by cromcrom
My script so far:

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
Bandages item:

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.

Re: wound and wound management system

Posted: Tue Oct 06, 2015 3:04 pm
by Drakkan
I like wound management as it is now, no need for further development, but I am happy you guys found each other to discuss about this :d

Re: wound and wound management system

Posted: Tue Oct 06, 2015 3:10 pm
by cromcrom
"You need everything to make a world" as we say in my ****** country.
The scripting system is so powerfull, its interesting just to try things, and, as far as I am concerned, try to make my "dream system".
And if I want a survival/gritty/"realistic" kind of game, I really feel like the wound system should be "improved".
However, thanks for passing by, and sharing a fresh line or two ^^