protected String getStatValue(Environmental E, String arg2)
	{
		boolean found=false;
		String val="";
		for(int i=0;i<E.getStatCodes().length;i++)
		{
			if(E.getStatCodes()[i].equalsIgnoreCase(arg2))
			{
				val=E.getStat(arg2);
				found=true;
				break;
			}
		}
		if((!found)&&(E instanceof MOB))
		{
			final MOB M=(MOB)E;
			for(final int i : CharStats.CODES.ALLCODES())
			{
				if(CharStats.CODES.NAME(i).equalsIgnoreCase(arg2)||CharStats.CODES.DESC(i).equalsIgnoreCase(arg2))
				{
					val=""+M.charStats().getStat(CharStats.CODES.NAME(i)); //yes, this is right
					found=true;
					break;
				}
			}
			if(!found)
			{
				for(int i=0;i<M.curState().getStatCodes().length;i++)
				{
					if(M.curState().getStatCodes()[i].equalsIgnoreCase(arg2))
					{
						val=M.curState().getStat(M.curState().getStatCodes()[i]);
						found=true;
						break;
					}
				}
			}
			if(!found)
			{
				for(int i=0;i<M.phyStats().getStatCodes().length;i++)
				{
					if(M.phyStats().getStatCodes()[i].equalsIgnoreCase(arg2))
					{
						val=M.phyStats().getStat(M.phyStats().getStatCodes()[i]);
						found=true;
						break;
					}
				}
			}
			if((!found)&&(M.playerStats()!=null))
			{
				for(int i=0;i<M.playerStats().getStatCodes().length;i++)
				{
					if(M.playerStats().getStatCodes()[i].equalsIgnoreCase(arg2))
					{
						val=M.playerStats().getStat(M.playerStats().getStatCodes()[i]);
						found=true;
						break;
					}
				}
			}
			if((!found)&&(arg2.toUpperCase().startsWith("BASE")))
			{
				for(int i=0;i<M.baseState().getStatCodes().length;i++)
				{
					if(M.baseState().getStatCodes()[i].equalsIgnoreCase(arg2.substring(4)))
					{
						val=M.baseState().getStat(M.baseState().getStatCodes()[i]);
						found=true;
						break;
					}
				}
			}
			if((!found)&&(gstatH.containsKey(arg2.toUpperCase())))
			{
				found=true;
				switch(gstatH.get(arg2.toUpperCase()).intValue())
				{
				case GSTATADD_DEITY:
					val = M.getWorshipCharID();
					break;
				case GSTATADD_CLAN:
				{
					Clan C = CMLib.clans().findRivalrousClan(M);
					if (C == null)
						C = M.clans().iterator().hasNext() ? M.clans().iterator().next().first : null;
					val = (C != null) ? C.clanID() : "";
					break;
				}
				case GSTATADD_CLANROLE:
				{
					Clan C = CMLib.clans().findRivalrousClan(M);
					if (C == null)
						C = M.clans().iterator().hasNext() ? M.clans().iterator().next().first : null;
					if (C != null)
					{
						final Pair<Clan, Integer> p = M.getClanRole(C.clanID());
						val = (p != null) ? p.second.toString() : "";
					}
					break;
				}
				}
			}
		}
		if(!found)
			return null;
		return val;
	}