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
ID:261743
![]() Mar 19 2003, 3:03 pm
|
|
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? |
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. |
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 |
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() |
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. 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. |
Lummox JR