ID:1388495
 
(See the best response by Ter13.)
Code:
obj
fire
icon='person.dmi'
icon_state = "fire"
density=1
Bump(mob/M)
if(istype(M,/mob))
var/damage = usr.nin - M.nindef
if(damage <= 0)
usr << "-_- you slow"
M << "your to fast for [usr]'s attack."
del(src)
else
M.hp -= damage
usr << "[usr] -_- up [M] and took [M]'s booty with [damage] HP!"
M << "[usr] -_- up [M] and took [M]'s booty with [damage] HP!"
M:deathcheck()
del(src)


Problem description: i keep getting a error for some reason

training.dm:149:error: del: expected end of statement
Without really knowing what the error is, we can't help you. It does look like you have some indention issues going on though, as all of your if blocks are empty.
obj
fire
icon='person.dmi'
icon_state = "fire"
density=1
Bump(mob/M)
var/damage = usr.nin - M.nindef
if(istype(M,/mob))
if(damage <= 0)
usr << "-_-"
M << "YOU'RE to fast for [usr]'s attack."
else
M.hp -= damage
usr << "[usr] -_- up [M] and took [M]'s booty with [damage] HP!"
M << "[usr] -_- up [M] and took [M]'s booty with [damage] HP!"
M.deathcheck()
del(src)


Try to keep the language toned down in your code snippets, if you could.

The major issue is that you had a del(src) breaking up an if-else statement that it really shouldn't have been.
so how do i fix it PS. lol sorry i was playing with it and got bored " the output text)
In response to LordAndrew
LordAndrew wrote:
Without really knowing what the error is, we can't help you. It does look like you have some indention issues going on though, as all of your if blocks are empty.
training.dm:149:error: del: expected end of statement

I fixed some of your indentation issues already.
now its saying that my damage is an undefined var
Best response
Which I just corrected. You had defined damage in the wrong place. You should really take a minute to read a brief tutorial on variable scope.

And your indentation was actually worse than I supposed. Fixed yet again.
then please show me where to define it >_>
nvm thankyou
its not doing anydamage for some weird reason
You shouldn't be using usr in Bump(). Usr should only be used in verbs and click procs. Likely, "usr" is referring to the wrong mob, which is why you are getting the wrong damage values.
so then how do i make it so that it still does usr.nin - M.nin
ooooh kk ill just give the ball statics
nope that didnt work proc name: Bump (/obj/fire/Bump)
runtime error: Cannot read 0.nin
You are going to need to keep track of who shot the fireball. A simple example of doing this would be:

obj
projectile
var
mob/shooter
Bump(atom/blockage)
if(istype(blockage,/mob))
var/mob/m = blockage
var/damage = max(shooter.nin-m.nindef,0)
m.hp -= damage
del src
New(var/mob/m,var/atom/nl=null)
src.shooter = m
return ..(nl)

mob
verb
shootfireball()
var/turf/t = get_step(usr,usr.dir) //get the turf in front of the user.
if(t) //make sure the location exists
var/obj/projectile/p = new/obj/projectile(usr,t)
walk(p,usr.dir) //move the projectile
i need to make the density 1 right?
no that doesnt show the icon at all right now its just going through the mobs
Yup, it's going to do that. I've warned you about copying and pasting code without thinking for yourself. I'm showing you examples of what you need to do, not solving your problem for you.

I'm giving you the information you need to solve the problem for yourself, not handing you a complete solution to the problem.

The first one helps you. The second doesn't.
Page: 1 2