Author Topic: RTS  (Read 14162 times)

0 Members and 1 Guest are viewing this topic.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: RTS
« Reply #20 on: April 14, 2007 »
coming along nicely the scrolling screen seems to be a nice choice even though it is more challenging to pull off

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: RTS
« Reply #21 on: April 17, 2007 »
I dont know if this can be useful in any way but years ago I coded this up on the PS2 it runs at good speed on the old black box and is a fairly large terrain with trees and hills if you are interested in using this I can clean it up a whole lot and make it even faster with more trees etc. also I can understand if you aren't interested its probably not a large enough terrain for your RTS and the black background / end of the terrain makes it seem even smaller but fell free to use it if you like.

Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #22 on: April 17, 2007 »
Thnaks, I'll see what it's like!
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #23 on: April 17, 2007 »
Thanks awesome!!!

 :updance:

Truely amazing! Hmm... yea - bummer it only uses the one screen.
Just a thought - if I implement it - would it make the RTS really slow? like - mega slow down?

We'll see about it. If it can be made into a larger size - then it would be a great addition if it was to be put in!

K+
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: RTS
« Reply #24 on: April 17, 2007 »
its gonna be slower then 2D you could reduce it to 16x16 but that would mean the map would be too small for a RTS but there is one trick that can speed it up that I learned much later than I coded this. This will be a top down game so you can rotate the terrain just once and store the coordinates then to move about the map all you have to do is add an offset for x & y (leave z alone) then apply perspective to the new co-ordinates and you have a 3D speeded up terrain this trick only works as long as the angles of rotation are fixed. moving the terrain like this is called translation. this may double the speed of the terrain but for large maps it will still be slow especially with the number of units moving around at once
« Last Edit: April 17, 2007 by rain_storm »

Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #25 on: April 19, 2007 »
Well, I think that I won't have the Options (Attack, Move, Stop)... I will just have it so that when you select a unit, it automatically has the Move function (press X and they move to that spot, press TRI and it de-selects)
If you want to attack you will have to scroll over the enemy and the attack cursor will appear (press X and you set the unit to attacking that enemy)
If you want to stop, select the unit and press CIRCLE.

I guess this will make it easier... (alot more like a real RTS).

I've mad a large map (press START to view, SEL to exit)

I'm wondering how I will be able to make AI!!! ??? kinda scarey thinking about it!
I don't want it so that you can pawn them all the time. That you will actually need to think a little before you build your units and just trounce the oppo!!!
hmmm... Well, I'll consintrate on getting the options done, then the movement. Then I'll think about the firing of your units!!!
... not sure how deep and fast flowing that river will be... but when it's done, I'll get cracking on some basic AI.
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: RTS
« Reply #26 on: April 19, 2007 »
For AI think about state machines.  Each 'thing' in your world has a state (or set of states) - what that thing is currently being or doing.  When one thing interacts with another thing it will change one or more states of each thing.
A simple one might be a player paying a non-player character (npc or AI) for some information.  cash for player goes down, cash for npc goes up, and player has information.
A more complicated one might be a npc on a quest - when he meets the thing he's questing for, they might compare states (good, evil, strength, army size) and then decide to make friends or have a battle.  As players move through the landscape their state might change from 'go to land of other player' to 'go to city of other player' once they're inside the bounds of the land.  Also, rand() is a VERY good piece of AI, it'll persuade most people.

Try to draw out the states for each thing on a piece of paper.  How many things can each thing in your world do?  How does it go from doing or being one thing to another thing?  Writing it down will help you understand better what you're trying to do and to avoid deadlocks (cycles or stuck states where the thing can't stop doing what it's doing).

Jim
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #27 on: April 21, 2007 »
Nice. I'll see what I can get up too!
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #28 on: April 22, 2007 »
For the AI, is something like:

--
Statments and Commands
--

000 - OFF
:: No Signal, specifys that unit is dead.

001 - ON
:: Signal, specifys that unit is alive.
   Specifys that the unit is on stand-by.
   >> No movement, and no attacking.

002 - MOVE
:: Specifys that the unit is randomly moving.
   >> Random movement.

003 - FIND
:: Specifys that the unit is searching for a unit to attack.
   >> Normally finds closest if;
      01: Number of units is proximity of other unit is low (~3)
      02: Units health is higher than 75%
      03: Other units health is lower than 85%
   >> Errors;
      01: If other unit is a jet, than a soldier will not seek

004 - CALL
:: Specifys that the unit is in trouble and needs assistance.
   >> Normally because the units health is low.
      01: Will call if the enemys health is low, and if no more than
          3 enemy units are included in, or surrounding the battle
   >> Errors;
      01: A soldier will not be called

005 - RETREAT
:: Specifys that the unit is not capable of defeting the enemy, and will
   try and evade all other attacks and return to base.
   >> Retreat will occur when;
      01: Units health is lower than 15%
      02: Enemys health is higher than 70%
      03: Enemy units in proximity is more than 2


That good for a basic start?

Attatched is the working demo of the states... not finished.
« Last Edit: April 22, 2007 by CLANKY »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: RTS
« Reply #29 on: April 22, 2007 »
Here is a really good way to control the flow of the ai so that the correct actions are taken and only the correct actions are considered

Code: [Select]
// (must start with one not zero so correct this now)
jumppoint = ai_state + 1

// on goto will allow you to jump to different positions in the code which label the code will jump to
// is dependent on the value of the variable used to call on goto
on jumppoint goto dead, stand_by, random_movement, search_for_enemy, call_for_help, retreat

label dead
// dead routine

label stand_by
// stand by routine

label random_movement
// random movement routine

label search_for_enemy
// search for enemy routine

label call_for_help
// call for help routine

label retreat
// retreat routnine

the on goto command will prove invaluable in an ai routine those labels that are in the list can be laid out any way you want and given any functionality desired but can be optimised for dealing with a certain set of conditions in this case the current state of a particular unit. "on goto" can also be called as "on gosub" but on gosub cannot be used within a subroutine due to the fact that return will break out of the subroutine instead of returning to the calling point. There is another advantage in using on goto it helps to make your code more modular each label can be cut out and replaced without effecting the functionality of the other labels

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: RTS
« Reply #30 on: April 22, 2007 »
Quote
That good for a basic start?
Yes, that's exactly the kind of thing you need to do.

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: RTS
« Reply #31 on: April 23, 2007 »
Forgot to say thats really compact code for getting the units to move to destinations less than 100 lines of code thats real nice +K

Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: RTS
« Reply #32 on: April 23, 2007 »
Thanks  :D
The random movement will be different... I wont use Up, Down, Left Right... but have angles so it looks sommother. Not sure whether or not this will make the code longer - or slower. But I'll see where it goes.

I still need to do the code for call and retreats, but it's all basically there.
I will also make it so that the FINDING unit will stop within a range around the enemy unit, attack until either the enemies death or retreat / call is satisfied - instead of having it so it's random selection and changes when ever.

Got class - so an update probably around 8.00 - 9.00 (my time)

--
EDIT
--

Cant do much more tonight - have to do other things. I added the range function.. and have made health for them. I am now working on the RETREAT and CALL commands.
« Last Edit: April 23, 2007 by CLANKY »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..