Author Topic: I: VP tilemap help!  (Read 8065 times)

0 Members and 1 Guest are viewing this topic.

Offline c.sprinkle

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 221
  • Rating: +23/-1
  • There ain't no rest for the wicked? True indeed.
    • View Profile
    • The Corread on NationStates.
Re: I: VP tilemap help!
« Reply #15 on: January 18, 2011, 10:10:36 am »
I am using a turn-based system, but I was just wondering whether to have enemies move around and attack or not. Then you go to the turn-based system. If they don't move, it would probably be too easy to get around them.  :-\

Ashbad

  • Guest
Re: I: VP tilemap help!
« Reply #16 on: January 18, 2011, 10:29:40 am »
EDIT: wow I posted a lot of stuff :/  didn't know it was THIS much


I think I know what you mean though: Zelda II style of encountering enemies :D  Where the enemies move around on the map liek you, but you don't fight them until you and them meet on the overworld map.  Then the action begins.

I can give you some guidance on how to do moving enemies on an overworld map.  My enemies are all 8 bytes large in data each, in this format:

byte1: enemy type, 0 if null
byte2: enemy x
byte3: enemy y
byte4: enemy health
byte5: extra byte, used for type-specific actions
byte6: direction of enemy
byte7: enemy movement counter
byte8: counter for whether the enemy is flashing after taking damage

Basically, you have to initiate all the enemies you want to have with stats you decide on (I suggest no more than 3 enemies -- that can get rather slow rather quick)

Once you do that, here is what you can do:

Code: [Select]
...Enemies...
Lbl ENE  //label here for me, because I used the enemy loop as a subroutine
For(A,0,2)  //A loop that loops for every enemy you have, in this case 3
If {A*8+L1+400}  //Pretending that each enemy's stats are 8 bytes large and L1+400 to L1+423 is where the stats are held
//That also makes sure it's doing the following steps for an actual monster, not some random stats with no enemy type
(Here you do your method of collision detection, similar but not as advanced as for your avatar)(
(Here you see if your avatar and the enemy collide, and then the actions)
(Here you can do other stuff like changing directions and moving)
End
End  //End of For statement

^basic format of dynamic enemies on the overworld

The moving stats and stuff for my enemies take up no less than about 100 lines, so I won't go through them here; but I can give you more tips on how my format works great:

Really quick  --  make sure the bytes of stats enemies take up are a power of 2 for best speed (like 4, 8, or 16)
Accessibility --  to get to a stat easily, just do something like {A*8+L1+400+ (byte number of stat you wish to access - 1)}
Optimizational -- while this is already fast in {Loopvar * statvars_size + buffer + offset} format, you can always change something like:

Code: [Select]
If {A*8+L+403} < 5
0 -> {A*8+L+403}
Else
{A*8+L+403} - 1 -> {A*8+L+403}
End

to:

Code: [Select]
{A*8+L+400} -> H
If {H+3} < 5
0 -> {H+3}
Else
{H+3} - 1 -> {H+3}
End

cutting out half the size and speed.



If you have any more questions, feel free to post them, I can help you with anything you need! :D
« Last Edit: January 18, 2011, 10:30:15 am by Ashbad »

Offline c.sprinkle

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 221
  • Rating: +23/-1
  • There ain't no rest for the wicked? True indeed.
    • View Profile
    • The Corread on NationStates.
Re: I: VP tilemap help!
« Reply #17 on: January 18, 2011, 10:44:54 am »
Yep, I always use the {ptr}->indicator var so I don't have to type it back in and leave more room for things I have to change in case of size increases of the tilemap, etc. The beautiful thing is that my enemies only have to have a few bytes. So:
byte0- type
byte1- x
byte2- y
byte3- direction

The enemy collision will be part of the normal check. The stats are loaded by the battle engine.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: I: VP tilemap help!
« Reply #18 on: January 18, 2011, 03:24:11 pm »
If you mean enemies that shows up on the map while walking around, it is fine if they don't move, like in Final Fantasy Mystic Quest, but as long as you make sure a lot of them block pathways, to force the user to fight them. Moving enemies like in Lufia II or Super Mario RPG is another idea.