mob
proc
Check_Objective(atom/A)
if(istype(A, /mob/monster))
for(var/obj/Questholder/Q in src.Questlog)
var/killcount = 0
if(!Q.completed && Q.quest_type == "Kill")
var/i = 1
for(i = 1;i <= Q.kill_target.len; i++)
var/killed = Q.kill_num[i]
var/tokill = Q.kill_amount[i] //this line does the same, no error
if(tokill == killed)
killcount++
if(A.type == Q.kill_target[i])
if(killed < tokill)
killed++
Q.kill_num[i] = killed
src << output("<font color = yellow>[A] [killed]/[tokill]</font>","spam")
if(tokill == killed)
killcount++
if(killcount == Q.kill_target.len)
src << output("<font color = yellow>[Q] Completed!</font>","spam")
Q.completed = 1
if(istype(A, /obj))
for(var/obj/Questholder/Q in src.Questlog)
var/collect = 0
if(!Q.completed && Q.quest_type == "Collect")
var/i = 1
for(i = 1; i < Q.collect_target.len; i++)
var/H = Q.collect_target[i]
var/J = Q.collect_num[i] // ERROR LINE
for(var/obj/K in src.contents)
if(K.type == H)
if(K.count >= J)
if(K.count == J && A.type == H)
usr << output("<font color = yellow>[K] [K.count]/[J]</font>","spam")
collect++
else if(A.type == H)
usr << output("<font color = yellow>[K] [K.count]/[J]</font>","spam")
if(collect == Q.collect_target.len)
usr << output("<font color = yellow>[Q] completed!</font>","spam")
Q.completed = 1
obj
Questholder
Reconstruction
collect_target = list(/obj/item/Alchemy/Orb_of_Gales, /obj/item/weapon/Adamantite_Rod)
collect_num = list(1,1)
It_is_Elementary
kill_target = list(/mob/monster/Flame_Head, /mob/monster/Lava_Golem)
kill_amount = list(5,3)
kill_num = list(0,0)
In my quest system, I utilize lists to hold the types of items or monsters that you need to collect or kill in order to complete the quests. Now then, the above code that handles collection type quests (where it checks the atom as an obj type) used to work without a problem. Now, all of a sudden it stopped working with no changes, giving the below runtime error.
runtime error: list index out of bounds
proc name: Check Objective (/mob/proc/Check_Objective)
source file: Quests.dm,33
usr: Asch (/mob/player)
src: Asch (/mob/player)
call stack:
Asch (/mob/player): Check Objective(Adamantite Rod (/obj/item/weapon/Adamantite_Rod))
Asch (/mob/player): Pickup(Adamantite Rod (/obj/item/weapon/Adamantite_Rod))
Pick Up Item (/obj/Spell_HUD/Pick_Up_Item): Click(null, "pane1.mainmap", "icon-x=14;icon-y=16;left=1;scr...")
What baffles me, though, is that the part of the code where the it checks for the mob type, it uses exactly the same code for filling the variable in the exact same manner and it does NOT have an error. Similar code is used to show progress in the quest log, and it does not have an error either. Even when showing the progress of a collection type quest.