Infinite loop suspected--switching proc to background.
If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: AI (/mob/enemy/proc/AI)
usr: Guest-308764653 (/mob)
src: the skull (/mob/enemy/skull)
usr.loc: Grass (7,14,1) (/turf/Grass)
src.loc: AI (9,15,1) (/turf/AI)
call stack:
the skull (/mob/enemy/skull): AI()
AI (8,14,1) (/turf/AI): Enter(Guest-308764653 (/mob), Grass (7,14,1) (/turf/Grass))
Here is my current code for the turf as well as the proc and enemy. This code format was found in the Dante's tutorial here https://www.youtube.com/ watch?v=sqGp3LGBRuc&list=PLvvX2aT8X6e6Lnry3-kp5_aiD0vo57YDR& index=10
Code:
mob/enemy
var/intelligence=0
skull
icon='skullenemy.dmi'
icon_state="skull"
baseIcon="skull"
New()
src.respawn=src.loc
proc/AI()
while(src.intelligence==1)
/* for(var/mob/m in view(3,src))
if(m.client&&src.target==null)
walk_towards(src,m,0,3)
src.target=m*/
if(src.target!=null)
var/mob/Target=src.target
if(Target.x<src.x-3||Target.x>src.x+3)
walk(src,0)
src.loc=src.respawn
src.target=null
src.intelligence=0
for(var/mob/m in get_step(src,src.dir))
if(m.client&&src.icon_state!="")
var/damage=src.str-(m.def/3)
m.hp-=damage
m.healthCheck()
src.deathCheck(m)
world<<"hey *8"
sleep(10)
turf/AI
icon='Grass.dmi'
icon_state="grass"
Enter(var/mob/m)
if(m.client)
for(var/mob/enemy/e in view(3,m))
if(e.target==null)
walk_towards(e,m,0,3)
e.target=m
e.intelligence=1
e.AI()
return 1
mob/proc/deathCheck(var/mob/killed)
if(killed.hp<=0)
if(killed.client)
killed.loc=locate(1,1,1)
killed.hp=killed.maxhp
killed.healthCheck()
else
var/mob/enemy/e=killed
killed.icon_state=""
walk(killed,0)
killed.loc=killed.respawn
killed.overlays-=killed.healthBar
var/obj/bar/healthOverlay/o=new();killed.overlays-=o
e.intelligence=0
sleep(50)
killed.icon_state=killed.baseIcon
killed.hp=killed.maxhp
killed.healthCheck()
killed.target=null
Problem description:
Here is all the code I have from the tutorial's AI turf video. Any help would be greatly appreciated.
Now, your main problem is right here:
At not point does src.intelligence change to a value that will allow the loop to terminate, and thus you have an infinite loop. There are many other problems with your code, though.
As for your other problems:
In this case, intelligence is what is known as a Boolean type. The specific value of it doesn't matter, only whether it's "true" or "false". DM does not have a specific boolean type as some other languages do (or data types at all), so it's more a semantic property rather than a syntactic property. Nevertheless, the values 0, null, and "" (an empty string) are all treated at "false", while everything else is treated as "true".
A good litmus test for whether something should be treated as boolean or not is: when this value is equal to 1, will it behave any differently at all compared to when it's equal to 2 or 3 or any other value? If the answer is "no", then you should treat is a boolean.
Thus, in this situation what you should have is,
src is not necessary or helpful here, so you can leave it off without issue.
So, what is going on in the above is that states in DM act only on boolean data; that is, whether a condition is "true" or "false". Because intelligence is set to a non-false value, it is true, and so the code will execute.
The second problem is that the above loop "should" be more like this:
Indentation is syntactically-important in DM, as it determines how the compiler interprets code order and scope. Because of how you had it above, there was nothing in the while loop and thus it just saw it as "so long as this value is true, do nothing over and over and over again". How I have it here, it interprets it as "so long as this value is true, do the stuff the code here tells me to".
There are numerous other issues that I'll get to in another reply, beyond the relevant stuff here, but I need to take care of some things first. Needless to say, though, stop using that tutorial. The person has barely an inkling of what they're doing.