Author Topic: Need Help with Artificial Intelligence  (Read 4704 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Need Help with Artificial Intelligence
« on: December 02, 2010, 12:08:12 pm »
Can anyone who is proficient with Axe lend me some help with Artificial Intelligence for a Legend of Zelda RPG. I am looking to make the enemies on screen head toward your character, unless invisibility is active, and try to collide. The routine needs to:

1. Get the number of enemies on the screen (up to 5 enemies) and return it.
2. Get the positions of each of those enemies.
3. Process movement of each enemy toward the player (either all move once per loop, or one moves at a time).
4. Update sprite display for the enemies on screen.

I can likely handle the collision detect.

Thank you in advance, and anyone who helps will be credited appropriately.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Need Help with Artificial Intelligence
« Reply #1 on: December 02, 2010, 04:20:34 pm »
smoothscrolling or not?


Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Need Help with Artificial Intelligence
« Reply #2 on: December 02, 2010, 04:40:26 pm »
No. Once you move to a screen boundary, the LCD clears and updates with the next screen.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Need Help with Artificial Intelligence
« Reply #3 on: December 02, 2010, 04:45:51 pm »
and how is the data for the enemies stored? or do i just make them appear at random positions?


Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Need Help with Artificial Intelligence
« Reply #4 on: December 02, 2010, 04:53:13 pm »
The map data hold the type of map "block" at that position. A value of 0x04h for a tile indicates that there is an enemy at that location, as opposed to some other block. The map data comes from appvar "ZMapData".

There is also a tile value of 0x18h for an endboss, but don't bother with that-I'll code the endboss differently.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Need Help with Artificial Intelligence
« Reply #5 on: December 02, 2010, 05:11:47 pm »
This may be of interest to you: http://ourl.ca/7848

Good luck! ;D
« Last Edit: December 02, 2010, 05:12:37 pm by ztrumpet »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Need Help with Artificial Intelligence
« Reply #6 on: December 02, 2010, 05:26:47 pm »
because i don't feel like asking a thousands questions, i'm just going to assume your maps are 8x12 tiles and i'm going to make up my own variables as i go along. i am assuming each tile is a byte.

Code: [Select]
.the following variables you must supply. the rest will be calculated.
.MapWidth - the map's width in tiles.
.MapWidthScreens - the map's width in screens
.ScreenX - X position of screen in map
.ScreenY - Y position of screen in map
.MapPointer - pointer to the beginning of the map
.CharXPos - x position of zelda
.CharYPos - y position of zelda
.NumEnemies - number of enemies (get this by calling getEnemies)
.EnemySprite - pointer to the sprite of the enemy
For(LoopVar,1,NumEnemies
   {LoopVar-1*2+L1->Temp}+(<CharXPos)-({Temp}>CharXPos)->{Temp}
   Pt-On(,{Temp+1},EnemySprite)
   {Temp+1}+(<CharYPos)-({Temp+1}>CharXPos)->{Temp+1}
End
Return
.Call this routine whenever you change screens. it returns the number of enemies.
Lbl getEnemies
ScreenY*MapWidthScreens+ScreenX+MapPointer->ScreenPointer
0->Counter
For(Row,0,7)
   For(Column,0,11)
      If Counter!=10 and ({Row*MapWidth+Column+ScreenPointer}=4)
         Row*2048+Column*8->{L1+Counter}r
         Counter+2->Counter
      End
   End
End
Counter/2
Return





« Last Edit: December 02, 2010, 05:28:16 pm by nemo »


Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Need Help with Artificial Intelligence
« Reply #7 on: December 02, 2010, 05:45:05 pm »
The tiles are actually 8x8.
Each screen has 9 tiles across by 7 tiles down
I'm not sure how many screens will be in the map, but I'll decide soon.
The L1 freeram area is reserved for player save data. Can we use the next best thing for this (L3)?

Here are the list of blocks. I will specify which can be walked over and which cannot.

00= tree (impassable)
01= ground (passable)
02= water (impassable)
03= solid block (impassable)
04= enemy
05= ice (ground) (passable)
06= ice (block) (impassable)
07= lava (impassable) enemies cannot cross. player can, but takes constant damage.
08= 1 heart refill (impassable)
09= 1 heart container (impassable)
0A= magic refill (impassable)
0B= forest temple entrance (don't bother with these next 13, up to boss)
0C= water temple entrance
0D= fire temple entrance
0E= death mountain entrance
0F=  light world dungeon exit
10= ganon castle entrance
11= ganon castle exit to dark world
12= warp to boss
13= standard sword
14= master sword
15= wand
16= sorcerer's ring
17= mirror
18= boss (you will never encounter a boss on the same map as a 0x04h enemy, so don't bother)
19= dark world portal (impassable)
1A= zelda talk (from here on down are characters you can talk to or building entrances---impassable)
1B= sage talk
1C= old woman talk
1D= young man talk
1E= guardian talk
1F= prophet talk
20= forest guardian talk
21= water guardian talk
22= fire guardian talk
23= death mountain guard talk
24= death mountain magic warning
25= death mountain lava warning
26= dark world "toggle" hint
27= dark world magic warning
28= dark world "head to ganon's castle"
29= ganon's castle hint 1
2A= ganon's castle hint 2
2B= ganon's castle hint 3
2C= ganon's castle magic warning
2D= healing site
2E= sage house entrance
2F= family house entrance
30= zelda house entrance
31= guardian house entrance
32= prophet house entrance
33= temple of time entrance

Impassable means that the enemy cannot move through this block. Passable means it can. hope this helps.

Thanks alot for your help.
« Last Edit: December 02, 2010, 06:33:27 pm by ACagliano »

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Need Help with Artificial Intelligence
« Reply #8 on: December 11, 2010, 02:25:50 pm »
Let me know if I can help you out with this at all. If you have any questions, feel free to ask. I'll be around here frequently in the next week or so.