this is a two part question..
ok first of all here is the first piece of unfinished coding..
mob/var
spawnchance=0
targeter=0
area/spawnisland
Entered(atom/movable/O)
..()
if(ismob(O))
var/mob/M = O
if(M.targeter==0)
M.spawnchance=rand(1,9)
if(M.spawnchance==3)
if(M.level<=30)
//Here I want to spawn monsters around the player
whats the code to use for making the enemys appear or what should I use rather?
next part:
when the enemy is spawned, I want it to focus on killing the player who spawned it.
so how would I do this,
I created a variable called "targeter"
so...
heres my current AI code:
mob
Heartless
name = "Shadow"
icon = 'HartlessMob.dmi'
class = "Heartless"
Mhealth=300
density = 1
HL=1
level=1
New()
src.move()
Bump(mob/M)
if(ismob(M))
if(M.client)
Fight(M)
else
return
else
..()
proc/Fight(mob/M)
var/damage = rand(5,10)
M.Mhealth -= damage
s_damage(M,damage,"#FFFFFF")
M.death()
proc
move()
for(var/mob/M in range(10))
if(M.client)
step_towards(src,M)
spawn(15)
src.move()
ok, so obviously I need to make the AI a bit smarter..
which I'll actually do.
but for now I just want to switch it up to where it only chases the player who spawned it.
and then if the player is out of range, I want it to delete itself..
anyone care to lend a hand?
-------if(M.level <= 30)---------------
you should put somthing like this....
And just repeat the var/mob/(Change Letter Here!) part for howmany heartless you want to appear becide them but remember to change the A to some other letter or else you'll end up with a runtime error
By the way instead of this part of your spawning code
it would be much easyier by duing the prob() in their such as this
Edit: i just typed in a long explination on how you could do the second halve of your question, but i accidentally pressed Tab and Backspace so i'm gonna have to type it all again D:<
How you could do your second part of what i'm thinking what you have to do is to create a var into the Heartless which tells them who their Creator is ex. usr.key, which would look somthing like this
Now you have to add in a part where it tells them who the creator is and you should put this in the same spot where you made it create the random heartless,
now what you have to do last is make the proc where the heartless checks the person before it attacks, for example (i have to get off the comp soon so i'm not gonna do the coding for this again...) their are two people playing your game, Example1, and Example2 (that is their byond keys) Example1 watches as Example2 Creates a series ammount of heartless around him, the heartless see both mobs, and they are confused on which one to attack. What you want is for the Heartless to attack their creator, so add a part in to the move() proc you already have in which the heartless have to check the var/Creator first before they pick which one to attack, do you understand so far? and if Example2 flee's from the area, they would go and attack Example1 because they would be just randomly walking around and doing nothing.
P.S. I haven't tested the code above out so dont complain if it doesn't work, i tried to specify what I mean the best i could.
Oh ya and I sent you an Email about aplication for your game as a pixel artist, I just forgot to add in that my byond key is Xxdragonslxx.