ID:149946
 
Hey i had asked for some help on a code awhile back but there seems that only a little help could be given. Im going to repost the old message in hope someone can help me. If no one can i understand.

OLD:
Hello its me kalzimere again and again lol. I took a little break to refresh my mind and just get off my game so wouldn't get to frustrated and drp whole idea. Well now to my question i have been searching for a tutorial or demo anythng that could some how explain to me how to create mob that would walk up and attack. Well i found some things and managed to put them into a small code which is this:

mobloop()
var/mob/M
if(get_dist(src,usr) >= 1)
step_towards(src,usr)
spawn(respawn) mobloop()
else
M.life -= (usr.attackpower)
M.DeathCheck()
spawn(respawn) mobloop()

Thne i wasn't sure what exactly the spawn(respawn) mobloop() purpose was?, so theres one of my questions. I think it is just telling the code to keep calling back up to the top so if runs and runs in a LOOP lol but then again im prob wrong. I think the respawn is a tiem so do i need to have a clock?, i placed 600 which i thought weere seconds under mob.Secondly i created a mob then placed the code like so:

monsters
Evilelf
mobloop()
icon_state="elfM"
name = "Evil-Wood-Elf"
density = 1
life = 100
lifemax = 100
attackpower=2
defense=2
respawn=600

now when i come more then a dist. of 1 the mobn does nothing and when i right next to the mob he still does nothing lol. So if you know what the problem is i be ver grateful in your help. And i also just want to say thanks for all your help in the past you guys do a great job in helping and i hope i can get my game up some day lol. Thansk again.

-kalzimere
Hi am I hated and no one wants to talk to me or help me ? I thought i always was nice in asking help and showed respect and courtesy along with presenting as much info as possible on my problem in hopes someone would help. Well i guess my welcomes runned out i won't write here anyomore i guess. Thanks for all your past help.

-kalzimere
You need to define a New() proc for the mob.
mob/evilelf
New() //This is what the monster will do when it is first created
mobloop() //Start off the mobloop

The New() proc is called when src is first created, so when you first start the server and the evilelf is first created, it will call mobloop() and then start attacking things.
In response to Kalzimere
I don't mean to be rude. However, if your code is still the same as that post, you still did not initialize M. You are attacking M, but there is no M to attack. Your code would basically work if this was fixed. In theory, the loop (recursion) should work.

There the step and walk family of procs which I far as I know you still have not looked into.

There is also Deadron's pathfinding library which you could at least look at for clues instead of dismissing another person's code. I would also suggest Deadron's EventLoop.

I did not mention before that the 600 value you gave is roughly 60 seconds (1 = 1/10 second), not 600 seconds. I admit I could have caught that before.

PS: You gave people less than a day to look at this second bump. The first bump, a couple days after the original post was reasonable. People might not hate you, but they will get annoyed with frequent bumping.
In response to ACWraith
Sorry about that i guess i over reacted pretty much big time. Thank you for clearing up those two things. I just reposted it because i went back on to check the post i made and they were on the third page o post pretty much. So i was just afraid that my question had just been lost in the shuffle of post as you will. So i thought i would try a quick repost just to make sure it could be seen. Sorry for the trouble.

ps: Thanks for the clearing up about the code i do have M used now i just had it taken out in the code i posted. I also have taken look at deadrons code along with many other peoples. I wasn't dissmissing the code either i thought you were just telling me to stick it in and not bother making my own lol sorry my bad. Oh ywah i will post code as soon as i get it working im sorry for my stupidy.

-kalzimere