ID:148601
 
I'm stumped. I read threw it a few times but I ain't really thinking code, so i'm confused the problem is, when i get into combat it says the slime is there, but there is no icon of him. Also, he ain't attacking back. I had this working, let it sit, now it don't. Hmm? I also un-compacked the code so it'll be easier to modify / understand.

turf
battlegrass
Enter()
var/F=rand(0, 10)
if (F<5)
var/K
K=new/mob/monster/slime
usr.RandBattle(K)
return..()
mob
proc
RandBattle(var/mob/Defender,var/mob/Defender1,var/mob/Defender2)
var/turf/Location
for (var/turf/BattleLocation/BatLoc in world)
var/NotAvailable = 0
for(var/atom/A in BatLoc)
if(A.density==1)
NotAvailable=1
if(!NotAvailable)
Location=BatLoc
if (!Location){return}
OldX=usr.x
OldY=usr.y
OldZ=usr.z
usr.inpvp=1
usr.Move(locate(Location.x , Location.y, Location.z))
if(Defender)
Defender.Move(locate(usr.x+1,usr.y,usr.z))
Defender.inpvp=1
if(Defender1)
Defender1.Move(locate(usr.x-1,usr.y+1,usr.z))
Defender1.inpvp=1
if(Defender2)
Defender2.Move(locate(usr.x-1,usr.y-1,usr.z))
Defender2.inpvp=1
for(var/mob/H in world)
if(H.groups=="[usr]")
H.inpvp=1
for (var/atom/A in oview(1))
if(A.y==usr.y-1&&A.x==usr.x)
if(A.density==1)
H.loc=locate(usr.x,usr.y-2,usr.z)
else
H.loc=locate(usr.x,usr.y-1,usr.z)
var/mob/G
while(1)
if(usr.Health<=0)
..()
else
switch(input(usr,"What would you like to do?","????") in list ("Attack","Run"))
if("Attack")
var/list/peeps=new()
for(var/mob/E in oview(4))
if(E.groups=="[usr]")
..()
else
peeps+=E
if(E.Health<=0)
peeps-=E
if(Defender.Health<=0)
peeps-=Defender
else
peeps+=Defender
var/mob/d=input(usr,"Who would you like to attack?","Attack")in peeps
if(d==null)
return
var{h=50+usr.Dexterity;h2=h-d.Agility}
if(h2>100)h2=100
if(h2<0)h= 0
var{h3=rand(1,100);e=rand(usr.Strength);dc=e-d.Defense}
if(h3<=h2)
if(dc>0)
view(3)<<"<B><font color = aqua>[usr] Attacks [d], [dc] Damage."
d.Health-=dc
else
view(3)<<"<B><font color = yellow>[usr]'s attack bounced off [d]."
else
view(3)<<"<B><font color = green>[usr] attacks [d], but misses."
if(d.Health<=0)
view()<<"<B>[d] was slain!"
d.icon_state=""
var/c=0
for(var/mob/monster/F in oview(4))
if(F!=null)
if(F.Health>0)
c++
if(c<=1)
var/Gained_Exp
for(var/mob/monster/L in oview(5))
Gained_Exp+=L.exp
del L
usr.exp+=Gained_Exp
usr<<"Victory is at hand"
usr<<"You Gained [Gained_Exp] Experience!"
usr.loc=locate(OldX,OldY,OldZ)
for(G in world)
if(G.groups=="[usr]")
if(G.Health<=0)
..()
else
switch(input(G,"What would you like to do?","????") in list ("Attack","Run"))
if("Attack")
var/list/peeps=new()
for(var/mob/E in oview(4))
if(E.groups=="[usr]")..()
else
peeps+=E
if(E.Health<=0)
peeps-=E
if(Defender.Health<=0)
peeps-=Defender
else
peeps+=Defender
var/mob/d=input(G,"Who would you like to attack?","Attack")in peeps
view()<<"[G] Attacks [d]!"
d.Health-=G.Strength
if(d.Health<=0)
view()<<"<B>[d] was slain!"
d.icon_state=null
var/c=0
for(var/mob/monster/F in oview(4))
if(F!=null)
if(F.Health>0)
c++
if(c==0)
var/Gained_Exp
for(var/mob/monster/L in oview(5))
Gained_Exp+=L.exp
del L
usr.exp+=Gained_Exp
usr<<"Victory is at hand"
usr<<"You Gained [Gained_Exp] Experience!"
usr.loc=locate(OldX,OldY,OldZ)
if(Defender.Health<=0)
..()
else
for(var/mob/E)
if(E.y==Defender.y&&E.x == Defender.x+1&&E.Health>1)view()<<"[Defender] Attacks [E]!"
else if(E.y==Defender.y-1&&E.x == Defender.x+1&&E.Health>1)view()<<"[Defender] Attacks [E]!"
else if(E.y==Defender.y+1&&E.x == Defender.x+1&&E.Health>1)view()<<"[Defender] Attacks [E]!"



mob/monster
icon='monsters.dmi'
slime
icon_state="green"
Health=100
MaxHealth=100
Strength=2
Defense=1
Gold=100


The vars for the human player are set to.

RaeKwon
That code's a little big to read; also it'd be good for readability if you'd quickly replace all tabs with just 2 or 4 spaces.

One thing I did notice is that even though you're using a proc, usr is plastered all over your code. Best change that to src, as usr isn't helping anything. What's funny is you've actually got it manually set up as the target for input() when it's the default anyway, so it's wrong but it's wrong in a very deliberate way.

Lummox JR