Animation Module System [DISC][OSP][WIP] Agent Jump-Attacking

Users who are viewing this thread

Zarthas

Knight at Arms
Hello Again,

Working on a leaping charge attack.  I've got the behavior and animation part down, I think, but I'm not actually entirely sure how to impart z-velocity to the leaping agent.

I've thought of a pretty inelegant solution, using another trigger and just moving him along the Z-axis so long as he's got the jump animation enabled, but do you guys know of anything else?

Code:
AI_jump_attack =  (
         3, 0, 0,
       [], [
	(get_player_agent_no,":player"),
	(try_for_agents, ":agent"),
		(neq, ":agent", ":player"),
		(agent_is_alive, ":agent"),
		(agent_is_human, ":agent"),
		(agent_is_active, ":agent"),
		#position_get_distance_to_ground_level, dest, pos1
		(agent_slot_eq, ":agent", slot_agent_is_running_away, 0),#Isn't fleeing the battle.
		##He's an eligible human.  Now see if he's in a position to jump-attack!
		(agent_get_attack_action, ":attack_action", ":agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
		(eq,":attack_action",1),#About to strike!
		(agent_get_team, ":team", ":agent"),
		(assign, ":maximum_distance", 300),
		(assign, ":minimum_distance", 100),
		#Target Acquisition
		(agent_ai_get_look_target,":suspect",":agent"),
		(gt,":suspect",0),#Make sure there is someone.
		(agent_is_alive, ":suspect"),
		(agent_get_team, ":suspect_team", ":suspect"),
		(neq, ":suspect_team", ":team"),
		(agent_get_position, pos1, ":agent"),#Distance check
		(agent_get_position, pos2, ":suspect"),
		(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind leaper.
		(get_distance_between_positions, ":distance", pos1, pos2),
		(le, ":distance", ":maximum_distance"),#Make sure he's close enough, but has enough room to leap
		(ge, ":distance", ":minimum_distance"),
		#Check chance
		(store_random_in_range,":jumpchance", 1,5),		
		#(eq,":jumpchance",1), #20% chance per check
			(display_message, "@Agent-jump attack!"),
			(agent_set_animation, ":agent", "anim_jump"),# Jump!
			(agent_set_attack_action, ":agent", 0, 0),#Downward slash attack
			(agent_get_position, pos1, ":agent"),
			#(position_get_z, ":z", pos1),
			#(val_add, ":z", 5),#Move up 5 meter?
			#(position_set_z, pos1, ":z"),
			(position_move_z, pos1, -500),
			(agent_set_position,":agent",pos1),
			#(agent_get_position, ":agent", ":start_pos"),
			#(agent_set_position, ":agent_no", pos1), 
			#(agent_set_position, ":agent", ":start_pos"),#Snap into the air a bit
	   (try_end),])
 
I think I am misunderstanding what you mean.  Do you mean the module_animations tuples, i.e. this guy :
Code:
 ["jump", acf_enforce_lowerbody, amf_priority_jump|amf_play|amf_client_prediction|amf_continue_to_next,
##   [1.09, "jump", 22, 48, arf_blend_in_1],
   [1.0, "jump", 22, 46, arf_blend_in_1],
##   [0.8, "anim_human", 270, 272, arf_blend_in_4],
 ],

I'm actually just assigning the jump animation to the agent, and it strangely doesn't move him on the z-axis, as I had expected it to.  I don't see anything that would mark it as having any kind of movement attached to it, do you know where that would that be?
 
I didnt realise there were no coordniates on the jump animation, but you should find something like that in the documentation at the top of the file. I did manage to get the coordinate thing working once, I just remember having some difficulty or other. My memory doesnt let me go into more detail unfortunately.
 
Oh, that seems like it would work.  I was looking specifically for a way to kind of mimic the smooth-ish jump the player has, but that'll do for now really.  It seems I'm not quite sure how to implement it though :facepalm:
Code:
(store_random_in_range,":jumpchance", 1,5),		
		#(eq,":jumpchance",1), #20% chance per check
			(display_message, "@Agent-jump attack!"),
			(agent_set_animation, ":agent", "anim_jump"),# Jump!
			(agent_set_attack_action, ":agent", 0, 0),#Downward slash attack
			(agent_get_position, pos1, ":agent"),
			(position_move_z, pos1, 500),
			(agent_set_position,":agent",pos1),

Does that look somewhat correct?  I'm still not getting him to actually shift Z positions, so I'm not sure I've done it correctly here...
 
Thanks!  That's very interesting.  Tried it out, and somehow the engine stops the agent from taking a Z-position other than ground-level if dynamics are enabled, but will allow you to move them about if dynamics are disabled.  I suppose now I need a separate trigger to check if he's in the jumping animation and raise his z, then after the animation enable dynamics again to see if he falls?  I'll edit with results.
 
I think you should be able to do it all in one trigger. Just switch the dynamics back on at the end, outside of a try block. I don't know how you're going to get a smooth jump up though, I tried doing little increments but it's so instantaneous it doesn't make a difference. But anyways, for anyone who may be interested in such a thing, here's a trigger to make AI jump over kicks during lord duels: (posted here since I just moved the pieces of Zarthas' code around)

Code:
	(0, 0.3, 1.3, [ #The delay and re-arm are very important and maybe not yet perfect. Too fast a re-arm and the player can spam kick key causing AI to fly higher and higher. Too long or short a delay and the AI will mis-time the jump
	(game_key_clicked, gk_kick),
		],
		[
		(get_player_agent_no,":player"),
	(try_for_agents, ":agent"),
			(neq, ":agent", ":player"),
			(agent_is_alive, ":agent"),
			(agent_is_human, ":agent"),
			(agent_is_active, ":agent"),
			(agent_get_position, pos1, ":player"),
			(agent_get_position, pos2, ":agent"),
			(get_distance_between_positions, ":dist", pos1, pos2),
		(try_begin), 
			(lt, ":dist", 150),
			 (agent_set_no_dynamics, ":agent", 1), #Dynamics off
			 (agent_set_animation, ":agent", "anim_jump", 0),
			 (position_move_z, pos2, 20), #These can be replaced with one move of 100cm
			 (agent_set_position, ":agent", pos2),
			 (position_move_z, pos2, 20),
			 (agent_set_position, ":agent", pos2),
			 (position_move_z, pos2, 20),
			 (agent_set_position, ":agent", pos2),
			 (position_move_z, pos2, 20),
			 (agent_set_position, ":agent", pos2),
			 (position_move_z, pos2, 20),
			 (agent_set_position, ":agent", pos2),
			 (agent_set_animation, ":agent", "anim_jump", 0), #Probably superfluous
		(try_end),
			(agent_set_no_dynamics, ":agent", 0), #Dynamics back on
	  (try_end),
		]),

This would work in other mission templates as well but you'd have to do checks for allies and bots that aren't fighting you etc so probably this is only useful in the 1 on 1 fights. As I mentioned in the comments the re-arm interval needs the most balance, if the player kicks twice the AI can get hit but if the re-arm is too short then spamming kick button (faster than the player character can actually kick) will continuously move the enemy up into the air. If anyone knows a neat way to have the jump up smoother that would be excellent!
 
Interesting, Ruthven.  Using that, were you able to actually move the agents upward?? Mine seem to snap back down to the ground in the next tick.  Do yours fall with gravity and stuff?

Bah!!  Messed around with checking animation of agents to see if they should be rising, and dragging them downward if they're above ground.  Very strange results.
The jump attack decision turns dynamics off and snaps the agent slightly above the ground.
So there's a jump tick.  Check to see if you should be rising.

It doesn't normally work, but sometimes, it will inexplicably work for one agent, and continue to work for that agent until you kill him.

Most of the time it looks like the trigger isn't even firing for most agents, they just hover 10CM above the ground...

edit:  Looks like my trigger just isn't firing right.  Testing test testing.
edit again:  Looks like it only runs for the first agent in the array.  Is my try_for_agents wrong???


Ignore all that babble.  As many have long suspected, I'm just a moron.

Its not super smooth, but its not as bad as the insta-jerk.  Is there a way to have increments of smaller than 0.1 on a trigger?

Stone Age warriors getting air like Jordan.  Its hilarious.

So now we'll need to add some forward momentum, anyone know a way to do that smoothly...??

Gravity Part
Code:
AI_jump = (
         0.1, 0, 0, [], [

	(get_player_agent_no,":player"),
	(try_for_agents, ":agent"),
		(neq,":agent",":player"),
		(agent_get_animation, ":anim", ":agent", 0),
		(try_begin),
			(eq,":anim","anim_jump"),
			(agent_get_position, pos1, ":agent"),
			(position_move_z, pos1, 10),
			(agent_set_position,":agent",pos1),
			(else_try),
			(agent_set_no_dynamics,":agent",0),
		(try_end),
	(try_end),
	])
Agent decision making part
Code:
AI_jump_attack =  (
         3, 0, 0,
       [], [
	(get_player_agent_no,":player"),
	(try_for_agents, ":agent"),
		(neq, ":agent", ":player"),
		(agent_is_alive, ":agent"),
		(agent_is_human, ":agent"),
		(agent_is_active, ":agent"),
		#position_get_distance_to_ground_level, dest, pos1
		(agent_slot_eq, ":agent", slot_agent_is_running_away, 0),#Isn't fleeing the battle.
		##He's an eligible human.  Now see if he's in a position to jump-attack!
		(agent_get_attack_action, ":attack_action", ":agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
		(eq,":attack_action",1),#About to strike!
		(agent_get_team, ":team", ":agent"),
		(assign, ":maximum_distance", 300),
		(assign, ":minimum_distance", 100),
		#Target Acquisition
		(agent_ai_get_look_target,":suspect",":agent"),
		(gt,":suspect",0),#Make sure there is someone.
		(agent_is_alive, ":suspect"),
		(agent_get_team, ":suspect_team", ":suspect"),
		(neq, ":suspect_team", ":team"),
		(agent_get_position, pos1, ":agent"),#Distance check
		(agent_get_position, pos2, ":suspect"),
		(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind leaper.
		(get_distance_between_positions, ":distance", pos1, pos2),
		(le, ":distance", ":maximum_distance"),#Make sure he's close enough, but has enough room to leap
		(ge, ":distance", ":minimum_distance"),
		#Check chance
		(store_random_in_range,":jumpchance", 1,5),		
		#(eq,":jumpchance",1), #20% chance per check
			(display_message, "@Agent-jump attack!"),
			(agent_set_animation, ":agent", "anim_jump"),# Jump!
			#(agent_set_attack_action, ":agent", 0, 0),#Downward slash attack
			(agent_get_position, pos1, ":agent"),
			#(position_get_z, ":z", pos1),
			#(val_add, ":z", 5),#Move up 5 meter?
			#(position_set_z, pos1, ":z"),
			(agent_set_no_dynamics,":agent",1),
			(position_move_z, pos1, 20),
			(agent_set_position,":agent",pos1),
			(agent_set_no_dynamics,":agent",1),
			#(agent_set_no_dynamics,":agent",0),
			#(agent_get_position, ":agent", ":start_pos"),

	   (try_end),])
 
It looks like this just got moved to Tutorials. Is it in working form yet? I would love to see a video of it in action! Are you planning on making the animations available as well?
 
Back
Top Bottom