/*
* Fighter.java
*
* Created on 20 juillet 2007, 04:31
*
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package thegame.comp;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.*;
import java.io.Serializable;
import java.util.*;
import javax.swing.AbstractAction;
import javax.swing.Action;
import net.sf.jiga.xtended.impl.Animation;
import net.sf.jiga.xtended.impl.AnimationHandler;
import net.sf.jiga.xtended.impl.Sprite;
import net.sf.jiga.xtended.impl.game.InteractiveModel;
import net.sf.jiga.xtended.impl.game.SpritesChar;
import net.sf.jiga.xtended.impl.game.XtendedModel;
import net.sf.jiga.xtended.impl.game.editor.ModelAnimBrowser;
import net.sf.jiga.xtended.impl.game.gl.AnimationGLHandler;
import net.sf.jiga.xtended.impl.game.physics.Player;
import net.sf.jiga.xtended.impl.game.physics.Player.id;
import net.sf.jiga.xtended.impl.game.physics.Player.key;
import net.sf.jiga.xtended.impl.system.LogicalSystem;
import net.sf.jiga.xtended.impl.system.input.KeyEventWrapper;
import net.sf.jiga.xtended.kernel.*;
import thegame.KeyboardPlayer;
import thegame.MachinePlayer;
import thegame.Sf3Player;
/**
* Class that acts like a Thread to compute the playerId's new position for each
* key or combinaison pressed (MOVE_UP,MOVE_DOWN,... or nothing) The fighter is
* positioned with the bottom of its actual sprite display. It also simulates a
* computer playerId with {@linkplain #Movement}.
* <pre>
* -------------
* | |
* | |
* | x | <- sprite
* | |
* | |
* ------o-------
*
* ^- O(x,y) for the Fighter
* </pre> <a
* href="https://sourceforge.net/apps/phpbb/sf3jswing/viewtopic.php?f=5&t=19#p48" target="_blank"
* >Di gital Logic Design</a> <br> VM system arg -J-Dthegame.debug.physics=true
* enables debug output at startup (fighter actions)
*
* @author www.b23prodtm.info
*/
public class Fighter extends Player implements Debugger {
public static Level DBUG_PHYSICS = DebugMap._getInstance().newDebugLevel(Fighter.class);
static {
if (JXAenvUtils._getSysBoolean("thegame.debug.physics")) {
DebugMap._getInstance().setDebugLevelEnabled(true, DBUG_PHYSICS);
}
}
public final static ResourceBundle rbAba = ResourceBundle.getBundle("aba.aba");
public final static String _defaultAction = rbAba.getString("animsID_default");
public static SortedMap<String, Integer> _actions = Collections.synchronizedSortedMap(new TreeMap<String, Integer>());
public static Vector<Action> getLoadLayers() {
Vector<Action> loadLayers = new Vector<Action>();
loadLayers.add(new AbstractAction("models actions...") {
public void actionPerformed(ActionEvent e) {
_actions.clear();
Enumeration<String> keys = rbAba.getKeys();
for (; keys.hasMoreElements();) {
String k = keys.nextElement();
if (!k.equals("animsID_default")) {
_actions.put(rbAba.getString(k), _makeSticky(rbAba.getString(k)));
}
}
playersAttr.clear();
buildFightersKeyEventsMaps();
}
});
return loadLayers;
}
private final static List<Map<String, Object>> playersAttr = Collections.synchronizedList(new Vector<Map<String, Object>>());
public final static String SUPERMOVEST1 = "super moves type 1";
public final static String SUPERMOVEST2 = "super moves type 2";
static void buildFightersKeyEventsMaps() {
InteractiveModel model;
Vector<KeyEventWrapper> seq;
HashMap<String, Object> map;
map = new HashMap<String, Object>();
map.put("player", id.ONE);
map.put("eventMapTYPE", SUPERMOVEST1);
playersAttr.add(map);
map = new HashMap<String, Object>();
map.put("player", id.TWO);
map.put("eventMapTYPE", SUPERMOVEST1);
playersAttr.add(map);
map = new HashMap<String, Object>();
map.put("player", id.ONE);
map.put("eventMapTYPE", SUPERMOVEST2);
playersAttr.add(map);
map = new HashMap<String, Object>();
map.put("player", id.TWO);
map.put("eventMapTYPE", SUPERMOVEST2);
playersAttr.add(map);
for (Map<String, Object> attr : playersAttr) {
model = new InteractiveModel("plrMvs" + attr.get("player"),
0, 0, new Dimension(0, 0), new Dimension(0, 0),
new int[][]{{}}, new String[]{}, new String[]{});
model.animsID_default = _defaultAction;
/**
* timing range
*/
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, -1, -1, 3000), "");
/**
* common moves
*/
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED), "stance forwards");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED), "stance backwards");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED), "stance crouch");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED), "stance jump");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED), "stance LP");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED), "stance MP");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED), "stance HP");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED), "stance LK");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED), "stance MK");
model.addKeyEventWrapperMapping(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED), "stance HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch block H");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch block H");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance crouch HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump backwards HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards HP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_up")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance jump forwards HK");
/**
* super moves
*/
if (SUPERMOVEST1.equals(attr.get("eventMapTYPE"))) {
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super HK");
} else if (SUPERMOVEST2.equals(attr.get("eventMapTYPE"))) {
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super LK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super MK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HK")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance super HK");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards super LP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards super MP");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance forwards super HP");
}
/**
* super combo moves
*/
/**
* fireballs
*/
if (SUPERMOVEST1.equals(attr.get("eventMapTYPE"))) {
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super L");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super L");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super M");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super M");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super H");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_PRESSED, 2000));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_backwards")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super H");
} else if (SUPERMOVEST2.equals(attr.get("eventMapTYPE"))) {
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_LP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super L");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_MP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super M");
seq = new Vector<KeyEventWrapper>();
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_forwards")), KeyEvent.KEY_PRESSED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_down")), KeyEvent.KEY_RELEASED));
seq.add(new KeyEventWrapper(0, _keyCodeMap.get(key.valueOf(attr.get("player") + "_HP")), KeyEvent.KEY_PRESSED));
model.addKeyEventWrapperMapping(new KeyEventWrapper(seq), "stance fireball super H");
}
registerKEMap((id) attr.get("player"), (String) attr.get("eventMapTYPE"), model);
}
}
static void registerKEMap(id playerId, String eventMapTYPE, InteractiveModel model) {
model.setAttribute("player", playerId);
model.setAttribute("eventMapTYPE", eventMapTYPE);
SpritesChar.characters.put(playerId + "::" + eventMapTYPE, model);
if (DebugMap._getInstance().isDebugLevelEnabled(DBUG_PHYSICS)) {
System.out.println("New KEM registry : " + model);
}
}
static InteractiveModel fetchKEMap(id playerId, String eventMapTYPE) {
return SpritesChar.characters.get(playerId + "::" + eventMapTYPE);
}
/**
* life from 100 to 0
*/
int life;
/**
*
*/
Fighter[] opponents;
/**
*
*/
Rectangle field;
/**
*
*/
SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>> collisionDefBounds;
/**
*
*/
SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>> collisionAtkBounds;
/**
*
*/
SortedMap<Integer, SortedMap<Integer, Point>> locationsMap;
Fighter ball = null;
public Fighter getBall() {
return ball;
}
/**
* int resolution = model.res;
*/
/**
* associated XtendedModel instance
*/
public XtendedModel getModel() {
return model;
}
public long getCurrent_tick() {
return current_tick;
}
public long getLast_tick() {
return last_tick;
}
/**
* returns the current position
*
* @return the current position
*/
public Point2D getPosPlayer() {
return pos;
}
/**
* model.getAttribute("name") value
*/
public String getModelName() {
return modelName;
}
/*
* public int getResolution() { return resolution; }
*/
/*
* public void setResolution(int resolution) { this.resolution = resolution;
* }
*/
static BitStack _FIGHTERMACHINE_bits = new BitStack();
public final static int FIGHTERMACHINE_NA = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_A = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_D = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Air = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Stance = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Crouch = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Fall = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Throw = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Thrown = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_Hit = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_HIGH = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_MID = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_LOW = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_SPECIAL = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_KICK = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_PUNCH = _FIGHTERMACHINE_bits._newBitRange();
public final static int FIGHTERMACHINE_blackList = _FIGHTERMACHINE_bits._newBitRange();
private int FIGHTERMACHINE = 0;
public int getFIGHTERMACHINESTATE() {
return FIGHTERMACHINE;
}
public static String[] action_blackList = new String[]{"stance intro", "win", "draw", "lose", "K.O."};
private static int _makeSticky(String action) {
int sticky = 0;
if (action == null) {
return sticky;
} else {
if (action.contains("fireball") || action.endsWith("K") || action.endsWith("P")) {
sticky |= FIGHTERMACHINE_A;
}
if (action.contains("block")) {
sticky |= FIGHTERMACHINE_D;
}
if ((sticky & (FIGHTERMACHINE_A | FIGHTERMACHINE_D)) == 0) {
sticky |= FIGHTERMACHINE_NA;
}
if (action.startsWith("stance jump")) {
sticky |= FIGHTERMACHINE_Air;
} else if (action.startsWith("stance crouch")) {
sticky |= FIGHTERMACHINE_Crouch;
} else if (action.startsWith("stance")) {
sticky |= FIGHTERMACHINE_Stance;
} else if (action.startsWith("fall")) {
sticky |= FIGHTERMACHINE_Fall;
}
if (action.contains("hit")) {
sticky |= FIGHTERMACHINE_Hit;
}
if (action.contains("thrown")) {
sticky |= FIGHTERMACHINE_Thrown;
}
if (action.contains("throw")) {
sticky |= FIGHTERMACHINE_Throw;
}
if (action.contains("super")) {
sticky |= FIGHTERMACHINE_SPECIAL;
}
if (action.endsWith("LK") || action.endsWith("LP") || action.endsWith("L")) {
sticky |= FIGHTERMACHINE_LOW;
}
if (action.endsWith("MK") || action.endsWith("MP") || action.endsWith("M")) {
sticky |= FIGHTERMACHINE_MID;
}
if (action.endsWith("HK") || action.endsWith("HP") || action.endsWith("H")) {
sticky |= FIGHTERMACHINE_HIGH;
}
if (action.endsWith("LK") || action.endsWith("MK") || action.endsWith("HK")) {
sticky |= FIGHTERMACHINE_KICK;
}
if (action.endsWith("LP") || action.endsWith("MP") || action.endsWith("HP")) {
sticky |= FIGHTERMACHINE_PUNCH;
}
for (String name : action_blackList) {
if (action.equals(name)) {
sticky |= FIGHTERMACHINE_blackList;
}
}
return sticky;
}
}
private boolean machine = false;
public boolean isMachine() {
return machine;
}
public void setMachine(boolean machine) {
this.machine = machine;
}
Sf3Player player;
public Fighter(Sf3Player player, id playerId, XtendedModel model, Fighter[] opponents, Rectangle fieldBounds,
int life, Point2D pos, boolean machine) {
this(player, playerId, model, opponents, fieldBounds, life, pos);
this.machine = machine;
}
/**
*
* @param opponents this array contains all present opponents fighters
* @param field
* @param life
* @param lifeInertia
* @param pos
* @param ballSpeed
* @param fighterSpeed
* @param fighterWeight
* @param gravity
*/
public Fighter(Sf3Player player, id playerId, XtendedModel model, Fighter[] opponents, Rectangle fieldBounds,
int life, Point2D pos) {
super(model, pos);
synchronized (playersAttr) {
for (Map<String, Object> map : playersAttr) {
if (map.get("player").equals(playerId) && map.get("eventMapTYPE").equals(model.getAttribute("eventMapTYPE"))) {
attrs = Collections.synchronizedMap(map);
model.animsID_default = _defaultAction;
model.setAttribute("player", (Serializable) attrs.get("player"));
model.clearKeyEventWrapperMap();
model.addKeyEventWrapperMap(fetchKEMap((id) attrs.get("player"), (String) attrs.get("eventMapTYPE")).keyEvents);
if (model.getAttribute("ball") instanceof XtendedModel) {
XtendedModel ballModel = (XtendedModel) model.getAttribute("ball");
ball = new Fighter(isMachine() ? new MachinePlayer(player.getPlayerNum(), player.getGui()) : new KeyboardPlayer(player.getPlayerNum(), player.getGui()), (id) attrs.get("player"), ballModel, opponents, fieldBounds, life, pos);
}
break;
}
}
}
this.collisionDefBounds = Collections.synchronizedSortedMap(new TreeMap<Integer, SortedMap<Integer, Vector<Rectangle>>>((SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>>) model.getAttribute(ModelAnimBrowser.COLLISIONSDEF)));
this.collisionAtkBounds = Collections.synchronizedSortedMap(new TreeMap<Integer, SortedMap<Integer, Vector<Rectangle>>>((SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>>) model.getAttribute(ModelAnimBrowser.COLLISIONSATK)));
this.locationsMap = Collections.synchronizedSortedMap(new TreeMap<Integer, SortedMap<Integer, Point>>((SortedMap<Integer, SortedMap<Integer, Point>>) model.getAttribute(ModelAnimBrowser.LOCATIONS)));
playableActions = new Vector<String>();
playableActions.addAll(model.animsMap.keySet());
assert playableActions.contains(_defaultAction) : _defaultAction + " is not mapped to any animation in " + model;
model.setAnimsID_default(_defaultAction);
assert playerId instanceof id : "please set up a player identifier !";
this.player = player;
this.playerId = playerId;
properties.setProperty(PROP_SPEED, "" + (int) ((float) fieldBounds.width / 15f));
properties.setProperty(PROP_GRAVITY, "10");
this.opponents = opponents;
setState(fieldBounds,
life, pos);
setProcessed_tick();
}
@Override
public int hashCode() {
return ("fighter-" + model.hashCode()).hashCode();
}
@Override
public boolean equals(Object obj) {
return obj != null ? obj.hashCode() == hashCode() : false;
}
Movement ai = new Movement();
Combo aic = new Combo();
private id playerId = null;
private Map<String, Object> attrs = Collections.synchronizedMap(new HashMap<String, Object>());
public id getPlayerId() {
return playerId;
}
public Map<String, Object> getAttrs() {
return attrs;
}
List<String> playableActions;
public void setState(Rectangle fieldBounds,
int life, Point2D pos) {
pos.setLocation(pos);
this.field = fieldBounds;
this.life = life;
properties.setProperty(PROP_SPEED, "" + (int) ((float) fieldBounds.width / 15f));
properties.setProperty(PROP_GRAVITY, "10");
}
public Fighter getClosestOpponent() {
Fighter op = null;
for (Fighter f : opponents) {
if (op == null) {
op = f;
}
op = Math.abs(pos.distance(f.pos)) < Math.abs(pos.distance(op.pos)) ? f : op;
}
return op;
}
public Fighter getWidestOpponent() {
Fighter op = null;
for (Fighter f : opponents) {
if (op == null) {
op = f;
}
op = Math.abs(pos.distance(f.pos)) > Math.abs(pos.distance(op.pos)) ? f : op;
}
return op;
}
/**
*
*/
private boolean hasOpponentsAtLeft() {
for (Fighter f : opponents) {
if (f.pos.getX() < pos.getX()) {
return true;
}
}
return false;
}
/**
*
*/
private boolean hasOpponentsAtRight() {
for (Fighter f : opponents) {
if (f.pos.getX() > pos.getX()) {
return true;
}
}
return false;
}
@Override
public Rectangle2D getBounds2D(int resolution) {
Rectangle r = super.getBounds2D(resolution).getBounds();
r.translate(getModelPaintLocation(resolution).x - getModelDefaultPaintLocation(resolution).x,
getModelPaintLocation(resolution).y - getModelDefaultPaintLocation(resolution).y);
return r;
}
public Ellipse2D getBoundsCircle(int resolution) {
Rectangle2D bds = getBounds2D(resolution);
Ellipse2D enclosingRadius = new Ellipse2D.Float();
double diagonalLength = Math.abs(new Point((int) bds.getX(), (int) bds.getY()).distance(new Point((int) bds.getMaxX(), (int) bds.getMaxY())));
enclosingRadius.setFrame(bds.getCenterX() - diagonalLength / 2.0, bds.getCenterY() - diagonalLength / 2.0, diagonalLength, diagonalLength);
return enclosingRadius;
}
public static Rectangle2D _intersectCircles(Ellipse2D c0, Ellipse2D c1) {
Rectangle2D inter = c0.getBounds2D().createIntersection(c1.getBounds2D());
if (c0.intersects(inter) && c1.intersects(inter)) {
return inter;
} else {
return new Rectangle();
}
}
/**
*
*/
private boolean isCloseToOpponents() {
for (Fighter f : opponents) {
Ellipse2D circlingBounds = getBoundsCircle(player.gui.getModelResolution()), opCirclingBounds = f.getBoundsCircle(player.gui.getModelResolution());
if (!_intersectCircles(circlingBounds, opCirclingBounds).isEmpty()) {
return true;
}
}
return false;
}
/**
*
*/
public void resetTicker() {
last_tick = 0L;
}
@Override
protected void finalize() throws Throwable {
_reversedAxisX.put(playerId, false);
super.finalize();
}
public final Properties properties = new Properties();
public final static String PROP_SPEED = "speed";
public final static String PROP_GRAVITY = "gravity";
/*
* public boolean isAnimLoop() { return getCurrentAnimation() instanceof
* AnimationHandler ? getCurrentAnimation().getPlayerStatus() ==
* Animation.PLAYING && 0 != ((FIGHTERMACHINE_Air | FIGHTERMACHINE_Crouch |
* FIGHTERMACHINE_Stance) & _makeSticky(getCurrentAnimName())) : false; }
*/
public final static String NO_ANIM = "xxxNO_ANIMxxx";
public String getCurrentAnimName() {
String animName = model.getAnimName();
if (!_actions.containsKey(animName = (animName != null ? animName : NO_ANIM))) {
if (isDebugEnabled()) {
System.out.println("CURRENT ANIM " + animName + " NOT A VALID NAME");
System.out.println(model.getAttribute("player") + " anims Map : ");
}
synchronized (model.animsMap) {
for (String n : model.animsMap.keySet()) {
if (isDebugEnabled()) {
System.out.println(n);
}
}
}
}
return animName;
}
public String getCurrentAnimName_Lock() {
String animName = model.getAnimName_Lock();
if (!_actions.containsKey(animName != null ? animName : NO_ANIM)) {
if (isDebugEnabled()) {
System.out.println("CURRENT ANIMLOCK NOT A VALID NAME");
}
}
return animName;
}
Map<Integer, Map<String, Object>> collision_tag = Collections.synchronizedMap(new HashMap<Integer, Map<String, Object>>());
public Map<Integer, Map<String, Object>> getCollision_tag() {
return collision_tag;
}
/**
*
*/
private boolean enabled = false;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isLoaded() {
if (model != null) {
return model != null && model.isLoaded() && (player.isHardwareAccel() ? model.GLisLoaded() : true);
} else {
return false;
}
}
/**
* NOTICE : Fighter's Model's are known to be oriented to the left, that is
* when an opponent is on the right, the Model is flipped horizontally.
*/
public void run() {
if (!enabled) {
return;
}
current_tick = System.currentTimeMillis();
if (last_tick == 0) {
last_tick = current_tick;
} else {
if (isDebugEnabled()) {
System.out.println(toString() + " ticktime-resolution : " + (current_tick - last_tick));
}
}
if (!isLoaded()) {
if (isDebugEnabled()) {
System.out.println("the model is currently not available, for " + toString() + "; aborting Fighter tick " + current_tick);
}
return;
} else {
for (Fighter opp : opponents) {
if (!opp.isLoaded()) {
if (isDebugEnabled()) {
System.out.println("Some fighters are not ready.");
}
return;
}
}
}
if (!_actions.containsKey(getCurrentAnimName())) {
if (isDebugEnabled()) {
System.out.println("INVALID action changing to default " + _defaultAction);
}
model.GLanimPlayer_ChangeAnim(_defaultAction);
}
model.setTransformEnabled(true);
/**
* orientation of the model
*/
int speed = Math.round(Integer.parseInt((String) properties.get(PROP_SPEED)) * (current_tick - last_tick) / 1000f);
int xOrientation = 0;
Fighter op = getClosestOpponent();
xOrientation = (op.pos.getX() < pos.getX()) ? -1 : 1;
if (hasOpponentsAtLeft() && hasOpponentsAtRight()) {
if (isDebugEnabled()) {
System.out.print(toString(true) + " is facing opponents from both sides !!");
}
}
if (xOrientation > 0) {
model.setFlipEnabled(false, Sprite.HORIZONTAL);
} else if (xOrientation < 0) {
model.setFlipEnabled(true, Sprite.HORIZONTAL);
}
if (getCurrentAnimName().equals(NO_ANIM)) {
model.GLrunValidate();
}
if (xOrientation > 0) {
_reversedAxisX.put(playerId, id.TWO.equals(playerId));
} else if (xOrientation < 0) {
_reversedAxisX.put(playerId, id.ONE.equals(playerId));
}
if (isDebugEnabled()) {
System.out.println(getClass().getName() + " has" + ((_reversedAxisX.get(playerId)) ? "" : " not") + " reversed PLAYER " + playerId + " X-axis");
}
/**
* MACHINE PROCESSING
*/
FIGHTERMACHINE = _makeSticky(getCurrentAnimName());
/**
* anim computer playerId
*/
if (isMachine()) {
int oppState = getClosestOpponent().getFIGHTERMACHINESTATE();
if ((oppState & FIGHTERMACHINE_Air) != 0) {
ai.newInput(M_INPUT_OppH);
}
if ((oppState & FIGHTERMACHINE_Stance) != 0) {
ai.newInput(M_INPUT_OppM);
}
if ((oppState & FIGHTERMACHINE_Crouch) != 0) {
ai.newInput(M_INPUT_OppL);
}
if (life > 75) {
aic.newInput(C_INPUT_0pc);
} else if (life > 50) {
aic.newInput(C_INPUT_33pc);
} else if (life > 25) {
aic.newInput(C_INPUT_66pc);
} else {
aic.newInput(C_INPUT_RAGE100pc);
}
int aiState = ai.getState();
int aicState = aic.getState();
int sticky = 0;
if (aiState == M_STATE_Ah || aiState == M_STATE_Am || aiState == M_STATE_Al) {
sticky |= FIGHTERMACHINE_A;
if (aiState == M_STATE_Ah) {
sticky |= FIGHTERMACHINE_Air;
}
if (aiState == M_STATE_Am) {
sticky |= FIGHTERMACHINE_Stance;
}
if (aiState == M_STATE_Al) {
sticky |= FIGHTERMACHINE_Crouch;
}
if (aicState == C_STATE_RANDOM) {
}
if (aicState == C_STATE_L) {
sticky |= FIGHTERMACHINE_LOW;
}
if (aicState == C_STATE_M) {
sticky |= FIGHTERMACHINE_MID;
}
if (aicState == C_STATE_H) {
sticky |= FIGHTERMACHINE_HIGH;
}
if (aicState == C_STATE_S) {
sticky |= FIGHTERMACHINE_SPECIAL;
}
}
if (aiState == M_STATE_Dh || aiState == M_STATE_Dm || aiState == M_STATE_Dl) {
sticky |= FIGHTERMACHINE_D;
if (aiState == M_STATE_Dh) {
sticky |= FIGHTERMACHINE_Air;
}
if (aiState == M_STATE_Dm) {
sticky |= FIGHTERMACHINE_Stance;
}
if (aiState == M_STATE_Dl) {
sticky |= FIGHTERMACHINE_Crouch;
}
}
if (aiState == M_STATE_Mh || aiState == M_STATE_Mm || aiState == M_STATE_Ml) {
sticky |= FIGHTERMACHINE_NA;
if (aiState == M_STATE_Mh) {
sticky |= FIGHTERMACHINE_Air;
}
if (aiState == M_STATE_Mm) {
sticky |= FIGHTERMACHINE_Stance;
}
if (aiState == M_STATE_Ml) {
sticky |= FIGHTERMACHINE_Crouch;
}
}
model.GLanimPlayer_ChangeAnim(_findAction(sticky, playableActions, _defaultAction));
}
if (isDebugEnabled()) {
System.out.println(toString(true) + " : (\\) next action " + getCurrentAnimName());
}
/**
* PHYSICS PROCESSING
*/
if (isDebugEnabled()) {
System.out.println("(|) (x,y) calculation with Animation " + getCurrentAnimName());
}
if ((_makeSticky(getCurrentAnimName()) & FIGHTERMACHINE_Air) != 0) {
if (getCurrentAnimName().startsWith("stance jump backwards")) {
if (air_tStart == 0) {
air_tStart = current_tick;
}
calcHighJump(-xOrientation, air_tStart, speed);
} else if (getCurrentAnimName().startsWith("stance jump forwards")) {
if (air_tStart == 0) {
air_tStart = current_tick;
}
calcHighJump(xOrientation, air_tStart, speed);
} else if (getCurrentAnimName().startsWith("stance jump")) {
if (air_tStart == 0) {
air_tStart = current_tick;
}
calcHighJump(0, air_tStart, speed);
}
animMove(new String[]{"stance jump forwards", "stance jump backwards", "stance jump"});
}
if ((_makeSticky(getCurrentAnimName()) & FIGHTERMACHINE_Stance) != 0) {
if (getCurrentAnimName().startsWith("stance forwards")) {
calcStraightRun(xOrientation, speed);
} else if (getCurrentAnimName().startsWith("stance backwards")) {
calcStraightRun(-xOrientation, speed);
if ((getClosestOpponent().getFIGHTERMACHINESTATE() & FIGHTERMACHINE_A) != 0) {
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_D | FIGHTERMACHINE_Stance, playableActions, _defaultAction));
}
}/*
* else if (getCurrentAnimName().startsWith("stance")) { if
* (model.GLgetCurrentAnim().getPlayerStatus() != Animation.PLAYING)
* { model.GLanimPlayer_PlayOnce(); } }
*/
if (ball != null) {
if (ball.getModel() instanceof XtendedModel) {
if (getCurrentAnimName().startsWith("stance fireball")) {
ball.getModel().GLanimPlayer_ChangeAnim(getCurrentAnimName());
ball.getModel().GLanimPlayer_PlayAndLoop();
} else {
ball.getModel().GLanimPlayer_Stop();
}
}
}
animMove(new String[]{"stance"});
}
if ((_makeSticky(getCurrentAnimName()) & FIGHTERMACHINE_Crouch) != 0) {
/*
* animMove(new String[]{"crouch"});
*/
boolean backwards = false;
synchronized (model.getPressedKeys()) {
for (KeyEventWrapper kew : model.getPressedKeys().values()) {
if (_keyCodeMap.get(key.valueOf(playerId + "_backwards")) == kew.get_keyCode()) {
backwards = true;
break;
}
}
}
if ((getClosestOpponent().getFIGHTERMACHINESTATE() & FIGHTERMACHINE_A) != 0 && backwards) {
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_D | FIGHTERMACHINE_Crouch, playableActions, _defaultAction));
}
animMove(new String[]{"stance"});
}
/**
*
*/
if ((_makeSticky(getCurrentAnimName()) & FIGHTERMACHINE_Fall) != 0) {
/*
* if (getCurrentAnimName().contains("backwards")) {
* calcFall((Math.PI / alphaJumpSlope - 1) * xOrientation,
* air_tStart = current_tick, speed); } else if
* (getCurrentAnimName().contains("forwards")) { calcFall(-(Math.PI
* / alphaJumpSlope - 1) * xOrientation, air_tStart = current_tick,
* speed); /*} else {
*/
calcFall(Math.PI / alphaJumpSlope * (-xOrientation), air_tStart, speed);
/*
* }
*/
}
/**
* collision
*/
Rectangle2D collision = new Rectangle();
boolean outOfBounds = false;
Rectangle paddedBounds = field.getBounds();
paddedBounds.grow(-1, -1);
try {
collision_tag = calcCollision();
} catch (Exception ex) {
if (isDebugEnabled()) {
ex.printStackTrace();
}
outOfBounds = true;
} finally {
int tag = 0, outcode = 0, level = 0;
if (collision_tag.containsKey(tag = FIGHTERMACHINE_A) || collision_tag.containsKey(tag = FIGHTERMACHINE_D) || collision_tag.containsKey(tag = FIGHTERMACHINE_NA)) {
collision = ((Rectangle2D) collision_tag.get(tag).get("intersection")).getBounds();
outcode = (Integer) collision_tag.get(tag).get("outcode");
if ((outcode & Rectangle.OUT_BOTTOM) != 0) {
level = FIGHTERMACHINE_LOW;
}
if ((outcode & Rectangle.OUT_TOP) != 0) {
level = FIGHTERMACHINE_HIGH;
}
if ((outcode & Rectangle.OUT_LEFT) != 0) {
level = FIGHTERMACHINE_MID;
}
if ((outcode & Rectangle.OUT_RIGHT) != 0) {
level = FIGHTERMACHINE_MID;
}
}
if (!collision.isEmpty()) {
if (tag == FIGHTERMACHINE_A) {
int hitAct = FIGHTERMACHINE_NA | FIGHTERMACHINE_Hit;
if ((getFIGHTERMACHINESTATE() & (FIGHTERMACHINE_Air | FIGHTERMACHINE_Fall)) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Air | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Air | hitAct | level, playableActions, defaultAction));
}
if ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_Stance) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Stance | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Stance | hitAct | level, playableActions, defaultAction));
}
if ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_Crouch) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Crouch | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Crouch | hitAct | level, playableActions, defaultAction));
}
} else if (tag == FIGHTERMACHINE_D) {
int hitAct = FIGHTERMACHINE_D;
if ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_Air) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Air | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Air | hitAct | level, playableActions, defaultAction));
}
if ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_Stance) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Stance | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Stance | hitAct | level, playableActions, defaultAction));
}
if ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_Crouch) != 0) {
String defaultAction = _findAction(FIGHTERMACHINE_Crouch | hitAct, playableActions, _defaultAction);
model.GLanimPlayer_ChangeAnim(_findAction(FIGHTERMACHINE_Crouch | hitAct | level, playableActions, defaultAction));
}
} else if (tag == FIGHTERMACHINE_NA) {
reset("stance");
}
if (isDebugEnabled()) {
System.out.println(toString(true) + "'s been hit at : " + collision);
}
int x = 0, y = 0;
if ((outcode & Rectangle.OUT_BOTTOM) != 0) {
y -= speed;
}
if ((outcode & Rectangle.OUT_TOP) != 0) {
y += speed;
}
if ((outcode & Rectangle.OUT_LEFT) != 0) {
x += speed;
}
if ((outcode & Rectangle.OUT_RIGHT) != 0) {
x -= speed;
}
if (isDebugEnabled()) {
System.out.print(" Fighter's been hit, its position is changing by : " + x + "," + y);
}
pos.setLocation(pos.getX() + x, pos.getY() + y);
if (pos.getY() < paddedBounds.getMaxY()) {
if (isDebugEnabled()) {
System.out.print(" Fighter's falling.");
}
/*
* if (getCurrentAnimName().contains("backwards")) {
* calcFall((Math.PI / alphaJumpSlope - 1) * xOrientation,
* air_tStart = current_tick, speed); } else if
* (getCurrentAnimName().contains("forwards")) {
* calcFall(-(Math.PI / alphaJumpSlope - 1) * xOrientation,
* air_tStart = current_tick, speed); } else {
*/
calcFall(Math.PI / alphaJumpSlope * (-xOrientation), air_tStart = current_tick, speed);
/*
* }
*/
}
}
pos.setLocation(
Math.min(paddedBounds.getMaxX(), Math.max(paddedBounds.getX(), pos.getX())),
Math.min(paddedBounds.getMaxY(), Math.max(paddedBounds.getY(), pos.getY())));
}
/**
* update machine state
*/
FIGHTERMACHINE = _makeSticky(getCurrentAnimName());
setProcessed_tick();
if (isDebugEnabled()) {
System.out.println("(/) " + toString(true) + "'s new POSITION (x,y)=" + pos + " on field : " + field);
}
}
/**
* Will test the starting string of the current animation and animation lock
* "moves". If the test fails given a move name in "moves", the anim-loop is
* set locked on the move name and plays once the current action.
*
* @param moves must order the moves so that the most general action name is
* at the end. e.g. for air : new String[]{"stance jump forwards", "stance
* jump backwards", "stance jump"}
*/
private void animMove(String[] moves) {
boolean currentPlaying = model.GLgetCurrentAnim().getPlayerStatus() == Animation.PLAYING;
for (String move : moves) {
if (getCurrentAnimName().startsWith(move) && !move.equals(getCurrentAnimName_Lock())) {
String current = getCurrentAnimName();
model.GLanimPlayer_ChangeAnim(move);
model.GLanimPlayer_PlayAndLoop();
if (!current.equals(move) && currentPlaying) {
model.GLanimPlayer_ChangeAnim(current);
model.GLanimPlayer_PlayOnce();
model.GLanim(move, model.getFrameRate(), true);
model.GLanim(current, model.getFrameRate(), false);
}
break;
}
}
}
public static String _findAction(int sticky, List<String> actionsList, String defaultAction) {
Stack<String> actions = new Stack<String>();
actions.addAll(actionsList);
Collections.shuffle(actions);
while ((_makeSticky(actions.peek()) & sticky) != sticky || (_makeSticky(actions.peek()) & FIGHTERMACHINE_blackList) != 0) {
actions.pop();
}
if (actions.empty()) {
return defaultAction;
} else {
return actions.peek();
}
}
/**
*
*/
Point air_start = null;
/**
*
*/
long air_tStart = 0;
/**
*
*/
public void reset(String action) {
air_start = null;
air_tStart = 0L;
model.GLanimPlayer_ChangeAnim(action);
}
/**
*
*/
private void calcFall(double xDirection, long start, int speed) {
if (start == current_tick) {
reset("fall");
}
calcHighJump(xDirection, start, speed);
}
/**
*
*/
private double alphaJumpSlope = Math.PI / 16.0;
/*
* F = m.a ; a(t) = v'(t) = x''(t); x(t) = x0 + v0 * t * cos(alpha) ; y(t) =
* y0 + v0 * t * sin(alpha) - 1/2 G * t^2 angle is PI/2 - (xOrientation *
* alphaJumpSlope)
*/
private void calcHighJump(double xDirection, long start, int speed) {
int gravity = Integer.parseInt(properties.getProperty(PROP_GRAVITY));
if (air_start == null) {
air_start = new Point((int) pos.getX(), (int) pos.getY());
}
double alpha = Math.PI / 2.0 - (double) xDirection * alphaJumpSlope;
float elapsed = (float) ((float) (current_tick - start) / 1000f);
pos.setLocation(
air_start.x + ((float) Math.cos(alpha) * (float) speed * elapsed),
air_start.y - ((float) Math.sin(alpha) * (float) speed * elapsed - .5f * (float) gravity * Math.pow(elapsed, 2.0)));
Dimension outset = new Dimension((int) (.5 * getBounds2D(player.gui.getModelResolution()).getWidth()), 0);
pos.setLocation(Math.max(field.getMinX() + outset.width, Math.min(field.getMaxX() - outset.width, pos.getX())), Math.max(field.getMinY() + outset.height, Math.min(field.getMaxY() - outset.height, pos.getY())));
if (isDebugEnabled()) {
System.out.println(toString(true) + "'s in the air, from : " + air_start + " now : " + pos);
}
}
/**
* returns 4 coords from the upper-left corner clockwise of a Rectangle
*/
public static Point[] _get4Coords(Rectangle2D r) {
return new Point[]{
new Point((int) r.getX(), (int) r.getY()),
new Point((int) r.getMaxX(), (int) r.getY()),
new Point((int) r.getMaxX(), (int) r.getMaxY()),
new Point((int) r.getX(), (int) r.getMaxY())
};
}
public static Rectangle2D _makeRect(Point2D[] pts) {
Rectangle2D r = new Rectangle();
r.setFrameFromDiagonal(pts[0], pts[2]);
Rectangle2D r2 = new Rectangle();
r2.setFrameFromDiagonal(pts[1], pts[3]);
assert r.equals(r2) : "the specified points array does not define a valid rectangular shape";
return r;
}
private Point getModelDefaultPaintLocation(int resolution) {
Point location = new Point((int) pos.getX(), (int) pos.getY());
location.translate((int) Math.round(-(float) model.getWidth(resolution) / 2f), -model.getHeight(resolution) + model.getFloorDiff(resolution));
return location;
}
public AnimationHandler getCurrentAnimation() {
return model.GLgetCurrentAnim();
}
public Point getModelPaintLocation(int resolution) {
Point location = getModelDefaultPaintLocation(resolution);
AnimationHandler currentAnim = getCurrentAnimation();
if (currentAnim == null) {
return location;
}
int currentSprite = currentAnim.getPosition();
String animName = getCurrentAnimName();
double scale = SpritesChar.RES_FACTORS_map.get(resolution) / SpritesChar.RES_FACTORS_map.get(model.res);
AffineTransform resTx = new AffineTransform();
if (currentAnim.getMirrorOrientation() == Sprite.HORIZONTAL) {
resTx.scale(-1, 1);
}
if (animName instanceof String) {
int i;
if (locationsMap.containsKey(i = model.anim(animName))) {
Point locMap = locationsMap.get(i).containsKey(currentSprite) ? locationsMap.get(i).get(currentSprite) : new Point(0, 0);
Point resLocMap = new Point();
AffineTransform.getScaleInstance(scale, scale).transform(locMap, resLocMap);
resTx.transform(resLocMap, resLocMap);
if (player.getGui().isDebugEnabled()) {
if (isDebugEnabled()) {
System.out.println("location point tx : " + resTx + " location : " + location);
}
}
resLocMap.translate(location.x, location.y);
location = resLocMap;
}
}
return location;
}
public Rectangle[] getCollisionBounds(SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>> collisionBoundsMap, int resolution) {
Rectangle[] bounds = new Rectangle[]{};
AnimationHandler currentAnim = getCurrentAnimation();
if (currentAnim == null) {
return bounds;
}
int currentSprite = currentAnim.getPosition();
String animName = getCurrentAnimName();
Point location = getModelDefaultPaintLocation(resolution);
double scale = SpritesChar.RES_FACTORS_map.get(resolution) / SpritesChar.RES_FACTORS_map.get(model.res);
AffineTransform resTx = new AffineTransform();
if (currentAnim.getMirrorOrientation() == Sprite.HORIZONTAL) {
resTx.translate(model.getWidth(resolution), 0);
resTx.scale(-1, 1);
}
if (collisionBoundsMap instanceof SortedMap && animName instanceof String) {
int i;
if (collisionBoundsMap.containsKey(i = model.anim(animName))) {
Vector<Rectangle> boundsV = collisionBoundsMap.get(i).get(currentSprite);
Vector<Rectangle> boundsVLoc = new Vector<Rectangle>();
if (boundsV instanceof Vector) {
for (Rectangle r : boundsV) {
if (r instanceof Rectangle) {
Rectangle locR = AffineTransform.getScaleInstance(scale, scale).createTransformedShape(r).getBounds();
locR = resTx.createTransformedShape(locR).getBounds();
if (player.getGui().isDebugEnabled()) {
if (isDebugEnabled()) {
System.out.println("collisions rect tx : " + resTx + " location : " + location);
}
}
locR.translate(location.x, location.y);
boundsVLoc.add(locR);
}
}
bounds = boundsVLoc.toArray(bounds);
}
}
}
return bounds;
}
public SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>> getCollisionAtkBounds() {
return collisionAtkBounds;
}
public SortedMap<Integer, SortedMap<Integer, Vector<Rectangle>>> getCollisionDefBounds() {
return collisionDefBounds;
}
/**
* if one is intersecting with two, returns the map with the key
* "intersection" targeting th intersection Rectangle area and another key
* "outcode" that is the bitwise-OR combination of Rectangle.OUT_* codes.
* Rectangle.OUT_* indicates ABOUT WHERE IT'S INTERSECTING BOTTOM, TOP, LEFT
* or RIGHT of Rectangle ONE.
*/
private Map<String, Object> calcCollision(RectangularShape one, RectangularShape two) {
Map<String, Object> map = new HashMap<String, Object>();
boolean isEllipse = one instanceof Ellipse2D && two instanceof Ellipse2D;
Rectangle2D circleInter = isEllipse ? _intersectCircles((Ellipse2D) one, (Ellipse2D) two) : new Rectangle();
if (isEllipse ? !circleInter.isEmpty() : two.intersects(one.getBounds2D())) {
Rectangle2D intersection = isEllipse ? circleInter : two.getBounds2D().createIntersection(one.getBounds2D());
int outcode = 0;
Rectangle interOutcode = intersection.getBounds();
interOutcode.grow(1, 1);
for (Point p : _get4Coords(interOutcode)) {
outcode = outcode | one.getBounds2D().outcode(p);
}
map.put("intersection", intersection);
map.put("outcode", outcode);
}
return map;
}
/**
*
*/
private Map<Integer, Map<String, Object>> calcCollision() throws Exception {
Map<Integer, Map<String, Object>> collision_tag = Collections.synchronizedMap(new HashMap<Integer, Map<String, Object>>());
Map<String, Object> map = new HashMap<String, Object>();
int shortTag = 0;
Rectangle2D bds = getBounds2D(player.gui.getModelResolution());
/**
* collisions with opponents
*/
for (Fighter f : opponents) {
Rectangle2D oppBds = f.getBounds2D(player.gui.getModelResolution());
for (Rectangle oppAtk : f.getCollisionBounds(f.collisionAtkBounds, player.gui.getModelResolution())) {
for (Rectangle def : getCollisionBounds(collisionDefBounds, player.gui.getModelResolution())) {
if (oppAtk.intersects(def)) {
map.putAll(calcCollision(def, oppAtk));
shortTag = FIGHTERMACHINE_A;
break;
}
}
if (shortTag != 0) {
break;
}
}
if (shortTag == 0) {
for (Rectangle oppAtk : f.getCollisionBounds(f.collisionAtkBounds, player.gui.getModelResolution())) {
if (oppAtk.intersects(bds)) {
map.putAll(calcCollision(bds, oppAtk));
shortTag = FIGHTERMACHINE_D;
break;
}
}
if (shortTag != 0) {
break;
}
}
Ellipse2D innerCircleBds = new Ellipse2D.Float(), innerCircleOppBds = new Ellipse2D.Float();
innerCircleBds.setFrame(bds);
innerCircleOppBds.setFrame(oppBds);
if (!_intersectCircles(innerCircleOppBds, innerCircleBds).isEmpty()) {
map.putAll(calcCollision(innerCircleBds, innerCircleOppBds));
shortTag = FIGHTERMACHINE_NA;
}
}
/**
* collisions with field bounds
*/
Rectangle field = new Rectangle(this.field);
field.grow(1, 1);
if (shortTag == 0 && !field.contains(bds)) {
if (field.intersects(bds)) {
map.putAll(calcCollision(bds, field));
shortTag = FIGHTERMACHINE_NA;
} else {
throw new Exception("Fighter is out of the field : " + bds);
}
}
collision_tag.put(shortTag, map);
return collision_tag;
}
private String currentStatus = "";
public String toString() {
return toString(false);
}
public String toString(final boolean shortDesc) {
AnimationHandler currentAnimation = getCurrentAnimation();
if (currentAnimation instanceof AnimationGLHandler) {
String s = "*" + (currentAnimation.getPlayerStatus() == Animation.PLAYING ? ">" : "-") + "* Fighter " + (attrs.containsKey("player") ? attrs.get("player") : "");
s += ((getFIGHTERMACHINESTATE() & FIGHTERMACHINE_A) != 0 ? " is attacking" : (getFIGHTERMACHINESTATE() & FIGHTERMACHINE_D) != 0 ? " is defending" : (getFIGHTERMACHINESTATE() & FIGHTERMACHINE_NA) != 0 ? " takes no action" : " is not machine");
try {
if (!shortDesc) {
s += "\n || facing : " + (hasOpponentsAtLeft() ? "left" : "") + (hasOpponentsAtRight() ? "right" : "");
s += "\n || on screen res. factor = " + SpritesChar.RES_FACTORS_map.get(player.gui.getModelResolution());
s += "\n || on scene position = "
+ "\n || " + pos;
s += "\n || current move : " + getCurrentAnimName();
s += "\n || current frame : " + (currentAnimation instanceof AnimationHandler ? currentAnimation.getPosition() : "n/a");
Map<Integer, Map<String, Object>> coll = calcCollision();
Map<String, Object> r = new HashMap<String, Object>();
s += "\n || colliding box : ";
if (coll.containsKey(FIGHTERMACHINE_A)) {
r = coll.get(FIGHTERMACHINE_A);
s += "attacked at ";
}
if (coll.containsKey(FIGHTERMACHINE_D)) {
r = coll.get(FIGHTERMACHINE_D);
s += "defending at ";
}
if (coll.containsKey(FIGHTERMACHINE_NA)) {
r = coll.get(FIGHTERMACHINE_NA);
s += "rebounding at ";
}
s += "\n || " + r.get("intersection");
}
s += "\n **";
currentStatus = s;
} catch (InterruptedException ex) {
if (isDebugEnabled()) {
ex.printStackTrace();
}
} finally {
return currentStatus;
}
} else {
return "no anim playing";
}
}
/**
*
*/
private void calcStraightRun(int xOrientation, int speed) {
double x = pos.getX();
x += (float) xOrientation / Math.abs((float) xOrientation) * (float) speed * (float) ((float) (current_tick - last_tick) / 1000f);
pos.setLocation(x, pos.getY());
double outset = .5 * getBounds2D(player.gui.getModelResolution()).getWidth();
pos.setLocation(Math.max(field.getMinX() + outset, Math.min(field.getMaxX() - outset, pos.getX())), pos.getY());
if (isDebugEnabled()) {
System.out.println(toString(true) + "'s running " + (xOrientation > 0 ? "to the right" : "to the left"));
}
}
public final static BitStack M_STATE_bits = new BitStack();
final static int M_STATE_3 = M_STATE_bits._newBitRange();
final static int M_STATE_2 = M_STATE_bits._newBitRange();
final static int M_STATE_1 = M_STATE_bits._newBitRange();
final static int M_STATE_0 = M_STATE_bits._newBitRange();
public final static int M_STATE_Ah = 0;
public final static int M_STATE_Am = M_STATE_3;
public final static int M_STATE_Al = M_STATE_2 | M_STATE_3;
public final static int M_STATE_Dh = M_STATE_1 | M_STATE_2 | M_STATE_3;
public final static int M_STATE_Dm = M_STATE_0 | M_STATE_1 | M_STATE_2 | M_STATE_3;
public final static int M_STATE_Dl = M_STATE_0 | M_STATE_1 | M_STATE_2;
public final static int M_STATE_Mh = M_STATE_0 | M_STATE_1;
public final static int M_STATE_Mm = M_STATE_0;
public final static int M_STATE_Ml = M_STATE_0 | M_STATE_3;
public final static BitStack M_INPUT_bits = new BitStack();
final static int M_INPUT_2 = M_INPUT_bits._newBitRange();
final static int M_INPUT_1 = M_INPUT_bits._newBitRange();
final static int M_INPUT_0 = M_INPUT_bits._newBitRange();
public final static int M_INPUT_HITS = 0;
public final static int M_INPUT_FAILS = M_INPUT_2;
public final static int M_INPUT_OppH = M_INPUT_1 | M_INPUT_2;
public final static int M_INPUT_OppM = M_INPUT_0 | M_INPUT_1 | M_INPUT_2;
public final static int M_INPUT_OppL = M_INPUT_0 | M_INPUT_2;
public boolean isDebugEnabled() {
return DebugMap._getInstance().isDebuggerEnabled(Fighter.class);
}
public void setDebugEnabled(boolean b) {
DebugMap._getInstance().setDebuggerEnabled(b, Fighter.class);
}
/**
* COMPUTER AI
**/
class Movement extends LogicalSystem {
public Movement() {
super("moves AI");
reset();
}
int state = 0;
@Override
public int getState() {
return state;
}
@Override
protected int nextState(int in) {
int newState = 0;
int cs = getState();
if (lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) || lookUp(in, M_INPUT_1, true) && lookUp(in, M_INPUT_2, false) || lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, true) && (lookUp(in, M_INPUT_2, false) || lookUp(in, M_INPUT_1, false) && lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_1, true) && lookUp(cs, M_STATE_2, false) && lookUp(cs, M_STATE_3, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (false) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) || lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, false)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, false) || lookUp(in, M_INPUT_1, true) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, true))) {
newState |= M_STATE_0;
}
if (lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, false) || lookUp(in, M_INPUT_1, true) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, true) && (lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (false) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (false)) {
newState |= M_STATE_1;
}
if (lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_2, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, true) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, false)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (false) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) || lookUp(cs, M_STATE_2, true) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (lookUp(cs, M_STATE_2, true) && lookUp(cs, M_STATE_3, false) || lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) || lookUp(in, M_INPUT_1, false) && lookUp(cs, M_STATE_3, true) || lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_3, true)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(cs, M_STATE_3, true) || lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_3, true))) {
newState |= M_STATE_2;
}
if (lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_1, false) && lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_3, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, true) && (lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) || lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, true)) || lookUp(cs, M_STATE_0, false) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (false) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, false) && (lookUp(cs, M_STATE_2, true) && lookUp(cs, M_STATE_3, false) || lookUp(in, M_INPUT_1, true) && lookUp(cs, M_STATE_3, true) || lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_3, true) || lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, false)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, true) && lookUp(in, M_INPUT_0, true) && (lookUp(cs, M_STATE_3, true) || lookUp(in, M_INPUT_1, true) && lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_2, false) && lookUp(cs, M_STATE_2, true) || lookUp(in, M_INPUT_1, false) && lookUp(in, M_INPUT_2, true) && lookUp(cs, M_STATE_2, false)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(in, M_INPUT_2, false) || lookUp(in, M_INPUT_1, false) && lookUp(cs, M_STATE_3, false)) || lookUp(cs, M_STATE_0, true) && lookUp(cs, M_STATE_1, false) && lookUp(in, M_INPUT_0, false) && (lookUp(cs, M_STATE_3, false) || lookUp(in, M_INPUT_1, false) || lookUp(in, M_INPUT_2, false))) {
newState |= M_STATE_3;
}
return newState;
}
@Override
protected void setState(int arg0) {
this.state = arg0;
}
@Override
public void reset() {
setState(M_STATE_Mm);
}
}
final static BitStack C_STATE_bits = new BitStack();
final static int C_STATE_2 = C_STATE_bits._newBitRange();
final static int C_STATE_1 = C_STATE_bits._newBitRange();
final static int C_STATE_0 = C_STATE_bits._newBitRange();
/**
* randomize next attack
*/
public final static int C_STATE_RANDOM = 0;
/**
* next attack is low powered
*/
public final static int C_STATE_L = C_STATE_2;
/**
* next attack is middle powered
*/
public final static int C_STATE_M = C_STATE_1 | C_STATE_2;
/**
* next attack is high powered
*/
public final static int C_STATE_H = C_STATE_0 | C_STATE_1 | C_STATE_2;
/**
* next attack is a special attack
*/
public final static int C_STATE_S = C_STATE_0 | C_STATE_2;
final static BitStack C_INPUT_bits = new BitStack();
final static int C_INPUT_2 = C_INPUT_bits._newBitRange();
final static int C_INPUT_1 = C_INPUT_bits._newBitRange();
final static int C_INPUT_0 = C_INPUT_bits._newBitRange();
/**
* Fighter is in a power-rage fight
*/
public final static int C_INPUT_RAGE100pc = 0;
/**
* Fighter is 100% fighting
*/
public final static int C_INPUT_66pc = C_INPUT_2;
/**
* Fighter is 50% fighting
*/
public final static int C_INPUT_33pc = C_INPUT_1 | C_INPUT_2;
/**
* Fighter is almost not fighting
*/
public final static int C_INPUT_0pc = C_INPUT_0 | C_INPUT_1 | C_INPUT_2;
/**
* COMPUTER AI
*/
class Combo extends LogicalSystem {
public Combo() {
super("combo AI");
reset();
}
int state = 0;
@Override
public int getState() {
return state;
}
@Override
protected int nextState(int in) {
int cs = getState();
int newState = 0;
if (lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, false) && (lookUp(in, C_INPUT_1, false)) || lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, true) && (false) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, false) && (lookUp(in, C_INPUT_2, false) || lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_1, true)) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, true) && (lookUp(in, C_INPUT_1, false) || lookUp(in, C_INPUT_2, false))) {
newState |= C_STATE_0;
}
if (lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, false) && (lookUp(in, C_INPUT_2, true) || lookUp(in, C_INPUT_1, true) && lookUp(cs, C_STATE_1, true)) || lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, true) && (lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_1, true) || lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_1, true)) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, false) && (lookUp(in, C_INPUT_1, false) && lookUp(in, C_INPUT_2, true) && lookUp(cs, C_STATE_1, true) || lookUp(in, C_INPUT_1, true) && lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_1, true)) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, true) && (lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_1, true) || lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_1, true))) {
newState |= C_STATE_1;
}
if (lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, false) && (lookUp(cs, C_STATE_2, true) || lookUp(in, C_INPUT_1, false) || lookUp(in, C_INPUT_2, true)) || lookUp(cs, C_STATE_0, false) && lookUp(in, C_INPUT_0, true) && (lookUp(cs, C_STATE_1, false) && lookUp(cs, C_STATE_2, true) || lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_2, true) || lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_2, true) || lookUp(in, C_INPUT_1, true) && lookUp(in, C_INPUT_2, true) && lookUp(cs, C_STATE_2, false)) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, false) && (lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_1, true) || lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_2, true)) || lookUp(cs, C_STATE_0, true) && lookUp(in, C_INPUT_0, true) && (lookUp(in, C_INPUT_1, false) && lookUp(cs, C_STATE_2, true) || lookUp(in, C_INPUT_2, false) && lookUp(cs, C_STATE_2, true))) {
newState |= C_STATE_2;
}
return newState;
}
@Override
protected void setState(int arg0) {
if (arg0 == C_STATE_RANDOM) {
}
if (arg0 == C_STATE_L) {
}
if (arg0 == C_STATE_M) {
}
if (arg0 == C_STATE_H) {
}
if (arg0 == C_STATE_S) {
}
this.state = arg0;
}
@Override
public void reset() {
setState(C_STATE_RANDOM);
}
}
}