ID:146971
 
Yeah, uh.. i cant figure out why they wont. this is my code.

mob
verb
Attack(mob/M as mob in oview(1))
set category = "Combat"
var/damage = usr.Str - M.Def
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.Hp -= damage
s_damage(damage)
view() << "[usr] attacks [M] for [damage]!"
M:Death()


mob
proc
MonsterAttack(mob/M)
if(src.attacking == 0)
src.attacking = 1
//var/parrylist = list("High","Middle","Low")
//continu = 1
//else
// continu = 1
//tryagin
//if(continu == 1)
var/damage = src.Str - M.Def
M.Hp -= damage
view() << "[M] takes [damage] damage from [src]!"
M:Death()
sleep(src.Delay)
src.attacking = 0

ai_walk_to()
if(src.client)
return 0
else
for(var/mob/M in oview(5,src))
if(M.client)
if(get_dist(src,M) <= 5)//within 5 tiles
walk_to(src,M,1,5)//walk to the player
ai_check_dist(src,M)//checks distance
break//stops the loop
else
continue
else
continue

ai_check_dist(mob/attacker,mob/defender)
if(attacker.client)
return
else
if(get_dist(attacker,defender) <= 1)//if the monster is one tile away from the player
attacker.MonsterAttack(usr)//attack!
else
return


mob
proc
Death(mob/M)
if(src.client)
Playerdie()
else
if(src.Hp<=0)
view()<<"<b>[src] has been killed by [usr]!"
GlobalRepopWithDelay()
usr.exp += src.expgive
usr.Gold += src.goldgive
Levelup()
del(src)
Playerdie(mob/M)
if(src.Hp<=0)
view() << "[src] Died!"
src.loc = locate(3,5,1)
src.Hp = Max_Hp
GlobalRepopWithDelay()

proc/GlobalRepopWithDelay()
/* spawn() is used here so that the proc will return
and Death() may continue without waiting */

spawn(600) // do the following in 15 seconds
world.Repop()


mob/var
Delay = 10
killlist = list("")
attacking = 0
mob
monster
Mutant_Mushroom
icon = 'characters.dmi'
icon_state = "49"
Hp = 15
Max_Hp = 15
Delay = 60
Str = 5
expgive = 1
goldgive = 2
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes


mob
monster
WereWolf
icon = 'characters.dmi'
icon_state = "50"
Hp = 30
Max_Hp = 30
Delay = 40
Str = 10
expgive = 3
goldgive = 5
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
You never tell it to attack. You have only designed the proc to attack, it is never called upon. If you wish to call it keep the proc checking and add like a check for mobs being in the overview and if they are then tell it to walk towards it and if it is in the distance you desire call the damaging effect of the proc. If this makes no sense to you just say so and ill send you a demo.

~BlueScourge
In response to Blue Scourge
Ummm, a demo would be helpful XP
No put usr in proc. Ungh.

Lummox JR
In response to Lummox JR
Well i still dont know.. O.o

PS. I edited my code abit. this is the new version

mob
verb
Attack(mob/M as mob in oview(1))
set category = "Combat"
var/damage = M.Str - src.Def
if(damage <= 0)
M << "[src] easily dodges your attack!"
src << "You easily dodge [M]'s attack."
else
M.Hp -= damage
s_damage(damage)
view() << "[src] attacks [M] for [damage]!"
if(M.client)
M:Death()
else
M:Death()


mob
proc
MonsterAttack(mob/M)
if(M.attacking == 0)
M.attacking = 1
//var/parrylist = list("High","Middle","Low")
//continu = 1
//else
// continu = 1
//tryagin
//if(continu == 1)
var/damage = M.Str - src.Def
src.Hp -= damage
view() << "[src] takes [damage] damage from [M]!"
src:Death()
sleep(src.Delay)
M.attacking = 0

ai_walk_to()
if(src.client)
return 0
else
for(var/mob/M in oview(5,src))
if(src.client)
if(get_dist(src,M) <= 5)//within 5 tiles
walk_to(src,M,1,5)//walk to the player
ai_check_dist(src,M)//checks distance
break//stops the loop
else
continue
else
continue

ai_check_dist(mob/attacker,mob/defender)
if(attacker.client)
return
else
if(get_dist(attacker,defender) <= 1)//if the monster is one tile away from the player
attacker.MonsterAttack(defender)//attack!
else
return


mob
proc
Death(mob/M)
if(src.client)
Playerdie()
else
if(src.Hp<=0)
view()<<"<b>[src] has been killed by [usr]!"
GlobalRepopWithDelay()
usr.exp += src.expgive
usr.Gold += src.goldgive
Levelup()
del(src)
Playerdie(mob/M)
if(src.Hp<=0)
view() << "[src] Died!"
src.loc = locate(3,5,1)
src.Hp = Max_Hp
GlobalRepopWithDelay()

proc/GlobalRepopWithDelay()
/* spawn() is used here so that the proc will return
and Death() may continue without waiting */

spawn(600) // do the following in 15 seconds
world.Repop()




mob/var
Delay = 10
killlist = list("")
attacking = 0
mob
monster
Mutant_Mushroom
icon = 'characters.dmi'
icon_state = "49"
Hp = 15
Max_Hp = 15
Delay = 60
Str = 5
expgive = 1
goldgive = 2
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes


mob
monster
WereWolf
icon = 'characters.dmi'
icon_state = "50"
Hp = 30
Max_Hp = 30
Delay = 40
Str = 10
expgive = 3
goldgive = 5
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
In response to Takaru
I repeat: No put usr in proc. Ungh.

And don't use the : operator. Although there are legitimate uses for it, it's absolutely a bad idea for someone who's having code problems because all it does is change a compile-time error to a potential runtime error.

Lummox JR
In response to Lummox JR
Hmm, I know that this topic is pretty much dead, But Lummox, If not usr, Then what?
In response to Takaru
Takaru wrote:
Hmm, I know that this topic is pretty much dead, But Lummox, If not usr, Then what?

Since it isn't a datum, try using "src" instead of usr.
In response to Lenox
Lenox wrote:
Takaru wrote:
Hmm, I know that this topic is pretty much dead, But Lummox, If not usr, Then what?

Since it isn't a datum, try using "src" instead of usr.

Absolutely wrong. You can't simply start substituting things haphazardly and expect it'll turn out all right.

In this case the usr abuse happens in Death(), where src is the victim (and rightly so). Replacing usr, which was meant to represent the killer but really could be anything, with src, would be counting the death as a suicide. The killer should be M, the argument sent to the proc.

Lummox JR