#textdomain wesnoth-ai #define ANIMAL_AI_DESCRIPTIONS1 _"General: These AIs are set up to simulate (to some extent) how these animals behave in real life. This includes that they are animals, meaning that they are not super smart. As an example, the wolves generally hunt in a pack, but are easily distracted by prey coming into range. They are also decent, but not great at cornering deer. For the most part, this is intentional. Bears (replaced by Ghasts), Spiders and Yetis mostly just wander in their respective parts of the map. They stay out of each other's way (and out of the way of the dogs), but do attack each other if cornered. They attack the other, weaker animals (deer etc.) if those are within range. Wolves hunt in a pack. They actively go after the closest deer (as long as it stays in the forest) and try to corner it (not always super successfully), but are easily distracted by other prey coming into range. The wolves try to avoid getting into the range of bears, spiders, dogs and the yeti, except when they are going in for an attack. If you let them move for long enough, they will also learn that it is not healthy to attack the tusklets. When no deer is left, they wander randomly. Note that, unlike the Wolves Multipack AI (used in a different scenario), this Wolves AI combines all wolves of the side in the same pack." #enddef #define ANIMAL_AI_DESCRIPTIONS2 _"Each Deer (replaced by Vampire Bats) wanders randomly on forest tiles, except when enemies get in its (the deer's) range, in which case it flees to the farthest point it can reach. Tuskers (replaced by Ogres) exhibit the same behavior as deer, except when an enemy is next to one of the tusklets. This enemy will then experience the full wrath of an irate boar. Tusklets (replaced by Young Ogres) blindly follow the closest adult tusker, except when there is no tusker left, in which case they behave the same as deer. Rabbits (replaced by Rats) also wander randomly, but in addition disappear into their holes (replaced by straw bales; if any are within reach) when enemies are close. They reappear out of their holes at the beginning of the turn, if it is safe. Sheep dogs (replaced by Footpads) try to keep their sheep safe. This involves keeping them inside the area outlined by the path the dogs have worn into the meadow, positioning themselves in between the sheep and approaching enemies, and attacking the enemies if those get too close. You might have to let the scenario play for quite some time before you get to see an interesting dog/wolf interaction. If no active herding or protecting move is needed, the dogs go to a random location on the path. Sheep (replaced by Troll Whelps) wander aimlessly except when a sheep dog is next to them, in which case they run away from the dog. The dogs exploit this by positioning themselves on the outside of the sheep, if possible. Sheep also run away from approaching enemies. The sheep, dogs and forest creatures (deer, tuskers, rabbits) have learned that they are no threat to each other and leave each other alone, demonstrating the enormous self control of a well trained sheep dog." #enddef [test] id=animals name= _ "Animals" next_scenario=micro_ai_test map_data="{ai/micro_ais/maps/animals.map}" {DEFAULT_SCHEDULE} turns=-1 victory_when_enemies_defeated=no [side] side=1 controller=human hidden=no name= _ "Rutburt" id=Rutburt max_moves=99 type=Outlaw persistent=no team_name=humans user_team_name= _ "Humans" canrecruit=yes recruit=Ruffian,Footpad,Thug,Poacher gold=0 [/side] [side] side=2 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=forest user_team_name=_"Forest Creatures" gold=0 income=-2 [/side] [side] side=3 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=ghasts user_team_name= _ "Ghasts" # wmllint: no spellcheck gold=0 income=-2 [/side] [side] side=4 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=spiders user_team_name= _ "Spiders" gold=0 income=-2 [/side] [side] side=5 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=yetis user_team_name= _ "Yetis" gold=0 income=-2 [/side] [side] side=6 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=wolves user_team_name= _ "Wolves" gold=0 income=-2 [/side] [side] side=7 controller=ai no_leader=yes defeat_condition=no_units_left persistent=no team_name=whelps,forest user_team_name= _ "Whelps" gold=0 income=-2 [/side] [side] # This side is only here because we need one persistent side for the game to go on side=8 controller=null persistent=yes save_id=Grnk hidden=yes [/side] # Put all the units and markers out there [event] name=prestart {VARIABLE scenario_name animals} {SCATTER_UNITS 3 "Vampire Bat" 1 (x,y,terrain=6-99,12-99,G*^F*) (side,random_traits=2,no)} {NOTRAIT_UNIT 2 "Ogre" 6 20} {NOTRAIT_UNIT 2 "Ogre" 7 21} {NOTRAIT_UNIT 2 "Young Ogre" 7 20} {NOTRAIT_UNIT 2 "Young Ogre" 8 21} # Do this separately, so that there will definitely be two {SCATTER_UNITS 1 "Ghast" 1 (x,y,terrain=1-10,1-11,G*) (side,random_traits=3,no)} {SCATTER_UNITS 1 "Ghast" 1 (x,y,terrain=11-20,1-11,G*) (side,random_traits=3,no)} {SCATTER_UNITS 1 "Giant Spider" 1 (x,y=51-57,1-8) (side,random_traits=4,no)} {SCATTER_UNITS 1 "Giant Spider" 1 (x,y=36-50,1-9) (side,random_traits=4,no)} {SCATTER_UNITS 1 "Yeti" 1 (x,y,terrain=11-25,1-9,M*) (side,random_traits=5,no)} {NOTRAIT_UNIT 6 "Wolf" 1 33} {NOTRAIT_UNIT 6 "Wolf" 2 32} {NOTRAIT_UNIT 6 "Wolf" 2 33} {NOTRAIT_UNIT 7 "Footpad" 34 24} {NOTRAIT_UNIT 7 "Footpad" 25 32} {NOTRAIT_UNIT 7 "Footpad" 36 31} {NOTRAIT_UNIT 7 "Troll Whelp" 35 27} {NOTRAIT_UNIT 7 "Troll Whelp" 29 28} {NOTRAIT_UNIT 7 "Troll Whelp" 30 29} {NOTRAIT_UNIT 7 "Troll Whelp" 28 30} # Need to make sure these won't be on the border !!!! # Other dimension are carefully chosen to give good distribution on map # and not inside th Troll Whelp herding area {SCATTER_IMAGE ( terrain=Gg,Gs x,y=19-39,17-32 [not] x,y=26-38,25-32 [/not] ) 3 items/straw-bale1.png} {SCATTER_IMAGE ( terrain=Gg,Gs x,y=19-39,17-32 [not] x,y=26-38,25-32 [/not] ) 3 "items/straw-bale1.png~FL()"} {SCATTER_IMAGE ( terrain=Gg,Gs x,y=40-57,17-29 ) 2 items/straw-bale1.png} {SCATTER_IMAGE ( terrain=Gg,Gs x,y=40-57,17-29 ) 2 "items/straw-bale1.png~FL()"} # The right-click menu items [set_menu_item] id=m01_end_animals description= _ "End Scenario" image=items/ring-red.png~CROP(26,26,20,20) [show_if] {VARIABLE_CONDITIONAL scenario_name equals animals} [/show_if] [command] # So that game goes on to next scenario [modify_side] side=8 controller=human [/modify_side] {MESSAGE narrator "wesnoth-icon.png" "" _"Well, that was that."} [endlevel] result=victory bonus=no carryover_percentage=0 carryover_report=no linger_mode=no [/endlevel] [/command] [/set_menu_item] [micro_ai] side=2 ai_type=forest_animals action=add deer_type=Vampire Bat rabbit_type=Giant Rat tusker_type=Ogre tusklet_type=Young Ogre [filter_location] terrain=*^F* [/filter_location] [/micro_ai] # Set up the big_animals micro AI for the Ghasts [micro_ai] side=3 ai_type=big_animals action=add [filter] type=Ghast [/filter] [avoid_unit] type=Yeti,Giant Spider,Ghast,Footpad [/avoid_unit] [filter_location] x,y=1-40,1-18 [/filter_location] [/micro_ai] # Set up the big_animals micro AI for side 4 (the spiders) [micro_ai] side=4 ai_type=big_animals action=add [filter] type=Giant Spider [/filter] [avoid_unit] type=Yeti,Giant Spider,Ghast,Footpad [/avoid_unit] [filter_location] terrain=H* [/filter_location] [/micro_ai] # Set up the big_animals micro AI for the Yeti [micro_ai] side=5 ai_type=big_animals action=add [filter] type=Yeti [/filter] [avoid_unit] type=Yeti,Giant Spider,Ghast,Footpad [/avoid_unit] [filter_location] terrain=M* [/filter_location] [filter_location_wander] terrain=M*,M*^*,H*,H*^* [/filter_location_wander] [/micro_ai] # Set up the wolves micro AI [micro_ai] side=6 ai_type=wolves action=add [filter] type=Wolf [/filter] [filter_second] type=Vampire Bat [/filter_second] avoid_type=Yeti,Giant Spider,Ghast,Footpad [/micro_ai] # Set up the Troll Whelp micro AI [micro_ai] side=7 ai_type=herding action=add [filter] type=Footpad [/filter] [filter_second] type=Troll Whelp [/filter_second] herd_x,herd_y=32,28 [filter_location] terrain=Rb [/filter_location] [/micro_ai] [/event] [event] name=start {MESSAGE narrator "wesnoth-icon.png" "Important Note" _"Important: The animal Micro AIs in this scenario are written for a number of animal unit types that do not exist in Wesnoth mainline, such as bears, sheep and sheep dogs, or deer. In this test scenario, these units have been replaced by mainline units."} # wmlindent: start ignoring {MESSAGE narrator "wesnoth-icon.png" "" _"This is a fun little scenario with a bunch of different animal AIs, mostly for watching only. The animal AIs behave as follows: "+{ANIMAL_AI_DESCRIPTIONS1}} # wmlindent: stop ignoring {MESSAGE narrator "wesnoth-icon.png" "" {ANIMAL_AI_DESCRIPTIONS2}} [message] speaker=narrator caption= _ "Question for the Player" image=wesnoth-icon.png # wmllint: unbalanced-on # wmlindent: start ignoring message= _ "It is possible to include a human-controlled Side 1, so that the action stops once every turn for looking around (or to mess with things in debug mode). Note that there is no end to this scenario. For demonstration purposes, any unit that is killed is replaced by another unit of the same type at the beginning of the next turn. In order to end the scenario, there's a right-click option - but that only works in human-controlled mode. In AI-only mode, you have to press 'Esc' or reload a previous savefile. Also note: The Animal AIs are coded as Micro AIs. A Micro AI can be added and adapted to the need of a scenario easily using only WML and the [micro_ai] tag. Check out the Micro AI wiki page at http://wiki.wesnoth.org/Micro_AIs for more information." # wmllint: no spellcheck # wmlindent: stop ignoring # wmllint: unbalanced-off [option] message= _ "I'll just watch the animals." [command] [modify_side] side=1 controller=null hidden=yes [/modify_side] [kill] side=1 [/kill] [/command] [/option] [option] message= _ "I want to have control of Side 1." [/option] [/message] [objectives] side=1 summary= _ "Watch the animals do their things" [objective] description= _ "Use right-click option" condition=win [/objective] [objective] description= _ "Death of Rutburt" condition=lose [/objective] [note] description= _ "Check out the right-click menu options for additional actions" [/note] [/objectives] [/event] # After first Ogre attack on wolves, wolves do not attack those any more [event] name=attack end [filter] side=2 type=Ogre [/filter] [filter_second] side=6 type=Wolf [/filter_second] # wmlindent: start ignoring {MESSAGE $second_unit.id "" "" _"Yowl! Translation: Those Ogres are mean! We better stay away from them and their young."} # wmlindent: stop ignoring [micro_ai] side=6 ai_type=wolves action=change [filter] type=Wolf [/filter] [filter_second] type=Vampire Bat [/filter_second] avoid_type=Yeti,Giant Spider,Ghast,Footpad,Ogre,Young Ogre [/micro_ai] [/event] # At the beginning of each side turn, put another unit one out there, if it was lost # This is just for the sake of keeping the scenario going indefinitely #define NEW_UNIT_SIDE_TURN SIDE TYPE COUNT X Y [event] name=side {SIDE} turn first_time_only=no [if] [have_unit] type={TYPE} count={COUNT} [/have_unit] [then] {NOTRAIT_UNIT {SIDE} {TYPE} {X} {Y}} [/then] [/if] [/event] #enddef {NEW_UNIT_SIDE_TURN 2 "Vampire Bat" "0-2" 18 33} {NEW_UNIT_SIDE_TURN 2 "Ogre" "0-1" 1 20} {NEW_UNIT_SIDE_TURN 2 "Young Ogre" "0-1" 1 21} {NEW_UNIT_SIDE_TURN 3 Ghast "0-1" 1 1} {NEW_UNIT_SIDE_TURN 4 "Giant Spider" "0-1" 57 1} {NEW_UNIT_SIDE_TURN 5 Yeti 0 15 1} {NEW_UNIT_SIDE_TURN 6 Wolf "0-2" 1 33} {NEW_UNIT_SIDE_TURN 7 Footpad "0-2" 30 33} {NEW_UNIT_SIDE_TURN 7 "Troll Whelp" "0-3" 34 33} [/test]