mob/Enemy
icon = 'Graphics/NormalBase.dmi'
var/const/ConstantValue = 32
New()
src.MaxHealth = round(((src.Level ** 2 * 115) / 100) + ((src.Level * ConstantValue) + 100))
src.MaxMana = round(((src.Level ** 2 * 105) / 100) + ((src.Level * ConstantValue) + 100))
src.Strength = round(((src.Level ** 3 / 100) / ConstantValue) + ((src.Level * 2) + ConstantValue))
src.Defense = round(((src.Level ** 3 / 100) / ConstantValue) + ((src.Level * 2) + ConstantValue))
src.Agility = round(((src.Level ** 3 / 100) / ConstantValue) + ((src.Level * 2) + ConstantValue))
src.Magic = round(((src.Level ** 3 / 100) / ConstantValue) + ((src.Level * 2) + ConstantValue))
src.Health = src.GetMaxHP()
src.Mana = src.GetMaxMana()
spawn(-1)
src.Wander()
return..()
proc
Wander()
while(src)
while(PausedMove) // PausedMove is a tmp variable
sleep(10)
for(var/mob/Player/P in oview(src))
if(get_dist(src, P) <= 3)
PausedMove = 0
walk_rand(src, 5, 1)
else
P = null
PausedMove = 1
src.loc = locate(initial(src.x), initial(src.y), initial(src.z))
break
sleep(10)
Problem description:
I tho about 2 ways to my AI don't use high CPU resources. 1 - I am showing it, I am trying to make my AI only to wander whenever a play is within the req. distance. If I don't use PausedMove, whenever I go out of his range, it constantly tries to move and respawn at same time. But if I am using PausedMove, it doesn't move at all, just stays there. What I want to accomplish is when player gets near AI, it will move but when it goes out of AI distance, AI should stop do anything.
2 - If I wanted to make my NPCs only to spawn whenever a user goes within the monster area, do I need to map them ? Or I can do it programmatically ?
One more question, why if I do this
for(var/client/C in oview(src))
// Instead
for(var/mob/Player/P in oview(src))
It doesn't even do anything.. ?
Thanks in advance.
For the second question - No, you can use pick on area.contents to return a random turf in the area, and spawn them to that location.
For the third, I believe it would be because client does not have a location so it never gets in the oview. You may need to do some special check to see if client.eye is in the range.