#50368 - 2000-06-29 01:40 AM
Re: Compiler / formatter for Kix-scripts
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Still getting new ideas !CJ - If you read this, I have used your randseed function instead of inventing one myself. Encryption When Indent = 0, and KeepRemarks=N and KeepEmptyLines=N (Choices you make when executing Transform.kix) Transform.kix will enter pseudo-encryptionmode, lines can be until 30.000 characters long, each linefeed from original script is replaced by a random white space: Space, tab, or new line character. The script will be nearly impossible to read if it is not too small. You can still read the script, but average users will not be able to understand the script, and it will take a lot of effort to recreate it witout the original source, at least the remarks are lost. The advantage of this form of 'encryption' is that it is time-costless when executing the script. I have changed the original post, first in this topic, again ! (Top of this page) As an example i include CJ's Battle ships in 'encrypted' form Original script: 2nd KiX game ever!! Size before Compress/encrypt : 13,728 bytes Size after Compress/encrypt : 9,823 bytes
code:
break on $=setascii(on) $seed=val(substr("@time",7,2)) $seed=$seed+1 do $=rnd(1) $seed=$seed-1 until $seed=0 dim $boat[5] dim $name dim $nameA[8] dim $grid[100] dim $boatlen[5] dim $boathit[5] dim $g dim $gy dim $gx dim $ship1[7] dim $ship2[7] dim $ship3[7] $boat[0]="Frigate " $boatlen[0]=2 $boat[1]="Submarine " $boatlen[1]=3 $boat[2]="Cruiser " $boatlen[2]=3 $boat[3]="BattleShip" $boatlen[3]=4 $boat[4]="Carrier " $boatlen[4]=5 $name="Player" $last="o" $lose=0 $path=%TEMP% $random=0 $boathit[0]=0 $boathit[1]=0 $boathit[2]=0 $boathit[3]=0 $boathit[4]=0 $ship1[5]=" \ /" $ship1[6]=" \ /" $ship2[0]=" _" $ship2[1]=" __|_" $ship2[2]=" | 87 |" $ship3[5]=" \ \/ \/ / \/. / " $ship3[6]=" \ .\ \ / /. / " $ship2[3]=" ________|____|________" $ship2[4]=" / ooo -- ooo \" $ship3[3]=" | / \/ \/ | " $ship3[4]=" | \ /\ / /\ /. | " $ship2[5]=" [| -- |" $ship2[6]=" x\______________________/" $ship1[3]="_____|__|___|_____|___|__|____" $ship1[4]="\ 11 . . . . . /" $ship3[0]=" |\ | | /| " $ship3[1]=" | \/\| | | |/\/ | " $ship3[2]=" |/ \ \| |/ / | " $ship1[0]=" |" $ship1[1]=" \ \ __|__ / /" $ship1[2]=" \_\ | | /_/" $i=0 do $grid[$i]=9 $i=$i+1 until $i=100 goto MAIN :intro cls at(12,10) color b+/n "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" color w/n $y=0 do at(5+$y,17) $ship1[$y] at(16+$y,20) $ship2[$y] $y=$y+1 until $y=7 $x=20 do $y=0 do at(16+$y,$x) $ship2[$y] $y=$y+1 until $y=7 $x=$x+1 until $x=30 $y=19 do at($y+1,35) " " at(12,35) color b+/n "~" color w/n at($y,35) "!" at(19,35) "_" at(20,35) "o" at (31-$y,25) " " at(12,25) color b+/n "~" color w/n at(32-$y,25) "o" at(24,79) sleep 1 $y=$y-1 until $y=10 at(21,25) " " at(22,25) "*" $end=50 gosub burn at(22,25) " " color w/n $y=0 do at(5+$y,17) $ship3[$y] $y=$y+1 until $y=7 $end=30 gosub burn color w/n $d=0 do $y=6 at($d+11-$y,17) " " do color w/n at($d+12-$y,17) $ship3[6-$y] $y=$y-1 until $y=$d $end=10 gosub burn $d=$d+1 until $d=6 color w/n $x=30 do $y=0 do at(16+$y,$x) $ship2[$y] $y=$y+1 until $y=7 $x=$x+1 until $x=50 big color w/n at(0,0) "Battle" ? " Ships" small ? ? ? ? ? "Version 1.0" ? "by cj" ? ? ? "Press any key to begin" get$ cls return :burn $c=0 do $a=rnd(3)+8 $b=rnd(10)+27 $s1=rnd(2)+176 $s2=rnd(2)+176 $s3=rnd(2)+176 $col=rnd(2) if $col=0 color r+/n endif if $col=1 color r/n endif if $col=2 color y+/n endif at($a,$b) chr($s1) at($a-1,$b-1) chr($s2) at($a-1,$b+1) chr($s3) $c=$c+1 until $c=$end return :drawgrid $r=3 do at($r,3) "³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³" at($r+1,3) "ÃÄÄÅÄÄÅÄÄÅÄÄÅÄÄÅÄÄÅÄÄÅÄÄÅÄÄÅÄÄ´" $r=$r+2 until $r=23 at(2,3) "ÚÄÄÂÄÄÂÄÄÂÄÄÂÄÄÂÄÄÂÄÄÂÄÄÂÄÄÂÄÄ¿" at(22,3) "ÀÄÄÁÄÄÁÄÄÁÄÄÁÄÄÁÄÄÁÄÄÁÄÄÁÄÄÁÄÄÙ" color w/n at(1,4) "A B C D E F G H I J" at(1,4) $i=0 do at(3+2*$i,2) "$i" $i=$i+1 until $i=10 at(2,37) "Battleships" at(3,37) "Version 1.0" at(5,37) "Please enter your name :" $i=0 do $nameA[$i]=" " $i=$i+1 until $i=8 $i=0 do :wrong at(5,62+$i) get $a if $a=chr(13) if $i=0 $name="Chris" endif $i=8 goto leave endif if $a=chr(8) if $i>0 $i=$i-1 endif at(5,62+$i) " " endif if ((asc($a)>47) and (asc($a)<58)) or ((asc($a)>64) and (asc($a)<91)) or ((asc($a)>96) and (asc($a)<123)) at(5,62+$i) $a $nameA[$i]=$a $name="" $i=$i+1 else goto wrong endif :leave until $i=8 $i=0 do if $nameA[$i]<>" " $name=$name+$nameA[$i] endif $i=$i+1 until $i=8 at(5,37) " " at(5,37) "Welcome Commander $name." color w+/n at(7,37) "Enter co-ordinates:" color w/n return :getXY $boatname=$boat[$i] $nogo=0 select case $i=0 color b/n case $i=1 color g/n case $i=2 color c/n case $i=3 color m/n case $i=4 color y/n endselect at(8+$i,37) "$boatname : " :inputcol if $random=1 $gx=rnd(9) $gy=rnd(9) goto calc endif if $bad=0 $j=0 do at(3+2*$j,2) " " $j=$j+1 until $j=10 color w+/n at(1,4) ? color w/n else color w+/n at(9,62) "ABCDEFGHIJ" $z=0 do at(10+$z,61) " " $z=$z+1 until $z=10 endif at(8+$i,41+len($boatname)) flushkb get $c $c=ucase($c) if $c="Q" goto bye endif if $c="R" $random=1 $gx=rnd(9) $gy=rnd(9) goto calc else $random=0 endif if (asc($c)>64) and (asc($c)<75) at(8+$i,41+len($boatname)) "$c" else goto inputcol endif :inputrow if $bad=0 at(1,4) " " color w+/n $j=0 do at(3+2*$j,2) "$j" $j=$j+1 until $j=10 color w/n else at(9,62) " " color w+/n $z=0 do at(10+$z,61) "$z" $z=$z+1 until $z=10 endif at(8+$i,42+len($boatname)) flushkb get $r if $r="q" goto bye endif if (asc($r)>47) and (asc($r)<58) at(8+$i,42+len($boatname)) "$r" else goto inputrow endif $gx=asc($c)-65 $gy=asc($r)-48 :calc $x=(2*$gx)+($gx+4) $y=(2*$gy)+3 $g=($gy*10)+$gx if $bad=0 color w/n at(1,4) "A B C D E F G H I J" color w/n at(1,4) $j=0 do at(3+2*$j,2) "$j" $j=$j+1 until $j=10 else color w/n at(9,62) "ABCDEFGHIJ" $z=0 do at(10+$z,61) "$z" $z=$z+1 until $z=10 endif return :checkgrid $gn=$grid[$g] if $gn=9 else at(8+$i,41+len($boatname)) " " $nogo=1 goto out endif $b=$boatlen[$i] $by1=9-$b+1 $by2=0+$b-1 $ra="M" $da="P" $la="K" $ua="H" if $gx>($by1) $ra="" endif if $gx<($by2) $la="" endif if $gy>($by1) $da="" endif if $gy<($by2) $ua="" endif $j=1 $c=" " $rc="9" $dc="9" $lc="9" $uc="9" do if $ra<>"" $rc=$grid[$g+$j] endif if $da<>"" $dc=$grid[$g+($j*10)] endif if $la<>"" $lc=$grid[$g-$j] endif if $ua<>"" $uc=$grid[$g-($j*10)] endif if $rc<>9 $ra="" endif if $dc<>9 $da="" endif if $lc<>9 $la="" endif if $uc<>9 $ua="" endif $j=$j+1 until $j=$boatlen[$i] $avail=$ra+$da+$la+$ua if len($avail)=0 $nogo=1 color r+/n at(14,37) "Ship will not fit here" color w/n goto out else at(14,37) " " endif color w/n at(8+$i,44+len($boatname)) if $random=0 if $ra<>"" chr(16) " " endif if $da<>"" chr(31) " " endif if $la<>"" chr(17) " " endif if $ua<>"" chr(30) " " endif endif :getway if $random=0 get $way else $rndch=rnd(3) if $rndch=0 $way="M" endif if $rndch=1 $way="P" endif if $rndch=2 $way="K" endif if $rndch=3 $way="H" endif endif if $way="q" goto bye endif if instr($avail,$way) else goto getway endif if ($way="M") or ($way="K") $t=(($boatlen[$i]-1)*3)+2 $k=0 endif if ($way="P") or ($way="H") $t=($boatlen[$i]*2)-1 $k=0 endif select case $i=0 color b/n case $i=1 color g/n case $i=2 color c/n case $i=3 color m/n case $i=4 color y/n endselect do if $way="M" at($y,$x+$k) chr(219) endif if $way="P" at($y+$k,$x) chr(219) chr(219) endif if $way="K" at($y,$x-($k-1)) chr(219) endif if $way="H" at($y-$k,$x) chr(219) chr(219) endif $k=$k+1 until $k=$t color w/n $j=0 do $grid[$g]=$i if $way="M" $g=$g+1 endif if $way="P" $g=$g+10 endif if $way="K" $g=$g-1 endif if $way="H" $g=$g-10 endif $j=$j+1 until $j=$boatlen[$i] :out return :debug at(13,41) color w/n $y=0 $d=" " do $x=0 do at(13+$y,41+$x) $g=($y*10)+$x if $grid[$g]=9 $grid[$g] else "." endif $x=$x+1 until $x=10 $y=$y+1 until $y=10 return :status $i=0 $lose=1 do at(8+$i,51) if $boathit[$i]=0 at(8+$i,51) color g+/n "100%" $lose=0 endif if ($boathit[$i]>0) and ($boathit[$i]<$boatlen[$i]) $p=100-(($boathit[$i]*100)/$boatlen[$i]) color y+/n "$p% " $lose=0 endif if $boathit[$i]=$boatlen[$i] color r+/n "Lost" endif $i=$i+1 until $i=5 color w/n return :checkhit $gn=$grid[$g] $last="o" if $gn<>9 if $gn<>8 $boathit[$gn]=$boathit[$gn]+1 $last="X" endif $grid[$g]=8 color r+/n else color w/n endif at($y,$x) chr(178) chr(178) color w/n return :badguy color r+/n at(7,61) "$badguy" color w/n box(8,60,20,72,single) at(9,62) "ABCDEFGHIJ" $y=0 do at(10+$y,61) "$y" $x=0 do at(10+$y,62+$x)"." $x=$x+1 until $x=10 $y=$y+1 until $y=10 return :blowmeup $gx=rnd(9) $gy=rnd(9) $x=(2*$gx)+($gx+4) $y=(2*$gy)+3 $g=(10*$gy)+$gx gosub checkhit return :showbad if $mark="X" color r+/n else color w+/n endif at(10+$gy,62+$gx)"$mark" color w/n return :sendattack $=open(1,"$path\$name.txt",5) $out=$last+chr(13)+chr(10) $=writeline(1,$out) $out=chr($gx+65)+","+chr($gy+48) $=writeline(1,$out) $=close(1) return :getattack $r=exist("$path\$badguy.txt") if $r=0 sleep 1 goto getattack endif sleep 1 $=open(1,"$path\$badguy.txt") $in1=readline(1) if $in1="lose" color g+/n at(17,37) "You Won!" goto bye endif $in2=readline(1) $=close(1) del "$path\$badguy.txt" return :gameON del "$path\$name.txt" $r=open(1,"$path\game.txt") if $r=2 $create=1 $=open(1,"$path\game.txt",5) $=writeline(1,$name) $=close(1) :getreply $r=open(1,"$path\reply.txt") if $r=2 sleep 1 goto getreply endif $badguy=readline(1) $=close(1) del "$path\reply.txt" else $create=0 $badguy=readline(1) $=close(1) del "$path\game.txt" $=open(1,"$path\reply.txt",5) $=writeline(1,$name) $=close(1) endif return :bye $last="lose" gosub sendattack del "$path\$badguy.txt" at(22,0) color w+/n "Bye!" ? quit :MAIN gosub intro gosub drawgrid $i=0 $r=" " $c=" " $g=0 do :getagain $bad=0 gosub getXY gosub checkgrid if $nogo=1 goto getagain endif at(8+$i,41+len($boatname)) " " $i=$i+1 until $i=5 $random=0 color w+/n at(15,37) "Looking for player" gosub gameON at(7,37) "Ship Status " gosub badguy :shoot gosub status if $lose=1 $last="lose" gosub sendattack color r+/n at(17,37) "You lost!" goto bye endif if $create=0 goto waitnow endif color w+/n at(15,37) "Enter attack: " $i=7 $bad=1 $random=0 gosub inputcol $mark="?" gosub showbad color w/n at(15,37) "Processing... " gosub sendattack :waitnow $create=1 gosub getattack $mark=$in1 gosub showbad $gxc=substr($in2,1,1) $gyc=substr($in2,3,1) $gx=asc($gxc)-65 $gy=asc($gyc)-48 $x=(2*$gx)+($gx+4) $y=(2*$gy)+3 $g=(10*$gy)+$gx gosub checkhit goto shoot
Compressed/encrypted script still working without decryption !Logfile for transform of Battle ships script: T R A N S F O R M L O G Inputfile : Battle Outputfile : Battle.kix OPTIONS USED Indent : NONE Remarks removed Empty lines removed Battle.kix successfully created, no errors found.
[This message has been edited by kholm (edited 29 June 2000).]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 293 anonymous users online.
|
|
|