ID:2050594
 
(See the best response by Ter13.)
My obj Code:
obj
boatship
icon='Boaticon2.dmi'
Res=5000
density=1
Enter(mob/M)
if(istype(M,/obj/hit))
src.Res-=M.Power
if(src.Res<=0)
del(src)
del(M)



This next piece of code is part of my cannonball from the boat ship. (Which is the next and super large code I dont want to give out at this moment) As you can see, this piece sends a cannonball at usr dir.


var/obj/A=new/obj/hit/cannon
A.loc=locate(usr.x,usr.y,usr.z)
A.icon='ball'
A.density=1
A.Power=usr.Power
A.owner=usr
A.dir=usr.dir
A.limt()
walk(A,usr.dir)


the limit proc just kills the obj after a short sleep

Problem description:
The problem is that the ball just goes through the boat. Icon is 60x55 (Dont know if its the problem.)

Both objs have density
Enter(mob/M)

You would mean to use Entered() were Enter() the right proc.

You want Crossed() or you want to hook the cannonball's Bump() function.
In response to Ter13
Ter13 wrote:
Enter(mob/M)

You would mean to use Entered() were Enter() the right proc.

You want Crossed() or you want to hook the cannonball's Bump() function.

What is the difference between Enter() and Entered()?

Best response
Enter() determines whether an object CAN enter by returning 1 or 0.

Entered() is called after an object has successfully entered an atom.

Cross() determines whether an object CAN overlap another object by returning 1 or 0.

Crossed() is called after an object has successfully overlapped a movable.

When movables overlap a turf, they Enter()/Entered() the turf they overlap.

When movables overlap another movable (obj or mob), they Cross()/Crossed() the movable they overlap.

You need to be using Crossed(), but if the projectile is dense and the boat is dense, they will never overlap because the density will prevent them from crossing.

Let's take a look at properly creating projectiles:

projectile
parent_type = /obj
density = 1
var
power
mob/owner

Bump(atom/o)
if(hascall(o,"hit")) call(o,"hit")(src)
del src //you should ideally avoid deleting objects manually

New(loc,dir,power,owner)
src.loc = loc
src.dir = dir
src.power = power
src.owner = owner
walk(src,dir)


Now that we have our projectiles set up, we can deal with making objects respond to projectile hits.

obj
ship
var
health = 1000
proc
hit(projectile/p)
health -= p.power
if(health<=0)
del src //you should ideally avoid deleting objects manually


Quite a lot of this could be improved and expanded, but that's more or less the gist of it.
Well, my ball does work on mobs and turf. Both are dense.

If I could get it working on objs. Would I still need crossed()?

And they overlap while densed. (which is probably my bug).
okay. Used Crossed() and it fixed it.

Thanks (For the lesson on procs. My projectile code is just fine.)
My projectile code is just fine.

I disagree, but I'm glad you fixed your problem... Even though you broke density somehow.