Mob grazinimas atgal i spawn

    
  1. Atsijungęs

    Jeppi

    Pranešimai: 0

    Sveiki, reikia pagalbos del mobu. Noriu padaryti jog jei jie nubegs toli nuo savo spawn paskui zaideja bus grazinti atgal. Script isidejau, gal ne i ta vieta dedu, nes mob negali isvis daryt damage, i GS meta eror. Teleportas veikia, bet damage ne.

    int mob_lock_range = Config.MOBLOCKRAGE;
    		
    		if(mob_lock_range!=-1 && !npc.isInsideRadius(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz(), mob_lock_range, true, false))
    		{
    			npc.teleToLocation(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz(), 0);
    			npc.stopHating(attackTarget);
    		}

    SI script buvau isidejes i L2AttackableAi.java thinkAttack() voida.

    protected void thinkAttack()
    	{
    		final L2Attackable npc = getActiveChar();
    		if (npc.isCastingNow())
    			return;
    		
    		L2Character attackTarget = (L2Character) getTarget();
    		// If target doesn't exist, is dead or if timeout is expired (non-aggro mobs or mobs which are too far stop to attack)
    		if (attackTarget == null || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getGameTicks() && (!npc.isAggressive() || Math.sqrt(npc.getPlanDistanceSq(attackTarget.getX(), attackTarget.getY())) > npc.getAggroRange() * 2)))
    		{
    			// Stop hating this target after the attack timeout or if target is dead
    			if (attackTarget != null)
    				npc.stopHating(attackTarget);
    			
    			// Search the nearest target. If a target is found, continue regular process, else drop angry behavior.
    			attackTarget = targetReconsider(npc.getAggroRange(), false);
    			if (attackTarget == null)
    			{
    				setIntention(CtrlIntention.ACTIVE);
    				npc.setWalking();
    				return;
    			}
    		}
    		final int actorCollision = npc.getTemplate().getCollisionRadius();
    		
    		/**
    		 * FACTION CHECKS<br>
    		 * Handle agression behavior towards monsters of same faction.
    		 */
    		
    		final String[] actorClans = npc.getClans();
    		if (actorClans != null)
    		{
    			for (L2Npc called : npc.getKnownList().getKnownTypeInRadius(L2Npc.class, npc.getClanRange()))
    			{
    				// Caller clan doesn't correspond to the called clan.
    				if (!Util.contains(actorClans, called.getClans()))
    					continue;
    				
    				// Called mob doesnt care about that type of caller id (the bitch !).
    				if (Util.contains(called.getIgnoredIds(), npc.getNpcId()))
    					continue;
    				
    				// Check if the L2Object is inside the Faction Range of the actor
    				if (called.hasAI() && GeoData.getInstance().canSeeTarget(npc, called) && npc.getAttackByList().contains(attackTarget) && (called.getAI()._intention == CtrlIntention.IDLE || called.getAI()._intention == CtrlIntention.ACTIVE))
    				{
    					if (attackTarget instanceof L2Playable)
    					{
    						List<Quest> quests = called.getTemplate().getEventQuests(QuestEventType.ON_FACTION_CALL);
    						if (quests != null)
    						{
    							L2PcInstance player = attackTarget.getActingPlayer();
    							boolean isSummon = attackTarget instanceof L2Summon;
    							for (Quest quest : quests)
    								quest.notifyFactionCall(called, npc, player, isSummon);
    						}
    					}
    					else if (called instanceof L2Attackable && called.getAI()._intention != CtrlIntention.ATTACK)
    					{
    						((L2Attackable) called).addDamageHate(attackTarget, 0, npc.getHating(attackTarget));
    						called.getAI().setIntention(CtrlIntention.ATTACK, attackTarget);
    					}
    				}
    			}
    		}
    		
    		// Corpse AIs, as AI scripts, are stopped here.
    		if (npc.isCoreAIDisabled())
    			return;
    		
    		/**
    		 * TARGET CHECKS<br>
    		 * Chaos time for RB/minions.
    		 */
    		
    		if (npc.isRaid() || npc.isRaidMinion())
    		{
    			_chaostime++;
    			if (npc instanceof L2RaidBossInstance && _chaostime > Config.RAID_CHAOS_TIME && (Rnd.get(100) <= 100 - (npc.getCurrentHp() * ((((L2MonsterInstance) npc).hasMinions()) ? 200 : 100) / npc.getMaxHp())))
    			{
    				attackTarget = aggroReconsider(attackTarget);
    				_chaostime = 0;
    			}
    			else if (npc instanceof L2GrandBossInstance && _chaostime > Config.GRAND_CHAOS_TIME)
    			{
    				double chaosRate = 100 - (npc.getCurrentHp() * 300 / npc.getMaxHp());
    				if ((chaosRate <= 10 && Rnd.get(100) <= 10) || (chaosRate > 10 && Rnd.get(100) <= chaosRate))
    				{
    					attackTarget = aggroReconsider(attackTarget);
    					_chaostime = 0;
    				}
    			}
    			else if (_chaostime > Config.MINION_CHAOS_TIME && (Rnd.get(100) <= 100 - (npc.getCurrentHp() * 200 / npc.getMaxHp())))
    			{
    				attackTarget = aggroReconsider(attackTarget);
    				_chaostime = 0;
    			}
    		}
    		
    		setTarget(attackTarget);
    		npc.setTarget(attackTarget)
    Paskutinį kartą redagavo: Jeppi 14 Spalio 2014 - 17:00
    14 Spalio 2014 - 16:59 / #1
  2. 
  3. Atsijungęs

    Jeppi

    Pranešimai: 0

    Suklydau mobu damage veikia. Neveikia riadbossu minions . Isvis nepuola jie, stovi kaip prikalti
    14 Spalio 2014 - 17:19 / #2
  4. 
  5. Atsijungęs

    povis111

    Pranešimai: 0

    as deciau tarp
    
    /**
    	 * Reduce the current HP of the L2Attackable, update its _aggroList and launch the doDie Task if necessary.
    	 * @param attacker The L2Character who attacks
    	 * @param awake The awake state (If True : stop sleeping)
    	 */
    	@Override
    	public void reduceCurrentHp(double damage, L2Character attacker, boolean awake, boolean isDOT, L2Skill skill)
    	{
    


    
    if (this instanceof L2MonsterInstance)
    		{
    			final L2Attackable npc = this;
    			int mob_lock_range = Config.MOBLOCKRAGE;
    			
                            if(mob_lock_range!=-1 &&
    !npc.isInsideRadius(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz(), mob_lock_range, true, false))
    			{
                       npc.teleToLocation(npc.getSpawn().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz(), 0);
    				npc.stopHating(attacker);
    			}
    			
    			L2MonsterInstance master = (L2MonsterInstance) this;
    			
    			if (master.hasMinions())
    				master.getMinionList().onAssist(this, attacker);
    			
    			master = master.getLeader();
    			if (master != null && master.hasMinions())
    				master.getMinionList().onAssist(this, attacker);
    		}
    
    14 Spalio 2014 - 19:00 / #3
  6. 
  7. Atsijungęs

    Jeppi

    Pranešimai: 0

    Viskas butu gerai, bet jis isijungia tik kai as trenkiu i mob.
    14 Spalio 2014 - 19:36 / #4
  8. 
  9. Atsijungęs

    povis111

    Pranešimai: 0

    aj, tai tada su situo zaiskis, manyciau. tik nepamirsk patikros del l2monster tipo :D
    
    @Override
    	protected void moveToLocation(int x, int y, int z, int offset)
    	{
    		if (isAttackingNow())
    			return;
    		
    		super.moveToLocation(x, y, z, offset);
    	}
    
    14 Spalio 2014 - 21:46 / #5
  10. 
  11. Atsijungęs

    Jeppi

    Pranešimai: 0

    Mmission imposible man cia :D Su override neidedu net scripto niekur, error gaunu. Toki pasidariau, bet naudos irgi 0, nes nezinau kur ikelt.
    protected void checkAndReturnToSpawn()
    	{
    		final L2Attackable npc = getActiveChar();
    		int rb_lock_range = Config.RBLOCKRAGE;
    		if (npc.isDead() || npc.isMovementDisabled())
    			return;
    	
    		if(!npc.isInsideRadius(npc.getX(), npc.getY(), npc.getZ(), rb_lock_range, true, false))
    		{
    			npc.teleToLocation(npc.getX(), npc.getY(), npc.getZ(), 0);
    			return;
    
    		}
    
    		
    	}


    Gal pas pasakytumet kokia ovorride nauda javoje? Angliskai ziurejau bet, kaskaip nedaejo.
    14 Spalio 2014 - 22:51 / #6
  12. 
  13. Atsijungęs

    povis111

    Pranešimai: 0

    cia ne skriptas, cia funcija/metodas l2attackable klasej ;D tarp jo tau reikia isimest ta koda, kad kai mobas kuris ruosis kazkur judet nukeliautu i spawna. o del override bijau pameluot, bet susije su klasiu paveldimumu. tai reiskia kad vienai klasei abstract/interface tipam extendinant/implementinant persiduoda metodas, o esme tame, kad pagrindinei klasei pasaukus metoda sureguos ir kitos, zinoma, jei neklystu :D
    15 Spalio 2014 - 18:51 / #7
  14. 
  15. Atsijungęs

    Jeppi

    Pranešimai: 0

    Ok. Dekui uz pagalba. Meginsiu :D
    15 Spalio 2014 - 18:54 / #8
  16. 
  17. Atsijungęs

    Jeppi

    Pranešimai: 0

    Blemba meta erorr. Sitaip isidejau.
    @Override
    	protected void moveToLocation(int x, int y, int z, int offset)
    	{
    		int mob_lock_range = Config.MOBLOCKRAGE;
    		if(this instanceof L2MonsterInstance && mob_lock_range!=-1 && !isInsideRadius(getSpawn().getLocx(), getSpawn().getLocy(), getSpawn().getLocz(), mob_lock_range, true, false))
    		{
    			teleToLocation(getSpawn().getLocx(), getSpawn().getLocy(), getSpawn().getLocz(), 0);
    		}
    		if (isAttackingNow())
    			return;
    		
    		
    		super.moveToLocation(x, y, z, offset);
    	}
    	


    Va erorr photo
    PHOTO
    Paskutinį kartą redagavo: Jeppi 15 Spalio 2014 - 21:31
    15 Spalio 2014 - 21:21 / #9
  18. 
  19. Atsijungęs

    povis111

    Pranešimai: 0

    o, kad zinociau, kelintoj eilutej ten pas tave koks kodas, bet galiu tik spet, gali but, kad getSpawn() yra null arba this yra null. betkokiu atveju tikrint reiktu getSpawn() != null && this != null
    15 Spalio 2014 - 22:17 / #10