Runs best on mIRC 7.19 or later. I cannot guarantee stability with older versions.
If the wasd controls are not working for you, try turning on capslock!
Current Version: 1.4
Credit to peer for suggesting the filter system.
Credit to SReject for multiple enhancement and game balancing suggestions, pasting me the $incircle identifier, and ideas for extra game additions.
Credit to BlueThen for multiple suggestions on improvements
This is a game I've been building for the last week or two. A simple zombie shooter game. This is not the completed build, but as it sits right now it is very playable, and should have minimal/no issues besides a performance issue once in a while.
Features (this is what is in the script below, NOT what is in the complete game):
Scaled difficulty: gets tougher as you kill more zombies. More zombies will spawn, they will be more likely to spawn, and after a while they get faster!
Weapons: Pistol, Machinegun (more to come)
Powerups: Health Pickup, Speedboost (more to come)
Controls:
w,a,s,d moves you around.
arrow keys shoot in a direction.
To start the game, use the command /zombies.
You can move and shoot diagonally by holding two keys at once. I know that the laser reticle doesn't align with the bullets when pointing up-right and down-left. Fix coming soon for that.
Update from last version:
6/11/13 update - Been a long time since I delved into mIRC scripting, decided to get back in with a minor update to one of my favourite smaller projects. In this update:
There is now a cap of 250 bullets allowed for the machine gun. As before, the initial pickup gives 100 bullets, and every pickup thereafter provides an extra 50. The machinegun drop is now a little less common. The previous value was about a 5% drop, it is now about 3.5% drop chance.
The end screen is changed, now instead of a solid background and words presented immediately, it creates the illusion of blood running down the screen first. The old system is still in the code, if you want to change it back comment out lines 311-12 and uncomment 313.
There is now a "Fog of War". Zombies within about 180 pixels (about 36% of the map's length) from you will show up, dark at first, then lighter as they approach. A fun little effect, provides a little more suspense and surprise. As a bonus, with large amounts of zombies, only the ones near the player need to be drawn, rather than all of them. The old system is still there, to revert to it comment out lines 284-86 and uncomment line 287. The ultimate goal with this is to get mouse-aiming working, and to have a flashlight or view cone rather than a full radius, to provide a better atmosphere (what atmosphere can be given with dots and lines, anyway).
;Zombies by IllogicTC
;Credit to peer for suggesting the filter system.
;Credit to SReject for multiple enhancement and game balancing suggestions, pasting me the $incircle identifier, and ideas for extra game additions.
;Use /zombies to start!
alias zombies {
window -CdfpdB @Zombies -1 -1 500 500
window -fpdBh @ZombiesBuf -1 -1 500 500
window -hl10 @ZBulletBuf -1 -1 300 300
window -hl10 @ZMobBuf -1 -1 300 300
hadd -m zomb player_x 250
hadd zomb player_y 250
hadd zomb player_health 100
hadd zomb player_gun pistol
hadd zomb game_ticks 0
hadd zomb last_fired 0
hadd zomb kills 0
hadd zomb maxtog 2
hadd zomb mg_ammo 0
hadd zomb rl_ammo 0
hadd zomb sg_ammo 0
hadd zomb speedboost 0
set %zomb.toggle 0
.timerzombloop -ho 1 16 zomb_mainloop
}
alias zomb_mainloop {
if ($active != @Zombies) {
.timerzombloop -ho 1 16 zomb_mainloop
return
}
hinc zomb game_ticks
var %sb = $hget(zomb,speedboost),%killget = $calc($hget(zomb,kills) * .05),%killnum = $hget(zomb,kills),%killtog = $hget(zomb,maxtog)
if (%killnum isnum 250-499) && (%killtog > 1) {
hdec zomb maxtog
var %killtog $hget(zomb,maxtog)
}
elseif (%killnum isnum 500-999) && (%killtog > 0) {
hdec zomb maxtog
var %killtog $hget(zomb,maxtog)
}
if (%zomb.toggle < %killtog) inc %zomb.toggle
else set %zomb.toggle 0
if (%sb > 0) hdec zomb speedboost
if ($calc(%killget + $rand(1,1000)) >= 990) && ($line(@ZMobBuf,0) < $floor($calc(%killget + 10))) zomb_spawn
if ($hget(zomb,move_u) == 1) && ($hget(zomb,player_y) > 5) hdec zomb player_y $iif(%sb > 0,4,2)
elseif ($hget(zomb,move_d) == 1) && ($hget(zomb,player_y) < 495) hinc zomb player_y $iif(%sb > 0,4,2)
if ($hget(zomb,move_l) == 1) && ($hget(zomb,player_x) > 5) hdec zomb player_x $iif(%sb > 0,4,2)
elseif ($hget(zomb,move_r) == 1) && ($hget(zomb,player_x) < 495) hinc zomb player_x $iif(%sb > 0,4,2)
zomb_generate
if ($hget(zomb,player_health) > 0) .timerzombloop -ho 1 16 zomb_mainloop
else zomb_GAMEOVER
}
alias zomb_spawn {
var %x $rand(1,4))
if (%x == 1) aline @ZMobBuf %zomb.toggle 5 $rand(5,495)
elseif (%x == 2) aline @ZMobBuf %zomb.toggle 495 $rand(5,495)
elseif (%x == 3) aline @ZMobBuf %zomb.toggle $rand(5,495) 5
else aline @ZMobBuf %zomb.toggle $rand(5,495) 495
}
alias zomb_generate {
set %zomb.px $hget(zomb,player_x)
set %zomb.py $hget(zomb,player_y)
var %pg = $hget(zomb,player_gun),%gt = $hget(zomb,game_ticks),%fl = $hget(zomb,firing_l),%fr = $hget(zomb,firing_r),%fu = $hget(zomb,firing_u),%fd = $hget(zomb,firing_d),%lf = $hget(zomb,last_fired),%sb = $hget(zomb,speedboost)
drawrect -fr @ZombiesBuf $rgb(0,0,0) 1 0 0 500 500
if ($calc(%fu + %fl + %fd + %fr) == 1) {
if (%fu == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py 0 -6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py 0 -6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 $calc(%zomb.px - 2) $calc(%zomb.py - 7) $calc(%zomb.px - 2) 0
}
elseif (%fl == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 0
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 0
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 $calc(%zomb.px - 7) $calc(%zomb.py - 2) 0 $calc(%zomb.py - 2)
}
elseif (%fd == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py 0 +6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py 0 +6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 $calc(%zomb.px - 2) $calc(%zomb.py + 4) $calc(%zomb.px - 2) 500
}
elseif (%fr == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 0
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 0
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 $calc(%zomb.px + 4) $calc(%zomb.py - 2) 500 $calc(%zomb.py - 2)
}
}
elseif ($calc(%fu + %fl + %fd + %fr) == 2) {
if (%fu == 1) && (%fl == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 -6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 -6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 %zomb.px %zomb.py $iif(%zomb.px >= %zomb.py,$calc(%zomb.px - %zomb.py),0) $iif(%zomb.py >= %zomb.px,$calc(%zomb.py - %zomb.px),0)
}
elseif (%fu == 1) && (%fr == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 -6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 -6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 %zomb.px %zomb.py $calc(%zomb.px + %zomb.py) 0
}
elseif (%fd == 1) && (%fl == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 +6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py -6 +6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 %zomb.px %zomb.py 0 $calc(%zomb.px + %zomb.py)
}
elseif (%fd == 1) && (%fr == 1) {
if (%pg == pistol) && ($calc(%gt - %lf) >= 40) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 +6
}
elseif (%pg == machinegun) && ($calc(%gt - %lf) >= 6) {
hadd zomb last_fired %gt
aline @ZBulletBuf %gt %zomb.px %zomb.py +6 +6
hdec zomb mg_ammo
if ($hget(zomb,mg_ammo) == 0) hadd zomb player_gun pistol
}
drawline -r @ZombiesBuf $rgb(200,0,0) 1 %zomb.px %zomb.py $calc((%zomb.px + %zomb.py) * 500) $calc((%zomb.px + %zomb.py) * 500)
}
}
set %zomb.discard
set %zomb.discard2
filter -wkn @ZBulletBuf zomb_bullgen *
tokenize 32 %zomb.discard
dline @ZBulletBuf $*
filter -wkn @ZMobBuf zomb_mobmove *
filter -wkn @ZMobBuf zomb_mobgen *
set %zomb.discard
filter -lkn @ZMobBuf zomb_pickupgen *
tokenize 32 %zomb.discard
dline -l @ZMobBuf $*
drawdot -r @ZombiesBuf $rgb(0,160,0) 5 %zomb.px %zomb.py
drawtext -r @ZombiesBuf $rgb(255,255,255) arial 12 400 5 Health: $hget(zomb,player_health)
if (%pg == pistol) drawtext -r @ZombiesBuf $rgb(255,255,255) arial 12 400 18 Ammo: Infinite
elseif (%pg == machinegun) drawtext -r @ZombiesBuf $rgb(255,255,255) arial 12 400 18 Ammo: $hget(zomb,mg_ammo)
drawtext -r @ZombiesBuf $rgb(255,255,255) arial 12 400 31 Kills: $hget(zomb,kills)
if (%sb > 0) {
drawtext -r @ZombiesBuf $rgb(255,255,255) arial 12 400 44 SpeedUp!:
drawrect -fr @ZombiesBuf $rgb(255,0,0) 1 460 46 $ceil($calc((%sb / 450) * 38)) 10
}
drawcopy @ZombiesBuf 0 0 500 500 @Zombies 0 0
}
alias zomb_pickupgen {
tokenize 32 $1
if ($2 == B) && ($6 == 1) var %bb = $calc($6 - 1),%t = $5
else var %t = $calc($5 - 1),%d = 0,%ph = $hget(zomb,player_health)
if (%t == 0) var %d 1
if (%t > 0) {
if ($2 == B) && ($6 == 1) rline -l @ZMobBuf $1 $2 $3 $4 $5 %bb
else rline -l @ZMobBuf $1 $2 $3 $4 %t $6
drawrect -fr @ZombiesBuf $rgb(100,100,100) 1 $3 $4 10 10
drawtext -r @ZombiesBuf $rgb(255,0,0) arial 9 $3 $calc($4 + 1) $2
if ($inrect(%zomb.px,%zomb.py,$3,$4,10,10)) {
if ($2 == B) {
if ($6 == 0) rline -l @ZMobBuf $1 $2 $3 $4 $5 200
else {
if (%bb > 0) drawrect -e @ZombiesBuf $rgb(255,255,255) 1 $calc($3 - 20) $calc($4 - 20) 50 50
else {
drawrect -ef @ZombiesBuf $rgb(255,255,255) 1 $calc($3 - 20) $calc($4 - 20) 50 50
set %z_bombchecker $calc($3 - 20) $calc($4 - 20) 50 50
filter -wkn @ZMobBuf zomb_bombcheck *
var %d 1
}
}
}
if ($2 == H) && (%ph < 100) {
hadd zomb player_health $iif($calc(%ph + 25) > 100,100,$calc(%ph + 25))
var %d 1
}
if ($2 == M) {
if ($hget(zomb,mg_ammo) == 0) hadd zomb mg_ammo 100
else {
hadd zomb mg_ammo $calc($hget(zomb,mg_ammo) + 50)
if ($hget(zomb,mg_ammo) >= 250) {
hadd zomb mg_ammo 250
}
}
hadd zomb player_gun machinegun
var %d 1
}
if ($2 == S) {
hadd zomb speedboost 450
var %d 1
}
}
}
if (%d == 1) set %zomb.discard %zomb.discard $1
}
alias zomb_bombcheck {
tokenize 32 $1
var %zpx = $calc($3 - 5),%zpy = $calc($4 - 5),%zline = $1
}
alias zomb_bullgen {
set %zomb.discard2
tokenize 32 $1
set %zomb.curbull $1
var %gticks $hget(zomb,game_ticks)
var %dx $calc($3 + $5 * (%gticks - $2))
var %dy $calc($4 + $6 * (%gticks - $2))
rline -l @ZBulletBuf 1 %dx %dy
if (%dx isnum 0-500) && (%dy isnum 0-500) {
drawdot -r @ZombiesBuf $rgb(255,255,0) 2 %dx %dy
filter -wkn @ZMobBuf zomb_bullcheck
tokenize 32 %zomb.discard2
dline @ZMobBuf $*
}
elseif (!$istok(%zomb.discard,$1,32)) set %zomb.discard %zomb.discard $1
}
alias zomb_bullcheck {
tokenize 32 $1
var %zpx = $calc($3 - 5),%zpy = $calc($4 - 5),%zline = $1
tokenize 32 $line(@ZBulletBuf,1,1)
if ($inrect($1,$2,%zpx,%zpy,10,10) == $true) {
set %zomb.discard2 %zomb.discard2 %zline
hinc zomb kills
set %zomb.discard %zomb.discard %zomb.curbull
var %x $rand(1,1000)
if (%x isnum 966-1000) aline -l @ZMobBuf M %zpx %zpy 1000 0
elseif (%x isnum 926-950) aline -l @ZMobBuf H %zpx %zpy 1000 0
elseif (%x isnum 911-925) aline -l @ZMobBuf S %zpx %zpy 1000 0
}
}
alias zomb_mobgen {
tokenize 32 $1
var %e $calc($abs($calc($3 - %zomb.px)) + $abs($calc($4 - %zomb.py)) / 2)
var %f $calc(180 - %e)
if (%e <= 180) drawdot -r @ZombiesBuf $rgb(%f,%f,$int($calc(%e / 6))) 5 $3 $4
;drawdot -r @ZombiesBuf $rgb(180,180,30) 5 $3 $4
}
alias zomb_mobmove {
tokenize 32 $1
if ($2 > $hget(zomb,maxtog)) rline @ZMobBuf $1 $rand(0,$hget(zomb,maxtog)) $3 $4
if ($2 == %zomb.toggle) {
if ($inrect($3,$4,$calc(%zomb.px - 6),$calc(%zomb.py - 6),12,12) == $true) hdec zomb player_health
var %move_x = $calc($3 - %zomb.px),%move_y = $calc($4 - %zomb.py)
if ($abs($calc(%move_x / %move_y)) > 2.5) {
if (%move_x < 0) rline @ZMobBuf $1 $2 $calc($3 + 1) $4
else rline @ZMobBuf $1 $2 $calc($3 - 1) $4
}
elseif ($abs($calc(%move_y / %move_x)) > 2.5) {
if (%move_y < 0) rline @ZMobBuf $1 $2 $3 $calc($4 + 1)
else rline @ZMobBuf $1 $2 $3 $calc($4 - 1)
}
else {
rline @ZMobBuf $1 $2 $iif(%move_x < 0,$calc($3 + 1),$calc($3 - 1)) $iif(%move_y < 0,$calc($4 + 1),$calc($4 - 1))
}
}
}
alias zomb_GAMEOVER {
zomb_GO_setup
hfree zomb_endhash
; drawrect -fr @ZombiesBuf $rgb(255,0,0) 1 0 0 500 500
drawtext -r @ZombiesBuf $rgb(255,255,255) arial 50 $calc((500 - $width(You're Dead!,arial,50)) / 2) 225 You're Dead!
drawtext -r @ZombiesBuf $rgb(255,255,255) arial 32 $calc((500 - $width(Kills: $hget(zomb,kills),arial,32)) / 2) 300 Kills: $hget(zomb,kills)
drawcopy @ZombiesBuf 0 0 500 500 @Zombies 0 0
var %x $input(Would you like to play again?,yvs,@Zombies)
if (%x == $yes) {
close -@ @Zombies
close -@ @ZombiesBuf
close -@ @ZBulletBuf
close -@ @ZMobBuf
hfree zomb
zombies
}
else {
close -@ @Zombies
close -@ @ZombiesBuf
close -@ @ZBulletBuf
close -@ @ZMobBuf
hfree zomb
}
}
alias zomb_GO_setup {
hmake zomb_endhash 100
var %x 0
var %y 100
while (%x < %y) {
inc %x
hadd zomb_endhash %x $rand(2,5)
}
var %x 0
var %y 250
while (%x < %y) {
inc %x
var %t 0
var %u 100
while (%t < %u) {
inc %t
var %v $hget(zomb_endhash,%t)
drawline -r @ZombiesBuf $rgb(180,0,0) 5 $calc((%t - 1) * 5 + 3) 0 $calc((%t - 1) * 5 + 3)) $calc(%x * %v)
}
drawcopy @ZombiesBuf 0 0 500 500 @Zombies 0 0
}
}
on *:keydown:@Zombies:*: {
if ($keyval == 37) hadd zomb firing_l 1
if ($keyval == 38) hadd zomb firing_u 1
if ($keyval == 39) hadd zomb firing_r 1
if ($keyval == 40) hadd zomb firing_d 1
if ($keyval == 97) || ($keyval == 65) hadd zomb move_l 1
if ($keyval == 100) || ($keyval == 68) hadd zomb move_r 1
if ($keyval == 115) || ($keyval == 83) hadd zomb move_d 1
if ($keyval == 119) || ($keyval == 87) hadd zomb move_u 1
}
on *:keyup:@Zombies:*: {
if ($keyval == 37) hdel zomb firing_l
if ($keyval == 38) hdel zomb firing_u
if ($keyval == 39) hdel zomb firing_r
if ($keyval == 40) hdel zomb firing_d
if ($keyval == 97) || ($keyval == 65) hdel zomb move_l
if ($keyval == 100) || ($keyval == 68) hdel zomb move_r
if ($keyval == 115) || ($keyval == 83) hdel zomb move_d
if ($keyval == 119) || ($keyval == 87) hdel zomb move_u
}
on *:close:@Zombies: {
.timerzombloop off
close -@ @ZombiesBuf
close -@ @ZBulletBuf
close -@ @ZMobBuf
hfree zomb
unset %zomb.*
}
Yeah, I noticed the diagonal movement. Seems like bullets travel a little faster in those directions, too. I'll just have to do something to compensate and even it all out.
I did the herding, also, running an octagon-like pattern around the edge then pulling off to one corner of the map and firing like mad.
Think about it though, it's kinda like having a square and running a diagonal line through the square. The square is 3 inches on all side. When you travel in a cardinal direction, you're traveling 3 inches to the next point. But when you travel the diagonal, you're actually traveling about 4.24 inches from one point to the next. Ah, back to basic geometry, but this is the same principle showing up in the game.
After playing through quite a few times I've realized a few things.
1: You move faster diagonally than left/right or up/down.
2: Zombites move slower than you but in the same fashion.
3: Only a certain number of zombies are generated depending on your kills. Once that number is reached no new zombies are spawned until you kill another one.
Using these to my advantage I realized I could herd all the current zombies into a TIGHT cluster by just moving around the screen in a diamond pattern. Then I could mow em down with the machine gun, pick up the drops and repeat. Right now I'm at 700 kills using this method, with 100 life and well over 2k ammo for my machine gun. Thought I'd share.
Update coming soon.
Things completed in the update:
Invincibility Pickup (not only gives you invincibility for a short time, but zombie attacks HEAL you while invincible. Rare pickup.)
Pickups now flash when they are about to disappear.
Slight modification to the rarity of a machinegun pickup. When I played my full round, after building up over 2500 bullets for the machinegun and not being able to get rid of them faster than I could find them, I figured I should balance this out. I may also implement a maximum ammo capacity.
Working on:
Hit "zones." Instead of checking every bullet against every zombie to see if there's a hit, the bullet will now only check zombies within the "zone" it is in. I'm working out the bugs on zombies standing on a borderline between two zones, where a hit doesn't register, and the lag induced by having many zombies onscreen with this setup. However, bullet updates don't seem to affect performance so much now :D
@Kiddo96: After making my previous comment here, I decided to have a play.
I playtested this quite a bit, but I used a lot of hash table manipulation and whatnot to shortcut myself to possible scenarios, and otherwise just played through maybe 250 zombies in a semi-legitimate game. I had never, EVER sat down for a serious session, where I just started it, left the script and hashtable alone, and just tried to honestly see how far I could SERIOUSLY go, rather than just testing for a while and giving up.
Results:
Got a bit bored after a while because I have other things on my mind, and stopped picking up health. Otherwise, who knows how far I would have gone :P
Also, in regards to your key events: I would suggest checking for both upper and lower case wasd.
; in keydown
if ($keyval == 97) || ($keyval == 65) hadd zomb move_l 1
if ($keyval == 100) || ($keyval == 68) hadd zomb move_r 1
if ($keyval == 115) || ($keyval == 83) hadd zomb move_d 1
if ($keyval == 119) || ($keyval == 87) hadd zomb move_u 1
; in keyup
if ($keyval == 97) || ($keyval == 65) hdel zomb move_l
if ($keyval == 100) || ($keyval == 68) hdel zomb move_r
if ($keyval == 115) || ($keyval == 83) hdel zomb move_d
if ($keyval == 119) || ($keyval == 87) hdel zomb move_u
I took a look into your code, and I think I can help you with the aiming.
I would be more specific on the code, but I haven't coded in mSL in a long time, so most of this will be pseudo code.
There's two ways of doing this. You could find the angle between the player and the mouse, and use
speed cos(angle) for the x component of the velocity, and
speed sin(angle) for the y component.
OR, you could normalize the difference between the mouse and the player, and then multiply that by speed.
This can be achieved through these steps:
; find the difference between player and mouse position
deltaX = playerX - mouseX
deltaY = playerY - mouseY
; find the distance by using the differences
distance = sqrt( deltaX ^ 2 + deltaY ^ 2 )
; normalize the differences (this shortens the deltaX and deltaY so that their distance = 1)
normX = deltaX / distance
normY = deltaY / distance
; next, you can multiply by whatever speed you'd like
velX = normX * speed
velY = normY * speed
; Add the bullet to your buffer
aline @ZBulletBuf %gt %zomb.px %zomb.py velX velY
Thanks, BlueThen. Yeah I want mouse firing but I don't know how to do it with my current bullet buffering system. I also plan to add the bloodstains, however I DO know some ideas on how to go about that.
Also, for everyone having problems, I have added an update. Replace your old script with this one. The first time you try opening the game, it will ask you to type a lowercase-w. Do so and click OK, and the WASD controls should work!
The problem is older versions report lowercase w a s d as numbers 87 65 83 68, new versions report CAPITAL WASD as those, and lowercase w a s d as 119 95 115 100.
Love it. Please check out a similar game I made back in 2008: http://www.hawkee.com/snippet/4487/
Perhaps you can find some inspiration or ideas through it.
Actually you will probably be bored with my next offering. I have another dialog script planned out, lol, and it's not a game :( But it will have lots of clickies and stuff. It's going to be a Register.
My idea for Register is to offer to those with a small business who may not yet be able to afford a professional tool like Quicken Books the ability to do some basic book-keeping and tracking. While it will not replace a lot of the features of a professional suite of business tools, it will offer a Register, where you can ring people up for goods and services, Cash/Safe Counts where you can track counts on the money in your business as compared to how much is supposed to be in your drawer and safe, possibly some inventory tracking, and a few other things. Mainly stuff to make your end-of-day work a bit easier.
Frenetic, we're doing some things to hopefully make it a little more action-packed for you all. By we, I mean SReject and myself. I think he's semi-adopted my script and decided to toss out some ideas and fixes, so I am updating right now to give him credit. I will have a new version posted as soon as I feel there has been enough added and fixed.