Page 1 of 1 1
Topic Options
#53202 - 2001-01-15 11:37 PM Another KiX Game - DopeWars
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia

Hi all,

I have this on my Palm Pilot and thought I might make a KiX version. It is a little cut down (I am getting lazy in my old age), but it plays.

I copied some of the source code from the Palm version too, thanks Matthew Lee.

Basically, you are a drug dealer... you Jet around selling and buying dope. The prices vary and you want to make at least $1M in 30 days.

I haven't got around to the cops yet, so you have to finish the game the slow way. Each time you Jet, you lose a day - only have 30 days.

You can upgrade your coat to hold more drugs and don't forget to pay back the Loan Shark or else he'll send his thugs after you.

This should be mostly bug free :)

enjoy,

cj

code:

break on
$=setascii("on")
srnd(val(substr("@time",7,2)))

cls

color w+/n
"DopeWars Version 1.0" ?
"by cj" ? ?
color w/n
"Based on Drug Wars by John E. Dell"
at(21,0)
"Press Any Key"
?
;get$


; Setup vars
$location=""
$time=30
dim $qty[9]
dim $drugs[9]
$i=1 do $qty[$i]=0 $i=$i+1 until $i=9 ; reset quantities to 0
$startcash=2000
$cash=$startcash
$debt=5500
$savings=0
$coat=0
$coatmax=100
$hard=5 ; difficulty level, max=10
$bLoaned=0
$jet=0
$location="Bronx"

gosub randomise

goto main

:jet
cls
color w/n
box(1, 1, 20, 21, single)
at( 3, 3) "Where to, dude?"
at( 6, 4) "Bron" color w+/n "x"
at( 7, 4) "G" color w/n "hetto"
at( 8, 4) color w+/n "C" color w/n "entral Park"
at( 9, 4) color w+/n "M" color w/n "anhattan"
at(10, 4) "Coney " color w+/n "I" color w/n "sland"
at(11, 4) color w+/n "B" color w/n "rooklyn"
at(14, 3) "Current Location"
at(15, 3) color w+/n "$location" color w/n
at(18, 3) "ESC = Cancel trip"
at(23,1)
get $where
if $where=chr(224) get $where endif
$where=ucase($where)
select
case $where="X" $location="Bronx"
case $where="G" $location="Ghetto"
case $where="C" $location="Central Park"
case $where="M" $location="Manhattan"
case $where="I" $location="Coney Island"
case $where="B" $location="Brooklyn"
case $where=chr(27) return
case 1 goto jet
endselect
return

:screen
cls
color w/n
; draw drugs box
box(1, 1, 20, 39, single)
box(3, 3, 12, 25, single)
box(3, 9, 12, 17, single)
at( 3, 9) chr(194)
at(12, 9) chr(193)
at( 3, 17) chr(194)
at(12, 17) chr(193)
; update static info
at( 4, 10) "Acid"
at( 5, 10) "Cocaine"
at( 6, 10) "Ludes"
at( 7, 10) "PCP"
at( 8, 10) "Heroin"
at( 9, 10) "Weed"
at(10, 10) "Shrooms"
at(11, 10) "Speed"
at( 4, 28) "Cash"
at( 8, 28) "Debt"
at(12, 28) "Savings"
at(16, 28) "Coat"
at(16, 3) color w+/n "S" color w/n "ell " color w+/n "J" color w/n "et " color w+/n "B" color w/n "uy"
at(18, 3) color w+/n "Q" color w/n "uit"
; update dynamic info
at(14, 3) "Time remaining: "color w+/n "$time" color w/n " days"
at( 2, 7) color w+/n "$location "
; display current quantities
$i=1 do at($i+3, 4) $qty[$i] at($i+3, 18) " " at($i+3, 18) $t=$drugs[$i] if $t=0 " -" else "$$$t" endif $i=$i+1 until $i=9

if $jet=1
gosub randomevent
$i=1 do at($i+3, 4) $qty[$i] at($i+3, 18) " " at($i+3, 18) $t=$drugs[$i] if $t=0 " -" else "$$$t" endif $i=$i+1 until $i=9
endif
color w+/n
at( 5, 28) "$$$cash "
at( 9, 28) "$$$debt "
at(13, 28) "$$$savings "
at(17, 28) "$coat/$coatmax"

color w/n
if ($jet=1) and ($location="Bronx") ; the Bank and Loan Shark is at the Bronx
gosub loanshark
gosub bank
endif

:getwhat ; -----------------------------------------------------------------------------------------<<<<<<<<
get $what
$what=ucase($what)
select
case $what="S" ; sell
gosub highlight
at(16, 3) " "
at(16, 3) "Select drug to sell :"
gosub choosedrug
if $a<>"Q"
gosub sellcalc
$jet=0
endif
case $what="B" ; buy
gosub highlight
at(16, 3) " "
at(16, 3) "Select drug to buy :"
gosub choosedrug
if $a<>"Q"
gosub buycalc
$jet=0
endif

case $what="J" ; Jet to new location
$was=$location
$jet=0
gosub jet
if $location<>$was ; you have chosen a new location
$jet=1
$bLoaned=0
if $time=1 goto gameover endif ; time's up
$time=$time-1 ; a day has passed
gosub randomise ; the prices have changed
gosub interest ; you have earned interest
endif
case $what="Q" at(23,1) quit
case 1 goto getwhat
endselect

return

:randomevent
$i=0
do
$eventnum=rnd(16)+1 ; select event at random
select
case $eventnum=1 $message="The cops just did a big Cocaine bust! Prices are sky-high!" $affected=2 $affect="*10"
case $eventnum=2 $message="The cops just did a big Ludes bust! Prices are sky-high!" $affected=3 $affect="*10"
case $eventnum=3 $message="The cops just did a big PCP bust! Prices are sky-high!" $affected=4 $affect="*10"
case $eventnum=4 $message="The cops just did a big Heroin bust! Prices are sky-high!" $affected=5 $affect="*10"
case $eventnum=5 $message="The cops just did a big Weed bust! Prices are sky-high!" $affected=6 $affect="*10"
case $eventnum=6 $message="The cops just did a big Speed bust! Prices are sky-high!" $affected=8 $affect="*10"
case $eventnum=7 $message=" The market has been flooded with cheap home-made Acid!" $affected=1 $affect="/5"
case $eventnum=8 $message=" Addicts are buying Cocaine at outrageous prices!" $affected=2 $affect="/5"
case $eventnum=9 $message=" A gang raided a local pharmacy and are selling cheap Ludes!" $affected=3 $affect="/5"
case $eventnum=10 $message=" Addicts are buying PCP at outrageous prices!" $affected=4 $affect="/5"
case $eventnum=11 $message=" Addicts are buying Heroin at outrageous prices!" $affected=5 $affect="/5"
case $eventnum=12 $message="Columbians dusted the Coast Guard, weed prices bottomed out!" $affected=6 $affect="/5"
case $eventnum=13 $message=" Addicts are buying Shrooms at outrageous prices!" $affected=7 $affect="/5"
case $eventnum=14 $message=" Addicts are buying Speed at outrageous prices!" $affected=8 $affect="/5"
case $eventnum=15 $message="You found some Acid on a dead dude in the subway!" $affected=1 $affect="" $extra=rnd(10)
case $eventnum=16 $message="You found some Cocaine on a dead dude in the subway!" $affected=2 $affect="" $extra=rnd(10)
case $eventnum=17 $message="You found some PCP on a dead dude in the subway!" $affected=4 $affect="" $extra=rnd(10)
endselect
if len($affect)>0
$amount=$drugs[$affected]
if $amount<>0 ; if the drug exists here
$exec="$$newamount=($amount" + "$affect)"
$=execute($exec)
$drugs[$affected]=$newamount
else
goto eventdone
endif
else
$space=$coatmax-$coat if $extra>$space $extra=$space endif
$amount=$qty[$affected]
$qty[$affected]=$amount+$extra
$coat=$coat+$extra
endif

color w+/n
at(22,1) "$message" ; write message
get$ ; get key
at(22,1) $j=0 do " " $j=$j+1 until $j=len($message) ; clear message

$i=$i+1
until $i=1 ; <-- runs this many times

if rnd(10)=1 ; 1 in 10 of coat upgrade
at(22,1) "Do you want to upgrade your coat for $100?"
get $a
if $a="y"
if $cash<100
at(22,1) " "
at(22,1) "You do not have enough cash."
get$
else
$cash=$cash-100
$coatmax=$coatmax+100
endif
at(22,1) " "
endif
endif

:eventdone
return

:loanshark
at(16, 3) " " at(16, 3) "Vist the Loan Shark?"
at(18, 3) " " at(18, 3) color w+/n "Y" color w/n "es " color w+/n "N" color w/n "o " color w+/n "Q" color w/n "uit"
get $a
if $a="q" at(23,1) quit endif
if $a="y"
:loansharkmenu
at(16, 3) " " at(16, 3) if ($debt>0) and ($cash>0) color w+/n "R" color w/n "epay " endif
if $bLoaned=0 color w+/n "B" color w/n "orrow " endif color w+/n "D" color w/n "one"
at(18, 3) " " at(18, 3) color w+/n "Q" color w/n "uit"
get $a
if $a="q" at(23,1) quit endif if $a="d" goto loansharkdone endif
if $a="b" ; borrow
if $bLoaned=1 at(16, 3) " " at(16, 3) "Borrowed enough today" get$ goto loansharkmenu endif
:loansharkborrow
at(16, 3) " " at(16, 3) "How much? $$" gets $newloan $newloan=val($newloan)
if $newloan>$cash*30 at(16, 3) " " at(16, 3) "Too much, max $$" $cash*30 " " get$ goto loansharkborrow endif
$cash=$cash+$newloan $debt=$debt+$newloan $bLoaned=1 color w+/n at( 5, 28) "$$$cash " at( 9, 28) "$$$debt " color w/n
endif
if $a="r" ; repay
:loansharkrepay
at(16, 3) " " at(16, 3) "How much? $$" gets $repay $repay=val($repay)
if $repay>$cash at(16, 3) " " at(16, 3) "You don't have enough $$" get$ goto loansharkrepay endif
$cash=$cash-$repay $debt=$debt-$repay if $debt<1 $debt=0 endif $bLoaned=0 color w+/n at( 5, 28) "$$$cash " at( 9, 28) "$$$debt " color w/n
endif
endif
:loansharkdone
at(16, 3) " " at(16, 3) color w+/n "S" color w/n "ell " color w+/n "J" color w/n "et " color w+/n "B" color w/n "uy"
return

:bank
at(16, 3) " " at(16, 3) "Vist the Bank?"
get $a
if $a="q" at(23,1) quit endif
if $a="y"
at(16, 3) " " at(16, 3) if $cash>0 color w/n "D" color w+/n "e" color w/n "posit " endif
if $savings>0 color w+/n "W" color w/n "ithdraw " endif color w+/n "D" color w/n "one"
at(18, 3) " " at(18, 3) color w+/n "Q" color w/n "uit"
get $a
if $a="q" at(23,1) quit endif if $a="d" goto bankdone endif
if $a="w" ; withdraw
:bankwithdraw
at(16, 3) " " at(16, 3) "How much? $$" gets $withdraw $withdraw=val($withdraw)
if $withdraw>$savings at(16, 3) " " at(16, 3) "Too much, max $$$savings " get$ goto bankwithdraw endif
$cash=$cash+$withdraw $savings=$savings-$withdraw color w+/n at( 5, 28) "$$$cash " at(13, 28) "$$$savings " color w/n
endif
if $a="e" ; dEposit
:bankdeposit
at(16, 3) " " at(16, 3) "How much? $$" gets $deposit $deposit=val($deposit)
if $deposit>$cash at(16, 3) " " at(16, 3) "You don't have enough $$" get$ goto bankdeposit endif
$cash=$cash-$deposit $savings=$savings+$deposit color w+/n at( 5, 28) "$$$cash " at(13, 28) "$$$savings " color w/n endif
endif
:bankdone
at(16, 3) " " at(16, 3) color w+/n "S" color w/n "ell " color w+/n "J" color w/n "et " color w+/n "B" color w/n "uy"
return


:highlight ; only highlight if there are some for sale
$t=$drugs[1] if $t<>0 at( 4, 10) color w+/n "A" color w/n "cid" endif
$t=$drugs[2] if $t<>0 at( 5, 10) color w+/n "C" color w/n "ocaine" endif
$t=$drugs[3] if $t<>0 at( 6, 10) color w+/n "L" color w/n "udes" endif
$t=$drugs[4] if $t<>0 at( 7, 10) color w+/n "P" color w/n "CP" endif
$t=$drugs[5] if $t<>0 at( 8, 10) color w+/n "H" color w/n "eroin" endif
$t=$drugs[6] if $t<>0 at( 9, 10) color w+/n "W" color w/n "eed" endif
$t=$drugs[7] if $t<>0 at(10, 10) color w+/n "S" color w/n "hrooms" endif
$t=$drugs[8] if $t<>0 at(11, 10) "Spee" color w+/n "d" color w/n endif
return

:choosedrug
$a="" $c=0
do
get $a
select
case $a="A" $c=1
case $a="C" $c=2
case $a="L" $c=3
case $a="P" $c=4
case $a="H" $c=5
case $a="W" $c=6
case $a="S" $c=7
case $a="D" $c=8
case $a="Q" $c=0
case 1 $a=""
endselect
if $c<>0 $t=$drugs[$c] if $t=0 $a="" endif endif ; check that there is some
until $a<>""
return

:buycalc
; buying calculator
$a="" $h="" ; $c=drug number
do
at(18, 3) " "
at(18, 3) color w+/n "Q" color w/n "uit " color w+/n "M" color w/n "aximum"
at(16, 3) " "
at(16, 3) "Enter quantity :"
gets $h
select
case $h="M" ; maximum
$t=$drugs[$c] $max=$cash/$t
if $max>$coatmax $max=$coatmax endif
$space=$coatmax-$coat
if $max>$space $max=$space endif
$have=$qty[$c] $qty[$c]=$have+$max $coat=$coat+$max
$spent=$max*$t $cash=$cash-$spent
$a=" "
case $h="Q" ; quit buy
$a=" "
case 1 ; other amount
$h=val($h)
if $h<>0
$t=$drugs[$c]
$spent=$h*$t
if $spent<$cash
$space=$coatmax-$coat
if $h<$space
$have=$qty[$c] $qty[$c]=$have+$h
$coat=$coat+$h
$cash=$cash-$spent
$a=" "
else
at(16, 3) " "
at(16, 3) "Not enough coat space"
get$
endif
else
at(16, 3) " "
at(16, 3) "Not enough cash."
get$
endif
endif
endselect
until $a<>""
return

:sellcalc
; selling calculator
$a="" $h="" ; $c=drug number
do
$t=$qty[$c] ; $t=price of selected drug
if $t=0
at(16, 3) " "
at(16, 3) "You don't have any"
get$
goto selldone
else
at(18, 3) " "
at(18, 3) color w+/n "Q" color w/n "uit " color w+/n "M" color w/n "aximum"
at(16, 3) " "
at(16, 3) "Enter quantity :"
gets $h
select
case $h="M" ; maximum
$t=$drugs[$c]
$max=$qty[$c] ; $max=what you got
$cash=$cash+($t*$max)
$qty[$c]=0 $coat=$coat-$max
$a=" "
case $h="Q" ; quit buy
$a=" "

case 1 ; other amount
$h=val($h)
if $h<>0
$t=$drugs[$c]
$have=$qty[$c] ; $have=what you got
if $h<$have+1
$qty[$c]=$have-$h
$coat=$coat-$h
$cash=$cash+($t*$h)
$a=" "
else
at(16, 3) " "
at(16, 3) "You don't have enough"
get$
endif
endif
endselect
endif
until $a<>""
:selldone
return


:randomise
; set drugs prices
; some of this code is converted from the DopeWars Palm Pilot version C++ code by Matthew Lee
$drugs[1]=1000 +rnd(3500)
$drugs[2]=15000+rnd(15000)
$drugs[3]=10 +rnd(50)
$drugs[4]=1000 +rnd(2500)
$drugs[5]=5000 +rnd(9000)
$drugs[6]=300 +rnd(600)
$drugs[7]=600 +rnd(750)
$drugs[8]=70 +rnd(180)

$i=1
do
$drugs[rnd(7)]=0
$i=$i+1
until $i=$hard

return

:interest
; calculate interest on loans and bank
$savings=$savings+(($savings*625)/10000) ; 6.25%
$debt=$debt+(($debt*125)/1000) ; 12.5%
return

:drugs
color w/n
return

:gameover

cls

color w+/n
"DopeWars Version 1.0" ?
"by cj" ?
?
color w/n "Based on Drug Wars by John E. Dell" ?
?
?
"Game Over" ?
?
?
"How you did:"?
?
$total=$cash+$savings
"Total Cash: $$$total" ?
"Debt: $$$debt" ?
?
if $debt>0
"The Loan Shark's thugs broke your legs"
else
if $total>1000000
"Congradulations, you retired a millionaire in the Carribbean!"
else
if $total>$startcash
"Congradulations, you didn't do half bad!"
else
"You didn't make any money, better luck next time"
endif
endif
endif

? ?
at(23,1)

quit

:main


:again
gosub screen
goto again



Top
#53203 - 2001-01-16 12:24 AM Re: Another KiX Game - DopeWars
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
CJ

Your script dosn't work

In the code you have included:
$exec="$$newamount=($amount" + "$affect)"

But you never declare $amount or $newamount

Erik

ps.
It is the Exec() that dosn't work

[This message has been edited by kholm (edited 16 January 2001).]

Top
#53204 - 2001-01-16 12:42 AM Re: Another KiX Game - DopeWars
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
cj - did you fix it - mine seems to work ok !

[unless I haven't played to that point yet]

Shawn.

[This message has been edited by Shawn (edited 16 January 2001).]

Top
#53205 - 2001-01-16 01:01 AM Re: Another KiX Game - DopeWars
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
code:

DopeWars Version 1.0
by cj

Based on Drug Wars by John E. Dell
Game Over
How you did:

Total Cash: $364883
Debt: $0

Congradulations, you didn't do half bad!


Oh it's soo like the real world! (Or so i've been told by my dealer

With your permission I'd like to try and make a Dutch version.


------------------
Greetz,

Roger the Young
------------------------
The code is out there...
------------------------

_________________________
The Code is out there

Top
#53206 - 2001-01-16 06:15 PM Re: Another KiX Game - DopeWars
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Kolm,

$exec="$$newamount=($amount" + "$affect)"


Here is the code snippet:

code:

if len($affect)>0
$amount=$drugs[$affected]
if $amount<>0 ; if the drug exists here
$exec="$$newamount=($amount" + "$affect)"
$=execute($exec)
$drugs[$affected]=$newamount
...

if len($affect)>0

The $affect has the modifier to the price of the drug - ie *10 to increase the price or /5 to decrease it. I was going to change that to *11 so that you wouldn't notice the extra 0 appear in the price list, but never did.


$amount=$drugs[$affected]

$amount gets the current price of the affected drug: 1=Acid, 2=Coke etc


if $amount<>0 ; if the drug exists here

If the $amount is 0 then this drug is not available and you don't get the event. No point telling you that Weed is cheaper when there is no weed for sale.


$exec="$$newamount=($amount" + "$affect)"
$=execute($exec)

This is eqivalent to:
$newamount=$amount*10 or $newamount=$amount/5

but, rather than:

if $affect="*10" $newamount=$amount*10 endif
if $affect="/5" $newamount=$amount/5 endif

I did the Exec. When the exec runs, it sees:

exec("$newamount=X*10")
because the $$newamount becomes $newamount
the $amount becomes a numerical value as taken from the array $drugs
and $affect becomes "*10" or "/5"

I did this also to allow the flexability of making the *10 into *9 or *2 etc, so that you can make the price of drugs more "realistic" ie if the Columbians dusted the coast guard, the price of weed would not increase tenfold, as Canada also makes weed :P

and finally

$drugs[$affected]=$newamount

We update the $drugs array with the new price.

If you are having problems with the code, check you KiX version (I use 3.62) and put

"$$variable=$variable " get$

after every line with variable is the $variable that you are interested in monitoring. Also, try changing $= to

"EXEC code = "

before the

exec($exec)

and it will show you if any errors occur.


DrillSergeant,

go for it!


cj



Top
#53207 - 2001-01-16 07:25 PM Re: Another KiX Game - DopeWars
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Sorry CJ

The script works just fine. I must have made a mistake when saving it.

Erik

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.033 seconds in which 0.014 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org