Jump to content
  • 0

Custom Zone (Random Race Display)


Question

Posted (edited)

Hello.

 

I created a custom zone. And I edited the charinfo, so when a player enters the zone his/her name will be "Unknown".

 

However, my problem is that the system damage message still displays the original name of the characters. (I guess becuase the changes in charinfo only affect the client and the server still recognize the character's origianl name).

 

My question is: what should I edit or change in order to have the system message display "unknown" instead of the original names?

 

I know i could create new system messsages (instead of $c1 done $s3 damge $c2 to unknown done $s3 damage to unknown) but I'd rather avoid this if theres a better way.

 

 

EDIT:

 

Does anybody have any suggestion, ideas how could I make  Random Race displayed in a specific zone for players?

 

Either in Charinfo, or some other working method would be great.

 

Thank you.

 

 

P.S: Im using High Five latest rev.

Edited by Horse

Recommended Posts

  • 0
Posted

Search for the msg sent and edit the msg. Add a check about your zone, if inside send 'unknown', otherwise name (as it is) or simply another msg (your example) if inside. No other way.

  • 0
Posted

Search for the msg sent and edit the msg. Add a check about your zone, if inside send 'unknown', otherwise name (as it is) or simply another msg (your example) if inside. No other way.

Yea, this was my original idea as well. But I was wondering if there was a way to change the name serverside while the player is in the specified zone.

 

 

 

Also, I'd have an other question.

 

How can I  make the chars have random race in that zone?

 

I was thinking of a simalier method to add a check at the    writeD(_activeChar.getRace().ordinal());  But I'm not sure how can i change this in order to have a random race displayed.

  • 0
Posted (edited)

Thanks for the answers, guys yea either rnd.get or other random seems to be fine.

 

But the problem is I don't know what should I add in the writeD(    to get  a specified race to displayed.

Edited by Horse
  • 0
Posted

disable chat maybe? or you need that?

Disable chat, auto change names to unknown or something, random sex------These I've already done.

 

What i need is a method to change randomly the race displayed to others when you enter this zone.  For exemple: You are an "elf male" but when you enter that zone the others will see an other random template like orc female, human male, etc etc.

 

 

I even tried to adopt the method used in nexus antifeed protection, but for some reason it doesn't seem to work,, no errors in eclipse and yet it doesnt change the races.

  • 0
Posted

Disable chat, auto change names to unknown or something, random sex------These I've already done.

 

What i need is a method to change randomly the race displayed to others when you enter this zone.  For exemple: You are an "elf male" but when you enter that zone the others will see an other random template like orc female, human male, etc etc.

 

 

I even tried to adopt the method used in nexus antifeed protection, but for some reason it doesn't seem to work,, no errors in eclipse and yet it doesnt change the races.

ohhh i see , you want it visual not to make them all such a race and after leaving back to the old!.. So can i see the code of nexus anti feed?

  • 0
Posted

Search for the msg sent and edit the msg. Add a check about your zone, if inside send 'unknown', otherwise name (as it is) or simply another msg (your example) if inside. No other way.

 

No way, you will need to edit wherever it's needed.

 

Rework directly addCharName or addPcName from SystemMessage, which will affect every single case.

  • 0
Posted

ohhh i see , you want it visual not to make them all such a race and after leaving back to the old!.. So can i see the code of nexus anti feed?

    private L2PcTemplate _antifeedTemplate = null;
    private boolean _antifeedSex;
    
    private L2PcTemplate createRandomAntifeedTemplate()
    {
        Race race = null;
        
        while(race == null)
        {
            race = Race.values()[Rnd.get(Race.values().length)];
            if(race == getRace() || race == Race.KAMAEL)
                race = null;
        }
        
        PlayerClass p;
        for(ClassId c : ClassId.values())
        {
            p = PlayerClass.values()[c.getId()];
            if(p.isOfRace(race) && p.isOfLevel(ClassLevel.Fourth))
            {
                _antifeedTemplate = PlayerTemplateData.getInstance().getTemplate(c);
                break;
            }
        }
        
        if(getRace() == Race.KAMAEL)
            _antifeedSex = getAppearance().getSex();
        
        _antifeedSex = Rnd.get(2) == 0 ? true : false;
        
        return _antifeedTemplate;
    }
    
    public void startAntifeedProtection(boolean start, boolean broadcast)
    {
        if(!start)
        {
            getAppearance().setVisibleName(getName());
            _antifeedTemplate = null;
        }
        else
        {
            getAppearance().setVisibleName("Unknown");
            createRandomAntifeedTemplate();
        }
    }
    
    public L2PcTemplate getAntifeedTemplate()
    {
        return _antifeedTemplate;
    }
    
    public boolean getAntifeedSex()
    {
        return _antifeedSex;
    }


The L2PcInstance.

 

 

The CharInfo:

			writeD(_objId);

			if (_activeChar.isInsideZone(ZoneId.PVP))
			{
				writeS("Unknown"); // visible name
				
				writeD(_activeChar.getAntifeedTemplate().getRace().ordinal()); // race
				writeD(_activeChar.getAntifeedSex() ? 0 : 1); // sex

				writeD(_activeChar.getAntifeedTemplate().getClassId().getId()); // class
			}
			else
			{
				writeS(_activeChar.getAppearance().getVisibleName());
				writeD(_activeChar.getRace().ordinal());
				writeD(_activeChar.getAppearance().getSex() ? 1 : 0);
				
				if (_activeChar.getClassIndex() == 0)
					writeD(_activeChar.getClassId().getId());
				else
					writeD(_activeChar.getBaseClass());
			}

			
			for (int slot : getPaperdollOrder())
			{
				writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
			}
			
			for (int slot : getPaperdollOrder())
			{
				writeD(_activeChar.getInventory().getPaperdollAugmentationId(slot));
			}
			
			writeD(_activeChar.getInventory().getTalismanSlots());
			writeD(_activeChar.getInventory().canEquipCloak() ? 1 : 0);
			
			writeD(_activeChar.getPvpFlag());
			writeD(_activeChar.getKarma());
			
			writeD(_mAtkSpd);
			writeD(_pAtkSpd);
			
			writeD(0x00); // ?
			
			writeD(_runSpd);
			writeD(_walkSpd);
			writeD(_swimRunSpd);
			writeD(_swimWalkSpd);
			writeD(_flyRunSpd);
			writeD(_flyWalkSpd);
			writeD(_flyRunSpd);
			writeD(_flyWalkSpd);
			writeF(_moveMultiplier);
			writeF(_activeChar.getAttackSpeedMultiplier());
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
        	{
				if(_activeChar.getAntifeedSex())
				{
					writeF(_activeChar.getAntifeedTemplate().getFCollisionRadiusFemale());
            		writeF(_activeChar.getAntifeedTemplate().getFCollisionHeightFemale());
				}
				else
				{
					writeF(_activeChar.getAntifeedTemplate().getfCollisionRadius());
            		writeF(_activeChar.getAntifeedTemplate().getfCollisionHeight());
				}
        	}
        	else
        	{
        		writeF(_activeChar.getCollisionRadius());
				writeF(_activeChar.getCollisionHeight());
        	}
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
			{
				writeD(0);
				writeD(0);
				writeD(0);
			}
			else
			{
				writeD(_activeChar.getAppearance().getHairStyle());
				writeD(_activeChar.getAppearance().getHairColor());
				writeD(_activeChar.getAppearance().getFace());
			}
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
				writeS("");
			else
				writeS(gmSeeInvis ? "Invisible" : _activeChar.getAppearance().getVisibleTitle());
			
			if (!_activeChar.isCursedWeaponEquipped() && !_activeChar.isInsideZone(ZoneId.PVP))
			{
				writeD(_activeChar.getClanId());
				writeD(_activeChar.getClanCrestId());
				writeD(_activeChar.getAllyId());
				writeD(_activeChar.getAllyCrestId());
			}
			else
			{
				writeD(0x00);
				writeD(0x00);
				writeD(0x00);
				writeD(0x00);
			}
			
			writeC(_activeChar.isSitting() ? 0 : 1); // standing = 1 sitting = 0
			writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
			writeC(_activeChar.isInCombat() ? 1 : 0);
			
			writeC(!_activeChar.isInOlympiadMode() && _activeChar.isAlikeDead() ? 1 : 0);
			
			writeC(!gmSeeInvis && isInvisible() ? 1 : 0); // invisible = 1 visible =0
			
			writeC(_activeChar.getMountType().ordinal()); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
			writeC(_activeChar.getPrivateStoreType().getId());
			
			writeH(_activeChar.getCubics().size());
			for (int cubicId : _activeChar.getCubics().keySet())
			{
				writeH(cubicId);
			}
			
			writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);
			
			writeD(gmSeeInvis ? (_activeChar.getAbnormalVisualEffects() | AbnormalVisualEffect.STEALTH.getMask()) : _activeChar.getAbnormalVisualEffects());
			
			writeC(_activeChar.isInsideZone(ZoneId.WATER) ? 1 : _activeChar.isFlyingMounted() ? 2 : 0);
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
			{
				writeH(0);
			}
			else
			{
				writeH(_activeChar.getRecomHave()); //Blue value for name (0 = white, 255 = pure blue)
			}
			
			writeD(_activeChar.getMountNpcId() + 1000000);
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
				writeD(_activeChar.getAntifeedTemplate().getClassId().getId());
			else
				writeD(_activeChar.getClassId().getId());
			
			writeD(0x00); // ?
			writeC(_activeChar.isMounted() ? 0 : _activeChar.getEnchantEffect());
			
			writeC(_activeChar.getTeam().getId());
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
	        {
	        	writeD(0);
				writeC(1); // Symbol on char menu ctrl+I
				writeC(0); // Hero Aura
	        }
	        else
	        {
	        	writeD(_activeChar.getClanCrestLargeId());
				writeC(_activeChar.isNoble() ? 1 : 0); // Symbol on char menu ctrl+I
				writeC(_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA) ? 1 : 0); // Hero Aura
			}
			
			writeC(_activeChar.isFishing() ? 1 : 0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
			writeD(_activeChar.getFishx());
			writeD(_activeChar.getFishy());
			writeD(_activeChar.getFishz());
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
			{
				writeD(0xFFFFFF);
			}
			else
			{
				writeD(_activeChar.getAppearance().getNameColor());
			}
			
			writeD(_heading);
			
			writeD(_activeChar.getPledgeClass());
			writeD(_activeChar.getPledgeType());
			
			if (_activeChar.isInsideZone(ZoneId.PVP))
			{
	        	writeD(0xFFFF77);
			}
			else
			{
				writeD(_activeChar.getAppearance().getTitleColor());
			}
			

After reading the the erros that popped up in the gameserver panel. It seems to have some problem with the antifeedgetAntifeedTemplate

  • 0
Posted

No way, you will need to edit wherever it's needed.

 

Rework directly addCharName or addPcName from SystemMessage, which will affect every single case.

Yep, that's what I did.

  • 0
Posted (edited)

http://stackoverflow.com/questions/1972392/java-pick-a-random-value-from-an-enum and use Rnd.get

 

-------------------

Rnd.get(2) == 0 ? true : false; 

Rnd.nextBoolean();

----------------

 

You miss NPE check on getAntifeedTemplate() uses.

Edited by Tryskell
  • 0
Posted

http://stackoverflow.com/questions/1972392/java-pick-a-random-value-from-an-enum and use Rnd.get

 

-------------------

Rnd.get(2) == 0 ? true : false; 

Rnd.nextBoolean();

----------------

 

You miss NPE check on getAntifeedTemplate() uses.

 

I got the Rnd part thanks.

 

But about the null pointer exception check, I'm not so sure.

 

Could you explain me what or how could i apply an npe check to the getAntifeedTemplate() ?

  • 0
Posted
getAntifeedTemplate() != null 

wherever it's needed, because it is null the majority of time, and not null only for events. As you use the packets both for events and regular, it needs a null check, until you initialize it with a default template and avoids to null it after the event as you currently do.

 

PS : easiest would be to initialize and get same template for everyone. That avoid your do/while loop for race, that avoid to generate shitloads amount of pointless templates, that avoid to get NPE checks. You initialize a static template and refers to it everytime you need it ; can't be null, single object, best performance.

Guest
This topic is now closed to further replies.


×
×
  • Create New...