ID:261743
 
I'm experiencing problems with my code and dreamseeker, when I fire dreamseeker freezes up.

CODE:

obj
bullet
icon = 'bullet.dmi'
density = 1
Bump(M)
if(istype(M, /mob))
M:Hit()
sleep(1)
del(src)
proc
Shoot()
var/turf/aturf
if(src:East)
aturf = locate(src.x + 1, src.y, 1)
if(src:West)
aturf = locate(src.x - 1, src.y, 1)
if(src:North)
aturf = locate(src.x ,1, src.y + 1)
if(src:South)
aturf = locate(src.x ,1, src.y - 1)
if(aturf == null)
del(src)
return
src.Move(aturf)
spawn(1) src.Shoot()
mob
proc
Hit()
src.hp -= rand(1,10)
mob
verb
Fire()
if(world.time - src.delay_time >= src.delay)
src.delay_time = world.time
var/obj/bullet/S
if(src:East)
S = new /obj/bullet(locate(src.x + 1, src.y, src.z))
if(src:West)
S = new /obj/bullet(locate(src.x - 1, src.y, src.z))
if(src:North)
S = new /obj/bullet(locate(src.x, src.y + 1, src.z))
if(src:South)
S = new /obj/bullet(locate(src.x, src.y - 1, src.z))
var/turf/aturf = locate(S.x, S.y, S.z)
for(var/atom/A in aturf)
if(A.density == 1 && A != S)
if(istype(A, /mob))
A:Hit()
del(S)
return
if(aturf.density == 1)
del(S)
return
spawn(1) S.Shoot()
mob
var/delay = 5
var/delay_time
Urk; I don't know why you're messing with vars like North and East and such, and those complex locate() statements, when you should be using get_step(src,dir) or step(src,dir). This could be done a lot more simply. It'd help to look up projectile code that other people have posted on the forums.

Lummox JR
In response to Lummox JR
I tried it another way it works but it looks stupid for example if I shoot east it will look south than east and it looks really weird and dreamseeker gives it some problems too. here is my other Gun Code:

obj
bullet
icon='bullet.dmi'
density=1
Bump(mob/M)
if(istype(M,/mob))
var/damage = rand(1,10)
M:hp -= damage
del(src)

mob
verb
fire()
usr.projectile(new/obj/bullet(usr.loc),usr.dir,40)

mob
proc
projectile(obj/projectile,var/dir,var/delay)
sleep(1)
walk(projectile,dir)
sleep(delay)
del(projectile)


-end code-

Am I just trying to hard? Is there an easy way?
In response to SSJ4 Majin Trunks
SSJ4 Majin Trunks wrote:
I tried it another way it works but it looks stupid for example if I shoot east it will look south than east and it looks really weird and dreamseeker gives it some problems too. here is my other Gun Code:

This one is much cleaner than the first. Can you post the errors you are getting from Dream Seeker?

Here is a minor modification of your projectile() proc that should get rid of the initial south facing.

mob
proc
projectile(obj/projectile,var/<font color=#0033ff>D</font>ir,var/delay)
<font color=#0033ff>projectile.dir = Dir // this will make it face the right direction</font>
sleep(1) <font color=#0033ff>// is there any reason for this sleep?</font>
walk(projectile,<font color=#0033ff>D</font>ir)
sleep(delay)
del(projectile)


You can name arguments the same as atom vars, but it will only lead to confusion. I capitalized Dir so you can keep it separate from the mob's dir var.
In response to SSJ4 Majin Trunks
SSJ4 Majin Trunks wrote:
Am I just trying to hard? Is there an easy way?

Yes, there is.
I'm currently writing my next BYONDscape article on this, but basically you'll find good projectile code if you do a forum search. Search for "projectile author:lummoxjr" without the quotes.

The key to good projectiles is stuffing everything into the New() proc, and telling the projectile who fired it.

Lummox JR
In response to Shadowdarke
Thanks Shadow now it fires the right way, why did I put that sleep? lol, this is the error message I get in Dreamseeker when I put it up and fire.

runtime error: undefined variable /turf/grass3/var/screen
proc name: New (/obj/New)
usr: SSJ4 Majin Trunks (/mob)
src: the bullet (/obj/bullet)
call stack:
the bullet (/obj/bullet): New(the grass3 (2,1,1) (/turf/grass3))
SSJ4 Majin Trunks (/mob): fire()
In response to SSJ4 Majin Trunks
SSJ4 Majin Trunks wrote:
Thanks Shadow now it fires the right way, why did I put that sleep? lol, this is the error message I get in Dreamseeker when I put it up and fire.

runtime error: undefined variable /turf/grass3/var/screen
proc name: New (/obj/New)
usr: SSJ4 Majin Trunks (/mob)
src: the bullet (/obj/bullet)
call stack:
the bullet (/obj/bullet): New(the grass3 (2,1,1) (/turf/grass3))
SSJ4 Majin Trunks (/mob): fire()

You've done something screwy in your New() code. You're sending it a turf location, which is typically the first argument of New(), but it is expecting a client.
In response to Shadowdarke
SO how would I fix that?
In response to Lummox JR
You arent giving him that bit flag thing are you? I still cant figure out how to use it.