ID:148627
 
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 set, now it don't. Hmm?
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==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)
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=10
MaxHealth=100
Strength=2
Defense=1
Gold=100


RaeKwon
Raekwon, your like a really good coder and I suck soo... I cant help ya. I wish I could man. Oh and you need to teach me how to code! =). Later.
In response to SSJKaclis
SSJKaclis wrote:
Raekwon, your like a really good coder and I suck soo... I cant help ya. I wish I could man. Oh and you need to teach me how to code! =). Later.

That sure helped.

RaeKwon
In response to RaeKwon
Lol yes It did help.... ME! rofl.
Anyone got any idea...?

RaeKwon
In response to RaeKwon
RaeKwon wrote:
Anyone got any idea...?

RaeKwon

Well that's one rather large chunk of code to read. You should probably cut up that proc into several smaller ones. It's also harder to read with all those if statements having a command after them on the same line. If you want help debuging a piece of code it's best to have it in an easy to read form and if you can the problem narrowed down as much as possible.

Anyways some debugging tips would be to output important variables at multiple times to check on the state of things to try and see exactly where things go wrong. Make sure to send any bounds errors to the world.log even in they seem infeasable since it's easy to make stupid mistakes. If all else fails think up some test data and manually read your code and try to interpret the code as the seeker would do. This may be slow and painful but it usually catches those "No duh" errors. Occasionally small mistakes mis-interpreted by the compiler makes everything go wrong.