ID:261340
 
mob/npc/attackers /*this will only effect the mobs defined as mob/npc/"name"*/
var
think_delay = 10 /*this is a default think delay*/
New()
..()
spawn(rand(1,think_delay)) AILoop()
proc/AILoop()
var/mob/M /*this monster attacks mobs only*/
for(M as mob in oview(src)) break /*this is done to the mob closest*/
if(!M)
spawn(think_delay) AILoop()
return
if(get_dist(src,M) > 1)
step_towards(src,M)
spawn(think_delay) AILoop() /*this means, that if the opponent is more then a block away, the mob will walk toward him*/
else
flick("attack",src)
M.HP -= 10 /*again, this just takes hp from the opponent*/
M.DeathCheck() /*again this insures that the deathcheck proc is in effect*/
spawn(think_delay) AILoop() /*this means that the mob will wait its think_del



with that code tha AI still attack each other even though they are not ment to what could be added?
Super saiyan3 wrote:
with that code tha AI still attack each other even though they are not ment to what could be added?

Which line do you think is keeping them from attacking each other?
In response to Deadron
var/mob/M /*this monster attacks mobs only*/

this is supposed to stop them from doing it, but it does not work.
In response to Super saiyan3
This line does specify that the variable representing the thing they attack is a mob.

Monsters are mobs. Players are mobs. All God's children are mobs. You're telling them to attack anything, so they do.
In response to Lesbian Assassin
Can some one ive me a line that makes the A.I attack other players
In response to Super saiyan3
if(!M.client)//no client attached (NPC)
return..()
//don't attack
else
attack(M)
In response to Nadrew
Where exactly does that go?

i added it where
var/mob/M

was but it came up with a heck of amount of errors.
In response to Super saiyan3
Super saiyan3 wrote:
Where exactly does that go?

i added it where
var/mob/M

was but it came up with a heck of amount of errors.

I wouldn't help this guy anymore, at least not by giving him code. He's just going to paste it right into his game and not even think about what it does anyway.
In response to Ebonshadow
i agree you should think about what it does as to were to put it. I have made manny games and they all had many problems but i have done little posting.
In response to Ebonshadow
I know, that code I wrote works fine, except I have no idea how his code works so I don't know where it goes.
In response to Super saiyan3
Super saiyan3 wrote:
Where exactly does that go?

i added it where
var/mob/M

was but it came up with a heck of amount of errors.

You clearly don't have any idea what you're doing... do some more tutorials, read the guide and the reference, and do so with the right frame of mind.

Game making is not like playing with a set of Lego blocks (although Lego blocks can be just as fun)... you don't just take "a line" or "a code" and stack it on top of other lines. You have to think of every word in the code as... well, words... and you have to realize that those lines you're viewing as discreet snippets are actually sentences, instructions to the computer.

I know that I use different words to describe my monsters to the computer than you do for yours. How do I know this? Because we're making different monsters. The sentence I use to tell the computer that my monsters should only attack players wouldn't mean anything to the computer in your game.

Now, go back to the basics... figure out how to actually write code, instead of just rearrange it... and then think. What is a player? What is a monster? If there are "players" and "monsters" in your game, it's because you've told the computer "players are this" and "monsters are that." Now, you just have to tell it "attack this, but not that."
In response to Ebonshadow
Ebonshadow wrote:
Super saiyan3 wrote:
Where exactly does that go?

i added it where
var/mob/M

was but it came up with a heck of amount of errors.

I wouldn't help this guy anymore, at least not by giving him code. He's just going to paste it right into his game and not even think about what it does anyway.

Even though i love DBZ-Spar, which is beside the point do you actaully think i am sad enough to copy and paste examples of code?

I looked at it and added it where the A.I should check who to attack before Nadrews help.

Secondly its not really a game; its a Demo.
In response to Super saiyan3
Im new at this myself, so i needed all the help i could get. after playin with it a little sayin, i got it to work although not exactly like you wanted it but here it is :D


New()
..()
spawn(rand(1,50)) AILoop()
proc/AILoop()
var/mob/npc/M /*this monster attacks mobs only*/
for(M as mob in oview(src)) break /*this is done to the mob closest*/
if(!M.client) //this looks for mobs that are "client controlled"
spawn(50) AILoop()
return
if(get_dist(src,M) > 1)
step_towards(src,M)
spawn(50) AILoop() /*this means, that if the opponent is more then a block away, the mob will walk toward him*/
else
spawn(50) AILoop() //this means that the mob will wait its think_del
damage= roll("2d4")
world << "The [src] deals [damage] damage to [M]!"
M.HP -= 5 /*again, this just takes hp from the opponent*/
M.DeathCheck() /*again this insures that the deathcheck proc is in effect*/

and.. to reply to assasin's remark:
You clearly don't have any idea what you're doing... do some more tutorials, read the guide and the reference, and do so with the right frame of mind.

Game making is not like playing with a set of Lego blocks (although Lego blocks can be just as fun)... you don't just take "a line" or "a code" and stack it on top of >other lines. You have to think of every word in the code as... well, words... and you have to realize that those lines you're viewing as discreet snippets are actually >sentences, instructions to the computer.

dude this is like taking a new language you want to learn and all you have to go by is a dictionary (it aint gonna happen without help) :D
btw thx again :)

-Darien "Hawkeyes"