ID:145516
 
Code:
mob/npc

var/list/agrolist

proc/ai_life()
//some more AI code here

var/agronum=0 //Agrovated number (anger level to a mob)
var/mob/M
for(M in oview(5))
//if faction is low
if(M.factionlist[src.race]< -900)
//add to agrolist
ai_add_agro(M,1)

//if there is an agrolist
if(src.agrolist.len)//if there is somethign in the agro list
for(M in src.agrolist)//Get the highest agro'd mob as my target
if(src.agrolist[M]>agronum && M.HP >0)//set target and new agro number and if they have any Hit points
src.enemy=M
agronum=src.agrolist[M]
//attack Target
if(src.enemy.HP > 0)//If the target has any hitpoint
walk_to(src,src.enemy,1)
src.Attack()
sleep(10)//delay
src.ai_life()//Check agro list again


Problem description:
Heres a bit of code from my AI procs. Im really not sure what part is giving me the problem so I dont exspect allot, but I was hoping that if there is somethign obvious to someone else maybe they'll point it out.

I get Index errors when running my game but the compiler sees no troubles
var/list/agrolist = list()

As far as I can tell, you never initialized the list.
In response to DarkCampainger
Ok, I just tried that and i still get the same inder errors...


runtime error: bad index
proc name: New (/mob/New)
usr: Grihm (/mob/npc/orc/trainers/swordmaster)
src: Grihm (/mob/npc/orc/trainers/swordmaster)
call stack:
Grihm (/mob/npc/orc/trainers/swordmaster): New(the grass (4,8,1) (/turf/grass))
Grihm (/mob/npc/orc/trainers/swordmaster): New(the grass (4,8,1) (/turf/grass))
Grihm (/mob/npc/orc/trainers/swordmaster): New(the grass (4,8,1) (/turf/grass))



the src, Grihm, is obviously the npc..
In response to karver
Euhm, could we see mob/New() ?
In response to Mysame
,dm>
mob/npc
New()//when a mob is created
..()
sleep(20)

if(isnull(src.client))//if it's not human

src.ai_life()//Go about your business

return..()//continue on with normal New() (create and whatnot)
else
return..()

</dm>

.. as requested

I do a New above this one under'mob' only as well..
mob
var/list/factionlist=list()

New()
ResetValues()
MakeMarkers()
factionlist+=src.race//adds the race name
factionlist[race]=300//adds the number of that faction with that race


I also have a New() under the NPC himself but I started it
mob/npc
orc
trainers
swordmaster
name="Grihm"
New()
..()
//code to add items and change some stats