Cuando el npc "MUSIC_MAKER" te ve, emite aleatoriamente una musica de la lista.
/*
* 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 ai.npc.TheMusicMaker;
import ai.npc.AbstractNpcAI;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.network.clientpackets.Say2;
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
/**
* The Music Maker<br>
* Dedicated to DJ_MELERIX
* @author nonom
*/
public final class TheMusicMaker extends AbstractNpcAI
{
private static final int MUSIC_MAKER = 22353; // Or whatever you want
// Pieces of Music
private static final String[] MUSICS =
{
"ssq_dusk_01",
"ssq_dawn_01",
"ssq_neutral_01",
"s_pirate",
"s_crystal",
"s_theme",
"s_tower",
"t01_f",
"t02_f",
"t03_f",
"t04_f",
"br_music_hero",
"br_music_theme_park",
"br_music_town",
"tp05_f",
"tp04_f",
"tp03_f",
"tp02_f",
"tp01_f",
"t25_s01",
"t24_s01",
"t23_s01",
"t22_s01",
"t21_s01",
"t20_s01"
};
private static final String[] PHRASES =
{
"Sounds good!",
"Listening!",
"It rocks!"
};
@Override
public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon)
{
if (creature.isPlayer())
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.NPC_ALL, npc.getName(), PHRASES[getRandom(PHRASES.length - 1)]));
npc.broadcastPacket(new PlaySound(1, MUSICS[getRandom(MUSICS.length - 1)], 0, 0, 0, 0, 0));
}
return super.onSeeCreature(npc, creature, isSummon);
}
public TheMusicMaker()
{
super(TheMusicMaker.class.getSimpleName(), "ai/npc");
addKillId(MUSIC_MAKER);
addSeeCreatureId(MUSIC_MAKER);
}
public static void main(String[] args)
{
new TheMusicMaker();
}
}