U3Games

Games | Desarrollo & Soporte => L2 | Sección de Servidores => Lineage => L2 | Implementaciones => Mensaje iniciado por: Jerry en Ago 02, 2025, 08:10 PM

Título: StatusRealTime rusacis interface
Publicado por: Jerry en Ago 02, 2025, 08:10 PM
### Eclipse Workspace Patch 1.0
#P aCis_gameserver
diff --git java/net/sf/l2j/gameserver/GameServer.java java/net/sf/l2j/gameserver/GameServer.java
index 3f55474..1be729e 100644
--- java/net/sf/l2j/gameserver/GameServer.java
+++ java/net/sf/l2j/gameserver/GameServer.java
@@ -91,6 +91,7 @@
 import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
 import net.sf.l2j.gameserver.idfactory.IdFactory;
 import net.sf.l2j.gameserver.model.World;
+import net.sf.l2j.gameserver.model.actor.StatusRealTime;
 import net.sf.l2j.gameserver.model.entity.events.capturetheflag.CTFManager;
 import net.sf.l2j.gameserver.model.entity.events.deathmatch.DMManager;
 import net.sf.l2j.gameserver.model.entity.events.lastman.LMManager;
@@ -319,6 +320,9 @@
  StringUtil.printSection("Teleport Interface Location Data");
  TeleportLocationData.getInstance();
 
+ StringUtil.printSection("TargetStatus Interface");
+ StatusRealTime.getInstance();
+
  StringUtil.printSection("Handlers");
  LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
  LOGGER.info("Loaded {} chat handlers.", ChatHandler.getInstance().size());
diff --git java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java
new file mode 100644
index 0000000..3f2004c
--- /dev/null
+++ java/net/sf/l2j/gameserver/model/actor/StatusRealTime.java
@@ -0,0 +1,86 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.model.actor;
+
+import java.util.Collection;
+import net.sf.l2j.commons.pool.ThreadPool;
+
+import net.sf.l2j.gameserver.enums.StatusType;
+import net.sf.l2j.gameserver.model.World;
+import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
+
+/**
+ * @author Sobek
+ *
+ */
+public class StatusRealTime
+{
+ public StatusRealTime()
+ {
+ ThreadPool.scheduleAtFixedRate(new LoadStatus(), 500, 500);
+ }
+
+ public static StatusRealTime getInstance()
+ {
+ return SingletonHolder.INSTANCE;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final StatusRealTime INSTANCE = new StatusRealTime();
+ }
+
+}
+
+class LoadStatus implements Runnable
+{
+ @Override
+ public void run()
+ {
+ try
+ {
+ Collection<Player> allPlayers = World.getInstance().getPlayers();
+ for (Player player : allPlayers)
+ {
+ try
+ {
+ if (player != null )
+ if (player.getTarget() != null && player.getTarget() instanceof Player)
+ {
+ Player target = (Player) player.getTarget();
+ updateStatus(target,player);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ private static void updateStatus(Player _target,Player player)
+ {
+ StatusUpdate su = new StatusUpdate(_target);
+ su.addAttribute(StatusType.CUR_HP, (int) _target.getStatus().getHp());
+ su.addAttribute(StatusType.CUR_CP, (int) _target.getStatus().getCp());
+ su.addAttribute(StatusType.MAX_HP, _target.getStatus().getMaxHp());
+ su.addAttribute(StatusType.MAX_CP, _target.getStatus().getMaxCp());
+ player.sendPacket(su);
+ }
+}
\ No newline at end of file
diff --git java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
index dcae5f4..11381f4 100644
--- java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/StatusUpdate.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
 package net.sf.l2j.gameserver.network.serverpackets;
 
 import java.util.ArrayList;
@@ -5,19 +19,64 @@
 
 import net.sf.l2j.gameserver.enums.StatusType;
 import net.sf.l2j.gameserver.model.WorldObject;
+import net.sf.l2j.gameserver.model.actor.Player;
 import net.sf.l2j.gameserver.model.holder.IntIntHolder;
 
+
+
+/**
+ * by Sobek
+ */
 public class StatusUpdate extends L2GameServerPacket
 {
+ public static final int LEVEL = 0x01;
+ public static final int EXP = 0x02;
+ public static final int STR = 0x03;
+ public static final int DEX = 0x04;
+ public static final int CON = 0x05;
+ public static final int INT = 0x06;
+ public static final int WIT = 0x07;
+ public static final int MEN = 0x08;
+
+ public static final int CUR_HP = 0x09;
+ public static final int MAX_HP = 0x0a;
+ public static final int CUR_MP = 0x0b;
+ public static final int MAX_MP = 0x0c;
+
+ public static final int SP = 0x0d;
+ public static final int CUR_LOAD = 0x0e;
+ public static final int MAX_LOAD = 0x0f;
+
+ public static final int P_ATK = 0x11;
+ public static final int ATK_SPD = 0x12;
+ public static final int P_DEF = 0x13;
+ public static final int EVASION = 0x14;
+ public static final int ACCURACY = 0x15;
+ public static final int CRITICAL = 0x16;
+ public static final int M_ATK = 0x17;
+ public static final int CAST_SPD = 0x18;
+ public static final int M_DEF = 0x19;
+ public static final int PVP_FLAG = 0x1a;
+ public static final int KARMA = 0x1b;
+
+ public static final int CUR_CP = 0x21;
+ public static final int MAX_CP = 0x22;
+
  private final int _objectId;
  private final List<IntIntHolder> _attributes;
 
+ private Player _actor;
+
+
+
  public StatusUpdate(WorldObject object)
  {
  _attributes = new ArrayList<>();
  _objectId = object.getObjectId();
+ if(object instanceof Player)
+ _actor = (Player) object;
  }
-
+
  public void addAttribute(StatusType type, int level)
  {
  _attributes.add(new IntIntHolder(type.getId(), level));
@@ -27,13 +86,84 @@
  protected final void writeImpl()
  {
  writeC(0x0e);
- writeD(_objectId);
- writeD(_attributes.size());
-
- for (IntIntHolder temp : _attributes)
+ if (_actor != null)
  {
- writeD(temp.getId());
- writeD(temp.getValue());
+
+ writeD(_actor.getObjectId());
+ writeD(28); // all the attributes
+
+ writeD(LEVEL);
+ writeD(_actor.getStatus().getLevel());
+ writeD(EXP);
+ writeD((int) _actor.getStatus().getExp());
+ writeD(STR);
+ writeD(_actor.getStatus().getSTR());
+ writeD(DEX);
+ writeD(_actor.getStatus().getDEX());
+ writeD(CON);
+ writeD(_actor.getStatus().getCON());
+ writeD(INT);
+ writeD(_actor.getStatus().getINT());
+ writeD(WIT);
+ writeD(_actor.getStatus().getWIT());
+ writeD(MEN);
+ writeD(_actor.getStatus().getMEN());
+
+ writeD(CUR_HP);
+ writeD((int) _actor.getStatus().getHp());
+ writeD(MAX_HP);
+ writeD(_actor.getStatus().getMaxHp());
+ writeD(CUR_MP);
+ writeD((int) _actor.getStatus().getMp());
+ writeD(MAX_MP);
+ writeD(_actor.getStatus().getMaxMp());
+ writeD(SP);
+ writeD(_actor.getStatus().getSp());
+ writeD(CUR_LOAD);
+ writeD(_actor.getCurrentWeight());
+ writeD(MAX_LOAD);
+ writeD(_actor.getWeightLimit());
+
+ writeD(P_ATK);
+ writeD(_actor.getStatus().getPAtk(null));
+ writeD(ATK_SPD);
+ writeD(_actor.getStatus().getPAtkSpd());
+ writeD(P_DEF);
+ writeD(_actor.getStatus().getPDef(null));
+ writeD(EVASION);
+ writeD(_actor.getStatus().getEvasionRate(null));
+ writeD(ACCURACY);
+ writeD(_actor.getStatus().getAccuracy());
+ writeD(CRITICAL);
+ writeD(_actor.getStatus().getCriticalHit(null, null));
+ writeD(M_ATK);
+ writeD(_actor.getStatus().getMAtk(null, null));
+
+ writeD(CAST_SPD);
+ writeD(_actor.getStatus().getMAtkSpd());
+ writeD(M_DEF);
+ writeD(_actor.getStatus().getMDef(null, null));
+ writeD(PVP_FLAG);
+ writeD(_actor.getPvpFlag());
+ writeD(KARMA);
+ writeD(_actor.getKarma());
+ writeD(CUR_CP);
+ writeD((int) _actor.getStatus().getCp());
+ writeD(MAX_CP);
+ writeD(_actor.getStatus().getMaxCp());
+
+ }
+ else
+ {
+
+ writeD(_objectId);
+ writeD(_attributes.size());
+
+ for (IntIntHolder temp : _attributes)
+ {
+ writeD(temp.getId());
+ writeD(temp.getValue());
+ }
  }
  }
 }
\ No newline at end of file