ID:147354
 
Okay in the following code, the mob will be created, and will follow the player like it should, but when it is recreated when the player logs on, it wont follow anymore. Any help? Here's the code.
                Use(mob/Newchar/C)
if(usr.monsterinparty == null)
usr << "The [src] begins to shake aruptly! A blue beam comes out of the [src] and a Blue Slime is formed! The [src] shatters into millions of pieces which are absorbed into the new monster..."
var/mob/summons/Blue_Slime_Summon/B = new/mob/summons/Blue_Slime_Summon()
usr << "<b><font color = olive>[B]:</b><font color = blue> Hiya! I'm a [B]! Since You're my new master, name me properly! I hate this name!"
sleep(20)
var/namea = input("What do you want to name the new [B]?","Name!")
B.name = namea
usr << "<b><font color = olive>[namea]:</b><font color = blue> Thanks! My new name is [name]!"
usr.monsterinparty = B
var/mob/A = new usr.monsterinparty.type(locate(C.x-1,C.y,C.z))
A.name = B.name
A.density = 0
usr.monsterfollow = A
usr.verbs+=typesof(/mob/summons/verb)
del(src)
else
usr << "You cannot have 2 monsters at once, get rid of your old one!"

That's the code that makes the original version that moves like it should, heres the moving code:
mob
Move()
..()
if(src.monsterfollow != null)
if(get_dist(src,src.monsterfollow) <= 1) return
step_towards(src.monsterfollow,src)

okay and next up is the new code that recreates the monster after the player relogs, the monster DOES NOT follow now.
        if(src.monsterfollow != null)
//var/mob/m = new src.monsterfollow.type(usr.x-1,usr.y,usr.z)
new src.monsterfollow.type(usr.x-1,usr.y,usr.z)

Neither ways on that, including the //ed out ones work. Any help will be apreciated, unless its telling me to change the whole thing...Please help though! Thanks!
//src.monsterfollow = m
Why don't you create another var for the mob to specifically hold the type of the monster. Then, when you recreate the monster, create a new monster of the type that your new vaiable held and set the players monsterfollow var to that:

mob/var/monstertype
mob/proc/RespawnMonester()
var/mob/A = new src.monstertype(src.x-1,src.y,src.z)
src.monsterfollow = A


One thing that you should do if you do this is make a monsterfollow a tmp var and eleminate the check to see if monsterfollow is null, because it will be everytime now that it's a tmp var.

Resonating Light
In response to Resonating_Light
monsterfollow is specific to just being the one on the map to move. But I figured it out. I rewrote it and it started working, dunno why, either way I have a new problem.
How can I get the mob to enter with this
area/housing
Enter(mob/a)
if(ismob(a))
if(a == usr.monsterfollow)
return 1
if(a.key == src.owner)
a << "<i><b>[src.welcomemsg]</i></b>"
a.drophouseitems = 1
return 1
if(a.houseowned == src.name)
a << "<i><b>[src.welcomemsg]</i></b>"
a.drophouseitems = 1
return 1
else if(a.key in src.invited)
a << "<i><b>[src.welcomemsg]</i></b>"
return 1
else
if(src.owner == null)
a << "<i><b>You don't own this house! But since no one owns this house, if you talk to the House Buyer, you can buy it! This is [src.name]!</font>"
else
a << "<i><b>You don't own this house! [src.owner] owns this house!</font>"
a << "<i><b>[src.welcomemsg]</i></b>"
return 0

The top part WAS supposed to work for letting the mob in the house no matter what, but it doesnt work, and i dont get runtimes...please help.
In response to Metroid
I knew that it was specific towards the mob on the map. That's why creating another variable to hold the type path for that mob and storing it away, rather than storing the mob itself is what should have been done. The mob gets deleted, so it no longer exists, and that makes putting away that mob into a var illegal. But puting away a type path is not. And you would use monsterfollow, to hold a reference to the mob following while you're in the game, but since that mob gets deleted, it's not needed and that's why you would make it a tmp var.

And the problem with this one is that usr probably isn't being set, and you're trying to compare the monsters type to an invalid var. You'll want to check if the mob is a type of the base monster type using typesof()

if(A in typesof(/mob/monster)) return 1


Something like that. And please, bear with me here. I'm not the best, but I'm trying.

Resonating Light
In response to Resonating_Light
I understand that, and I'm tring everything you say and more. Though, that did not help -_- it still wouldnt move the guy, and top that off, still no runtimes. I double checked the mob that wont enter if he was mob/summons too, and still nothing (I fixed the mob/monster to mob/summons) Nevertheless, any other help will be apreciated.
In response to Metroid
My friend helped me fix the problem, thanks anyway...