↑ ↓

Virtual characters

Тема в разделе "Помощь", создана пользователем jack, 17 окт 2019.

  1. TopicStarter Overlay
    Offline

    jack Рядовой

    98
    0
    32
    Кредиты:
    $261,36
    Репутация:
    0
    AL3.9's dumming system, but I don't know how to create these dummies, if anyone knows! ! Please tell me, thank you very much.

    Код:
    包com.aionemu.gameserver.model;
    
    
    进口的java.io.File;
    进口java.lang.reflect.Constructor中;
    进口java.lang.reflect.Field中;
    
    进口javax.xml.XMLConstants;
    进口javax.xml.bind.JAXBContext;
    进口javax.xml.bind.JAXBException;
    进口javax.xml.bind.Unmarshaller;
    进口javax.xml.validation.Schema;
    进口javax.xml.validation.SchemaFactory中;
    
    进口org.xml.sax.SAXException;
    
    进口com.aionemu.gameserver.controllers.effect.PlayerEffectController;
    进口com.aionemu.gameserver.controllers.movement.PlayerMoveController;
    进口com.aionemu.gameserver.dataholders.DataManager;
    进口com.aionemu.gameserver.dataholders.PlayerStatsData;
    进口com.aionemu.gameserver.model.gameobjects.player.Equipment;
    进口com.aionemu.gameserver.model.gameobjects.player.Player;
    进口com.aionemu.gameserver.model.gameobjects.player.PlayerCommonData;
    import com.aionemu.gameserver.model.items.storage.PlayerStorage;
    import com.aionemu.gameserver.model.items.storage.StorageType;
    import com.aionemu.gameserver.model.stats.container.PlayerGameStats;
    import com.aionemu.gameserver.model.stats.container.PlayerLifeStats;
    import com.aionemu.gameserver.model.templates.BoundRadius;
    import com.aionemu.gameserver.world.knownlist.KnownList;
    
    /**
     * @author Rolandas
     */
    public final class DummyPlayer {
    
    	private static PlayerStatsData dummyStats;
    	private static String DEFAULT_STATS = "assassin-templates.xml";
    	private static PlayerClass DEFAULT_CLASS = PlayerClass.ASSASSIN;
    
    	static {
    		File xml = new File("./data/static_data/stats/player/" + DEFAULT_STATS);
    		SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    		Schema schema;
    		try {
    			schema = sf.newSchema(new File("./data/static_data/stats/stats.xsd"));
    			JAXBContext jc;
    			jc = JAXBContext.newInstance(PlayerStatsData.class);
    			Unmarshaller unmarshaller = jc.createUnmarshaller();
    			unmarshaller.setSchema(schema);
    			dummyStats = (PlayerStatsData) unmarshaller.unmarshal(xml);
    		}
    		catch (SAXException e) {
    			e.printStackTrace();
    		}
    		catch (JAXBException e) {
    			e.printStackTrace();
    		}
    		DataManager.PLAYER_STATS_DATA = dummyStats;
    	}
    
    	public static Player createAsmodian() {
    		return create(Race.ASMODIANS, DEFAULT_CLASS, "asmo");
    	}
    
    	public static Player createElyo() {
    		return create(Race.ELYOS, DEFAULT_CLASS, "ely");
    	}
    
    	private static Player create(Race race, PlayerClass playerClass, String name) {
    		Player player = null;
    		try {
    			Constructor<Player> c = Player.class.getDeclaredConstructor(PlayerCommonData.class);
    			c.setAccessible(true);
    			PlayerCommonData asmoCommon = new PlayerCommonData(1);
    			asmoCommon.setRace(race);
    			asmoCommon.setPlayerClass(playerClass);
    			asmoCommon.setBoundingRadius(new BoundRadius(0.5f, 0.5f, 2));
    			asmoCommon.setName(name);
    			player = c.newInstance(new Object[] { asmoCommon });
    			player.setGameStats(new PlayerGameStats(player));
    			player.setLifeStats(new PlayerLifeStats(player));
    			player.setKnownlist(new KnownList(player));
    			player.getController().setOwner(player);
    			Field mv = Player.class.getSuperclass().getDeclaredField("moveController");
    			mv.setAccessible(true);
    			mv.set(player, new PlayerMoveController(player));
    			player.setEquipment(new Equipment(player));
    			player.getPlayerAccount().setName("Dummy");
    			player.setEffectController(new PlayerEffectController(player));
    			player.setStorage(new PlayerStorage(StorageType.CUBE), StorageType.CUBE);
    		}
    		catch (Exception e) {
    		}
    		return player;
    	}
    
    }