ID:266382
 
I got this code of of a lib i want to ask a few questions

CODE


mob
proc
Levelup()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp0
src.maxexp*=2//makes your maxexp double
src<<"You gained a level!"
src.Statup()
else
..()//defaults if the if() doesn't return it's arguments
mob
proc
Statup()
src.maxhealth+=20//adds to your health
src.health=src.maxhealth
src<<"Your stats increase!"//Outputs a message telling you that you gained stats
//Call both of these procs in your attack process here's an example

/*
mob/verb/Attack(mob/M as mob in oview(1))
usr.exp+=1
usr.Levelup()//called the procs
*/

//End proc defining

//Start var defining
mob
var
health = 100//Makes a var called health and gives it the value 100
maxhealth = 100
exp = 0
maxexp = 1000
level = 1
//end var defining

//start stat process

mob
Stat()//Calls the stat proc.
..()
statpanel("Stats")//Makes a new statpanel called "Stats"
stat("Health","[health]/[maxhealth]")
stat("Experience","[exp]/[maxexp]")//Creates a new stat called "Experience" and gives it the value of "exp/maxexp"
stat("Level",level)

/*
Now, for the demo internals here. These procs and verbs are
only for the demo, you don't need them, but you can still learn from them
I'll even comment them for you :)

-Nadrew
*/

mob/proc/attack(mob/M)//This will be used to make the demo challenging
var/damage = rand(1,15)//a bit of damage never hurt..wait, yes it does!
M<<"[src] attacked you for [damage] damage!"
if(src.client)
src<<"You attacked [M] for [damage] damage!"
M.health-=damage
src.deathcheck(M)
if(src.client)//Only players can gain levels
src.exp+=rand(50,300)//adds random exp points
src.Levelup()//calls the levelup proc
else
return..()//normal action
mob/proc/deathcheck(mob/M as mob)//handles death
if(M.health<=0)//checks health
if(M.client)//if is a player
M.loc = locate(1,1,1)//restarts
M.health = M.maxhealth//resets health
M<<"[src] killed you!"//tells you, you were killed.

else//not a player
src<<"You killed [M]!"//Tells you who you killed
M.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.ma xz))
//random location after death

//Now for the NPC things.

mob/NPC//Defines a /mob/NPC
icon = 'slime.dmi'
icon_state = "slime"
Click()//When clicked
usr.attack(src)//attack!
proc/move()//Now, this proc handles NPC movement
for(var/mob/M in oview())//loops over all mobs in view
if(get_step_away(src,M,3))//checks distance
if(!M.client)//Not a player
continue//continues through the loop
else//Player
walk_to(src,M,1,0)//Move to the person
else//4-or-more spaces away
continue
spawn(20) move()//loops the proc after 2 seconds

proc/attackplayer()//Handles attacking
for(var/mob/M in oview(1))//Within one space this time
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.attack(M)//Calls the attack proc
else
return..()
spawn(20) attackplayer()

New()//When created
attackplayer()//Calls the procs for it
move()

Its for a battle system i have a few questions

1. When he regenerates how do i make it to where he goes back to just wondering around and not attacking me

2.How do I make it to ware if he get a few steps behind me he stops attacking me and wonders areound agian
Flame Sage wrote:
I got this code of of a lib i want to ask a few questions

CODE


mob
proc
Levelup()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.level++//Add to your level
src.exp=0//resets your exp0
src.maxexp*=2//makes your maxexp double
src<<"You gained a level!"
src.Statup()
else
..()//defaults if the if() doesn't return it's arguments
mob
proc
Statup()
src.maxhealth+=20//adds to your health
src.health=src.maxhealth
src<<"Your stats increase!"//Outputs a message telling you that you gained stats
//Call both of these procs in your attack process here's an example

/*
mob/verb/Attack(mob/M as mob in oview(1))
usr.exp+=1
usr.Levelup()//called the procs
*/

//End proc defining

//Start var defining
mob
var
health = 100//Makes a var called health and gives it the value 100
maxhealth = 100
exp = 0
maxexp = 1000
level = 1
//end var defining

//start stat process

mob
Stat()//Calls the stat proc.
..()
statpanel("Stats")//Makes a new statpanel called "Stats"
stat("Health","[health]/[maxhealth]")
stat("Experience","[exp]/[maxexp]")//Creates a new stat called "Experience" and gives it the value of "exp/maxexp"
stat("Level",level)

/*
Now, for the demo internals here. These procs and verbs are
only for the demo, you don't need them, but you can still learn from them
I'll even comment them for you :)

-Nadrew
*/

mob/proc/attack(mob/M)//This will be used to make the demo challenging
var/damage = rand(1,15)//a bit of damage never hurt..wait, yes it does!
M<<"[src] attacked you for [damage] damage!"
if(src.client)
src<<"You attacked [M] for [damage] damage!"
M.health-=damage
src.deathcheck(M)
if(src.client)//Only players can gain levels
src.exp+=rand(50,300)//adds random exp points
src.Levelup()//calls the levelup proc
else
return..()//normal action
mob/proc/deathcheck(mob/M as mob)//handles death
if(M.health<=0)//checks health
if(M.client)//if is a player
M.loc = locate(1,1,1)//restarts
M.health = M.maxhealth//resets health
M<<"[src] killed you!"//tells you, you were killed.

else//not a player
src<<"You killed [M]!"//Tells you who you killed
M.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.ma xz))
//random location after death

//Now for the NPC things.

mob/NPC//Defines a /mob/NPC
icon = 'slime.dmi'
icon_state = "slime"
Click()//When clicked
usr.attack(src)//attack!
proc/move()//Now, this proc handles NPC movement
for(var/mob/M in oview())//loops over all mobs in view
if(get_step_away(src,M,3))//checks distance
if(!M.client)//Not a player
continue//continues through the loop
else//Player
walk_to(src,M,1,0)//Move to the person
else//4-or-more spaces away
continue
spawn(20) move()//loops the proc after 2 seconds

proc/attackplayer()//Handles attacking
for(var/mob/M in oview(1))//Within one space this time
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.attack(M)//Calls the attack proc
else
walk_rand(src)
spawn(20) attackplayer()

New()//When created
attackplayer()//Calls the procs for it
move()

Its for a battle system i have a few questions

1. When he regenerates how do i make it to where he goes back to just wondering around and not attacking me

I don't know what you mean, please be more specific.

2.How do I make it to ware if he get a few steps behind me he stops attacking me and wonders areound agian

I edited your (my) code to do that read the code up there ^.