Hello,
So there's no code around the forums for making AI combatants kick each other or you. Here's a code snippet for mission_templates that makes AI agents occasionally kick people that are super close to them. The AI tries to kick when he either parries or gets parried, meaning he wants to open up some space between you and him, which seems like a reasonable implementation.
There's no experience quite like being kicked to death by 30 angry farmers.
It works nicely, but you may have to adjust the ":kickchance" or the timer for your personal liking. There's a 10% chance every 3 seconds, meaning under the best circumstances every 30 seconds in a melee an agent will kick someone.
To any coders out there, this is the first time I've used the agent_ai_get_look_target operation. Are there any potential problems with using this? I like that its much less CPU expensive than running another loop to check for targets, and it ensures that the target he's trying to attack is the same one he'll try to kick.
Also, does anyone know if Power Strike affects agent_deliver_damage_to_agent?
Presently, from a Game Design perspective, its a "no-risk" option for the AI, unlike it being a fairly high-risk option for the player due to the long animation time. I suppose this is fine, since the AI doesn't know that and can't exploit it, but I think I'll write in a chance to have a poorly timed kick that has no effect, exposes him to attacks.
edit: Realized AI would occasionally try to kick something that no longer exists, should be fixed now.
edit again: Animation was slightly wonky, should look better now.
So there's no code around the forums for making AI combatants kick each other or you. Here's a code snippet for mission_templates that makes AI agents occasionally kick people that are super close to them. The AI tries to kick when he either parries or gets parried, meaning he wants to open up some space between you and him, which seems like a reasonable implementation.
There's no experience quite like being kicked to death by 30 angry farmers.
It works nicely, but you may have to adjust the ":kickchance" or the timer for your personal liking. There's a 10% chance every 3 seconds, meaning under the best circumstances every 30 seconds in a melee an agent will kick someone.
To any coders out there, this is the first time I've used the agent_ai_get_look_target operation. Are there any potential problems with using this? I like that its much less CPU expensive than running another loop to check for targets, and it ensures that the target he's trying to attack is the same one he'll try to kick.
Also, does anyone know if Power Strike affects agent_deliver_damage_to_agent?
Code:
AI_kick = (
2, 0, 0,
[], [
(get_player_agent_no,":player"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),#Only humans can kick....FOR NOW
(agent_is_active, ":agent"),
(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 kick.
(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
(agent_get_defend_action, ":defend_action", ":agent"),#
(this_or_next|eq,":attack_action",4),#Just got parried
(this_or_next|eq,":defend_action",1),#Parrying an enemy
##So he'll only try to kick if he just parried an enemy attack, or his own attack just got parried.
(agent_get_team, ":team", ":agent"),
(assign, ":maximum_distance", 100),
#Target Acquisition
(agent_ai_get_look_target,":suspect",":agent"),
(gt,":suspect",0),#Make sure there is someone.
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),#Only kick humans
(agent_is_active, ":suspect"),
(agent_get_team, ":suspect_team", ":suspect"),
(neq, ":suspect_team", ":team"),#Friends don't let friends kick friends.
(agent_get_position, pos1, ":agent"),#Distance check
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind kicker.
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":maximum_distance"),
#Check chance
(store_random_in_range,":kickchance", 1, 10),
(try_begin),
(eq,":kickchance",1), #10% chance per check
(display_message, "@Agent kicks."),
(agent_set_animation, ":agent", "anim_prepare_kick_0"),
(agent_deliver_damage_to_agent, ":agent", ":suspect", 3),
(agent_set_animation, ":suspect", "anim_strike3_abdomen_front"),#Get Kicked
(try_end),
(try_end),])
Presently, from a Game Design perspective, its a "no-risk" option for the AI, unlike it being a fairly high-risk option for the player due to the long animation time. I suppose this is fine, since the AI doesn't know that and can't exploit it, but I think I'll write in a chance to have a poorly timed kick that has no effect, exposes him to attacks.
edit: Realized AI would occasionally try to kick something that no longer exists, should be fixed now.
edit again: Animation was slightly wonky, should look better now.