Index · Preferences · Help
Announcements · BYOND Features · Bug Reports · Fixes and Features · Developer How-To · Code Problems · Design Philosophy · Creations · Classified Ads · Gaming · Computers & Technology · Community
Forum Search:

[Advanced Search]

[Messages in this Thread] [Show All (12)] [Return to Code Problems]

Author:Garthor [Posts]
Date:11/7/09 1:57 pm
Topic:Re: AI problem
Post ID:726190
Parent ID:726186
Next ID:726193
First, your AI proc is written wrong. It should look more like this:

mob/proc/AI()
  while(src)
    for(var/mob/M in oview(5,src))
      if(M.client)
        if(get_dist(src,M) > 1)
          step_to(src,M)
        else
          src.attack(M)
        //break so we don't try to attack two players at once
        break
    //sleep 2 ticks between moves
    sleep(2)

I don't know what you want the AIdef() proc to be, so it just shouldn't exist really.

Second, you need to change oview(2) in your attack() proc to be oview(2,src). Though, probably it should be view().

Third, you are never actually calling your AI() proc. The line that you do have:

mob
  CircleDemon
    AI()

doesn't call the proc, it overrides it and replaces it with one that does nothing. To call it, you should put it in New(), like so:

mob
  CircleDemon
    New()
      ..()
      spawn() AI()

spawn() is used because we don't want to wait for AI() to finish (as it never will) before continuing with the New() proc.

Messages in this Thread: [Show All (12)]

  AI problem Scarymonkeys623 (11/7/09 1:46 pm)
      Re: AI problem Garthor (11/7/09 1:57 pm)
          Re: AI problem Scarymonkeys623 (11/7/09 2:11 pm)
              Re: AI problem Garthor (11/7/09 2:40 pm)
                  Re: AI problem Scarymonkeys623 (11/7/09 3:03 pm)
                      Re: AI problem Kaioken (11/7/09 3:46 pm)
                          Re: AI problem Garthor (11/7/09 6:29 pm)
                              Re: AI problem Kaioken (11/11/09 11:07 am)
                                  Re: AI problem Loduwijk (11/11/09 11:54 am)
                                      Re: AI problem Kaioken (11/12/09 5:41 am)
                                          Re: AI problem Garthor (11/12/09 12:36 pm)
                                              Re: AI problem Loduwijk (11/12/09 4:30 pm)