ID:1537398
 
Code:
    Animals
NPC_Type="Animal"
var
Random_Walker=0
Random_Direction=0

Fear_Level=2
Speaks//Sound File

Second_Icon
AgeEvo_Second
Third_Icon
AgeEvo_Third

Aggression=0
Bump(mob/M)
..()
if(istype(M,/mob/))
if(M==Owner||src.Aggression==0)
return
else
var/Swiftt=0
if(src.Owner)
var/mob/A=src.Owner
Swiftt=A.Pet_Swift
if(src.AttackDelay)
return
src.AttackDelay=1
flick("Attack",usr)
src.Attacking(M,"Hands")
sleep(11-Swiftt)
src.AttackDelay=0
return
New()
..()
var/obj/Ax=new();Ax.icon='ShadowX3.dmi';Ax.pixel_y-=1;src.underlays+=Ax
src.Commence_AI()

mob/var/tmp/PetOut=0
mob/var
//Pet System
Pet_Owner=0

Pet_Name=""
Pet_Species=""
Pet_Age=0
Pet_Age_EXP=0
Pet_Icon=null

Pet_Vitality=0
Pet_Max_Vitality=0
Pet_Stamina=0
Pet_Max_Stamina=0

mob/proc
Tame(mob/NPC/Animals/M)
if(M.Owner)
src<<"You can't tame someone else's pet.";return
else
switch(input(usr,"Are you sure you'd like to Tame [M.name]? You can not have any other Pets, and this is permanent for the rest of your life.", "") in list ("Yes","No","Cancel"))
if("Yes")
usr.Pet_Name=input(usr,"Please select a name for your new [M.Species].") as text

usr.Pet_Owner=1
src.Pet_Species=M.Species
src.Pet_Age=M.Age
src.Pet_Icon=M.icon
src.Give_Skillcard("Drop_Pet")
src.Give_Skillcard("Pickup_Pet")

src.Pet_Vitality=M.Max_Vitality
src.Pet_Max_Vitality=M.Max_Vitality

src.Pet_Stamina=M.Max_Stamina
src.Pet_Max_Stamina=M.Max_Stamina

M.Owner=src

Drop_Pet()
if(usr.inso)
usr<<"You're currently fused with your pet.";return
if(usr.PetOut==1)
usr<<"Your pet is already out.";return
if(usr.UsingDomu)
return
if(usr.Pet_Vitality<=0)
usr<<"Your pet is knocked out!";return
else if(usr.Pet_Owner==1)
usr<<"You drop [src.Pet_Name]."
var/mob/NPC/Animals/P=new()
usr.PetOut=1
if(P)
P.name=src.Pet_Name
P.icon=src.Pet_Icon
P.loc = locate(usr.x+1, usr.y, usr.z)
P.Owner=usr
P.Species=src.Pet_Species
P.Max_Stamina=src.Pet_Max_Stamina
P.Max_Vitality=src.Pet_Max_Vitality

P.Stamina=src.Pet_Stamina
P.Vitality=src.Pet_Vitality
P.Chakra=src.Pet_Chakra

Pickup_Pet()
for(var/mob/NPC/Animals/P in oview(1))
if(P.Owner==usr)
usr.PetOut=0

src.Pet_Stamina=P.Stamina
src.Pet_Vitality=P.Vitality

del(P)
else
usr<<"This is not your pet."


Problem description: Taming the creature/pet seems to work, but when I try to drop the pet, all I get is a spam of 'You drop [petname]' and the pet doesn't come out.

Try:
P.Move(get_step(src, EAST))
Can you run a loop on the (src.x+1, src.y, src.z) turf to see if the pet is there?
Tested what you suggested. The pet still didn't show up even after putting it into an infinite loop, all I was left with again was;

You drop Test.
You drop Test.
You drop Test.
e.t.c
No, I don't want to know if it's on the ground. You're going to get a loop that works like that because the pet is still in the player's variable list or something (mob/pet = 1 or something).

No, I wanted you to loop through the turf's contents to see if the pet was there.
No the pet is never there.
Remove the if(P). I think because P's location 0,0,0 that it's not registering.
Removed if(P) pet still didn't show up.
Looks like usr abuse. Unless you know what you're doing, don't put usr in proc. This is a /mob proc, use src.
Tested the usr abuse theory. Changed whatever was usr to src, still didn't summon the pet into the world.
It wasn't usr abuse. Your logic looks fine, the last thing I could think of is that CommenceAI() proc that may be deleting the object before it's spotted.
Try
            var/mob/NPC/Animals/P=new/mob/NPC/Animals()
In response to Lugia319
Lugia319 wrote:
It wasn't usr abuse. Your logic looks fine, the last thing I could think of is that CommenceAI() proc that may be deleting the object before it's spotted.

I didn't even see this - if CommenceAI() is a loop it may not be deleting, it would need to return execution.
Checked Commence_AI() it isn't deleting the pet, and adding that onto the var didn't help either.

I dunno why this is happening. I get no run-time errors, no errors, nothing at all, but it doesn't bring the pet out.

Here is the Commence_AI

mob/NPC
proc/Commence_AI()
set background = 1
if(src.client||src.NPC_Type==""||src.NPC_Type=="Merchants")
return
else
if(src.NPC_Type=="Animal")
var
list/piv
attack

var/Tamerr=0
if(src.Owner)
var/mob/O=src.Owner
if(O.Controlled_Taming)
Tamerr=1
while(src.Vitality>0&&!Tamerr)
Roam
sleep(5)
piv = list()
while(piv.len<=0)
if(src.FrozenBind==""||src.FrozenBind==null)
step_rand(src)
sleep(25)
if(src.attacker!=null)
piv+=src.attacker
if(src:Fear_Level==4)
for(var/mob/NPC/Animals/m in view(src))
piv+=m
for(var/mob/NPC/Ninja/m in view((src.view/2),src))
piv+=m
if(src:Fear_Level==3)
for(var/mob/NPC/Animals/m in view((src.view/2),src))
if(m.Fear_Level<2&&m.name!=src.name)
piv+=m
for(var/mob/NPC/Ninja/m in view((src.view/2),src))
piv+=m
if(src:Fear_Level>=3||src:Fear_Level<=1)
for(var/mob/m in oview(src))
if(m.client&&m.key)
piv+=m
else
sleep(50)
var/A=pick(piv)
if(src.Overriding_Target)
A=src.Overriding_Target
src.attacker=A
while(get_dist(src.attacker,src)<=src.view&&!src.attacker:knockedout&&!src.attacker:Dead)
var/SleepTimez=1
if(src:Fear_Level==3)
SleepTimez=11
sleep(SleepTimez)
if(src.Stun>0) src.Stun--;sleep(1)
if(src.Stun>0)
src.Stun--
sleep(1)
if(src.Stamina<0)
var/Drain=abs(src.Stamina)
src.Stamina=0
src.Vitality-=Drain
if(src:Fear_Level>2||src.Vitality<src.Max_Vitality*0.25)
walk_away(src,src.attacker,20,2)
if(src:Fear_Level<=2&&src.Vitality>src.Max_Vitality*0.25)
if(get_dist(src,src.attacker)==1)
if(prob(10))
src.FaceAtom(src.attacker)
src.Right_Hand_Attack()
if(src:Fear_Level<2||prob(30))
src.Left_Hand_Attack()
var/random=rand(1,60)
if(random>50)
var/R=pick(-45,45,-90,90)
var/D=turn(src.dir,R)
src.dir=D
if(src.FrozenBind==""||src.FrozenBind==null)
step(src,src.dir)
else
if(src.FrozenBind==""||src.FrozenBind==null)
step_to(src,src.attacker,1)
if(src.attacker:Dead||src.attacker:z!=src.z)
src.attacker=null
goto Roam
Change this line:

src.Commence_AI()


to

spawn(0) src.Commence_AI()


This will say place Commence_AI in the queue, but don't stop execution until it returns.
Thanks for all the help. Putting spawn(0) seemingly fixed it.