Acis remote class master

    
  1. Atsijungęs

    Jeppi

    Pranešimai: 0

    Sveiki. Turiu tokia beda. Remote class master veikia viskas tvarkoje. Pasiekus 20-4076 lvl ismeta lentele su class pasiirnkimu. Taciau paspaudus niekas neivyksta. Jei esant priepat class master npc viskas veikia puikiai. Va kodas, gal kasnors zinos beda :) Dekui is anksto

    @Override
    	public void onAction(L2PcInstance player)
    	{
    		if(Config.DEBUG)
    		{
    			_log.info("Class master activated!");
    		}
    
    		player.setCurrentFolkNPC(this);
    
    		// Check if the L2PcInstance already target the L2NpcInstance
    		if(this != player.getTarget() && !Config.ALLOW_REMOTE_CLASS_MASTERS)
    		{
    			// Set the target of the L2PcInstance player
    			player.setTarget(this);
    
    			// Send a Server->Client packet MyTargetSelected to the L2PcInstance player
    			MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
    			player.sendPacket(my);
    			my = null;
    
    			// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
    			player.sendPacket(new ValidateLocation(this));
    		}
    		else
    		{
    			// Calculate the distance between the L2PcInstance and the L2NpcInstance
    			if(!canInteract(player) && !Config.ALLOW_REMOTE_CLASS_MASTERS)
    			{
    				// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
    				player.getAI().setIntention(CtrlIntention.INTERACT, this);
    			}
    			else
    			{
    				ClassId classId = player.getClassId();
    				int jobLevel = 0;
    				int level = player.getLevel();
    				ClassLevel lvl = PlayerClass.values()[classId.getId()].getLevel();
    				switch(lvl)
    				{
    					case First:
    						jobLevel = 1;
    						break;
    					case Second:
    						jobLevel = 2;
    						break;
    					case Third:
    						jobLevel = 3;
    						break;
    					default:
    						jobLevel = 4;
    				}
    				
    				
    				if(level >= 20 && jobLevel == 1 && Config.ALLOW_CLASS_MASTERS_FIRST_CLASS || level >= 40 && jobLevel == 2 && Config.ALLOW_CLASS_MASTERS_SECOND_CLASS || level >= 76 && jobLevel == 3 && Config.ALLOW_CLASS_MASTERS_THIRD_CLASS || Config.CLASS_MASTER_STRIDER_UPDATE)
    				{
    					NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    					StringBuilder sb = new StringBuilder();
    					sb.append("<html><title>Class Manager</title><body><font color=FFFFFF>Kai the Cat:</font><br><br>");
    
    					if(level >= 20 && jobLevel == 1 && Config.ALLOW_CLASS_MASTERS_FIRST_CLASS || level >= 40 && jobLevel == 2 && Config.ALLOW_CLASS_MASTERS_SECOND_CLASS || level >= 76 && jobLevel == 3 && Config.ALLOW_CLASS_MASTERS_THIRD_CLASS)
    					{
    						sb.append("<font color=FFFFFF>You can change you occupation to the following:</font><br><br>");
    
    						for(ClassId child : ClassId.values())
    							if(child.childOf(classId) && child.level() == jobLevel)
    							{
    								sb.append("<br><a action=\"bypass -h npc_" + getObjectId() + "_change_class " + child.getId() + "\"> " + CharTemplateTable.getClassNameById(child.getId()) + "</a>");
    							}
    
    						if(Config.CLASS_MASTER_SETTINGS.getRequireItems(jobLevel) != null && Config.CLASS_MASTER_SETTINGS.getRequireItems(jobLevel).size() > 0)
    						{
    							sb.append("<br><br>Item(s) required for class change:");
    							sb.append("<table width=220>");
    							for(Integer _itemId : Config.CLASS_MASTER_SETTINGS.getRequireItems(jobLevel).keys())
    							{
    								int _count = Config.CLASS_MASTER_SETTINGS.getRequireItems(jobLevel).get(_itemId);
    								sb.append("<tr><td><font color=\"LEVEL\">" + _count + "</font></td><td>" + ItemTable.getInstance().getTemplate(_itemId).getName() + "</td></tr>");
    							}
    							sb.append("</table>");
    						}
    					}
    					if(Config.CLASS_MASTER_STRIDER_UPDATE)
    					{
    						sb.append("<br><br><a action=\"bypass -h npc_" + getObjectId() + "_upgrade_hatchling\">Upgrade Hatchling to Strider</a><br>");
    					}
    					sb.append("</body></html>");
    					html.setHtml(sb.toString());
    					player.sendPacket(html);
    				}
    				else
    				{
    					NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    					StringBuilder sb = new StringBuilder();
    					sb.append("<html><title>Class Manager</title><font color=FFFFFF>Kai the Cat:</font><body><br><br>");
    					switch(jobLevel)
    					{
    						case 1:
    							sb.append("Come back here when you reach level 20 to change your class.<br>");
    							break;
    						case 2:
    							sb.append("Come back here when you reach level 40 to change your class.<br>");
    							break;
    						case 3:
    							sb.append("Come back here when you reach level 76 to change your class.<br>");
    							break;
    						case 4:
    							sb.append("There are no more class changes for you.<br>");
    							break;
    					}
    					
    					sb.append("</body></html>");
    					html.setHtml(sb.toString());
    					player.sendPacket(html);
    				}
    				lvl = null;
    				classId = null;
    			}
    		}
    		player.sendPacket(ActionFailed.STATIC_PACKET);
    	}
    7 Spalio 2014 - 18:36 / #1
  2. 
  3. Atsijungęs

    wewewe

    Pavadinimas: L2 žaidėjas

    Narys

    Pranešimai: 727

    Vartotojo apdovanojimai: 16

    canInteract metode stopudovai atstuma tikrina
    7 Spalio 2014 - 18:57 / #2
  4. 
  5. Atsijungęs

    Jeppi

    Pranešimai: 0

    Na problema ne su interact, nes html ismeta ir dideliu atstumu nuo npc, kad isirinkti class, bet ja paspaudus jos nekeicia.
    Paskutinį kartą redagavo: Jeppi 7 Spalio 2014 - 19:24
    7 Spalio 2014 - 19:15 / #3
  6. 
  7. Atsijungęs

    Grax

    Pranešimai: 0

    pazek ka wewewe parase, nes ir man taip atrodo jog ten tikrina
    7 Spalio 2014 - 19:47 / #4
  8. 
  9. Atsijungęs

    Jeppi

    Pranešimai: 0

    /**
    	 * This method checks if the player given as argument can interact with the L2Npc.
    	 * @param player The player to test
    	 * @return true if the player can interact with the L2Npc
    	 */
    	public boolean canInteract(L2PcInstance player)
    	{
    		// Can't interact while casting a spell.
    		if (player.isCastingNow() || player.isCastingSimultaneouslyNow())
    			return false;
    		
    		// Can't interact while died.
    		if (player.isDead() || player.isFakeDeath())
    			return false;
    		
    		// Can't interact sitted.
    		if (player.isSitting())
    			return false;
    		
    		// Can't interact in shop mode, or during a transaction or a request.
    		if (player.isInStoreMode() || player.isProcessingTransaction())
    			return false;
    		
    		// Can't interact if regular distance doesn't match.
    		if (!isInsideRadius(player, L2Npc.INTERACTION_DISTANCE, true, false))
    			return false;
    		
    		return true;
    	}
    7 Spalio 2014 - 19:53 / #5
  10. 
  11. Atsijungęs

    Grax

    Pranešimai: 0

    L2Npc.INTERACTION_DISTANCE
    7 Spalio 2014 - 22:07 / #6
  12. 
  13. Atsijungęs

    DNG3R

    Pranešimai: 0

    Jeppi
    // Can't interact if regular distance doesn't match.
    if (!isInsideRadius(player, L2Npc.INTERACTION_DISTANCE, true, false))
    return false;

    mėgink šitą nutrint
    7 Spalio 2014 - 23:07 / #7
  14. 
  15. Atsijungęs

    povis111

    Pranešimai: 0

    DNG3R,
    nebandyk, nes tada su visais npc eis kalbet per atstuma ir dar kitokiu klaidu isdyks. siulau:
    
    if(!(this instanceof L2ClassMasterInstance))
       if (!isInsideRadius(player, L2Npc.INTERACTION_DISTANCE, true, false))
          return false;
    
    8 Spalio 2014 - 17:05 / #8
  16. 
  17. Atsijungęs

    Jeppi

    Pranešimai: 0

    povis111,
    Nepadejo. Na as kiek suprantu tas interact kad ismestu chata npc kai prie jo prieini. Su interact viskas gerai speju, nes man pakilus tarkim 40 lvl ismeta profesijos keitimo langa. Pasirenku tarkim treasure hunter bet nekeicia.
    Paskutinį kartą redagavo: Jeppi 8 Spalio 2014 - 20:04
    8 Spalio 2014 - 20:04 / #9
  18. 
  19. Atsijungęs

    povis111

    Pranešimai: 0

    Jeppi,
    Nu jo, jau anksciau norejau pasakyt, kad bypassai su npc_objid per atstuma nelabai veikia, bet galvojau, kad apsirikau :D
    action=\"bypass -h npc_" + getObjectId() + "_

    ir kiek katik pastebejau tikrina papildomai atstuma(RequestBypassToServer.java), nes nebutinai yra naudot anoki koda instance'o kurimui.
    
    else if (_command.startsWith("npc_"))
    			{
    				if (!activeChar.validateBypass(_command))
    					return;
    				
    				int endOfId = _command.indexOf('_', 5);
    				String id;
    				if (endOfId > 0)
    					id = _command.substring(4, endOfId);
    				else
    					id = _command.substring(4);
    				
    				try
    				{
    					L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
    					
                                            if (object != null && object instanceof L2Npc && endOfId > 0 && 
                                                 activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
    					((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
    					
    					activeChar.sendPacket(ActionFailed.STATIC_PACKET);
    				}
    				catch (NumberFormatException nfe)
    				{
    				}
    			}
    

    tokiais atvejais as pasidarau papildoma bypass'a tarp RequestBypassToServer. Taciau, jei ir pas tave taip packe parasyta, gali bandyt ta pati dalykeli ten pat pasidaryt ir pazet.
    
    if(object != null && !(object instanceof L2ClassMasterInstance))
    if (object instanceof L2Npc && endOfId > 0 && 
          activeChar.isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
    		((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));
    

    kitas budas pati bool'a pasiredaguot
    /**
    	 * Check if this object is inside the given radius around the given object. Warning: doesn't cover collision radius!
    	 * @param object the target
    	 * @param radius the radius around the target
    	 * @param checkZ should we check Z axis also
    	 * @param strictCheck true if (distance < radius), false if (distance <= radius)
    	 * @return true is the L2Character is inside the radius.
    	 */
    	public final boolean isInsideRadius(L2Object object, int radius, boolean checkZ, boolean strictCheck)
    	{
                    if(this instanceof L2ClassMasterInstance)
                        return true;
    		return isInsideRadius(object.getX(), object.getY(), object.getZ(), radius, checkZ, strictCheck);
    	}
    
    Paskutinį kartą redagavo: povis111 9 Spalio 2014 - 00:12
    9 Spalio 2014 - 00:06 / #10