ID:264210
 
Code:
mob/verb


Attack(mob/M as mob in get_step(usr,usr.dir))
set category = ("Commands")
var/damage
flick("attack",usr)
flick(damage,usr)
usr.Deathcheck()
if(usr.level >=100)
damage = rand(1,350) + usr.str - M.def
else
if(usr.level >=75)
damage = rand(1,275) + usr.str - M.def
else
if(usr.level >=50)
damage = rand(1,200) + usr.str - M.def
else
if(usr.level >=25)
damage = rand(1,100) + usr.str - M.def
else
if(usr.level >=10)
damage = rand(1,50) + usr.str - M.def
else
if(usr.level >=5)
damage = rand(1,20) + usr.str - M.def
else
if(usr.level <=5)
damage = rand(1,10) + usr.str - M.def
if(usr.doing==0)
if(istype(M, /mob/npc))
usr<<"YOU CANT ATTACK A NPC"
return
if(istype(M, /mob/pet))
usr<<"YOU CANT ATTACK A NPC"
return
else
if(damage <= 0)
if(istype(M, /mob/anisters/))
M.Attack2()
else
usr.doing=1
usr<<"You start attacking [M]"
sleep(5)
M<<"[src] attacks you"
M << "You dodge [src]'s attack."
usr<<"[M] dodges your attack."
usr.doing=0

else
if(usr.doing==0)
usr.doing=1
usr<<"You start to attack [M]"
sleep(5)
M.hp -= damage
usr.doing=0
M<<"[src] attacks you!"
usr<< "[src] attacks [M] with [damage] damage!"
if(istype(M, /mob/anisters/))
M.Attack2()
M.Deathcheck()
usr.doing=0
usr.BarCheck()
M.BarCheck()


mob
proc
Attack2(mob/M as mob in get_step(usr,usr.dir))
var/damage2
if(usr.level >=100)
damage2 = rand(120,350) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=75)
damage2 = rand(75,275) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=50)
damage2 = rand(40,200) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=20)
damage2 = rand(25,100) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=10)
damage2 = rand(5,50) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level >=6)
damage2 = rand(5,20) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"
else
if(usr.level <=5)
damage2 = rand(1,10) + src.str - usr.def
if(damage2>=0)
flick("attack",src)
flick(damage2,src)
usr.hp-=damage2
usr.doing=0
usr<<"[damage2] damage done in return!"
src.Deathcheck()
usr.doing=0
else
usr<<"You block the attack!"


Problem description:

i keep getting the following error on DD

____

runtime error: Cannot modify null.doing.
proc name: Deathcheck (/mob/proc/Deathcheck)
source file: battle.dm,303
usr: null
src: Moungral (/mob/anisters/Moungral)
call stack:
Moungral (/mob/anisters/Moungral): Deathcheck()
Moungral (/mob/anisters/Moungral): Attack2(null)
Attack(Moungral (/mob/anisters/Moungral))
runtime error: Cannot modify null.doing.
proc name: Attack2 (/mob/proc/Attack2)
source file: battle.dm,183
usr: null
src: Moungral (/mob/anisters/Moungral)
call stack:
Moungral (/mob/anisters/Moungral): Attack2(null)
Attack(Moungral (/mob/anisters/Moungral))

______

it happens on more than one monster. please help
No usr in proc :P

You always use src. I also recommend: using Boolean logic (there's a section in the DM guide devoted to it!), modular coding (I wrote an article on it for dream makers, as did Iain Peregrine), and you should use a formula instead of that long else if chain! Formulas are much more dynamic and offer much better, consistent damage calculation.
BOOLEAN! MODULAR!!!

Check into those.

But mainly what I see instead of checking the level do something like this:

var/dmg=rand(1,round(Level*3.5))
if(dmg>350) dmg=350
//And continue here!

Use that instead of 8 if() checks and tons of lines of code.


DONT put usr in procs! use src or dont put anything at all:
usr.hp//BAD!!!
src.hp//Good
hp//GREAT!


I also think the line:
Attack2(mob/M as mob in get_step(usr,usr.dir))


Might be wrong, i'm sure a programming guru will come here and say everything I did but more. I'm just too lazy to find out the exact problem, but what I said will help you out alot! ^^
In response to Bakasensei
i'm sure a programming guru will come here and say everything I did but more

Beat you :P

Either way, I'm pretty sure the get_step() thing works, considering it returns a turf, which is a valid argument. Also, don't encourage not using src.var. I still use src.var for everything, especially in my larger procs, because I might name a variable the same thing as a variable belonging to the src (in my cases, it usually is just to simplify and organize things; I pick those things out relatively well). Plus, the src. just helps organize things in general, especially if you're new to DM.

As far as your formula goes, maybe he wants to write his own :P? I personally find writing formulas fun, especially the more complicated ones involving probability.
In response to Jeff8500
if im not suppose to usr and src in the same proc then how would i use two different mobs?

usr = player
src = monster

or at least thats how i thought it through.


also looking at your dmg code above, if i specified a specific damage amount thats what i want to avoid. i want the damage to be different for each level.
In response to Chase_Hammer
No, no, no! In a proc, usr is usually null, hence your errors null.variable does not exist (null has no variables). To get more than one mob, you use arguments; I'm sure the Zilal Beginner Tutorials taught you about args?

mob/verb/Attack(mob/M in view()) //mob/M is an arg. In a verb called by the player
//it asks who they want M to be.
//you don't have to worry about that though

mob/proc/Hax(mob/M) //mob/M is also an arg in this. However, it won't
//ask the mob (src) about it
world << "[src] haxes [M]" //src is the mob that called this
//M is the argument we gave the proc


mob/verb/Use_Hax(mob/M in world) //get a mob in the world
// the player chooses this
usr.Hax(M) /*notice how we put M in parenthises. This means that
M is first arg in Hax(), which is also M
Keep in mind the name of the variable doesn't matter
If I really wanted to, I could have put
usr.Hax(32) and would have worked (keep in mind that
would cause runtime errors in most procs)*/
In response to Chase_Hammer
How I did it it will gain everytime you level up(You will be able to do more damage).
So like: at level one the most damage you could do is 4, while at level 100 the most you could do is 350(Which I capped at that, because that what you have.

Also Jeff(WHOS NOT A GURU! xD) I here ya, its just I like white space, and thats better overall(Cause in-general if you have more white space, the code takes up less kb(Don't rape me on this subject, i'm just saying in general!)). Though I just suggested that small formula, I encourage him to make his own though!(Thats always fun).

Edit: Nvm Jeff already covered the src, usr thing >.>