All pastes #25820 Raw Edit

Anonymous

public text v1 · immutable
#25820 ·published 2005-10-18 09:03 UTC
rendered paste body
Index: java/net/sf/l2j/gameserver/model/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2PcInstance.java	(revision 1339)
+++ java/net/sf/l2j/gameserver/model/L2PcInstance.java	(working copy)
@@ -98,6 +98,7 @@
 import net.sf.l2j.gameserver.serverpackets.SystemMessage;
 import net.sf.l2j.gameserver.serverpackets.TargetSelected;
 import net.sf.l2j.gameserver.serverpackets.UserInfo;
+import net.sf.l2j.gameserver.skills.Formulas;
 import net.sf.l2j.gameserver.skills.Stats;
 import net.sf.l2j.gameserver.templates.L2CharTemplate;
 import net.sf.l2j.gameserver.templates.L2Henna;
@@ -128,8 +129,14 @@
     public static final int STORE_PRIVATE_SELL = 1;
     public static final int STORE_PRIVATE_BUY = 3;
     public static final int STORE_PRIVATE_MANUFACTURE = 5;
+    
+    private static final String STR = "STR";
+    private static final String DEX = "DEX";
+    private static final String MEN = "STR";
+    private static final String WIT = "STR";
+    private static final String CON = "STR";
+    private static final String INT = "STR";
 
-
 	/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S)*/
 	private static final int[] EXPERTISE_LEVELS =
 	{
@@ -141,9 +148,8 @@
 		SkillTreeTable.getExpertiseLevel(5), //S
 	};
 
+    protected static Logger _log = Logger.getLogger(L2PcInstance.class.getName());
 
-    private static Logger _log = Logger.getLogger(L2PcInstance.class.getName());
-
 	public class AIAccessor extends L2Character.AIAccessor
 	{
 		protected AIAccessor() {}
@@ -389,6 +395,9 @@
     private boolean _hero = false;
     private int _team = 0;
     
+    /** Temp Values for stats **/
+    private int str, con, men, wit, dex, inte;
+    
 	/**
 	 * Create a new L2PcInstance and add it in the characters table of the database.<BR><BR>
 	 *
@@ -5847,4 +5856,107 @@
     {
         _nameColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
     }
+    
+    class InvalidStatValue implements Runnable
+    {
+        String stat;
+        int statValue;
+        
+        public InvalidStatValue(String stat, int statValue)
+        {
+            this.stat = stat;
+            this.statValue = statValue;
+        }
+        
+        public void run()
+        {
+            String message  = "Player " + getName() + " has a " + stat + " value of " + stat;
+            _log.warning(message);
+            GmListTable.getInstance().broadcastMessageToGMs(message);
+        }
+    }
+
+    /**
+     * Return the STR of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getSTR()
+    {
+        str = super.getSTR();
+        if (str >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(STR, str), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return str;
+    }
+
+    /**
+     * Return the COM of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getCON()
+    {
+        con = super.getCON();
+        if (con >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(CON, con), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return con;
+    }
+
+    /**
+     * Return the DEX of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getDEX()
+    {
+        dex = super.getDEX();
+        if (inte >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(DEX, dex), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return dex;
+    }
+
+    /**
+     * Return the INT of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getINT()
+    {
+        inte = super.getINT();
+        if (inte >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(INT, inte), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return inte;
+    }
+
+    /**
+     * Return the WIT of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getWIT()
+    {
+        wit = super.getWIT();
+        if (wit >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(WIT, wit), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return wit;
+    }
+
+    /**
+     * Return the MEN of the L2Character (base+modifier).<BR><BR>
+     */
+    public int getMEN()
+    {
+        men = super.getMEN();
+        if (men >= Formulas.MAX_STAT_VALUE)
+        {
+            ClientScheduler.scheduleEvent(new InvalidStatValue(MEN, men), 500);
+            return Formulas.MAX_STAT_VALUE - 1;
+        }
+        return men;
+    }
 }
Index: java/net/sf/l2j/gameserver/skills/Formulas.java
===================================================================
--- java/net/sf/l2j/gameserver/skills/Formulas.java	(revision 1339)
+++ java/net/sf/l2j/gameserver/skills/Formulas.java	(working copy)
@@ -100,12 +100,15 @@
 		+1.2367571569199400E-02,
 		-1.6963187489087200E-01 + 1
 	};
-    protected static final double[] WITbonus = new double[100];
-    protected static final double[] MENbonus = new double[100];
-    protected static final double[] INTbonus = new double[100];
-    protected static final double[] STRbonus = new double[100];
-    protected static final double[] DEXbonus = new double[100];
-    protected static final double[] CONbonus = new double[100];
+    
+    public static int MAX_STAT_VALUE = 100;
+    
+    protected static final double[] WITbonus = new double[MAX_STAT_VALUE];
+    protected static final double[] MENbonus = new double[MAX_STAT_VALUE];
+    protected static final double[] INTbonus = new double[MAX_STAT_VALUE];
+    protected static final double[] STRbonus = new double[MAX_STAT_VALUE];
+    protected static final double[] DEXbonus = new double[MAX_STAT_VALUE];
+    protected static final double[] CONbonus = new double[MAX_STAT_VALUE];
 
 	private static double polynom(double[] p, int idx) {
 		double val = 0;
Index: java/net/sf/l2j/gameserver/ClientScheduler.java
===================================================================
--- java/net/sf/l2j/gameserver/ClientScheduler.java	(revision 1289)
+++ java/net/sf/l2j/gameserver/ClientScheduler.java	(working copy)
@@ -341,4 +341,9 @@
             "ScheduledTasks:  "+_executorLowPriority.getTaskCount()
         };
     }
+    
+    public static ScheduledFuture scheduleEvent(Runnable event, long delay)
+    {
+        return getInstance().scheduleLow(event, delay);
+    }
 }