ID:268720
 
client
Northwest()
var/mob/monster/M = new (usr.loc,usr)
M.dir = usr.dir
step_towards(M,usr)

Anyways, whenever I create the mob, it doesn't follow. :9
Would I do this by using step_to, or a totally different thing?
What I mean is...

O = Player
M = Monster
X = Ground

XXXXXX
XXXPMX
XXXXXX

That's the player going left.

XXXXXX
XXXPXX
XXXMXX

And that's the player going up. ;o
How would you go about doing that?
What you're doing above there should be creating a NEW monster everytime you move Northwest...

1) Stop using usr in proc's.

2) Make the Monster(or what seems more like a pet) have it's own proc to follow a player.

To do so, you can set a variable to the monster indicating who it has to follow(in this case the Player). Then in the monster's new proc, spawn a proc which constantly follows(using step_towards) the variable(the player) and then loops itself(using while?), but make sure you put a sleep() in the loop, or it'll create major lag up to a point the game crashes.

3) You dont need M.dir = usr.dir.
In response to DeathAwaitsU
"usr" has to be put in, as of it's the client.
I could've used "C", but I needed a fast example.
Well, thanks.
In response to Hell Ramen
No instead of usr you can use mob. So...

mob.density = 1
mob << "Haha it sucks to be you"

...are the correct ways of doing the player, in client/procs, or atleast I think.
In response to DeathAwaitsU
Ahhh, well... >_>... I was using Northwest just for a test, and now another question...

        create_monster()
if(src.monsters.len >= 3)
for(var/mob/monster/M in src.monsters)
src << "You have too many monsters!"
else
var/mob/monster/M = new(src.loc,src)
M.owner = src
M.name = "Drakee"
src.monsters += src

;o
<font color = red>
runtime error: Cannot read null.len
proc name: create monster (/mob/verb/create_monster)
usr: Hell Ramen (/mob)
src: Hell Ramen (/mob)
call stack:
Hell Ramen (/mob): create monster()
</font>
It can't read the "len" part I suppose, but I can't think of any other way to do it. :(
In response to Hell Ramen
I don't know about checking sizes of lists but an easier approach would be to make a new variable called something like monnum and check against that:

        create_monster()
if(src.monnum >= 3)
for(var/mob/monster/M in src.monsters)
src << "You have too many monsters!"
else
var/mob/monster/M = new(src.loc,src)
M.owner = src
M.name = "Drakee"
src.monsters += src
src.monnum ++

In response to DeathAwaitsU
Now it has a type mismatch. :(
<font color = red>runtime error: type mismatch
proc name: create monster (/mob/verb/create_monster)
usr: Hell Ramen (/mob)
src: Hell Ramen (/mob)
call stack:
Hell Ramen (/mob): create monster()</FONT>
Should I use...
if(src.monsters.Find(M,Start = 1,End = 0)
M.name = "Drakee [pick("A","B",C"]
?

Well, thanks for the help so far. :D

[Edit]: Note, this is only if I create more then one... later I'm going to make it so if(tmon = 2),M.follow2(),etc.
In response to Hell Ramen
What line is this on and show me how you've defined the monsters variable.
In response to DeathAwaitsU
mob
var
list
monsters
monttl

verb
delete_monsters()
del(src.monsters)
create_monster()
if(src.monttl >= 3)
for(var/mob/monster/M in src.monsters)
src << "You have too many monsters!"
else
src.monttl ++


var/mob/monster/M = new(src.loc,src)
M.monsternum = src.monttl
M.owner = src
M.name = "Drakee"
src.monsters += M //Right here


:o
That's how I'm doing it, I don't get what you mean... so, yeah. =/
[Edit] It's the "src.monsters += M" part. :o
Line 158, I figured out Debug Mode. :D
In response to Hell Ramen
Both of those errors are because you didn't actually create the monsters list; you declared it, but you didn't actually give it a value. Set it to list(), like so:

mob
var
list
monsters = list()


Now you can also get rid of that dodgy monttl variable and use monsters.len, which is a whole lot more reliable because you don't have to remember to increment/decrement it all the time.

Also, don't delete src.monsters; that will delete the list, not the monsters. To delete the contents of this list, you have to do this:

for (var/mob/monster/M in src.monsters)
del M


And finally, why are you looping through src.monsters to say "You have too many monsters"? You'll just end up with the message getting displayed three times for no reason.
In response to Crispy
I dunno'...
But, thanks Crispy. :)