Ticket #1686: update-attack-animations.sh

File update-attack-animations.sh, 5.0 KB (added by Doménique, 11 years ago)

Sets up actors to use attack_type animation labels instead of just melee

Line 
1#!/bin/sh
2
3# All attack animations are currently categorised as Melee.
4# Some units may have multiple types though, such as Ranged and Slaughter.
5# This batch edit sets up the contents of actor files accordingly.
6#
7# INSTRUCTIONS FOR CORRECT USE
8#
9# - RUN THIS SHELL SCRIPT FROM WITHIN THE binaries/mods/public/art/actors FOLDER!
10# It will automatically find and edit files in subfolders as well.
11# - Avoid running this from the /public/ folder directly, as it will also falsely
12# adjust simulation entity XML files.
13# - It will edit the files in place, and add <name>.bu backup files. If anything
14# goes wrong those provide a way out. Anyway, OS X requires this argument for
15# the sed -i command to work, although it can be left as empty string ('').
16# The backups can be removed with: find . -name "*.xml.bu" -type f -delete
17#
18# SOME CAVEATS
19#
20# 1. Only actor files that are appropriately named can be given their correct
21# animation, such as attack_ranged. Special actors, heroes, and champion actors
22# are often not labelled with their specific ability (e.g., javelinist).
23# Those actors will remain with the default attack_melee, if not manually adjusted
24# below (list should be exhaustive, but not guaranteed).
25# 2. Actors that feature multiple capabilities are not set properly, although
26# it presents no change from the current situation with only Melee available.
27# 3. The engine will give errors for those actors that have a ranged attack but no
28# properly set projectile attachment, hinting that for this actor its
29# actor file needs some manual work to correctly set attack_ranged.
30# 4. Since the engine defaults to the idle animation if no animation with a given
31# name is found, any problems should be easy to spot.
32
33# before starting, check if indeed in actors directory (avoids a mess)
34if [ ${PWD##*/} != "actors" ]
35 then
36 echo "ERROR: make sure you are in the <mod name>/art/actors folder"
37 exit 1
38fi
39
40# first, set all actors that have a melee animation to the attack_melee type.
41find . -name "*.xml" -print | xargs sed -i '.bu' 's/name="[m|M]elee/name="attack_melee/g'
42
43# also fix some (older?) actors that have an unspecified 'Attack' animation
44# note: the more complex regex (requiring -E) also captures attack_melee here to avoid
45# ending up with weird stuff like attack_melee_melee.
46find . -name "*.xml" -print | xargs sed -E -i '.bu' 's/name="[a|A]ttack(_[a-z]+)?/name="attack_melee/g'
47
48# now, adjust ranged actor animations to attack_ranged
49find . -name "*archer*.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
50find . -name "*javelinist*.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
51find . -name "*ranged.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
52find . -name "*slinger*.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
53find . -name "*skirmisher.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
54
55# individual actor adjustments: melee->ranged
56sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' props/special/palisade_rocks_fort.xml
57sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/athenians/iphicrates.xml
58sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/carthaginians/siege_rock.xml
59sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/celts/boudicca_*.xml
60sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/celts/champion_unit_4*.xml
61sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/hellenes/champion_unit_2.xml
62sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/hellenes/siege_fireraiser.xml
63sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/hellenes/xenophon.xml
64sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/iberians/champion_unit_2*.xml
65sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/macedonians/thureophoros.xml
66sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/mauryans/hero_chariot*.xml
67sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/persians/hero_darius_chariot*.xml
68sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/persians/pers_chariot_darius_h1.xml
69sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/persians/hero_xerxes*.xml
70sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/romans/siege_rock.xml
71sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g' units/thebans/siege_fireraiser.xml
72
73# for all structures that do have attack capabilities, it is of type attack_ranged
74# note: must be tested to exist, so unit-only mods can apply this as well
75# if structures folder does not exist, all actors set to attack_ranged, world will end.
76if [ -d "structures" ]
77 then
78 cd structures
79 find . -name "*.xml" -print | xargs sed -i '.bu' 's/name="attack_melee/name="attack_ranged/g'
80 # now revert siege_ram.xml files because those are melee
81 find . -name "*_ram.xml" -print | xargs sed -i '.bu' 's/name="attack_ranged/name="attack_melee/g'
82 else
83 echo "Skipping structures folder: does not exist"
84fi
85
86echo '==> DONE <=='