ID:139143
 
Code:
turf

// modify Enter()

Enter( atom/movable/atom )

// find out if a projectile is trying to enter a turf with a player on it

if( istype ( atom , /Shikai ) || istype ( atom ,/Projectiles ) || istype ( atom , /Inoues/Fairies ) )

// check for both densities

if( density && atom.density ) blow_up_turf( src ) // blow up the turf

// check for projectile Bump()

for( var/mob/mob in contents ) atom.Bump( mob ) // bump

// allow them to walk through, permit

return 1


Problem description:

While trying out this, when I create a projectile with:

new/Shikai/Rukia/Hakuren/Middle( get_step ( src , src.dir ) , src.dir , src , damage )


It doesn't hit the turf it's created on, nor does it always accurately hit the player. It "misses", and allows the player to completely walk through the projectile without triggering Bump().
Do both objects have a density of 1?
In response to Lugia319
Yes, they both have densities of one, that's why I am modifying turf/Enter() so the projectile can "pierce" through the mob.
In response to Neimo
What is your blow up turf proc?
In response to Lugia319
Lugia319 wrote:
What is your blow up turf proc?

Um, you need it?

proc

blow_up_turf( var/turf/turf )

var/Destruction/Crater/crater = new( turf )

spawn( 300 ) del crater
In response to Neimo
You might want to ask Garthor for a second opinion, but here's what I think.

I think that's where the issue is. You're creating a new turf but you're not passing the contents with it. Because you did not pass the contents of the previous turf to the new one, and because the mob/obj did not "Enter" the new one, then there is nothing for the for() to find.
In response to Lugia319
Lugia319 wrote:
You might want to ask Garthor for a second opinion, but here's what I think.

I think that's where the issue is. You're creating a new turf but you're not passing the contents with it. Because you did not pass the contents of the previous turf to the new one, and because the mob/obj did not "Enter" the new one, then there is nothing for the for() to find.

I'm creating a new object, how would I pass the contents list?

I've also tried:

for( var/mob/mob in atom.loc ) // the projectile's location when create

for( var/mob/mob in src ) // the player located on the turf

for( var/mob/mob in contents || atom.loc ) // this never worked correctly

// i've tried a lot of stuff, but it just won't work 100%


I don't really understand everything you're saying.
In response to Neimo
Now I see it. Ok, for future reference, please use abbreviations or SOMETHING other than what you're actually referring to at the end of those comments. The issue might be the istype(). Is there a datum of Shikai, Projects, etc.? Or are they coded objects?
In response to Lugia319
Lugia319 wrote:
Now I see it. Ok, for future reference, please use abbreviations or SOMETHING other than what you're actually referring to at the end of those comments. The issue might be the istype(). Is there a datum of Shikai, Projects, etc.? Or are they coded objects?

Yes, there is.

// projectiles

Projectiles

parent_type = /obj

// shikai

Shikai

parent_type = /obj


I didn't need abbreviations because the default was src, which was the turf.
In response to Neimo
Why not just use the projectile's Bump() proc to see if it Bump()s into a mob, and if it does, do damage, then make it keep going?
In response to Albro1
Albro1 wrote:
Why not just use the projectile's Bump() proc to see if it Bump()s into a mob, and if it does, do damage, then make it keep going?

To be honest, I have no idea how it would work like that, only with turf/Enter() I know.
In response to Neimo
Projectiles
parent_type = /obj
Bump(atom/movable/O)
if(istype(O,/mob))
var/mob/m = O
do_damage(m)
jump_forward() //If we didn't have this, walk() would make you bump into the mob again. You can substitute this
//in any way you want.
walk(src,dir)

proc/do_damage(mob/m)
proc/jump_forward()
switch(dir)
if(NORTH)
loc = locate(x,y+1,z)
if(SOUTH)
loc = locate(x,y-1,z)
if(WEST)
loc = locate(x-1,y,z)
if(EAST)
loc = locate(x+1,y,z)

This is just a quick example.
In response to Neimo
var/turf/turf is not an abbreviation. It is a restatement. I was referring to using things like

var/mob/M in src.contents and so on. The thing Albro is talking about is instead of making a turf proc for the projectile, just have a bump() period of the object, like so.

obj // Object Tree
Projectile // Projectile in Obj Tree
Bump(atom/movable/mob/M) // When the object comes into contact with a mob (With a density of 1)
M.Hp -= src.Dmg // Do damage


Also, I'm not entirely sure loc is a list.
In response to Lugia319
They already have modified <small>Bump()</small>'s , they're in need of piercing the mob.
In response to Neimo
Look at the end of my post. It Bump()s a mob, then keeps going, for a piercing effect.
In response to Albro1
I used your fix as a theory, but I figured it out with something else.
In response to Neimo
Glad to have helped.