PDA

View Full Version : Array insertion touble


mackman88
02-20-2010, 05:53 AM
I'm having trouble with some arrays in the my following patch code.

It grabs stats from an xml file and puts them in an array, but for some reason there not inserted properly and the outcome is very inaccurate, particularly in the FreeForAllZone class


===================================================================

/**
* This class ...
@@ -427,6 +428,14 @@
if (player.isInsideZone(L2Character.ZONE_MONSTERTRACK))
return new Location(12661, 181687, -3560);

+ // Checking if in FreeForAll Zone
+ L2FreeForAllZone ffa = ZoneManager.getInstance().getFreeForAll(player);
+ if (ffa != null)
+ {
+ coord = ffa.getSpawnLoc();
+ return new Location(coord[0], coord[1], coord[2]);
+ }
+
Castle castle = null;
Fort fort = null;
ClanHall clanhall = null;


===================================================================

@@ -189,6 +189,8 @@
temp = new L2PaganZone(zoneId);
else if (zoneType.equals("NoHqZone"))
temp = new L2NoHqZone(zoneId);
+ else if (zoneType.equals("FreeForAllZone"))
+ temp = new L2FreeForAllZone(zoneId);

// Check for unknown type
if (temp == null)
@@ -469,6 +471,17 @@

return null;
}
+ // FreeForAll Zone
+ public final L2FreeForAllZone getFreeForAll(L2Character character)
+ {
+ for (L2ZoneType temp : ZoneManager.getInstance().getZones(character.getX(), character.getY(), character.getZ()))
+ {
+ if (temp instanceof L2FreeForAllZone && temp.isCharacterInZone(character))
+ return ((L2FreeForAllZone) temp);
+ }
+
+ return null;
+ }

public final L2OlympiadStadiumZone getOlympiadStadium(L2Character character)
{



===================================================================
+++ C:/

/**
* Intended for a special free for all reward zone
*
* @author Mou(moooo)
*/
public class L2FreeForAllZone extends L2ZoneType
{
@SuppressWarnings("unused")
private String _freeForAllName;
private int[] _spawnLoc;

public L2FreeForAllZone(int id)
{
super(id);

_spawnLoc = new int[3];
}

@Override
public void setParameter(String name, String value)
{
int randomSpawn = Rnd.get(20);
if (name.equals("name"))
{
_freeForAllName = value;
}
if (randomSpawn < 5)
{
if (name.equals("spawnX"))
{
_spawnLoc[0] = Integer.parseInt(value);
}
else if (name.equals("spawnY"))
{
_spawnLoc[1] = Integer.parseInt(value);
}
else if (name.equals("spawnZ"))
{
_spawnLoc[2] = Integer.parseInt(value);
}
}
else if (randomSpawn < 10)
{
if (name.equals("spawnX2"))
{
_spawnLoc[0] = Integer.parseInt(value);
}
else if (name.equals("spawnY2"))
{
_spawnLoc[1] = Integer.parseInt(value);
}
else if (name.equals("spawnZ2"))
{
_spawnLoc[2] = Integer.parseInt(value);
}
}
else if (randomSpawn < 15)
{
if (name.equals("spawnX3"))
{
_spawnLoc[0] = Integer.parseInt(value);
}
else if (name.equals("spawnY3"))
{
_spawnLoc[1] = Integer.parseInt(value);
}
else if (name.equals("spawnZ3"))
{
_spawnLoc[2] = Integer.parseInt(value);
}
}
else if (randomSpawn < 20)
{
if (name.equals("spawnX4"))
{
_spawnLoc[0] = Integer.parseInt(value);
}
else if (name.equals("spawnY4"))
{
_spawnLoc[1] = Integer.parseInt(value);
}
else if (name.equals("spawnZ4"))
{
_spawnLoc[2] = Integer.parseInt(value);
}
}
else
super.setParameter(name, value);
}

@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_FREEFORALL, true);
((L2PcInstance) character).sendMessage("You have entered a Free For All zone!");
}

@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_FREEFORALL, false);
((L2PcInstance) character).sendMessage("You have left a Free For All zone!");
}

@Override
public void onDieInside(L2Character character)
{
}

@Override
public void onReviveInside(L2Character character)
{
}

public final int[] getSpawnLoc()
{
return _spawnLoc;
}

}


===================================================================
Added to zone.xml
===================================================================

<!-- Free For All Zones -->
<zone id="40100" type="FreeForAllZone" shape="NPoly" minZ="-2500" maxZ="-1700">
<stat name="name" val="Reward"/>
<stat name="spawnX" val="19475"/>
<stat name="spawnY" val="255777"/>
<stat name="spawnZ" val="-2083"/>
<stat name="spawnX2" val="20032"/>
<stat name="spawnY2" val="250508"/>
<stat name="spawnZ2" val="-2006"/>
<stat name="spawnX3" val="21836"/>
<stat name="spawnY3" val="252761"/>
<stat name="spawnZ3" val="-2018"/>
<stat name="spawnX4" val="17589"/>
<stat name="spawnY4" val="254069"/>
<stat name="spawnZ4" val="-2018"/>
</zone>
</list>



Any help is appreciated! thanks.

servlet
02-20-2010, 09:08 AM
Instead of patch.. paste actual code.. explain problem well and write down what out put you expect and what you actually get.