Skip to content

Mana Potion

Featured Replies


/*

* 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 handlers.itemhandlers;



import com.l2jserver.Config;

import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;

import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;

import com.l2jserver.gameserver.model.actor.L2Playable;

import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import com.l2jserver.gameserver.network.SystemMessageId;

import com.l2jserver.gameserver.network.serverpackets.SystemMessage;



public class ManaPotion extends ItemSkills

{

/**

 * 

 * @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)

 */

@Override

public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)

{

	L2PcInstance activeChar=(L2PcInstance) playable;

	boolean isPet = playable instanceof L2PetInstance;

	if (isPet)

		activeChar = ((L2PetInstance) playable).getOwner();

	else if (playable instanceof L2PcInstance)

		activeChar = (L2PcInstance) playable;

	else

		return false;

	if (!Config.ENABLE_MANA_POTIONS_SUPPORT)

	{

	playable.sendPacket(SystemMessageId.NOTHING_HAPPENED);
		return super.useItem(playable, item, forceUse);

	}



	if (item.getItemId()==728 && item.getCount()>0&& playable.getPvpFlag() == 0)

	{
		double aux  = playable.getCurrentMp();

		playable.setCurrentMp(playable.getCurrentMp()+300);

		playable.sendMessage((playable.getCurrentMp()-aux)+"Mana Bonus restored[Not Flaged]");			
	}

return super.useItem(playable, item, forceUse);
}

}

I'm having a problem, the bonus in pvp works well, but is not in pvp, I mean normal mode one can use as many times you want the potions of mp .. and not spend

 

I can do?

item.getCount()>0&&

I doubt it simply compiles correctly, and so you can even use it. You probably got GS log about failed handler loading.

  • Author

clear, the code is in pvp mode, only consumes 100 mp, and it works perfect.

I to them agrege MP potions of delay and when the char is not in pvp mode can use the potions you want and do not eat anything I mean? in normal mode "with delay" does not waste potions

 

----------

3. WARNING in scripts/handlers/itemhandlers/ManaPotion.java (at line 69)

L2PcInstance activeChar=(L2PcInstance) playable;

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.