Axelut

StatusRealTime rusacis interface

Jan 23rd, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. diff --git java/net/sf/l2j/gameserver/GameServer.java java/net/sf/l2j/gameserver/GameServer.java
  4. index 3f55474..1be729e 100644
  5. --- java/net/sf/l2j/gameserver/GameServer.java
  6. +++ java/net/sf/l2j/gameserver/GameServer.java
  7. @@ -91,6 +91,7 @@
  8.  import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  9.  import net.sf.l2j.gameserver.idfactory.IdFactory;
  10.  import net.sf.l2j.gameserver.model.World;
  11. +import net.sf.l2j.gameserver.model.actor.StatusRealTime;
  12.  import net.sf.l2j.gameserver.model.entity.events.capturetheflag.CTFManager;
  13.  import net.sf.l2j.gameserver.model.entity.events.deathmatch.DMManager;
  14.  import net.sf.l2j.gameserver.model.entity.events.lastman.LMManager;
  15. @@ -319,6 +320,9 @@
  16.         StringUtil.printSection("Teleport Interface Location Data");
  17.         TeleportLocationData.getInstance();
  18.        
  19. +       StringUtil.printSection("TargetStatus Interface");
  20. +       StatusRealTime.getInstance();
  21. +      
  22.         StringUtil.printSection("Handlers");
  23.         LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
  24.         LOGGER.info("Loaded {} chat handlers.", ChatHandler.getInstance().size());
  25. diff --git java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java
  26. new file mode 100644
  27. index 0000000..3f2004c
  28. --- /dev/null
  29. +++ java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java
  30. @@ -0,0 +1,86 @@
  31. +/*
  32. + * This program is free software: you can redistribute it and/or modify it under
  33. + * the terms of the GNU General Public License as published by the Free Software
  34. + * Foundation, either version 3 of the License, or (at your option) any later
  35. + * version.
  36. + *
  37. + * This program is distributed in the hope that it will be useful, but WITHOUT
  38. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  39. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  40. + * details.
  41. + *
  42. + * You should have received a copy of the GNU General Public License along with
  43. + * this program. If not, see <http://www.gnu.org/licenses/>.
  44. + */
  45. +package net.sf.l2j.gameserver.model.actor;
  46. +
  47. +import java.util.Collection;
  48. +import net.sf.l2j.commons.pool.ThreadPool;
  49. +
  50. +import net.sf.l2j.gameserver.enums.StatusType;
  51. +import net.sf.l2j.gameserver.model.World;
  52. +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  53. +
  54. +/**
  55. + * @author Sobek
  56. + *
  57. + */
  58. +public class StatusRealTime
  59. +{
  60. +   public StatusRealTime()
  61. +   {
  62. +       ThreadPool.scheduleAtFixedRate(new LoadStatus(), 500, 500);
  63. +   }
  64. +  
  65. +   public static StatusRealTime getInstance()
  66. +   {
  67. +       return SingletonHolder.INSTANCE;
  68. +   }
  69. +  
  70. +   private static class SingletonHolder
  71. +   {
  72. +       protected static final StatusRealTime INSTANCE = new StatusRealTime();
  73. +   }
  74. +  
  75. +}
  76. +
  77. +class LoadStatus implements Runnable
  78. +{
  79. +   @Override
  80. +   public void run()
  81. +   {
  82. +       try
  83. +       {
  84. +           Collection<Player> allPlayers = World.getInstance().getPlayers();
  85. +           for (Player player : allPlayers)
  86. +           {
  87. +               try
  88. +               {
  89. +                   if (player != null )
  90. +                       if (player.getTarget() != null && player.getTarget() instanceof Player)
  91. +                       {
  92. +                           Player target = (Player) player.getTarget();
  93. +                           updateStatus(target,player);
  94. +                       }
  95. +               }
  96. +               catch (Exception e)
  97. +               {
  98. +                   e.printStackTrace();
  99. +               }
  100. +           }
  101. +       }
  102. +       catch (Exception e)
  103. +       {
  104. +           e.printStackTrace();
  105. +       }
  106. +   }
  107. +   private static void updateStatus(Player _target,Player player)
  108. +   {
  109. +       StatusUpdate su = new StatusUpdate(_target);
  110. +       su.addAttribute(StatusType.CUR_HP, (int) _target.getStatus().getHp());
  111. +       su.addAttribute(StatusType.CUR_CP, (int) _target.getStatus().getCp());
  112. +       su.addAttribute(StatusType.MAX_HP, _target.getStatus().getMaxHp());
  113. +       su.addAttribute(StatusType.MAX_CP, _target.getStatus().getMaxCp());
  114. +       player.sendPacket(su);
  115. +   }
  116. +}
  117. \ No newline at end of file
  118. diff --git java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
  119. index dcae5f4..11381f4 100644
  120. --- java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
  121. +++ java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
  122. @@ -1,3 +1,17 @@
  123. +/*
  124. + * This program is free software: you can redistribute it and/or modify it under
  125. + * the terms of the GNU General Public License as published by the Free Software
  126. + * Foundation, either version 3 of the License, or (at your option) any later
  127. + * version.
  128. + *
  129. + * This program is distributed in the hope that it will be useful, but WITHOUT
  130. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  131. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  132. + * details.
  133. + *
  134. + * You should have received a copy of the GNU General Public License along with
  135. + * this program. If not, see <http://www.gnu.org/licenses/>.
  136. + */
  137.  package net.sf.l2j.gameserver.network.serverpackets;
  138.  
  139.  import java.util.ArrayList;
  140. @@ -5,19 +19,64 @@
  141.  
  142.  import net.sf.l2j.gameserver.enums.StatusType;
  143.  import net.sf.l2j.gameserver.model.WorldObject;
  144. +import net.sf.l2j.gameserver.model.actor.Player;
  145.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  146.  
  147. +
  148. +
  149. +/**
  150. + * by Sobek
  151. + */
  152.  public class StatusUpdate extends L2GameServerPacket
  153.  {
  154. +   public static final int LEVEL = 0x01;
  155. +   public static final int EXP = 0x02;
  156. +   public static final int STR = 0x03;
  157. +   public static final int DEX = 0x04;
  158. +   public static final int CON = 0x05;
  159. +   public static final int INT = 0x06;
  160. +   public static final int WIT = 0x07;
  161. +   public static final int MEN = 0x08;
  162. +  
  163. +   public static final int CUR_HP = 0x09;
  164. +   public static final int MAX_HP = 0x0a;
  165. +   public static final int CUR_MP = 0x0b;
  166. +   public static final int MAX_MP = 0x0c;
  167. +  
  168. +   public static final int SP = 0x0d;
  169. +   public static final int CUR_LOAD = 0x0e;
  170. +   public static final int MAX_LOAD = 0x0f;
  171. +  
  172. +   public static final int P_ATK = 0x11;
  173. +   public static final int ATK_SPD = 0x12;
  174. +   public static final int P_DEF = 0x13;
  175. +   public static final int EVASION = 0x14;
  176. +   public static final int ACCURACY = 0x15;
  177. +   public static final int CRITICAL = 0x16;
  178. +   public static final int M_ATK = 0x17;
  179. +   public static final int CAST_SPD = 0x18;
  180. +   public static final int M_DEF = 0x19;
  181. +   public static final int PVP_FLAG = 0x1a;
  182. +   public static final int KARMA = 0x1b;
  183. +  
  184. +   public static final int CUR_CP = 0x21;
  185. +   public static final int MAX_CP = 0x22;
  186. +  
  187.     private final int _objectId;
  188.     private final List<IntIntHolder> _attributes;
  189.    
  190. +   private Player _actor;
  191. +  
  192. +
  193. +  
  194.     public StatusUpdate(WorldObject object)
  195.     {
  196.         _attributes = new ArrayList<>();
  197.         _objectId = object.getObjectId();
  198. +       if(object instanceof Player)
  199. +           _actor = (Player) object;
  200.     }
  201. -  
  202. +
  203.     public void addAttribute(StatusType type, int level)
  204.     {
  205.         _attributes.add(new IntIntHolder(type.getId(), level));
  206. @@ -27,13 +86,84 @@
  207.     protected final void writeImpl()
  208.     {
  209.         writeC(0x0e);
  210. -       writeD(_objectId);
  211. -       writeD(_attributes.size());
  212. -      
  213. -       for (IntIntHolder temp : _attributes)
  214. +       if (_actor != null)
  215.         {
  216. -           writeD(temp.getId());
  217. -           writeD(temp.getValue());
  218. +
  219. +           writeD(_actor.getObjectId());
  220. +           writeD(28); // all the attributes
  221. +          
  222. +           writeD(LEVEL);
  223. +           writeD(_actor.getStatus().getLevel());
  224. +           writeD(EXP);
  225. +           writeD((int) _actor.getStatus().getExp());
  226. +           writeD(STR);
  227. +           writeD(_actor.getStatus().getSTR());
  228. +           writeD(DEX);
  229. +           writeD(_actor.getStatus().getDEX());
  230. +           writeD(CON);
  231. +           writeD(_actor.getStatus().getCON());
  232. +           writeD(INT);
  233. +           writeD(_actor.getStatus().getINT());
  234. +           writeD(WIT);
  235. +           writeD(_actor.getStatus().getWIT());
  236. +           writeD(MEN);
  237. +           writeD(_actor.getStatus().getMEN());
  238. +          
  239. +           writeD(CUR_HP);
  240. +           writeD((int) _actor.getStatus().getHp());
  241. +           writeD(MAX_HP);
  242. +           writeD(_actor.getStatus().getMaxHp());
  243. +           writeD(CUR_MP);
  244. +           writeD((int) _actor.getStatus().getMp());
  245. +           writeD(MAX_MP);
  246. +           writeD(_actor.getStatus().getMaxMp());
  247. +           writeD(SP);
  248. +           writeD(_actor.getStatus().getSp());
  249. +           writeD(CUR_LOAD);
  250. +           writeD(_actor.getCurrentWeight());
  251. +           writeD(MAX_LOAD);
  252. +           writeD(_actor.getWeightLimit());
  253. +          
  254. +           writeD(P_ATK);
  255. +           writeD(_actor.getStatus().getPAtk(null));
  256. +           writeD(ATK_SPD);
  257. +           writeD(_actor.getStatus().getPAtkSpd());
  258. +           writeD(P_DEF);
  259. +           writeD(_actor.getStatus().getPDef(null));
  260. +           writeD(EVASION);
  261. +           writeD(_actor.getStatus().getEvasionRate(null));
  262. +           writeD(ACCURACY);
  263. +           writeD(_actor.getStatus().getAccuracy());
  264. +           writeD(CRITICAL);
  265. +           writeD(_actor.getStatus().getCriticalHit(null, null));
  266. +           writeD(M_ATK);
  267. +           writeD(_actor.getStatus().getMAtk(null, null));
  268. +          
  269. +           writeD(CAST_SPD);
  270. +           writeD(_actor.getStatus().getMAtkSpd());
  271. +           writeD(M_DEF);
  272. +           writeD(_actor.getStatus().getMDef(null, null));
  273. +           writeD(PVP_FLAG);
  274. +           writeD(_actor.getPvpFlag());
  275. +           writeD(KARMA);
  276. +           writeD(_actor.getKarma());
  277. +           writeD(CUR_CP);
  278. +           writeD((int) _actor.getStatus().getCp());
  279. +           writeD(MAX_CP);
  280. +           writeD(_actor.getStatus().getMaxCp());
  281. +          
  282. +       }
  283. +       else
  284. +       {
  285. +          
  286. +           writeD(_objectId);
  287. +           writeD(_attributes.size());
  288. +          
  289. +           for (IntIntHolder temp : _attributes)
  290. +           {
  291. +               writeD(temp.getId());
  292. +               writeD(temp.getValue());
  293. +           }
  294.         }
  295.     }
  296.  }
  297. \ No newline at end of file
  298.  
Add Comment
Please, Sign In to add comment