Dulens. Posted June 19, 2012 Posted June 19, 2012 Hello, I want to add effect when someone win at casino. For example, someone won at casino I want to do something like firework. What about this line? MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0); Thanks! Quote
0 Malzahax Posted June 19, 2012 Posted June 19, 2012 Hello, I want to add effect when someone win at casino. For example, someone won at casino I want to do something like firework. What about this line? MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0); Thanks! seems fine just add after case if sucess Quote
0 Dulens. Posted June 19, 2012 Author Posted June 19, 2012 seems fine just add after case if sucess Hm, thanks but where I can find these effects? This one is just an example from another code ;3 Quote
0 SweeTs Posted June 19, 2012 Posted June 19, 2012 1050 it's id of the skill, so simply check what skill uses fireworks. Quote
0 Dulens. Posted June 19, 2012 Author Posted June 19, 2012 1050 it's id of the skill, so simply check what skill uses fireworks. So this code it's working? Thanks for your help! Quote
0 SweeTs Posted June 19, 2012 Posted June 19, 2012 So this code it's working? I have no idea, try this MagicSkillUse MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0); Anyway, here you go Casino with such effects. ### Eclipse Workspace Patch 1.0 #P aCis_gameserver Index: java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java =================================================================== --- java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java (revision 0) +++ java/net/sf/l2j/gameserver/model/actor/instance/L2CasinoInstance.java (revision 0) @@ -0,0 +1,469 @@ +package net.sf.l2j.gameserver.model.actor.instance; + +import javolution.text.TextBuilder; + +import net.sf.l2j.gameserver.ai.CtrlIntention; +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; +import net.sf.l2j.gameserver.network.serverpackets.SetupGauge; +import net.sf.l2j.gameserver.network.serverpackets.SocialAction; +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate; +import net.sf.l2j.gameserver.ThreadPoolManager; +import net.sf.l2j.gameserver.util.Broadcast; +import net.sf.l2j.util.Rnd; + +public class L2CasinoInstance extends L2NpcInstance +{ + public String filename; + + public L2CasinoInstance(int objectId, L2NpcTemplate template) + { + super(objectId, template); + } + + @Override + public void onBypassFeedback(L2PcInstance player, String command) + { + if(player == null) + return; + + if(command.startsWith("play1") && player.getInventory().getInventoryItemCount(9142, 0) >= 2) + Casino1(player); + if(command.startsWith("play2") && player.getInventory().getInventoryItemCount(9142, 0) >= 4) + Casino2(player); + if(command.startsWith("play3") && player.getInventory().getInventoryItemCount(9142, 0) >= 8) + Casino3(player); + if(command.startsWith("play4") && player.getInventory().getInventoryItemCount(9142, 0) >= 16) + Casino4(player); + if(command.startsWith("play5") && player.getInventory().getInventoryItemCount(57, 0) >= 500000) + Casino5(player); + if(command.startsWith("play6") && player.getInventory().getInventoryItemCount(57, 0) >= 1000000) + Casino6(player); + if(command.startsWith("play7") && player.getInventory().getInventoryItemCount(57, 0) >= 10000000) + Casino7(player); + } + + public static void displayCongrats(L2PcInstance player) + { + player.broadcastPacket(new SocialAction(player, 3)); + MagicSkillUse MSU = new MagicSkillUse(player, player, 2024, 1, 1, 0); + player.broadcastPacket(MSU); + player.sendMessage("Congratulations! you won"); + } + + @Override + public void showChatWindow(L2PcInstance player, int val) + { + filename = (getHtmlPath(getNpcId(), val)); + NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId()); + msg.setHtml(casinoWindow(player)); + msg.replace("%objectId%", String.valueOf(this.getObjectId())); + player.sendPacket(msg); + } + + private String casinoWindow(L2PcInstance player) + { + TextBuilder tb = new TextBuilder(); + tb.append("<html><title>Casino Manager</title><body>"); + tb.append("<center>"); + tb.append("<br>"); + tb.append("<font color=\"999999\">Chance to win : 50%</font><br>"); + tb.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>"); + tb.append("Welcome "+player.getName()+"<br>"); + tb.append("<tr><td>Double or Nothing ?</td></tr><br>"); + tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>"); + tb.append("<center>"); + tb.append("Place your bets"); + tb.append("</center>"); + tb.append("<img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br>"); + tb.append("<br>"); + tb.append("<center>"); + tb.append("<tr>"); + tb.append("<td><button value=\"2 Apiga\" action=\"bypass -h npc_%objectId%_play1\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("<td><button value=\"4 Apiga\" action=\"bypass -h npc_%objectId%_play2\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("</tr>"); + tb.append("<tr>"); + tb.append("<td><button value=\"8 Apiga\" action=\"bypass -h npc_%objectId%_play3\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("<td><button value=\"16 Apiga\" action=\"bypass -h npc_%objectId%_play4\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("</tr>"); + tb.append("<tr>"); + tb.append("<td><button value=\"500k\" action=\"bypass -h npc_%objectId%_play5\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("<td><button value=\"1kk\" action=\"bypass -h npc_%objectId%_play6\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("</tr>"); + tb.append("<tr>"); + tb.append("<td><button value=\"10kk\" action=\"bypass -h npc_%objectId%_play7\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21></td>"); + tb.append("</tr>"); + tb.append("</center>"); + tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\">"); + tb.append("</body></html>"); + return tb.toString(); + } + + public static void Casino1(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino1 ef = new Casino1(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino1 implements Runnable + { + private L2PcInstance _player; + Casino1(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(2); + + if(_player.getInventory().getInventoryItemCount(9142, 0) >= 2) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 9142, 2, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 2, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino2(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino2 ef = new Casino2(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino2 implements Runnable + { + private L2PcInstance _player; + Casino2(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(3); + + if(_player.getInventory().getInventoryItemCount(9142, 0) >= 4) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 9142, 4, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null); + } + if(chance == 2) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 4, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino3(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino3 ef = new Casino3(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino3 implements Runnable + { + private L2PcInstance _player; + Casino3(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(3); + + if(_player.getInventory().getInventoryItemCount(9142, 0) >= 8) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 9142, 8, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null); + } + if(chance == 2) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 8, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino4(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino4 ef = new Casino4(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino4 implements Runnable + { + private L2PcInstance _player; + Casino4(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(3); + + if(_player.getInventory().getInventoryItemCount(9142, 0) >= 16) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 9142, 16, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null); + } + if(chance == 2) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 9142, 16, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino5(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino5 ef = new Casino5(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino5 implements Runnable + { + private L2PcInstance _player; + Casino5(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(2); + + if(_player.getInventory().getInventoryItemCount(57, 0) >= 500000) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 57, 500000, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 57, 500000, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino6(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino6 ef = new Casino6(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino6 implements Runnable + { + private L2PcInstance _player; + Casino6(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(3); + + if(_player.getInventory().getInventoryItemCount(57, 0) >= 1000000) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 57, 1000000, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null); + } + if(chance == 2) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 57, 1000000, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } + + public static void Casino7(L2PcInstance player) + { + int unstuckTimer = 1000; + player.setTarget(player); + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); + player.disableAllSkills(); + MagicSkillUse msk = new MagicSkillUse(player, 361, 1, unstuckTimer, 0); + Broadcast.toSelfAndKnownPlayersInRadius(player, msk, 810000); + SetupGauge sg = new SetupGauge(0, unstuckTimer); + player.sendPacket(sg); + + Casino7 ef = new Casino7(player); + ThreadPoolManager.getInstance().scheduleGeneral(ef, unstuckTimer); + } + + static class Casino7 implements Runnable + { + private L2PcInstance _player; + Casino7(L2PcInstance player) + { + _player = player; + } + public void run() + { + if(_player.isDead()) + return; + + _player.setIsIn7sDungeon(false); + _player.enableAllSkills(); + int chance = Rnd.get(3); + + if(_player.getInventory().getInventoryItemCount(57, 0) >= 10000000) + { + if(chance == 0) + { + displayCongrats(_player); + _player.getInventory().addItem("Adena", 57, 10000000, _player, null); + } + if(chance == 1) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null); + } + if(chance == 2) + { + _player.sendMessage("You lost the bet"); + _player.getInventory().destroyItemByItemId("Adena", 57, 10000000, _player, null); + } + } + else + _player.sendMessage("You do not have eneough items."); + } + } +} \ No newline at end of file Quote
0 Dulens. Posted June 19, 2012 Author Posted June 19, 2012 Oh, thanks for your casino code! I will test it soon, and I will give feedback. Again, thanks dude! d: Quote
0 Rizlaaa Posted June 26, 2012 Posted June 26, 2012 MagicSkillUser msk = new MagicSkillUser(activeChar, 1050, 1, teleportTimer, 0); Forgot to say that this line only creates the packet , then you must send it to the player also , so you will have to add one more line to work fine. activeChar.sendPacket(msk); Quote
0 Dulens. Posted June 26, 2012 Author Posted June 26, 2012 Yes, I saw another casino in l2jfrozen with MagicSkillUser and works fine. Thanks everyone! Quote
Question
Dulens.
Hello, I want to add effect when someone win at casino.
For example, someone won at casino I want to do something like firework.
What about this line?
Thanks!
8 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.