Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to: script Artificial Intelligence
#21
(06-20-2012, 07:41 AM)Alblaka Wrote:  Uhm, how do I tell the AI to WALK into a certain direction?
We can only issue left() and right()... and without globals it's hard to make the AI only press it ONCE, exspecially since the self.left readers barely work.
if (self.state==0){left()}

i guess i will include this in the first post as silva might not include a hold button command
Reply
Thanks given by:
#22
(06-20-2012, 02:14 PM)YinYin Wrote:  
(06-20-2012, 07:41 AM)Alblaka Wrote:  Uhm, how do I tell the AI to WALK into a certain direction?
We can only issue left() and right()... and without globals it's hard to make the AI only press it ONCE, exspecially since the self.left readers barely work.
if (self.state==0){left()}

Doesn't work if the char is moving on z axis, as well.
As well a normal AI is sort of never "standing around", but doing something, thus state==0 is rare if I don't enforce the AI to be idling. If I do, it would sort of result in 1-0-1-0-1 movement (1 tick moving, 1 tick state 0).
Too lazy to code that variant right now, but may that would still trigger running (as it's a double-tap into a single direction).
My Creations: (Click to View)

Return (String) System.getNewsOfTheDay();
Barely active, expect slow responses. If at all.


Greetz,
Alblaka
Reply
Thanks given by:
#23
trust me it works
yes you do have to skip basic AI
but you never get to see the standing frame as it starts walking before that gets printed to the screen

and the double tap for running only works in state 1, which wont happen with this code

edit: and z axis movement can be done separately and they work perfectly at the same time - see my mirror AI
edit: i guess i will start a thread with all my AI scripts just like you
edit: also state 0 is not rare for basic AI - it can be read after every next 999 before it starts walking off again
Reply
Thanks given by:
#24
Hmmm... I will have to refine some lines of my AI scripts then.. currently Striker tends to do an interesting running back and forth dance for a few seconds until he manages to stop within the target area ^^'
My Creations: (Click to View)

Return (String) System.getNewsOfTheDay();
Barely active, expect slow responses. If at all.


Greetz,
Alblaka
Reply
Thanks given by:
#25
(06-20-2012, 02:14 PM)YinYin Wrote:  if (self.state==0){left()}
hm i thought i had it working already - in the current version i cannot get it to make the character only walk left anymore ...

edit: updated vrest arest clone and shake description
Reply
Thanks given by:
#26
How do i let the AI switch the target to a ball if it is near?
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#27
you will need to run a for loop inside the id function that goes through all object slots that can contain hostile projectiles and check them all through (distance/direction/speed, team and type)
store the object number if the conditions for it being threatening are met - overwrite it if you find a closer/more threatening object in a later loop

once the loop is done reload the most threatening object (last object number stored) - voila, target changed

keep in mind you will also need to still apply conditions for normal character targeting (and possibly also item picking if you want your char to do that)
Reply
Thanks given by:
#28
UPDATE for Angel Script!

now including a separate function and error section

edit: i might be missing a few new variables - i will double check them myself later but if you already recognize something missing just post it here
Reply
Thanks given by: A-Man
#29
Nice work man. There is still one thing you forgot to note. The line number noted in the exception starts the counting with 1, and starts counting at the first line of the text file, not the main function. It took me a while to figure out that the first blank lines are counted, and i kept staring at the right code thinking that the problem is there.
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#30
well i am kind of assuming you are using some sort of editor that does the line and position counting for you just like the data changer - this is pretty common
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)