Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/core/config
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11841/src/games/stendhal/server/core/config
Modified Files:
CreaturesXMLLoader.java
Log Message:
Load creature sounds from xml and generate sound events for them
Index: CreaturesXMLLoader.java
===================================================================
RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/core/config/CreaturesXMLLoader.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** CreaturesXMLLoader.java 30 Dec 2012 10:09:33 -0000 1.16
--- CreaturesXMLLoader.java 19 Jan 2013 20:22:27 -0000 1.17
***************
*** 76,79 ****
--- 76,82 ----
private List<EquipItem> equipsItems;
+ /** List of possible sound events. */
+ private List<String> sounds;
+
private LinkedHashMap<String, LinkedList<String>> creatureSays;
***************
*** 164,167 ****
--- 167,171 ----
dropsItems = new LinkedList<DropItem>();
equipsItems = new LinkedList<EquipItem>();
+ sounds = new LinkedList<String>();
creatureSays = new LinkedHashMap<String, LinkedList<String>>();
aiProfiles = new LinkedHashMap<String, String>();
***************
*** 271,293 ****
} else if (ai && qName.equals("says")) {
says = true;
! } else if (says && qName.equals("noise")) {
! final String states = attrs.getValue("state");
! final String value = attrs.getValue("value");
! final List<String> keys=Arrays.asList(states.split(" "));
! // no such state in noises, will add it
! for (int i=0; i<keys.size(); i++) {
! final String key=keys.get(i);
! if(creatureSays.get(key)==null) {
! final LinkedList<String> ll=new LinkedList<String>();
! ll.add(value);
! creatureSays.put(key, ll);
! // no such value in existing state, will add it
! } else if (creatureSays.get(key).indexOf(value)==-1) {
! creatureSays.get(key).add(value);
! // both state and value already exists
! } else {
! logger.warn("CreatureXMLLoader: creature ("+name+
! "): double definition for noise \""+key+"\" ("+value+")");
}
}
} else if (qName.equals("abilities")) {
--- 275,301 ----
} else if (ai && qName.equals("says")) {
says = true;
! } else if (says) {
! if (qName.equals("noise")) {
! final String states = attrs.getValue("state");
! final String value = attrs.getValue("value");
! final List<String> keys=Arrays.asList(states.split(" "));
! // no such state in noises, will add it
! for (int i=0; i<keys.size(); i++) {
! final String key=keys.get(i);
! if(creatureSays.get(key)==null) {
! final LinkedList<String> ll=new LinkedList<String>();
! ll.add(value);
! creatureSays.put(key, ll);
! // no such value in existing state, will add it
! } else if (creatureSays.get(key).indexOf(value)==-1) {
! creatureSays.get(key).add(value);
! // both state and value already exists
! } else {
! logger.warn("CreatureXMLLoader: creature ("+name+
! "): double definition for noise \""+key+"\" ("+value+")");
! }
}
+ } else if (qName.equals("sound")) {
+ sounds.add(attrs.getValue("value"));
}
} else if (qName.equals("abilities")) {
***************
*** 340,343 ****
--- 348,352 ----
creature.setSusceptibilities(susceptibilities);
creature.setDamageTypes(damageType, rangedDamageType);
+ creature.setCreatureSounds(sounds);
list.add(creature);
} else if (qName.equals("attributes")) {
|