proc
fireprojectile(Type, mob/Who)
/*
Type = the type of projectile
Who = who fired/threw the projectile
*/
var/obj/projectile/S = new Type(Who.loc) // make a new projectile where the mob is
if(!istype(S,/obj/projectile)) // make sure they are
world.log << "Invalid projectile:[Type]"
return
S.dir = Who.dir // projectile faces same dir as the mob
S.who = Who
S.shooter = S.who
S.missileloop()
obj
projectile
density = 1
layer = FLY_LAYER
var
mob/who // the mob that fires the projectile
damage = 1 // how much damage the projectile causes
mrange = 10 // how far the projectile can go
delay = 0 // number of ticks between movements
proc
missileloop()
walk(src,dir, 0) // T = space the
if(--mrange > 0) // decriment range
spawn(delay) missileloop()
else
endmissile()
endmissile()
/* This proc is called when the missile stops moving.
Override it for missiles that have special effects
like explosions or leaving items where they land.
*/
del(src)
Bump(O)
if(ismob(O))
// damage proc
O:HP -= src.damage
O:DeathCheck()
endmissile() // we hit something, so the missile stops
obj
var
shooter
ID:174969
Jun 28 2003, 3:26 am
|
|
I need help modifying my Bump proc so that it gives the object's shooter +10 Experience. Here is all the code that has relevance.
|
In response to Lummox JR
|
|
Is this what you meant, Lummox?
Bump(O) |
In response to Drafonis
|
|
Bump(mob/O)//Wasn't defined correctly Agghhh! Evil colons choking me! Worlds: Looks like a job for Superworlds! I've done the code as it should be (roughly). |
In response to Drafonis
|
|
Drafonis wrote:
Is this what you meant, Lummox? Bump(O) No, because you did several things wrong. First, you're still using usr in DeathCheck(). Totally wrong. Never ever ever do that. Second, you called DeathCheck() with src, which is the projectile, not the porjectile's owner. Third: Give P a type like mob/P, so you don't have to use a colon. Lummox JR |
In response to Lummox JR
|
|
I'm not 100% sure what you meant about the second problem (src is the projectile, not the projectile's owner.) I think the projectile's owner (using the system I set up) would, in this case, be src.owner, which I have pointing to src.shooter. How can I make that a bit less cumbersome?
|
In response to Drafonis
|
|
Drafonis wrote:
I'm not 100% sure what you meant about the second problem (src is the projectile, not the projectile's owner.) I think the projectile's owner (using the system I set up) would, in this case, be src.owner, which I have pointing to src.shooter. You're correct. The correct thing to call DeathCheck() with would be src.shooter. How can I make that a bit less cumbersome? The best way to handle projectiles is to handle all initialization of the projectile in New(), not in the verb where you fire it. Pass a second argument to new() saying who fired, and then rewrite New() like this: obj/projectile Lummox JR |
In response to Lummox JR
|
|
I am not sure exactly how this is. However, here's how I did this. I made DeathCheck accept 2 arguments. One is mob/P, one is mob/S. On Bump, mob/P is defined as src.shooter, mob/S is O. The rest is the same.
|
In response to Drafonis
|
|
Drafonis wrote:
I am not sure exactly how this is. However, here's how I did this. I made DeathCheck accept 2 arguments. One is mob/P, one is mob/S. On Bump, mob/P is defined as src.shooter, mob/S is O. The rest is the same. The mob/S bit is useless. The O in your Bump() is the thing that was bumped into, which is the mob whose DeathCheck() proc is called, so S==src in DeathCheck(). Therefore you don't need it; get rid of it. It may be useful however to also tell DeathCheck() something about the weapon, so passing src (from Bump()) as a second argument (but not the first) might not be a bad idea. Lummox JR |
Lummox JR