/* This program is free software; you can redistribute it and/or modify */
package com.l2jfree.gameserver.handler.voicedcommandhandlers;
import javolution.util.FastList;
import com.l2jfree.gameserver.datatables.BuffTemplateTable;
import com.l2jfree.gameserver.handler.IVoicedCommandHandler;
import com.l2jfree.gameserver.model.L2Skill.SkillType;
import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfree.gameserver.network.SystemMessageId;
import com.l2jfree.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jfree.gameserver.network.serverpackets.SystemMessage;
import com.l2jfree.gameserver.templates.L2BuffTemplate;
/**
* @author v
*
*/
public class Buffz implements IVoicedCommandHandler
{
//private static final Log _log = LogFactory.getLog(Wedding.class);
private static String[] _voicedCommands = { "fighterbuff","magebuff" };
/* (non-Javadoc)
* @see com.l2jfree.gameserver.handler.IUserCommandHandler#useUserCommand(int, com.l2jfree.gameserver.model.L2PcInstance)
*/
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
if(activeChar!=null)
{
FastList<L2BuffTemplate> _templateBuffs = new FastList<L2BuffTemplate>();
boolean _wasInvul=false;
if(command.startsWith("fighterbuff"))
_templateBuffs = BuffTemplateTable.getInstance().getBuffTemplate(98);
else
_templateBuffs = BuffTemplateTable.getInstance().getBuffTemplate(99);
if (_templateBuffs == null || _templateBuffs.size() == 0)
return false;
activeChar.setTarget(activeChar);
//is this really need?
double _mp=activeChar.getStatus().getCurrentMp(); //to disable mp consuming
// for those who is invulnerable
if(activeChar.isInvul()&&activeChar.isGM())
{
_wasInvul=true;
activeChar.setIsInvul(false);
}
for (L2BuffTemplate _buff:_templateBuffs)
{
if ( _buff.checkPlayer(activeChar))
{
// regeneration ^^ //is this really need?
activeChar.getStatus().setCurrentMp(_mp);
String _name="";
// some more functions depending on _buff name
if(_buff.getName().equalsIgnoreCase("RestoreHpMp")) {
MagicSkillUse msu = new MagicSkillUse(activeChar, activeChar, _buff.getSkillId(), _buff.getSkillLevel(), 110, 0);
activeChar.broadcastPacket(msu);
activeChar.getStatus().setCurrentHpMp(activeChar.getMaxHp(), activeChar.getMaxMp());
_name="Health and Mana Restoration";
}
else if(_buff.getName().equalsIgnoreCase("Heal")) {
MagicSkillUse msu = new MagicSkillUse(activeChar, activeChar, _buff.getSkillId(), _buff.getSkillLevel(), 110, 0);
activeChar.broadcastPacket(msu);
activeChar.getStatus().setCurrentHp(activeChar.getMaxHp());
_name="Health Restoration";
}
else if(_buff.getName().equalsIgnoreCase("Mana"))
{
MagicSkillUse msu = new MagicSkillUse(activeChar, activeChar, _buff.getSkillId(), _buff.getSkillLevel(), 110, 0);
activeChar.broadcastPacket(msu);
activeChar.getStatus().setCurrentMp(activeChar.getMaxMp());
_name="Mana Restoration";
}
else if(_buff.getName().equalsIgnoreCase("CP"))
{
MagicSkillUse msu = new MagicSkillUse(activeChar, activeChar, _buff.getSkillId(), _buff.getSkillLevel(), 110, 0);
activeChar.broadcastPacket(msu);
activeChar.getStatus().setCurrentCp(activeChar.getMaxCp());
_name="Combat Points Restoration";
}
else if (_buff.getSkill().getSkillType() == SkillType.SUMMON)
activeChar.doCast(_buff.getSkill());
else
{
// if this buff is first buff of this category - show animation
if(_templateBuffs.getFirst()==_buff){
MagicSkillUse msu = new MagicSkillUse(activeChar, activeChar, _buff.getSkillId(), _buff.getSkillLevel(), 200, 0);
activeChar.broadcastPacket(msu);
try{
Thread.sleep(200);//is this really need?
}catch (Exception f) {}
}
// buff process :D
_buff.getSkill().getEffects(activeChar, activeChar);
}
//text part
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
if (_name.equalsIgnoreCase("")||_name==null)
sm.addSkillName(_buff.getSkill().getId());
else sm.addString(_name);
activeChar.sendPacket(sm);
sm = null;
}
else return false;
}
if(_wasInvul&&activeChar.isGM())
{
activeChar.setIsInvul(true);
_wasInvul=false;
}
return true;
}
else
return false;
}
/* (non-Javadoc)
* @see com.l2jfree.gameserver.handler.IUserCommandHandler#getUserCommandList()
*/
public String[] getVoicedCommandList()
{
return _voicedCommands;
}
}
INSERT INTO `buff_templates` VALUES ('98', 'Ww', '1204', 'Wind Walk', '2', '1', '1', '1', '80', '0', '0', '0', '1000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'sh', '1040', 'Shield', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'mi', '1068', 'Might', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'ms', '1035', 'Mental Shield', '4', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'btb', '1045', 'Bless the Body', '6', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'bts', '1048', 'Bless the Soul', '6', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'mb', '1036', 'Magic Barrier', '2', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'rs', '1259', 'Resist Shock', '4', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'dw', '1257', 'Decrease Weight', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'bers', '1062', 'Berserker Spirit', '2', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'vamp', '1268', 'Vampiric Rage', '4', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'hast', '1086', 'Haste', '2', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'gui', '1240', 'Guidance', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'foc', '1077', 'Focus', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'dea', '1242', 'Death Whisper', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'life', '1229', 'Chant of Life', '18', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'ward', '267', 'Song of Warding', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'wind', '268', 'Song of Wind', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'hunt', '269', 'Song of Hunter', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'vita', '304', 'Song of Vitality', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'venge', '305', 'Song of Vengeance', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'storm', '308', 'Song of Storm Guard', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'rene', '349', 'Song of Renewal', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'reveng', '1284', 'Chant of Revenge', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'victory', '1363', 'Chant of Victory', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'warrior', '271', 'Dance of Warrior', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'fire', '274', 'Dance of Fire', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'fury', '275', 'Dance of Fury', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'vampi', '310', 'Dance of Vampire', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'heal', '1218', 'Greater Battle Heal', '33', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'Ww11', '1204', 'Wind Walk', '2', '1', '1', '1', '80', '0', '0', '0', '1000', '0');
INSERT INTO `buff_templates` VALUES ('99', 's11h', '1040', 'Shield', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('98', 'm11i', '1068', 'Might', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'm11s', '1035', 'Mental Shield', '4', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'bt11b', '1045', 'Bless the Body', '6', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'bt11s', '1048', 'Bless the Soul', '6', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'm11b', '1036', 'Magic Barrier', '2', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'r11s', '1259', 'Resist Shock', '4', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'co11ns', '1078', 'Concentration', '6', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'd11w', '1257', 'Decrease Weight', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'be11rs', '1062', 'Berserker Spirit', '2', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'a11cu', '1085', 'Acumen', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'em11p', '1059', 'Empower', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'wa11rd', '267', 'Song of Warding', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'wi11nd', '268', 'Song of Wind', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'vi1ta', '304', 'Song of Vitality', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'ven1ge', '305', 'Song of Vengeance', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'st1orm', '308', 'Song of Storm Guard', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 're1ne', '349', 'Song of Renewal', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 're1veng', '1284', 'Chant of Revenge', '3', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'vi1ctory', '1363', 'Chant of Victory', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'mys1tic', '273', 'Dance of Mystic', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'c1once', '276', 'Dance of Concentration', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'si1ren', '365', 'Dance of Siren', '1', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
INSERT INTO `buff_templates` VALUES ('99', 'h1eal', '1218', 'Greater Battle Heal', '33', '1', '1', '1', '80', '0', '0', '0', '30000', '0');
Creditos: VaneSs11