ID:2017422
 
(See the best response by Maximus_Alex2003.)
Code:
obj

attack
blast //This is the projectile, it can be used for anything
proc
smoke2(mob/user)
var/obj/smoke2 = new(user.loc)
smoke2.icon = 'Bolt_smoke.dmi'
smoke2.layer = MOB_LAYER + 0.2
flick("smoke",smoke2)

spawn(6)
del smoke2


Bump()
var/player/M
var/obj/attack/B
if(istype(M,/player)) //if its a player...
var/dmg=(round(power/M.endurance))
if(dmg<0)
dmg=0
M.health-=dmg
if(M.health<=0)
M.deathCheck() //kill them
smoke2(M)
view()<<sound('kiplosion.ogg')
sleep(90)
del(src)


Problem description:

Okay so, there are no compile errors or any in-game errors, but for some reason.. The "smoke2" proc doesn't flick or show the icon I inputted.

What's suppose to happen is, if a blast comes in contact with a player or mob, it flicks a smoke effect as if exploded on contact, sorta like how you'd see in Dragonball Z when characters block ki-blasts and a sort of smoke cloud evaporates before them.

Can someone help me find out what I'm doing wrong?

You never defined M inside your bump parameters.
Bump(mob/M)

instead of var/player/M

on top of that, if you're passing a player datum into smoke2, depending on if it's an actual mob or not, it won't be able to detect user."loc" as one of the variables.
why don't you just make it spawn a new obj that is the smoke when it hits a player/mob?
Best response
I would also suggest to not even make a seperate proc for smoke2 since all it should do is just flick().

Since you don't need the blast obj anymore since it has already made contact, and I assume it disappears right after contact, make the actual obj/attack/blast flick() instead of creating a new /obj. This saves on resources which allows for 2x the blasts with the same performance which will come in handy later.


So,

Step #1. Player uses blast attack which creates a /obj/attack/blast and sends it flying.
Step #2. When the /obj/attack/blast contacts something, or Bumps()'s something, call flick() in /obj/attack/blast's Bump() to have it not delete the /obj/attack/blast, but to first:
(1) Set the /obj/attack/blast density to 0.
(2) flick() the /obj/attack/blast instead.
(3) After flick(), del the src or the /obj/attack/blast


obj
attack
blast
Bump(atom/obstacle)
// Stop the /obj movement here. I would recommend a variable thats used in the /obj movement procs.
// Example: src.stop_moving = 1
// Then, set src.density = 0 to prevent it being Bump()'d again by the same target or someoene else.
if(istype(obstacle, /mob/player))
var/mob/player/player_obstacle = obstacle
var/damage = round(src.power / player_obstacle.endurance)
if(damage < 0)
damage = 0
player_obstacle.health -= damage
if(player_obstacle.health <= 0)
player_obstacle.deathCheck()
src.icon = 'Bolt_smoke.dmi'
src.layer = MOB_LAYER + 0.2
flick("smoke", src)
view() << sound('kiplosion.ogg')
spawn(6)
del(src)


Sorry if I mess this up, it's been a while for me.

In short, reduce the /obj amount by 2, and reduce the proc calls by 2 all within Bump().
All of your ideas helped alot thanks alot, I ended up working with Ishuri's fix at first and noticed a bug that nearly lags my computer to fuck. Trying Maximus' code, realized the difference but-

Why would the purpose be for making the src.moving=0? For it to stop walking after it makes contact?- But it already deletes itself.
In response to HaxRp
HaxRp wrote:

Why would the purpose be for making the src.moving=0? For it to stop walking after it makes contact?- But it already deletes itself.

You might not need it, to be honest. I can't remember the exact details of Bump() whether it stops movement. It's been a little over a year since I touched code.

Also, I made a mistake:
var/mob/player/player_obstacle
should be
var/mob/player/player_obstacle = obstacle


I corrected the typo and the missing assignment in my previous post.