Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Blackjack NPC

Newbie Spellweaver
Joined
Jul 1, 2010
Messages
5
Reaction score
0
Wow, this script is so long. This could be scripted so much easier, but nonetheless blackjack is still a sick game so props to you.
 
Newbie Spellweaver
Joined
Jul 5, 2010
Messages
46
Reaction score
15
So this is basically getting 2 numbers then getting back the total? not too much special, but nice release anyways.

Basically, the dealer gets two cards. If his total is under 17, he'll automatically ask for another card. He'll then stop whenever he gets over 17. You get to see ONE of his first two cards.

Then it's your turn - you get told your total, and you decide if you want another card or not - up to a maximum of five cards (there's no limit in real blackjack, i think).
If you go over 21, you bust, and you lose your money.
Once you decide to stay, the script figures out whether the dealer busted OR, and if he did not, it checks if your total was closer to 21 than his. If his was closer, you lose, but if yours was closer, you win.

IN REAL BLACKJACK, dealer hits, you choose to hit, dealer chooses to hit/stay, you choose, instead of dealer going all at once. Couldn't figure a way to do this, so.. bleh.

I couldn't really figure out what to use - Could I use
PHP:
while (dtotal < 17) {
      dtotal = dtotal + (some array of cards..?)
}

@carrino
that was just something the NPC says if you try to bet negative money, which would mean if you won, you'd lose money.
 
Last edited:
Joined
May 23, 2010
Messages
528
Reaction score
23
This looks cool, kinda made me wanna make a "Vegas Island" or something with a bunch of gambling NPCs...hmm. I just might do that!! *runs off to do something completely unneeded* (and to learn how to spell)
 
Newbie Spellweaver
Joined
Jul 5, 2010
Messages
46
Reaction score
15
Fixed two errors, typo and was missing a brace..
Will update when I fix the DC after the betting.

This looks cool, kinda made me wanna make a "Vegas Island" or something with a bunch of gambling NPCs...hmm. I just might do that!! *runs off to do something completely unneeded* (and to learn how to spell)

I'm so making a slot machine NPC now. Just you wait.
 
Newbie Spellweaver
Joined
Jun 15, 2010
Messages
29
Reaction score
2
I'm about to steal the Vegas Island idea. Another contribute to Vegas Island, put Katy Perry, singing Waking Up in Vegas or something.
 
Newbie Spellweaver
Joined
Jul 20, 2008
Messages
8
Reaction score
0
It just disconnects after the betting confirmation window no matter how many time i try :(
 
Newbie Spellweaver
Joined
Sep 15, 2009
Messages
11
Reaction score
0
i dont know when its a bump:mellow:, but i got an error:
if (pcard2 < 11 && pcard1 = 1) {
pcard1 = 11;
}
it says syntax error
and in the bat:
Code:
28-aug-2010 10:44:44 net.sf.odinms.scripting.AbstractScriptManager getInvocable
SEVERE: Error executing script.
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorExcep
tion: Invalid assignment left-hand side. (<Unknown source>#101) in <Unknown sour
ce> at line number 101
        at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
        at javax.script.AbstractScriptEngine.eval(Unknown Source)
        at net.sf.odinms.scripting.AbstractScriptManager.getInvocable(AbstractSc
riptManager.java:53)
        at net.sf.odinms.scripting.npc.NPCScriptManager.start(NPCScriptManager.j
ava:27)
        at net.sf.odinms.net.channel.handler.NPCTalkHandler.handlePacket(NPCTalk
Handler.java:23)
        at net.sf.odinms.net.MapleServerHandler.messageReceived(MapleServerHandl
er.java:96)
        at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messa
geReceived(AbstractIoFilterChain.java:570)
        at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageR
eceived(AbstractIoFilterChain.java:299)
        at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(Abst
ractIoFilterChain.java:53)
        at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.mess
ageReceived(AbstractIoFilterChain.java:648)
        at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flus
h(SimpleProtocolDecoderOutput.java:58)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Prot
ocolCodecFilter.java:180)
        at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageR
eceived(AbstractIoFilterChain.java:299)
        at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(Abst
ractIoFilterChain.java:53)
        at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.mess
ageReceived(AbstractIoFilterChain.java:648)
        at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorF
ilter.java:220)
        at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.
run(ExecutorFilter.java:264)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnabl
e.java:51)
        at java.lang.Thread.run(Unknown Source)
can someone help me... if it isnt a bump:mellow:
 
Newbie Spellweaver
Joined
Feb 13, 2009
Messages
12
Reaction score
0
This is awesome. I enjoyed it in DoodleStory. :) Good Job, T!
 
Back
Top