ID:262093
 
Ok, I'm tryin to sell a monster so that when bought, it appears on top of theplayer. Also I'm tryin to allow the monster to actually deal damage, here's the code:

Shopkeeper:

mob
Shopkeeper
icon = 'misc.dmi'
icon_state="keeper"
HP=99999999999999
density = 1
verb
Buy()
set src in oview(1)
set category = "NPC"
switch(input("What would you like to purchase?","Shopkeeper") in list ("Dragon","Black_Dragon","White_Dragon"))
if("Pet_Dragon")
if(usr.Gold <= 150)
usr << "You need more money to buy a dragon!"
if(usr.Gold >= 150)
usr << "
You have bought a dragon!!"
usr.Gold -= 150

if("Pet_Black_Dragon")
if(usr.Gold <= 300)
usr << "You need more money to buy a dragon!"
if(usr.Gold >= 300)
usr << "
You have bought a dragon!"
usr.Gold -= 300

if("Pet_White_Dragon")
if(usr.Gold <= 700)
usr << "You need more money to buy a dragon!"
if(usr.Gold >= 700)
usr << "
You have bought a dragon!"
usr.Gold -= 700

Pets:

pets //The different pets
icon = 'icons.dmi'
red
icon_state = "red"
orange
icon_state = "orange"
blue
icon_state = "blue"
yellow
icon_state = "yellow"
New() //When a pet is created
..()
spawn() StartPetAI() //Start the pet AI
proc/StartPetAI() //The StartPetAI proc
var/gottarget = 0 //Used to see if the pet has a target
for(var/mob/M in oview()) //For all the mobs in view of the pet
if(src.owner == M.key) //If that mob is the pet's master
walk_to(src,M,1,5) //Walk to that master
for(var/mob/H in oview()) //For all mobs in oview of the pet
if(H in src.killlist) //If H is in the pet's enemy list
if(gottarget == 0) //if H does not have a target
gottarget = 1 //H has a target!!!
walk_to(src,H,1,5) //Walk to that target
if(H in oview(1)) //If that target is one space away
step_towards(src,H) //Step towards that target causing a 'Bump'
spawn(5) StartPetAI() //in a half a second, restart StartPetAI()
Bump(mob/M) //What happens when a pet bumps
if(!M.client) //If M is not a player
PetDamage(M) //Calls the proc PetDamage and send M as info
proc/PetDamage(mob/M) //The proc, PetDamage
if(prob(83)) //83% chance of hitting
var/damage = rand(1,10) //Assigns a random number to damage, 1 - 10
view() << "[src] attacked [M] for [damage] damage!"
M.hp -= damage //Minus damage from M.hp
if(M.hp <= 0) //If the enemy is dead
del(M) //Delete the enemy
else
view() <<"[src] attacked [M] but missed!"
mob
Login() //When a player logs in
src.icon = 'icons.dmi' //Give him a Rifthaven Spazzy look
src.icon_state = "player"
src<<"Welcome to Rifthaven's Pet Demo!"
src.loc = locate(1,1,1) //Set's the player in the map at 1,1,1
var/whatpet = input(src,"What type of pet do you wish to have?","Selecting a pet")in list("Red","Orange","Blue","Yellow") //Gives the player an option between Red, Orange, Blue, and Yellow
var/mob/M //Makes the variable M, but does not assign it...yet
if(whatpet == "Red") //if the player chose "Red"
M = new/mob/pets/red(src.loc) //Assigns a Red pet to M, and creates it at the player's location
if(whatpet == "Orange") //if the player chose "Orange"
M = new/mob/pets/orange(src.loc)//Assigns a Orange pet to M, and creates it at the player's locatio
if(whatpet == "Blue") //if the player chose "Blue"
M = new/mob/pets/blue(src.loc)//Assigns a Blue pet to M, and creates it at the player's locatio
if(whatpet == "Yellow") //if the player chose "Yellow"
M = new/mob/pets/yellow(src.loc)//Assigns a Yellow pet to M, and creates it at the player's locatio
M.owner = src.key //Makes the newly created pet the player's
verb //Verbs for the player
Pet_Attack(var/mob/M in oview()) //You want your pet to do damage? Gives an option of all mobs in oview
set category = "Pet" //Puts this verb under a "Pet" tab
if(M.owner == src.key) //If you just sent your pet on itself
src<<"[M]: That's me, silly master!" //It'll let you know
else //If you sent it on a real monster
for(var/mob/H in oview()) //Searches for all mobs
if(H.owner == src.key) //If that mob is your pet
H.killlist.Add(M) //Adds M to your pet's list to kill
Pet_Status() //How is your pet doing?
set category = "Pet"
for(var/mob/M in oview()) //Searches for all mobs in oview
if(M.owner == src.key) //If that mob is your pet
src<<"[M]'s HP: [M.hp]" //Tells you your pet's status
Pet_Heal() //Gotta keep 'em alive
set category = "Pet"
for(var/mob/M in oview()) //Searches for all mobs in oview
if(M.owner == src.key) //If M is your pet
var/heal = rand(1,10) //Assigns a random number to heal, 1 - 10
M.hp += heal //Adds heal to M.hp
view() <<"[src] has healed [M] for [heal] points!"
if(M.hp > 30) //If M's hp is over it's max (which in this case is 30)
M.hp = 30 //Makes it equal 30
First of all use DM and /DM secondly what is wrong with the code? Most people don't like searching through tons of code.
In response to Artekia
What i'm tryin to do is to make the monster appear when bought and make it where the monster actually does damage when it attacks....
In response to Mecha Destroyer JD
(1). Do DM Tags
(2). Make the NPC a Turf, so users don't just hold down theri attack marco and kill him for laughs and giggles.
 
> Shopkeeper:
>
> mob
> Shopkeeper
> icon = 'misc.dmi'
> icon_state="keeper"
> HP=99999999999999
> density = 1
> verb
> Buy()
> set src in oview(1)
> set category = "NPC"
> switch(input("What would you like to purchase?","Shopkeeper") in list ("Dragon","Black_Dragon","White_Dragon"))
> if("Pet_Dragon")
> if(usr.Gold <= 150)
> usr << "<B>You need more money to buy a dragon!"
> if(usr.Gold >= 150)
> usr << "<B>You have bought a dragon!!"
> usr.Gold -= 150
>
> if("Pet_Black_Dragon")
> if(usr.Gold <= 300)
> usr << "<B>You need more money to buy a dragon!"
> if(usr.Gold >= 300)
> usr << "<B>You have bought a dragon!"
> usr.Gold -= 300
>
> if("Pet_White_Dragon")
> if(usr.Gold <= 700)
> usr << "<B>You need more money to buy a dragon!"
> if(usr.Gold >= 700)
> usr << "<B>You have bought a dragon!"
> usr.Gold -= 700
>
> Pets:
>
> pets //The different pets
> icon = 'icons.dmi'
> red
> icon_state = "red"
> orange
> icon_state = "orange"
> blue
> icon_state = "blue"
> yellow
> icon_state = "yellow"
> New() //When a pet is created
> ..()
> spawn() StartPetAI() //Start the pet AI
> proc/StartPetAI() //The StartPetAI proc
> var/gottarget = 0 //Used to see if the pet has a target
> for(var/mob/M in oview()) //For all the mobs in view of the pet
> if(src.owner == M.key) //If that mob is the pet's master
> walk_to(src,M,1,5) //Walk to that master
> for(var/mob/H in oview()) //For all mobs in oview of the pet
> if(H in src.killlist) //If H is in the pet's enemy list
> if(gottarget == 0) //if H does not have a target
> gottarget = 1 //H has a target!!!
> walk_to(src,H,1,5) //Walk to that target
> if(H in oview(1)) //If that target is one space away
> step_towards(src,H) //Step towards that target causing a 'Bump'
> spawn(5) StartPetAI() //in a half a second, restart StartPetAI()
> Bump(mob/M) //What happens when a pet bumps
> if(!M.client) //If M is not a player
> PetDamage(M) //Calls the proc PetDamage and send M as info
> proc/PetDamage(mob/M) //The proc, PetDamage
> if(prob(83)) //83% chance of hitting
> var/damage = rand(1,10) //Assigns a random number to damage, 1 - 10
> view() << "[src] attacked [M] for [damage] damage!"
> M.hp -= damage //Minus damage from M.hp
> if(M.hp <= 0) //If the enemy is dead
> del(M) //Delete the enemy
> else
> view() <<"[src] attacked [M] but missed!"
> mob
> Login() //When a player logs in
> src.icon = 'icons.dmi' //Give him a Rifthaven Spazzy look
> src.icon_state = "player"
> src<<"Welcome to Rifthaven's Pet Demo!"
> src.loc = locate(1,1,1) //Set's the player in the map at 1,1,1
> var/whatpet = input(src,"What type of pet do you wish to have?","Selecting a pet")in list("Red","Orange","Blue","Yellow") //Gives the player an option between Red, Orange, Blue, and Yellow
> var/mob/M //Makes the variable M, but does not assign it...yet
> if(whatpet == "Red") //if the player chose "Red"
> M = new/mob/pets/red(src.loc) //Assigns a Red pet to M, and creates it at the player's location
> if(whatpet == "Orange") //if the player chose "Orange"
> M = new/mob/pets/orange(src.loc)//Assigns a Orange pet to M, and creates it at the player's locatio
> if(whatpet == "Blue") //if the player chose "Blue"
> M = new/mob/pets/blue(src.loc)//Assigns a Blue pet to M, and creates it at the player's locatio
> if(whatpet == "Yellow") //if the player chose "Yellow"
> M = new/mob/pets/yellow(src.loc)//Assigns a Yellow pet to M, and creates it at the player's locatio
> M.owner = src.key //Makes the newly created pet the player's
> verb //Verbs for the player
> Pet_Attack(var/mob/M in oview()) //You want your pet to do damage? Gives an option of all mobs in oview
> set category = "Pet" //Puts this verb under a "Pet" tab
> if(M.owner == src.key) //If you just sent your pet on itself
> src<<"[M]: That's me, silly master!" //It'll let you know
> else //If you sent it on a real monster
> for(var/mob/H in oview()) //Searches for all mobs
> if(H.owner == src.key) //If that mob is your pet
> H.killlist.Add(M) //Adds M to your pet's list to kill
> Pet_Status() //How is your pet doing?
> set category = "Pet"
> for(var/mob/M in oview()) //Searches for all mobs in oview
> if(M.owner == src.key) //If that mob is your pet
> src<<"[M]'s HP: [M.hp]" //Tells you your pet's status
> Pet_Heal() //Gotta keep 'em alive
> set category = "Pet"
> for(var/mob/M in oview()) //Searches for all mobs in oview
> if(M.owner == src.key) //If M is your pet
> var/heal = rand(1,10) //Assigns a random number to heal, 1 - 10
> M.hp += heal //Adds heal to M.hp
> view() <<"[src] has healed [M] for [heal] points!"
> if(M.hp > 30) //If M's hp is over it's max (which in this case is 30)
> M.hp = 30 //Makes it equal 30

I felt nice.