Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Enemy A.I.

Author
Message
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 18th Feb 2009 18:52 Edited at: 2nd Mar 2009 14:28
Can someone help me create AI for now I just need to get a sphere to follow the player and I need it to kill the player if it touches them.The player also has to be able to kill it by shooting it
This is my code with the A.I. from Quirkyjim. It dose not work. Do NOT do it for me but I would like someone to help me correctly insert it

Thanks sixty squares bambam

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 18th Feb 2009 19:46
Here is some simple chasing ai:


Perfect? No. But it will give simple chasing ai to the enemy. The logic:
If my target is to my left, I go left. Otherwise I go right.

If my target is behind me, I go back, otherwise I go forward.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 18th Feb 2009 23:16
Quote: "Otherwise I go right."

What if you're directly behind the player?
...and therein lies the problem of a simple ai such as this.

I'd go more like this:



~QJ
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 19th Feb 2009 04:56
If Dist#<200
point object enemy towards player
move object enemy 5
endif


(psuedo code lol)
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 19th Feb 2009 05:41
@Quirky
Yeah, you caught the fundamental problem, however, if it is a pixel based system (not tile based), it wouldn't make too much of a difference, and the enemy would end up shuddering a little.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 20th Feb 2009 01:09 Edited at: 25th Feb 2009 02:53
can someone help me figure out what I am doing wrong
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 20th Feb 2009 07:49
A tip:
Most people are reluctant to do the work for you. The idea is that you post here to learn how to do it and we can help you implement it, but very rarely will someone actually write code into your code for you.

Here is some chase and evade code I wrote a while back. Don't recall ever finishing the whole thing, but got the logic in (including getting the chaser to aim itself ahead of the the evader so as to intercept it).



Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 21st Feb 2009 16:04 Edited at: 7th Mar 2009 22:47
BN2 I tried and couldn't get it to work I edited my code to show I tried so could you read the code I edited and see if it is right

You didn't say anything Caleb
Wait now I see it never mind
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 21st Feb 2009 19:46
Maybe the simple Point Object and Move object AI system would work here?



Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th Feb 2009 21:51
thats what i said! aahhh i'm being ignored! lol
Urist McCoder
19
Years of Service
User Offline
Joined: 27th Sep 2005
Location: At the computer.
Posted: 6th Mar 2009 01:04
The easiest way is the point object command. Point the enemy at the player and have him move. Theirs one problem with this though; the enemy won't move around objects. For me, he simply went through the objects in the way. For getting hurt, you could have a variable that goes down when the enemy object collides with you. One other thing is that you should stop the enemy object if he collides with you too. Otherwise he will push the player back.
The pizza man
17
Years of Service
User Offline
Joined: 7th Aug 2007
Location:
Posted: 6th Mar 2009 01:42
Dude! Your enemy A.I. code is outside of your game loop. It's only going run that part once.

Hehe

Login to post a reply

Server time is: 2025-05-17 03:36:31
Your offset time is: 2025-05-17 03:36:31