Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075926 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:55:13 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)How to give specific steps to an object, do I need scripting?
Pages: [1]
Print
Author Topic: How to give specific steps to an object, do I need scripting?  (Read 692 times)
test84
Level 0
**


View Profile WWW
« on: November 03, 2011, 05:08:43 PM »

Hi,  Smiley

For one my enemies, my game designer needs to set specific steps for that level. For example I have an enemy that has four sections and he needs to call them the way he wants, like first spot, then second spot then first spot again then fourth spot four times and so on.

I wrote my code to handle these things, like how to wake one spot and tell the other one to sleep (by "active" property) but I don't know how to set those commands and where.

When I was at a AAA project, they used somekind of in-house text scripting (nothing like Lua, standard text) and parsed it and did what the text said but in flixel and my game, I don't have such thing. Since I will probably need this for bosses and so, thought asking you guys what would you suggest me to do and give some insights on big steps to do so. Should I parse a text? Should I somehow integrate Lua, which I have no idea how, or what.

As mentioned, I'm using flixel for my game.

Thanks.
Logged

Triplefox
Level 9
****



View Profile WWW Email
« Reply #1 on: November 03, 2011, 05:51:03 PM »

You don't need scripting until you know that there are specific bottlenecks with how you implement the boss movements, etc.

The most conservative way to do it is to hard-code behavior (timers, states, positions) so that you can learn more about the problem, and if your needs are small enough this may be fine for the game even if the iteration time is slow. Once you've done some work in this way, the things that need to be exposed as designer data will become more clear and you can restructure the code around those elements. Most of the time you will not need anything like a powerful scripting language.
Logged

Hima
Level 4
****


OM NOM NOM


View Profile WWW Email
« Reply #2 on: November 03, 2011, 08:54:31 PM »

I don't think you need to embed a scripting engine. If you want the designer to design the level easily, then I'd suggest a simple text format like XML or JSON. A simple JSON would be...

Code:
[
   [10, "SpawnEnemyGroupA"],
   [20, "SpawnEnemyGroupB"],
   [30, "SpawnEnemyGroupA"],
]
Where the format is 

Code:
[ time it happens, Function You want to call ]

Of course, you can make it in any way you want, but the point here is that let the text file act like a simple scripting. Then, you can just use the existing parser to parse each argument and response to it in your code. What I did in Unity is I let the designer write the level in google spreadsheet, and the debug version of the game would fetch the data from Google Doc, parse it and create the level according to the text in google spreadsheet

For boss movement, I'd hard code it, since there is a lot of possibility and it's very complex. If you want this to be flexible as well then you'd need some kind of scripting language. But since you're using flixel, so it isn't possible to use any scripting language as far as I know,  so your choice would be to use some kind of dynamic actionscript engine like
http://www.riaone.com/products/deval/ or http://eval.hurlant.com/

I've used deval in my project Grace's Diary. It was a visual novel, and I made a homebrew text scripting, but I integrated deval into my scripting so that if there is something too complicate to implement in my text scripting engine, I'd just call AS3 directly. Something like,

Code:
@@ShowImage  CG1, 0, 0,
@@ActionScript
      GameEffectManager.Instance.FlashScreen( 0, 0, 0, 5.0f );
      SceneManager.Instance.GoTo( new InventoryScene() )
@@End ActionScript
Logged

test84
Level 0
**


View Profile WWW
« Reply #3 on: November 04, 2011, 11:33:21 PM »

Thanks man, but I'm not timeline based. My spawner's work is done when all of enemies that it created are dead. I can find out when but I want a way to point the next spawner via that text file.

So I would write:
Spawner1, 1 // meaning call spawner1 and tell him to spawn 1 enemy
Spawner2, 2 // when we reach here, call spawner 2 and let him spawn 2 enemies
Spawner3, 1, Spawner4, 1
Spawner 2, 1

and like that.

I just don' know the big picture. Maybe I have to create a SpawnManager class and it reads a file, then instantiate spawners based on that file, then manage their behavior so when each of them returns that their work is finished, it would call other one(s) to start working.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #4 on: November 05, 2011, 03:49:35 AM »

I'd suggest a simple text format like XML or JSON.
+1. Parsing data is a pain, at least with XML or JSON (or standard scripting languages) this is done fore you.
Logged
Hima
Level 4
****


OM NOM NOM


View Profile WWW Email
« Reply #5 on: November 05, 2011, 05:31:57 AM »

Thanks man, but I'm not timeline based. My spawner's work is done when all of enemies that it created are dead. I can find out when but I want a way to point the next spawner via that text file.

So I would write:
Spawner1, 1 // meaning call spawner1 and tell him to spawn 1 enemy
Spawner2, 2 // when we reach here, call spawner 2 and let him spawn 2 enemies
Spawner3, 1, Spawner4, 1
Spawner 2, 1

and like that.

I just don' know the big picture. Maybe I have to create a SpawnManager class and it reads a file, then instantiate spawners based on that file, then manage their behavior so when each of them returns that their work is finished, it would call other one(s) to start working.

Parse every command and save it in a stack. Only pop the command and execute that command when there is no enemy on the screen. If the stack is empty, it means the stage is over.
You could even create all the spawners before hand and save it in the dictionary. Then the Spawner1 or Spawner2 in your json file would be the key to gain direct access to the spawner and pass the second one as an argument for a spawn method. What you describe is actually a good idea already, so you would have something like SpawnerManager class and Spawner Class, where SpawnerManager will read the text file, parse it and create many instances of Spawner and call it according to the parsed text file.
Logged

test84
Level 0
**


View Profile WWW
« Reply #6 on: November 06, 2011, 07:03:15 AM »

Thanks, I think we are getting somewhere.
I have one more thing on my mind about this matter, how I can make my SpawnManager go step by step through the sequence? Like it has to do the first group of name/numEnemies/etc then it has wait until the spawner returns something and then should fire the next group. How I can make it to work so?
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic