EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Quests (https://www.eqemulator.org/forums/forumdisplay.php?f=624)
-   -   Casino Quest (https://www.eqemulator.org/forums/showthread.php?t=15511)

jimbox114 08-24-2004 06:45 AM

Casino Quest
 
Was just wondering if anybody has ever tried to write a quest that would be similar to the Shadowhaven Casino quest from live?

Cisyouc 08-24-2004 07:02 AM

Nah, but it would be pretty easy to write =)

Cisyouc 08-24-2004 07:37 AM

You know what.. im bored, so...

Here is something I just created. It requires the NPC to have 'qglobal' set to '1' in `npc_types` and it requires you to change the item IDs. You can easily add more and you can easily increase and decreate the chances.

This code has not been tested.
Code:

#1000 is used for the coin to play
#1001-1011 Rewards
#1021 Reward Ticket
#1022 Lesser Prize
#######################
#perlQuest by Cisyouc
#Please do not remove this header
#EQEMulator.net
#NPCID: 000000
#Usage: Casino
#Quest: King's Court
#######################

sub EVENT_SAY
{
if($text=~/hail/i)
  {
  quest::say("Hail, $name! To play the King`s Court, hand me a token to begin!");
  }
}
sub EVENT_ITEM
  {
  if($itemcount{1000} == 1)
    {
    $playing = (int(rand(80));
    if($playing == 80)
      {
      quest::say("Congrats! Here is a reward ticket! Hand this to me when you want your reward!");
      quest::summonitem(1021);
      }
    if($playing <= 20)
      {
      quest::say("You've won a lesser prize!");
      quest::summonitem(1022);
      }
      else
      {
      quest::say("Sorry! Not a winner! Please play again.")l
      }
    }
if($itemcount{1021} == 1)
  {
  if($casinoprize == 0)
    {
    quest::setglobal("casinoprize","1001","1","C999999");
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1002","1","C999999");
    }
  if($casinoprize == 1002)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1003","1","C999999");
    }
  if($casinoprize == 1003)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1004","1","C999999");
    }
  if($casinoprize == 1004)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1005","1","C999999");
    }
  if($casinoprize == 1005)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1006","1","C999999");
    }
  if($casinoprize == 1006)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1007","1","C999999");
    }
  if($casinoprize == 1007)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1008","1","C999999");
    }
  if($casinoprize == 1008)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1009","1","C999999");
    }
  if($casinoprize == 1009)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1010","1","C999999");
    }
  if($casinoprize == 1010)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","1011","1","C999999");
    }
  if($casinoprize == 1011)
    {
    quest::say("Congrats! A reward ticket! Here is your reward, you lucky one!");
    quest::summonitem($casinoprize);
    quest::setglobal("casinoprize","0","1","C999999");
    }
  }
}


Charmy 08-28-2004 06:41 AM

This quest looks good, but you made one mistake, a mistake that will force the same outcome each time the script is run. so no matter what, it will be almost impossible to get 80.

You didn't seed your random number generator, without seeding the generator the random outcome isn't really random at all, it comes out the same time each time it picks.

ex. a six sided die is rolled (int(rand(6)) 10 times, the outcome is

6
1
4
2
4
5
3
3
4
1

and if i run the script again guess what i get ?

6
1
4
2
4
5
3
3
4
1

so what you need to do is at the beginning of the script put in the line

srand($time|$$) this will put a number in the seeder based on the current server time making the number truly random.


All times are GMT -4. The time now is 09:05 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.