mob/proc
Initiate_Battle(mob/monster) //monster is the type of monster generated when entering turf
var/list/mob/order = new /list(rand(1,3) + 1) //turn order for battle
var/list/mob/monsters = new /list(order.len - 1) //list of monsters, used to choose which monster to attack
usr<<"[order.len]" //lets me know how many monsters are supposed to spawn
Create_Order(monsters,order,src,monster)
Test_Order(order) //lets me know the order to see if everything was added correctly
Create_Order(list/mob/monsters,list/mob/order,mob/player,mob/monster)
if(player.haste > monster.haste) //if player has higher haste
order += player //put him at the tope of the order
Add_Mons(monsters,order,monster) //add monsters to list
if(player.haste == monster.haste) //if equal haste
if(prob(50)) //50/50 who goes first
order += player
//Add_Mons(monsters,order,monster)
else
//Add_Mons(monsters,order,monster)
order += player
else
//Add_Mons(monsters,order,monster)
order += player
Add_Mons(var/list/monsters,var/list/order,var/mob/monster)
for(var/x = 1, x < order.len-1, x++) //while x < the length of the string - 1(minus one because one spot is reserved for player)
var/mob/y = monster //make a temp var that is the same as the monster type spawned
y.loc = locate(23,21-y,4) //assign location of monster
order += y //add monsters to order
monsters += y //add monsters to target list
Test_Order(var/tmp/list/Order)
var/tmp/mob/x
for(var/y = 1,y <= Order.len, y++)
x = Order[y]
usr<<"[y][x.name]"
/*********************************************************
*****************I tried a new way************************
*********************************************************/
mob/proc
Initiate_Battle(level) //monster is the type of monster generated when entering turf
var/list/mob/order = new /list(rand(1,3) + 1) //turn order for battle
var/list/mob/monsters = new /list(order.len - 1) //list of monsters, used to choose which monster to attack
usr<<"[order.len]" //lets me know how many monsters are supposed to spawn
AssignMon(monsters,level) // level is the monster's level group, its defined when the turf is entered
Test_Mons(monsters)
Test_Order(order) //lets me know the order to see if everything was added correctly
Create_Order(monsters,order,src)
Create_Order(list/mob/monsters,list/mob/order,mob/player)
var/mob/monster = monsters[1]
if(player.haste > monster.haste) //if player has higher haste
order = monsters.Copy(1,0)
order.Insert(1,player)
if(player.haste == monster.haste) //if equal haste
if(prob(50)) //50/50 who goes first
order = monsters.Copy(1,0)
order.Insert(1,player)
else
order = monsters.Copy(1,0)
order += player
else
order = monsters.Copy(1,0)
order += player
AssignMon(list/mob/monsters,level)
switch(level)
if("level1")
var/choice = rand(1,10)
if(choice >= 1 && choice <= 4)
for(var/x = 1, x < monsters.len, x++)
var/mob/y = new /mob/Monsters/Level1/Red_Slime
y.loc = locate(23,21-y,4)
monsters += y
if(choice >=5 && choice <= 8)
for(var/x = 1, x < monsters.len, x++)
var/mob/y = new /mob/Monsters/Level1/Goblin
y.loc = locate(23,21-y,4)
monsters += y
else
for(var/x = 1, x < monsters.len, x++)
var/mob/y = new /mob/Monsters/Level1/White_Tiger
y.loc = locate(23,21-y,4)
monsters += y
Problem description:
I'm trying to make a turn based battle system. I base it on the haste of the two mobs. I keep getting a run time error caused by Add_Mon(). I'm not sure how to correct it, please help.
Making a new mob and giving it the type path /monster (as opposed to /mob/monster) is probably not the way to go about making a new monster - And it may help to actually use the word new() somewhere, at that.
The correct way to do it:
;)
PS. In future, it would be more helpful if you could show us the runtime error you got (ie. copy + paste it) so that the people helping you can see any useful information about it that you might have left out in your post.