Jump to content
  • 0

Bug when i start the gameserver


Question

Posted

L2J version 4086

L2JDP version 7279

 

Screen :

 

errorgc.jpg

 

All is on the screen.

 

The code for the lign error :

 

            L2TamedBeastInstance oldTrained = player.getTrainedBeast();
            if (oldTrained != null)
            {
                oldTrained.doDespawn();
            }

4 answers to this question

Recommended Posts

  • 0
Posted

i dont know , which pack are u using?

 

Are you blind?

 

L2J version 4086

L2JDP version 7279

 

Next time I will dekarma you, I saw your replys (95% - offtopic or stupid replys)

  • 0
Posted

Here is my code of this file. Anyone can help me for find the problem ?

/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.actor.instance;

import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;

import java.util.concurrent.Future;

import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.network.serverpackets.AbstractNpcInfo;
import com.l2jserver.gameserver.network.serverpackets.StopMove;
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Point3D;
import com.l2jserver.util.Rnd;

import javolution.util.FastMap;

// While a tamed beast behaves a lot like a pet (ingame) and does have
// an owner, in all other aspects, it acts like a mob.
// In addition, it can be fed in order to increase its duration.
// This class handles the running tasks, AI, and feed of the mob.
// The (mostly optional) AI on feeding the spawn is handled by the datapack ai script
public final class L2TamedBeastInstance extends L2FeedableBeastInstance
{
private int _foodSkillId;
private static final int MAX_DISTANCE_FROM_HOME = 30000;
private static final int MAX_DISTANCE_FROM_OWNER = 2000;
private static final int MAX_DURATION = 1200000;	// 20 minutes
private static final int DURATION_CHECK_INTERVAL = 60000;	// 1 minute
private static final int DURATION_INCREASE_INTERVAL = 20000;	// 20 secs (gained upon feeding)
private static final int BUFF_INTERVAL = 5000;	// 5 seconds
private int _remainingTime = MAX_DURATION;
private int _homeX, _homeY, _homeZ;
private L2PcInstance _owner;
private Future<?> _buffTask = null;
private Future<?> _durationCheckTask = null;

public L2TamedBeastInstance(int objectId, L2NpcTemplate template)
{
	super(objectId, template);
	setInstanceType(InstanceType.L2TamedBeastInstance);
	setHome(this);
}

public L2TamedBeastInstance(int objectId, L2NpcTemplate template, L2PcInstance owner, int foodSkillId, int x, int y, int z)
{
	super(objectId, template);
	setInstanceType(InstanceType.L2TamedBeastInstance);
	setCurrentHp(getMaxHp());
	setCurrentMp(getMaxMp());
	setOwner(owner);
	setFoodType(foodSkillId);
	setHome(x,y,z);
	this.spawnMe(x, y, z);
}

public void onReceiveFood()
{
	// Eating food extends the duration by 20secs, to a max of 20minutes
	_remainingTime = _remainingTime + DURATION_INCREASE_INTERVAL;
	if (_remainingTime > MAX_DURATION)
		_remainingTime = MAX_DURATION;
}

public Point3D getHome()
{
	return new Point3D(_homeX, _homeY, _homeZ);
}

public void setHome(int x, int y, int z)
{
	_homeX = x;
	_homeY = y;
	_homeZ = z;
}

public void setHome(L2Character c)
{
	setHome(c.getX(), c.getY(), c.getZ());
}

public int getRemainingTime()
{
	return _remainingTime;
}

public void setRemainingTime(int duration)
{
	_remainingTime = duration;
}

public int getFoodType()
{
	return _foodSkillId;
}

public void setFoodType(int foodItemId)
{
	if (foodItemId > 0)
	{
		_foodSkillId = foodItemId;

		// start the duration checks
		// start the buff tasks
		if (_durationCheckTask != null)
			_durationCheckTask.cancel(true);
		_durationCheckTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckDuration(this), DURATION_CHECK_INTERVAL, DURATION_CHECK_INTERVAL);
	}
}

@Override
public boolean doDie(L2Character killer)
{
	if (!super.doDie(killer))
		return false;

	getAI().stopFollow();
	if (_buffTask != null)
		_buffTask.cancel(true);
	if (_durationCheckTask != null)
		_durationCheckTask.cancel(true);

	// clean up variables
	if (_owner != null)
		_owner.setTrainedBeast(null);
	_buffTask = null;
	_durationCheckTask = null;
	_owner = null;
	_foodSkillId = 0;
	_remainingTime = 0;
	return true;
}

public L2PcInstance getOwner()
{
	return _owner;
}

public void setOwner(L2PcInstance owner)
{
	if (owner != null)
	{
		_owner = owner;
		setTitle(owner.getName());
		// broadcast the new title
		broadcastPacket( new AbstractNpcInfo.NpcInfo(this, owner) );

		owner.setTrainedBeast(this);

		// always and automatically follow the owner.
		getAI().startFollow(_owner,100);

		// instead of calculating this value each time, let's get this now and pass it on
		int totalBuffsAvailable = 0;
		for (L2Skill skill: getTemplate().getSkills().values())
		{
			// if the skill is a buff, check if the owner has it already [  owner.getEffect(L2Skill skill) ]
			if (skill.getSkillType() == L2SkillType.BUFF)
				totalBuffsAvailable++;
		}

		// start the buff tasks
		if (_buffTask !=null)
			_buffTask.cancel(true);
		_buffTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckOwnerBuffs(this, totalBuffsAvailable), BUFF_INTERVAL, BUFF_INTERVAL);
	}
	else
	{
		deleteMe();	// despawn if no owner
	}
}

public boolean isTooFarFromHome()
{
	return !(this.isInsideRadius(_homeX, _homeY, _homeZ, MAX_DISTANCE_FROM_HOME, true, true));
}

@Override
public void deleteMe()
{
	// stop running tasks
	getAI().stopFollow();
	_buffTask.cancel(true);
	_durationCheckTask.cancel(true);
	stopHpMpRegeneration();

	// clean up variables
	if (_owner != null)
		_owner.setTrainedBeast(null);
	setTarget(null);
	_buffTask = null;
	_durationCheckTask = null;
	_owner = null;
	_foodSkillId = 0;
	_remainingTime = 0;

	// remove the spawn
	super.deleteMe();
}

// notification triggered by the owner when the owner is attacked.
// tamed mobs will heal/recharge or debuff the enemy according to their skills
public void onOwnerGotAttacked(L2Character attacker)
{
	// check if the owner is no longer around...if so, despawn
	if ((_owner == null) || (_owner.isOnline()==0) )
	{
		deleteMe();
		return;
	}
	// if the owner is too far away, stop anything else and immediately run towards the owner.
	if (!_owner.isInsideRadius(this, MAX_DISTANCE_FROM_OWNER, true, true))
	{
		getAI().startFollow(_owner);
		return;
	}
	// if the owner is dead, do nothing...
	if (_owner.isDead())
		return;

	// if the tamed beast is currently in the middle of casting, let it complete its skill...
	if(isCastingNow())
		return;

	float HPRatio = ((float) _owner.getCurrentHp())/_owner.getMaxHp();

	// if the owner has a lot of HP, then debuff the enemy with a random debuff among the available skills
	// use of more than one debuff at this moment is acceptable
	if (HPRatio >= 0.8)
	{
		FastMap<Integer, L2Skill> skills = (FastMap<Integer, L2Skill>) getTemplate().getSkills();

		for (L2Skill skill: skills.values())
		{
			// if the skill is a debuff, check if the attacker has it already [  attacker.getEffect(L2Skill skill) ]
			if ((skill.getSkillType() == L2SkillType.DEBUFF) && Rnd.get(3) < 1 && (attacker != null && attacker.getFirstEffect(skill) != null))
			{
				sitCastAndFollow(skill, attacker);
			}
		}
	}
	// for HP levels between 80% and 50%, do not react to attack events (so that MP can regenerate a bit)
	// for lower HP ranges, heal or recharge the owner with 1 skill use per attack.
	else if (HPRatio < 0.5)
	{
		int chance = 1;
		if (HPRatio < 0.25 )
			chance = 2;

		// if the owner has a lot of HP, then debuff the enemy with a random debuff among the available skills
		FastMap<Integer, L2Skill> skills = (FastMap<Integer, L2Skill>) getTemplate().getSkills();

		for (L2Skill skill: skills.values())
		{
			// if the skill is a buff, check if the owner has it already [  owner.getEffect(L2Skill skill) ]
			if ( (Rnd.get(5) < chance) && ((skill.getSkillType() == L2SkillType.HEAL) ||
					(skill.getSkillType() == L2SkillType.HOT) ||
					(skill.getSkillType() == L2SkillType.BALANCE_LIFE) ||
					(skill.getSkillType() == L2SkillType.HEAL_PERCENT) ||
					(skill.getSkillType() == L2SkillType.HEAL_STATIC) ||
					(skill.getSkillType() == L2SkillType.COMBATPOINTHEAL) ||
					(skill.getSkillType() == L2SkillType.CPHOT) ||
					(skill.getSkillType() == L2SkillType.MANAHEAL) ||
					(skill.getSkillType() == L2SkillType.MANA_BY_LEVEL) ||
					(skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT) ||
					(skill.getSkillType() == L2SkillType.MANARECHARGE) ||
					(skill.getSkillType() == L2SkillType.MPHOT) )
			)
			{
				sitCastAndFollow(skill, _owner);
				return;
			}
		}
	}
}

/**
 * Prepare and cast a skill:
 *   First smoothly prepare the beast for casting, by abandoning other actions
 *   Next, call super.doCast(skill) in order to actually cast the spell
 *   Finally, return to auto-following the owner.
 *
 * @see com.l2jserver.gameserver.model.actor.L2Character#doCast(com.l2jserver.gameserver.model.L2Skill)
 */
protected void sitCastAndFollow(L2Skill skill, L2Character target)
{
	stopMove(null);
	broadcastPacket(new StopMove(this));
	getAI().setIntention(AI_INTENTION_IDLE);

	setTarget(target);
	doCast(skill);
	getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, _owner);
}

private class CheckDuration implements Runnable
{
	private L2TamedBeastInstance _tamedBeast;

	CheckDuration(L2TamedBeastInstance tamedBeast)
	{
		_tamedBeast = tamedBeast;
	}

	public void run()
	{
		int foodTypeSkillId = _tamedBeast.getFoodType();
		L2PcInstance owner = _tamedBeast.getOwner();
		_tamedBeast.setRemainingTime(_tamedBeast.getRemainingTime() - DURATION_CHECK_INTERVAL);

		// I tried to avoid this as much as possible...but it seems I can't avoid hardcoding
		// ids further, except by carrying an additional variable just for these two lines...
		// Find which food item needs to be consumed.
		L2ItemInstance item = null;
		if (foodTypeSkillId == 2188)
			item = owner.getInventory().getItemByItemId(6643);
		else if (foodTypeSkillId == 2189)
			item = owner.getInventory().getItemByItemId(6644);

		// if the owner has enough food, call the item handler (use the food and triffer all necessary actions)
		if (item != null && item.getCount() >= 1)
		{
			L2Object oldTarget = owner.getTarget();
			owner.setTarget(_tamedBeast);
			L2Object[] targets = {_tamedBeast};

			// emulate a call to the owner using food, but bypass all checks for range, etc
			// this also causes a call to the AI tasks handling feeding, which may call onReceiveFood as required.
			owner.callSkill(SkillTable.getInstance().getInfo(foodTypeSkillId, 1), targets);
			owner.setTarget(oldTarget);
		}
		else
		{
			// if the owner has no food, the beast immediately despawns, except when it was only
			// newly spawned.  Newly spawned beasts can last up to 5 minutes
			if (_tamedBeast.getRemainingTime() < MAX_DURATION - 300000)
				_tamedBeast.setRemainingTime(-1);
		}

		/* There are too many conflicting reports about whether distance from home should
		 * be taken into consideration.  Disabled for now.
		 *
    		if (_tamedBeast.isTooFarFromHome())
    			_tamedBeast.setRemainingTime(-1);
		 */

		if (_tamedBeast.getRemainingTime() <= 0)
			_tamedBeast.deleteMe();
	}
}

private class CheckOwnerBuffs implements Runnable
{
	private L2TamedBeastInstance _tamedBeast;
	private int _numBuffs;

	CheckOwnerBuffs(L2TamedBeastInstance tamedBeast, int numBuffs)
	{
		_tamedBeast = tamedBeast;
		_numBuffs = numBuffs;
	}

	public void run()
	{
		L2PcInstance owner = _tamedBeast.getOwner();

		// check if the owner is no longer around...if so, despawn
		if ((owner == null) || (owner.isOnline()==0) )
		{
			deleteMe();
			return;
		}
		// if the owner is too far away, stop anything else and immediately run towards the owner.
		if (!isInsideRadius(owner, MAX_DISTANCE_FROM_OWNER, true, true))
		{
			getAI().startFollow(owner);
			return;
		}
		// if the owner is dead, do nothing...
		if (owner.isDead())
			return;
		// if the tamed beast is currently casting a spell, do not interfere (do not attempt to cast anything new yet).
		if (isCastingNow())
			return;

		int totalBuffsOnOwner = 0;
		int i=0;
		int rand = Rnd.get(_numBuffs);
		L2Skill buffToGive = null;

		// get this npc's skills:  getSkills()
		FastMap<Integer, L2Skill> skills = (FastMap<Integer, L2Skill>) _tamedBeast.getTemplate().getSkills();

		for (L2Skill skill: skills.values())
		{
			// if the skill is a buff, check if the owner has it already [  owner.getEffect(L2Skill skill) ]
			if (skill.getSkillType() == L2SkillType.BUFF)
			{
				if (i++==rand)
					buffToGive = skill;
				if(owner.getFirstEffect(skill) != null)
				{
					totalBuffsOnOwner++;
				}
			}
		}
		// if the owner has less than 60% of this beast's available buff, cast a random buff
		if (_numBuffs*2/3 > totalBuffsOnOwner)
		{
			_tamedBeast.sitCastAndFollow(buffToGive, owner);
		}
		getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, _tamedBeast.getOwner());
	}
}
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Reconstructed the MSNP8 client/server chain in Lineage 2 (from C4 to HFp5) with full protocol capabilities + added Discord integration    Clean MSNP8:       MSNP8 + Discord Bridge:   
    • I'm looking for the GVE code for Luecera2.
    • Recommended seller, I'm using his services. Good luck @Ave
    • https://l2.gamedream.pl/ Update #2 — GameDream Interlude (C6)     This update focuses on Epic bosses, quest chains and overall QoL :cool Highlights: Frintezza access follows a full retail-like chain: Four Goblets → Last Imperial Prince → Journey to a Settlement Retail-like entry requirements restored (scroll + Command Channel) Four Goblets quest is now available in-game Shot visuals synced with attack/skill usage Community Board Premium Shop refreshed with classic Interlude buttons and cleaner tables Epic Raidboss access: Frintezza — 4–5 party Command Channel + scroll + Antique Brooch Antharas — Portal Stone Baium — Bloody Fabric Valakas — Floating Stone Queen Ant / Core / Orfen / Zaken — no quest gates Bug Fixes & QoL: Frintezza quest chain fully fixed TvT rewards — single reward + anti-abuse protection Shots — no double triggering Premium Shop — no blank tabs Mammon NPCs in Giran working correctly Cancel works retail-like (up to 5 buffs removed) Summon Friend fixed with anti-exploit guards YetiBuffer — Saved Buff Profiles (Save / Clear / Restore) PvE — increased aggro range + balance tweaks EXP toggle commands: expoff / expon / expblock Thanks for testing and feedback — more updates coming soon ❤️
    • Hello I would like to offer You my NEW 2026 Updater / Launcher with custom skins.   - UPDATER FEATURES -   1. Performance and Intelligent Resource Management: Smart Disk Detection (SSD/HDD): The updater automatically detects the user's drive type. For SSD/NVMe drives: Launches up to 8-12 concurrent threads, utilizing the full yet optimized connection speed. For HDD drives: Limits the thread count (to 2-3) to prevent computer slowdowns and avoid overloading the drive head. Multi-threaded Downloading: Instead of downloading file by file, the updater downloads multiple files simultaneously, drastically reducing update time. ZSTD Compression: Support for the modern Zstandard compression algorithm (.zst). Files are downloaded in compressed form and decompressed on the fly, saving bandwidth and accelerating downloads. HTTP/2 and Keep-Alive Support: Utilizing the HTTP/2 protocol and persistent connections allows for the instant download of thousands of small files without establishing a new connection for each one.   2. Modern User Interface (UI/UX): Transparency and PNG Graphics: Support for irregular window shapes, allowing for the creation of a unique, modern launcher look. Taskbar Integration: The progress bar is displayed not only in the window but also on the Windows taskbar icon. Built-in News Browser (Optional): The updater features a built-in browser module that displays news/changelogs directly within the launcher (without opening an external browser). Multi-language Support (Optional): Built-in language switching system (e.g., EN/PL/RU, etc.) with dynamic loading of button graphics and text. Animated Buttons (Optional): Dedicated, animated buttons redirecting to Discord, Facebook, YouTube, Instagram, and the website.   3. Technical Features and Application Security: Anti-Dual Run (Optional): The updater checks if the game is already running to prevent file conflicts during updates. Error Diagnostics: Built-in logging system (debug_log.txt) and hardware exception handling (SEH), facilitating the diagnosis of problems for players who cannot run the game. Internal Configuration: Updater settings are stored inside the .exe file, eliminating publicly accessible configuration files.   4. File Categorization (Normal vs. Critical vs. Once): Critical Files: Critical files are verified more thoroughly (via MD5 Hash) even in quick check mode to guarantee stability. Normal Files: Standard game files (textures, models, sounds) are checked depending on the selected mode (Quick vs. Full). Once Files (Overwrite Exclusions): Applies to user configuration files (e.g., Option.ini, User.ini).   5. Check Modes (Verification Algorithms): Self-Update: The updater can update itself before checking game files, allowing for easy deployment of launcher fixes. The updater supports two main operating modes that switch intelligently based on user action: Smart Check (Startup Quick Check): Runs automatically upon updater startup or pressing the START button (unless a full check is forced). Full Check (Full MD5 Verification): Manually triggered by the player via the "Full Check" button. Automatic Update Detection: If a newer version of a file appears on the server, it is automatically detected and downloaded without player interaction. Atomic Updates: Files are downloaded and verified first, and only then saved to the disk. This prevents game client corruption in case of internet connection loss. The entire process takes seconds, even with clients weighing 30GB+. - PATCH BUILDER FEATURES -   1. Professional File Structure Management (Tree-List Hybrid): Directory Tree Visualization: Instead of a flat file list, the Builder displays a clear structure of folders and subfolders. You can collapse and expand entire tree branches, facilitating work with thousands of files. Normal and Critical Division: A clear window division into two main zones: Normal Files and Critical Files. Ghost and Excluded Files Division: The interface visually informs about the status of unchanged files (existing in the previous patch version) and files excluded from the update. Show/Hide Ghosts: With one click, you can hide unchanged files to focus solely on what you are actually sending to players in this update.   2. Intuitive Interaction: Drag & Drop: Full Drag & Drop support. You can grab files or entire folders and drag them between the "Normal" and "Critical" lists. Transfer is intelligent – it moves the entire content of selected folders. Keyboard Shortcuts: Fast workflow thanks to keyboard support: Delete, Enter, Ctrl+A / Ctrl+C (select and copy paths).   3. Advanced Filtering and Searching: Context Search: The search bar works in real-time, filtering the file tree. Type /folder: Searches only within folder names. Type *ex: Shows only excluded files. Standard Typing: Searches files by name.   4. Automation and Security: Auto Self-Update: The Builder automatically detects the updater executable file. Real-Time Statistics: The status bar continuously shows the file count (Normal/Critical), total patch weight (in Bytes/MB/GB), and the last update date. System File Protection: Files marked as "Critical" cannot be accidentally added to the exclusion list – the program blocks such actions.   5. Performance (Backend): ZSTD Compression: The Builder uses the latest Zstandard algorithm to compress files before sending, ensuring a significantly smaller patch size than standard ZIP, saving server bandwidth and player time. Multi-threading: The packing and MD5 checksum generation process utilizes multiple CPU threads, drastically reducing patch building time.   - PRICING - NEW Updater standard price: 79 euro (if You ask for mods, price will change).   - CONTACT - Discord: ave7309   CLICK HERE TO CHECK LATEST TEMPLATES!                         * I have right to REFUSE to take an order. * Supported games: Lineage 2 / Black Desert / MU Online / Tantra / Rohan / Aion / Cabal / Fiesta any more...  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..