|  |  | @ -2,13 +2,14 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | local utils=require('utils') |  |  |  | local utils=require('utils') | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | local function addEmotionToUnit(emotions,thought,emotion,severity,subthought) |  |  |  | local function addEmotionToUnit(unit,thought,emotion,severity,strength,subthought) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     local emotions=unit.status.current_soul.personality.emotions | 
			
		
	
		
		
			
				
					
					|  |  |  |     if not (type(emotion)=='number') then emotion=df.emotion_type[emotion] end |  |  |  |     if not (type(emotion)=='number') then emotion=df.emotion_type[emotion] end | 
			
		
	
		
		
			
				
					
					|  |  |  |     if not (type(thought)=='number') then thought=df.unit_thought_type[thought] end |  |  |  |     if not (type(thought)=='number') then thought=df.unit_thought_type[thought] end | 
			
		
	
		
		
			
				
					
					|  |  |  |     emotions:insert('#',{new=df.unit_personality.T_emotions, |  |  |  |     emotions:insert('#',{new=df.unit_personality.T_emotions, | 
			
		
	
		
		
			
				
					
					|  |  |  |     type=emotion, |  |  |  |     type=emotion, | 
			
		
	
		
		
			
				
					
					|  |  |  |     unk2=1, |  |  |  |     unk2=1, | 
			
		
	
		
		
			
				
					
					|  |  |  |     strength=1, |  |  |  |     strength=strength, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     thought=thought, |  |  |  |     thought=thought, | 
			
		
	
		
		
			
				
					
					|  |  |  |     subthought=subthought, |  |  |  |     subthought=subthought, | 
			
		
	
		
		
			
				
					
					|  |  |  |     severity=severity, |  |  |  |     severity=severity, | 
			
		
	
	
		
		
			
				
					|  |  | @ -17,6 +18,10 @@ local function addEmotionToUnit(emotions,thought,emotion,severity,subthought) | 
			
		
	
		
		
			
				
					
					|  |  |  |     year=df.global.cur_year, |  |  |  |     year=df.global.cur_year, | 
			
		
	
		
		
			
				
					
					|  |  |  |     year_tick=df.global.cur_year_tick |  |  |  |     year_tick=df.global.cur_year_tick | 
			
		
	
		
		
			
				
					
					|  |  |  |     }) |  |  |  |     }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     local divider=df.emotion_type.attrs[emotion].divider | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if divider~=0 then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         unit.status.current_soul.personality.stress_level=unit.status.current_soul.personality.stress_level+math.ceil(severity/df.emotion_type.attrs[emotion].divider) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     end | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  | end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | validArgs = validArgs or utils.invert({ |  |  |  | validArgs = validArgs or utils.invert({ | 
			
		
	
	
		
		
			
				
					|  |  | @ -24,6 +29,7 @@ validArgs = validArgs or utils.invert({ | 
			
		
	
		
		
			
				
					
					|  |  |  |  'thought', |  |  |  |  'thought', | 
			
		
	
		
		
			
				
					
					|  |  |  |  'emotion', |  |  |  |  'emotion', | 
			
		
	
		
		
			
				
					
					|  |  |  |  'severity', |  |  |  |  'severity', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  'strength', | 
			
		
	
		
		
			
				
					
					|  |  |  |  'gui' |  |  |  |  'gui' | 
			
		
	
		
		
			
				
					
					|  |  |  | }) |  |  |  | }) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -41,19 +47,22 @@ local unit = args.unit and df.unit.find(args.unit) or dfhack.gui.getSelectedUnit | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | if not unit then qerror('A unit must be specified or selected.') end |  |  |  | if not unit then qerror('A unit must be specified or selected.') end | 
			
		
	
		
		
			
				
					
					|  |  |  | if args.gui then |  |  |  | if args.gui then | 
			
		
	
		
		
			
				
					
					|  |  |  |     local script=require('gui.script') |  |  |  |   local script=require('gui.script') | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     script.start(function() |  |  |  |   script.start(function() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         local tok,thought=script.showListPrompt('emotions','Which thought?',COLOR_WHITE,tablify(df.unit_thought_type),10,true) |  |  |  |     local tok,thought=script.showListPrompt('emotions','Which thought?',COLOR_WHITE,tablify(df.unit_thought_type),10,true) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if tok then |  |  |  |     if tok then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             local eok,emotion=script.showListPrompt('emotions','Which emotion?',COLOR_WHITE,tablify(df.emotion_type),10,true) |  |  |  |       local eok,emotion=script.showListPrompt('emotions','Which emotion?',COLOR_WHITE,tablify(df.emotion_type),10,true) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if eok then |  |  |  |       if eok then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 local sok,severity=script.showInputPrompt('emotions','At what severity?',COLOR_WHITE,'0') |  |  |  |         local sok,severity=script.showInputPrompt('emotions','At what severity?',COLOR_WHITE,'0') | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 if sok then |  |  |  |         if sok then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     addEmotionToUnit(unit.status.current_soul.personality.emotions,thought,emotion,severity,0) |  |  |  |           local stok,strength=script.showInputPrompt('emotions','At what strength?',COLOR_WHITE,'0') | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 end |  |  |  |           if stok then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             end |  |  |  |             addEmotionToUnit(unit,thought,emotion,severity,strength,0) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           end | 
			
		
	
		
		
			
				
					
					|  |  |  |         end |  |  |  |         end | 
			
		
	
		
		
			
				
					
					|  |  |  |     end) |  |  |  |       end | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   end) | 
			
		
	
		
		
			
				
					
					|  |  |  | else |  |  |  | else | 
			
		
	
		
		
			
				
					
					|  |  |  |     local thought = args.thought or 180 |  |  |  |     local thought = args.thought or 180 | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
	
		
		
			
				
					|  |  | @ -63,5 +72,7 @@ else | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     local subthought = args.subthought or 0 |  |  |  |     local subthought = args.subthought or 0 | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |     addEmotionToUnit(unit.status.current_soul.personality.emotions,thought,emotion,severity,subthought) |  |  |  |     local strength = args.strength or 0 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     addEmotionToUnit(unit,thought,emotion,severity,strength,subthought) | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  | end | 
			
		
	
	
		
		
			
				
					|  |  | 
 |