Re: [GD-Design] Scripting Engine and C++ Games
Brought to you by:
vexxed72
From: Mickael P. <mpo...@ed...> - 2002-07-19 09:36:52
|
> Yes, you've hit on a big part of the reason for ICE. We wanted a > language that end users could use. But we also wanted a language that > could support a robust, object-oriented coding style, because we > expected to write huge portions of our game in it. We shipped 40K > lines of ICE code as part of the game. > > I do think you should think seriously about your programming language > design. You can design for simplicity, but just make sure it's the > right kind of simplicity. All too often, simplicity of implementation > is confused with simplicity of language design. There are a lot of bad > scripting languages around that were easy to write but are not so easy > to use. As usual it's a matter of requirements. Before deciding for any kind of script language you have to know who will be using that language. So far I've worked on two projects where 100% of the game logic was made using a scripting language: "Little Big Adventure" (LBA) and "Time Commando". We know from the start for both those projects that a part of game coding will be done by people with almost no experience in programming, so we decided to make something very simple (and well, it was in 1995...) that even a non programmer would be able to understand. And I have to say that the result was ok. The game itself is perhaps not that good, but almost everybody was capable of pointing out bugs in behaviors by looking into the source code. For those interested, here is the complete source code (I just translated the french names in english for understandability) of the behavior of the "Sabertooth tiger" encountered in the level 1 of Time Commando: ===================================== StartProgram Tiger // Last update Mike: Sun 02/06/96 // // While the hero is not around here, do nothing // if the hero arrived at less than 2 meters of // distance, start roaring. // DoAnimRepeat Nothing If GetDistance(Hero)>3000 AND !TestTouched SetBeta 460 WaitDistance 6000 DoAnimRepeat Walk Wait GetDistance(Hero) < 2000 OR TestTouched If GetDistance(Hero) > 2000 AND !TestTouched DoAnimRepeat Guard FollowHero DoAnimOnce Roar WaitAnim EndIf EndIf // // The hero is now in the fight area. // Loop FollowHero DoAnimRepeat Guard While TestAlive(Hero) distance_hero=GetDistance(Hero) If GetSameHit > 2 AND GetDifficulty <> 0 Fury Furie WaitAnim ResetSameHit ElseIf distance_hero > 3200 // // At more than 3.2 meter, approach slowly // DoAnimRepeat Walk ElseIf distance_hero >= 3000 // // Between 3m et 3.2m, use the long jump // DoAnimOnce GetValueList(-1, LongJumpAttack, Roar) WaitAnim ElseIf TestBetween(distance_hero,700,900) // // Closer, try to bite // DoAnimOnce GetValueList(-1, BiteAttack, Guard) WaitAnim ElseIf distance_hero < 700 // // If too close for efficient hitting, get back or bite // If GetRandom(1) DoAnimOnce Recule Else DoAnimOnce GetValueList(-1, BiteAttack, Guard) EndIf WaitAnim ElseIf distance_hero > 1900 // // At more than 1,90m, stay on guard // and from time to time launch a roar. // DoAnimRepeat Guard If !GetRandom(10) DoAnimOnce GetValueList(-1, Roar, LongJumpAttack, Guard) WaitAnim Endif Else // // Hand to hand distance // If TestHeroAttacking & GetRandom(1) DoAnimOnce Recule Else DoAnimOnce GetValueList(-1, ClawAttack, Guard) Endif WaitAnim Endif ExitProgram EndWhile UnFollow DoAnimRepeat Nothing DoAnimOnce Roar Wait TestAlive(Hero) ExitProgram EndLoop EndProgram ===================================== It will certainly not win any award for engeeniering quality, but it was easy to code, easy to maintain, easy to extend. Please note that the language as a very special notion of case sensitiveness, that helps us a lot during production: It's case sensitive in the meaning that when you write something in a certain form, you have to use this form later. So it avoids people writing "Hero", "hero", "HERO" to indicate the same thing... but there is also a case insensitive check on each new encountered symbol, so you cannot have to variable/keywords/functions/objects that have the same name differently only by the case. Mickael Pointier |