B Tutorial Presentation Make the screen bloody when injured...

Users who are viewing this thread

HokieBT

Grandmaster Knight
ok, I want to add an option so the player can choose to make the screen bloody when injured.  Example below:

 

When I've done presentation overlay's before I've just displayed it once, but this one would need to dynamically change.  Its working decent, but the screen seems to be flickering so I think I need some help with the code design....

BRF File - I created a few semi-transparent textures that cover the screen

module_meshes.py - few different texture variations (25% health, 50% health, etc)
Code:
  ("player_damage_25", 0, "player_damage_25", 0, 0, 0, 0, 0, 0, 1, 1, 1),  
  ("player_damage_50", 0, "player_damage_50", 0, 0, 0, 0, 0, 0, 1, 1, 1), 
  ("player_damage_75", 0, "player_damage_75", 0, 0, 0, 0, 0, 0, 1, 1, 1),

module_mission_templates.py - if the player is <= 75% health and $player_damage <= 0 then display a presentation
Code:
#SW - new player_damage
common_player_damage = (0, 0, 0, [
	#(neg|conversation_screen_is_active),
	(le, "$player_damage", 0),
	],
	[
		(get_player_agent_no, ":player_agent"),
		#(agent_is_alive, ":player_agent"),
		(store_agent_hit_points,":player_hp",":player_agent",0),	# set absolute to 1 to retrieve actual hps, otherwise will return relative hp in range [0..100]
		(try_begin),
			(le, ":player_hp", 75),
			(assign, "$player_damage", 1),
			#(display_message, "@prsnt_player_damage..."),
			(start_presentation, "prsnt_player_damage"),
		(try_end),
	])

module_presentations.py - checks the player's current health, display a mesh, if their health changes then stop the presentation and it will be restarted by the MT trigger.
Code:
#SW - new presentation for player_damage
("player_damage", prsntf_read_only, 0, [		#must use prsntf_read_only or you cannot attack
	(ti_on_presentation_load,
		[
		(presentation_set_duration, 999999),
		#check the players health
		(get_player_agent_no, ":player_agent"),
		(store_agent_hit_points,":player_hp",":player_agent",0),	# set absolute to 1 to retrieve actual hps, otherwise will return relative hp in range [0..100]
		(try_begin),
			(le, ":player_hp", 25),
			(assign, "$player_damage", 25),
			(assign, ":mesh", "mesh_player_damage_25"),
		(else_try),
			(le, ":player_hp", 50),
			(assign, "$player_damage", 50),
			(assign, ":mesh", "mesh_player_damage_50"),
		(else_try),
			(le, ":player_hp", 75),
			(assign, "$player_damage", 75),
			(assign, ":mesh", "mesh_player_damage_75"),
		(else_try),
			(assign, "$player_damage", 0),
			(assign, ":mesh", 0),
		(try_end),
		#display the mesh if necessary
		(try_begin),
			(neq, ":mesh", 0),
			#(display_message, "@create_mesh_overlay..."),
			(create_mesh_overlay, reg1, ":mesh"),
			(position_set_x, pos1, 0),
			(position_set_y, pos1, 0),
			(overlay_set_position, reg1, pos1),	
		(try_end),		
		
		]),
	(ti_on_presentation_run,
    	[
		#check the players health
		(get_player_agent_no, ":player_agent"),
		(store_agent_hit_points,":player_hp",":player_agent",0),	# set absolute to 1 to retrieve actual hps, otherwise will return relative hp in range [0..100]		
		(try_begin),
			(neq, ":player_hp", "$player_damage"),
			(assign, "$player_damage", 0),
			#(display_message, "@presentation_set_duration 0..."),
			(presentation_set_duration, 0),
		(try_end),
       	]),	
]),

So the above code works, but it seems to be flickering on the screen like its opening/closing really fast....  Originally I tried putting the create_mesh_overlay in ti_on_presentation_run, and that worked decent, but it just seemed to be stacking the meshes on top of each other.  What I really need is a way to clear the overlay and then I could reload it?
 
I'm not a speciaist with presentations (yet :smile:), I only can give you an advice of contacting guys who have helmet vision implemented in their mods (Rus XIII comes to mind).

Also, I personally would prefer blood concentrated closer to screen borders with middle being relatively free from blood, so that the effect be still there but not impede view that much. Player can't heal during battle, and constant red veil one can't get rid of should be irritating

Looking through the code: if I did this stuff, I would run a new presentation (that is put blood mesh in front of the camera) only when player hp crosses threshold. And check the condition like once in 5 seconds or such. I'm wild guessing here, but maybe flickering means that your presentation starts every time the condition on current hp is met, and not when a threshold is crossed? I don't see in the code where/if-at-all you store player hp from previous run to check for threshold crossing
 
hehe.  Yeah, the texture I did was just very quick so it would be really obvious if it was working when I was testing.  If I get this working then I'll definetely have to improve it similar to what you described.  Maybe even something like when you are originally hit it goes red, but it fades after X seconds of not being hit more...  I'd also make this configurable, and players can heal in SWC, so it shouldn't be too bad.    :smile:

Anyway, I've done a bunch of presentations and helmet views in my mod, and things like the following pictures work fine.  But I haven't ever tried to dynamically switch a presentation's mesh before, so I think that is my problem right now... I'm guessing my code isn't efficient, or there is another problem that is causing the presentation to switch more often then I expected, so I'm wondering if anybody else has tried something like this, etc.

       

edit:

I wonder if you can call a presentation from a presentation?  I could just add some code to ti_on_presentation_run that checked the players health, then if it was between X and Y then close the current presentation and re-launch it or a different one.....  Will see if I can test that at some point, hmm.
 
I like the idea.

But it would be more easier to see if you do as CoD does. When you're injured the screen becomes more and more red.
Because the blood is nearly covering the screen.


Good luck.
 
HokieBT said:
Anyway, I've done a bunch of presentations and helmet views in my mod, and things like the following pictures work fine.  But I haven't ever tried to dynamically switch a presentation's mesh before, so I think that is my problem right now...
Hehe, yeah, I recalled SWC already has helmet views some minutes after I posted, but your counterpost was to quick for me to edit away that part  :mrgreen:

HokieBT said:
I wonder if you can call a presentation from a presentation?  I could just add some code to ti_on_presentation_run that checked the players health, then if it was between X and Y then close the current presentation and re-launch it or a different one.....  Will see if I can test that at some point, hmm.
Why do it from presentaion? Just make the same trigger that calls new presentation always close old one when a hp threshold is crossed. Store old hp in some global var and run trigger only on the condition that new hp is in new threshold range.
 
I had this flickering problem too, though I can't remember how I fixed it. The problem was that I was checking every 1 second or something to see if gk_zoom or whatever was down, but every time it checked the trigger the presentation would close and a new one would pop up. Hopefully I'll remember what I did soon enough.  :razz:
 
Just keep presentation running all the time. Create all overlay meshes at presentation start an then just hide or show them (change alpha or move them out of camera sight/back to 0 position), according to players health in ti_on_presentation_run. You can set those meshes to some globals, not a reg1, so you can easily manipulate them later.

By using "overlay_animate_to_alpha" and setting small delay you can make some very nice blood effect on the screen.

I wonder if you can call a presentation from a presentation?

Sure. But it will flicker anyway. :wink:
 
Slawomir of Aaarrghh said:
Just keep presentation running all the time. Create all overlay meshes at presentation start an then just hide or show them (change alpha or move them out of camera sight/back to 0 position), according to players health in ti_on_presentation_run. You can set those meshes to some globals, not a reg1, so you can easily manipulate them later.

By using "overlay_animate_to_alpha" and setting small delay you can make some very nice blood effect on the screen.

I wonder if you can call a presentation from a presentation?

Sure. But it will flicker anyway. :wink:

I like this idea. Give it a try Hokie
 
hmm, that is a good suggestion.  I had tried having the presentation only open for 1 second, and then having a MT trigger re-open it every 1 second, but you could still see a slight flicker when it switched.  I could have one large bloody texture that just zoomed in/out depending on how injured you were.... I'll have to play around with this concept, thx.
 
Unfortunately, this kind of fully screen presentation has been denied by warband hardcoded. Any kind of new presetation will curtain off the hardcoded icons behind it, even if your new presentation is totally transparent.
for example, if you use any of these meshes HokieBT gives you, the 3 parts of post and the number of remaining ammo will disappear.
 
Maybe the rendering order had changed? What happens when you wiggle material settings for the presentation?

Do the messages on  the screen disappear too? All other icons can be left out using piecewise blood screen instead of fullscreen
 
I didnt test the messages, but the battle order/tactic panels(the ones at the top left side of screen) will also be curtained off.
I think it is the rendering order which was changed, it is the same thing that you can alter in BRF files?
 
Is it possible to somehow stretch the texture and then I have here and so shows.
mb155.jpg

mb154.jpg
 
    It would be cool and realistic to have this effect only when you receive a projectile in the head.
 
Back
Top Bottom