ID:263197
 
Code:
chara/proc
Encounter()
var/times=10

var/mtype
var/list/monster/m
var/monster/mon
for(var/i=0;i<times;i++)
mtype=pick(typesof(/monster))
m+=new mtype()
for(var/monster/M in m)
if(!mon)
mon=M
else
var/oldrate=abs(mon.GetRating()-src.GetRating())
var/newrate=abs(M.GetRating()-src.GetRating())
if(newrate<oldrate)
mon=M
spawn()
src.Attack(mon)
spawn()
mon.Attack(src)


Problem description:
What I'm trying to do is make a list randomly from all the monster types and then pick the one that has the closest difficulty corresponding to the characters power. However, it just won't work. It gives a runtime error. It says there's a type mismatch. I must be missing where.
What line is the error on? Without knowing that, from my first glance I would guess that maybe your GetRating function is not returning a number.
In response to Loduwijk
Nevermind, I fixed it. The problem was (in case anyone's wondering) I had to change var/list/monster/m to var/monster/list/m. Silly mistake :P
In response to Dark Weasel
Dark Weasel wrote:
Nevermind, I fixed it. The problem was (in case anyone's wondering) I had to change var/list/monster/m to var/monster/list/m. Silly mistake :P

Why not just take out the "/monster" part of the var altogether?

Hiead