moeng-cvs Mailing List for Moonlight Engine (Page 4)
Status: Alpha
Brought to you by:
b_lindeijer
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(145) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(226) |
Feb
(13) |
Mar
(5) |
Apr
(13) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(3) |
2007 |
Jan
(4) |
Feb
(27) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <b_l...@us...> - 2004-01-13 19:48:45
|
Update of /cvsroot/moeng/CaveAdventure In directory sc8-pr-cvs1:/tmp/cvs-serv4247 Modified Files: TODO Log Message: Cave Adventure needs menu and HUD. Index: TODO =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/TODO,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TODO 13 Jan 2004 19:43:12 -0000 1.1 --- TODO 13 Jan 2004 19:48:41 -0000 1.2 *************** *** 12,15 **** --- 12,17 ---- * Killing a spider * Footsteps + - Add menu + - Re-add HUD Bjorn: |
From: <b_l...@us...> - 2004-01-13 19:46:36
|
Update of /cvsroot/moeng/CaveAdventure/src In directory sc8-pr-cvs1:/tmp/cvs-serv3708 Removed Files: Canvas.cpp Canvas.h Console.cpp Console.h Engine.cpp Engine.h Makefile RPG.cpp RPG.h Script.cpp Script.h Sound.cpp Sound.h TiledMap.cpp TiledMap.h lunar.h Log Message: Removed some source files. --- Canvas.cpp DELETED --- --- Canvas.h DELETED --- --- Console.cpp DELETED --- --- Console.h DELETED --- --- Engine.cpp DELETED --- --- Engine.h DELETED --- --- Makefile DELETED --- --- RPG.cpp DELETED --- --- RPG.h DELETED --- --- Script.cpp DELETED --- --- Script.h DELETED --- --- Sound.cpp DELETED --- --- Sound.h DELETED --- --- TiledMap.cpp DELETED --- --- TiledMap.h DELETED --- --- lunar.h DELETED --- |
From: <b_l...@us...> - 2004-01-13 19:43:17
|
Update of /cvsroot/moeng/CaveAdventure In directory sc8-pr-cvs1:/tmp/cvs-serv3015 Modified Files: .cvsignore rpg.cfg Added Files: TODO rpgedit.cfg update.bat Log Message: Misc stuff --- NEW FILE: TODO --- Legenda: ! Essentieel - Normaal ? Niet belangrijk Niet ingedeeld: - Experience fijn tunen - Sounds effects * Magic by EnemyCaveman * Hitting a spider (splotch) * Killing a spider * Footsteps Bjorn: - Re-introduce the map names - Fix AI for spider queen - Inventory ! Experience/levelup afmaken Georg: Frode: Hedde: --- NEW FILE: rpgedit.cfg --- [startup] load_map=data/maps/cells.map [video] fullscreen=0 width=1014 height=690 [tile_zoom] zoom_width=73 zoom_height=100 grid=0 # Automatically imported tilesets [tileset1] filename=data/bitmaps/jail_tiles.bmp tile_w=24 tile_h=24 tile_spacing=0 [tileset2] filename=data/bitmaps/tiles_subcity.bmp tile_w=24 tile_h=24 tile_spacing=0 [tileset3] filename=data/bitmaps/tiles_sewers.bmp tile_w=24 tile_h=24 tile_spacing=0 --- NEW FILE: update.bat --- del data.dat dat -a -k -t LUA data.dat data\scripts\*.lua dat -a -k -t BMP data.dat data\bitmaps\*.bmp data/bitmaps\*.tga dat -a -k -t FONT data.dat data\bitmaps\font_*.* dat -a -k -t MAP data.dat data\maps\*.map dat -a -k -t SAMP data.dat data\samples\*.wav Index: .cvsignore =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 30 May 2003 21:18:19 -0000 1.2 --- .cvsignore 13 Jan 2004 19:43:12 -0000 1.3 *************** *** 7,8 **** --- 7,11 ---- *.rar *.png + Makefile + rpg + rpgedit Index: rpg.cfg =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/rpg.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rpg.cfg 13 Jan 2004 17:18:06 -0000 1.1 --- rpg.cfg 13 Jan 2004 19:43:12 -0000 1.2 *************** *** 1,14 **** ! [Engine] ! Fullscreen=0 ! DoubleSize=0 ! VSync=0 ! DebugMode=0 ! DebugVerbose=0 ! ResolutionWidth=320 ! ResolutionHeight=240 ! ColorDepth=32 ! ! [Sound] ! EnableMusic=0 ! StreamChunkSize=32768 ! BufferSize=65536 --- 1,21 ---- ! [Engine] ! DebugMode=0 ! DebugVerbose=0 ! GameClass=CaveAdventure ! GameSpeed=100 ! LogEnabled=1 ! ! [Video] ! Fullscreen=0 ! DoubleSize=1 ! VSync=0 ! ResolutionWidth=320 ! ResolutionHeight=240 ! ColorDepth=32 ! ! [Sound] ! MusicEnabled=1 ! MusicFormat=MIDI ! MusicVolume=128 ! SfxEnabled=1 ! SfxVolume=255 |
From: <b_l...@us...> - 2004-01-13 19:42:55
|
Update of /cvsroot/moeng/BBRpg/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv2902/data/scripts Removed Files: CaveObjects.lua Log Message: Removed two Cave Adventure files. --- CaveObjects.lua DELETED --- |
From: <b_l...@us...> - 2004-01-13 19:42:54
|
Update of /cvsroot/moeng/BBRpg In directory sc8-pr-cvs1:/tmp/cvs-serv2902 Removed Files: README.CaveAdventure Log Message: Removed two Cave Adventure files. --- README.CaveAdventure DELETED --- |
From: <b_l...@us...> - 2004-01-13 19:31:30
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv31662 Added Files: Zzz.lua Log Message: Problemfile renamed. --- NEW FILE: Zzz.lua --- -- -- Z (sleeping thingy) -- import("Decoration.lua") import("AnimationFunctions.lua") Zzz = Decoration:subclass { name = "Z"; init = function(self) animSeq = { {self.animBmps[1], 10}, {self.animBmps[2], 1}, {self.animBmps[3], 2}, {self.animBmps[4], 2}, {self.animBmps[5], 1}, {self.animBmps[6], 1}, {self.animBmps[7], 2}, {self.animBmps[8], 2}, {self.animBmps[9], 1}, {self.animBmps[10], 1}, {self.animBmps[11], 1}, }, Decoration.init(self) self.animation.animation_speed = 0.2 end; defaultproperties = { animType = FrameDurationAni, animBmps = extr_array(m_get_bitmap("z.tga"), 24, 24), obstacle = 0, --offset_y = -6, tick_time = 1, draw_mode = DM_ALPHA, }; } |
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv30243 Modified Files: ActionController.lua Actor.lua Animation.lua Controller.lua Decoration.lua EnemySpider.lua Fence.lua Object.lua PlayerController.lua QueenController.lua Added Files: AnimationFunctions.lua Boss.lua CaveLang.lua CaveObjects.lua CaveTriggers.lua Caveman.lua ConversationWindow.lua DgeMapSwitches.lua Dummy.lua Game.lua Guard.lua IngameMenu.lua Interaction.lua InteractionMaster.lua LanguageMenu.lua MainMenu.lua Map.lua MusicController.lua PlayerSwitcher.lua Portal.lua Prisoners.lua Radio.lua Shadow.lua Sound.lua TextProvider.lua Log Message: A lot of more scripts. --- NEW FILE: AnimationFunctions.lua --- -- -- Animation functions to help extracting animations from bitmaps -- -- -- Creates subbitmaps and puts them in an array in the following structure: -- -- {u1, l1, r1, d1, -- u2, l2, r2, d2, -- u3, l3, r3, d3, -- ua, la, ra, da} -- -- Expecting the following bitmap structure: -- -- {d1, d2, d3, da, -- u1, u2, u3, ua, -- r1, r2, r3, ra, -- l1, l2, l3, la} -- function extr_char_anim(bm, w, h) -- Function shortcut local csb = m_create_sub_bitmap if (not bm) then m_message("extr_char_anim(): no bitmap!"); return; end if (not w) then w = 24 end if (not h) then h = 48 end return { csb(bm, 0, h, w, h), csb(bm, 0, h*3, w, h), csb(bm, 0, h*2, w, h), csb(bm, 0, 0, w, h), csb(bm, w, h, w, h), csb(bm, w, h*3, w, h), csb(bm, w, h*2, w, h), csb(bm, w, 0, w, h), csb(bm, w*2, h, w, h), csb(bm, w*2, h*3, w, h), csb(bm, w*2, h*2, w, h), csb(bm, w*2, 0, w, h), csb(bm, w*3, h, w, h), csb(bm, w*3, h*3, w, h), csb(bm, w*3, h*2, w, h), csb(bm, w*3, 0, w, h), } end -- -- Creates an array of subbitmaps from a given bitmap and given the size -- of each individual frame. Frames are extracted from the bitmap like: -- -- {1, 2, 3, 4, -- 5, 6, 7, 8} -- function extr_array(bm, w, h, spacing) if (not bm) then m_message("extr_array(): no bitmap!"); return; end local bw, bh = m_bitmap_size(bm) local bm_array = {} if (not w) then w = bw end if (not h) then h = bh end if (not spacing) then spacing = 0 end for y = 0, (bh / h) - 1 do for x = 0, (bw / w) - 1 do table.insert(bm_array, m_create_sub_bitmap(bm, x*(w+spacing), y*(h+spacing), w, h)) end end return bm_array end --- NEW FILE: Boss.lua --- -- boss.lua -- The big fat green boss import("Character.lua") -- -- The behaving boss with normal sit-in-chair mode -- CaveBoss = Character:subclass { name = "Boss"; defaultproperties = { draw_mode = DM_MASKED, speed = 3, bitmap = m_get_bitmap("boss_1.bmp"), }; } -- -- The super evil, hovering, boss -- EnemyBoss = Character:subclass { name = "EnemyBoss"; init = function(self) inherit(self, BasicChar) inherit(self, BossAI) self:event_init(self) -- Set our own common options self.attack_range = 2 -- nvt self.attack_min_damage = 0 self.attack_max_damage = 0 self.draw_mode = DM_MASKED self.speed = 3 self.bitmap = m_get_bitmap("boss_1.bmp") end; attack = function(self, obj) --ShootPoison(self, obj) end; died = function(self) self.animation = nil --self.bitmap = m_get_bitmap("spider2_dead.bmp") -- -- BIG BOSS DIES SEQUENCE ADDED HERE!!! -- ActionController:addSequence({ ActionAddSequence({ ActionSetVariable(self, "draw_mode", DM_TRANS), ActionSetVariable(self, "goal_z", 0), ActionTweenVariable(self, "alpha", 25, 255), }), ActionWait(50), ActionConversation(lang:getConv("BOSS_BEATEN_1")), ActionExModeOn(), ActionWait(25), ActionTweenVariable(self, "alpha", 200, 0), ActionDestroyObject(self), ActionWait(25), ActionChangeDirection(m_get_player(), DIR_DOWN), ActionConversation(lang:getConv("BOSS_BEATEN_2")), ActionFadeOutMap(100), ActionSetPosition(m_get_player(), 35, 11, DIR_DOWN), ActionSetVariable(m_get_player(), "tick_time", 0), -- DISABLELNG PLAYER TICK! ActionChangeBitmap(m_get_player(), m_get_bitmap("frode_sit1.tga")), ActionSetPosition(cavem1, 33, 11, DIR_RIGHT), ActionSetPosition(cavem2, 37, 11, DIR_LEFT), ActionSetPosition(cavem3, 34, 13, DIR_UP), ActionSetPosition(cavem4, 35, 14, DIR_UP), ActionSetPosition(cavem5, 36, 13, DIR_UP), ActionSetPosition(cavem6, 35, 13, DIR_UP), ActionFadeInMap(100), ActionConversation(lang:getConv("BOSS_BEATEN_3")), ActionFadeOutMap(300), ActionWait(100), ActionQuitGame(), }) end; } -- -- The trigger that sets the boss on the loose -- BossFightTrigger = Actor:subclass { name = "BossFightTrigger"; event_stand_on = function(self, obj) local player = m_get_player() if (player == obj and not boss_triggered) then boss_triggered = 1 ActionController:addSequence({ ActionExModeOn(), ActionSetVariable(camera, "target", self), ActionChangeDirection(player, DIR_UP), ActionConversation(lang:getConv("BOSS_AFTER_PRISON")), ActionAddObject("EnemyBoss", static_boss.x, static_boss.y), ActionDestroyObject(static_boss), ActionSetVariable(boss_block, "obstacle", 1), ActionExModeOff(), }) end end; defaultproperties = { obstacle = 0, w = 1, h = 1, }; } -- -- The boss shadow -- BossShadow = Shadow:subclass { name = "BossShadow"; preRender = function(self) Shadow.preRender(self) if (self.owner) then self.alpha = self.owner.alpha * 0.5 end end; defaultproperties = { bitmap = m_get_bitmap("boss_shadow.bmp"), draw_mode = DM_MULTIPLY, }; } -- -- BossBlock -- BossBlock = Actor:subclass { name = "BossBlock"; defaultproperties = { w = 5, h = 1, obstacle = 0, -- Not an obstacle permanently, used by scripts }; } --- NEW FILE: CaveLang.lua --- -- -- This object holds written text, to easy translation of the game. -- import("Lang.lua") CaveLang = Lang:subclass { name = "BBRpgLang"; -- -- An array containing speaker names and single words or word combinations. -- vars = { PLAYER = "Frode", CAVEMAN = "Caveman", CAVEMEN = "Cavemen", THE_LORD = "The Lord", HEALTH = "Health", EXPERIENCE = "Experience", STRENGTH = "Strength", DEXTERITY = "Dexterity", AGILITY = "Agility", ENDURANCE = "Endurance", }; -- -- An array containing all the conversations present in the game -- convs = { -- Game just starting INTRO = { {"{PLAYER}", "Arghh... My head hurts like hell. What happened?"}, {"{PLAYER}", "Alright, if you've read the README.TXT then by now you'll know how I got stranded in this cave. Further more, you'll be informed about which keys to use to control me. Well now, let's get some exploration done."}, }, -- Pickaxe and pile of rubble PILE_WONT_BUDGE = { {"{PLAYER}", "It won't budge. I need some tool to get through this..."}, }, PICKUP_PICKAXE = { {"{PLAYER}", "This should come in handy for large stony obstacles!"}, }, USE_PICKAXE = { {"{PLAYER}", "Now let's see how this pickaxe works..."}, }, PICKAXE_WORKED = { {"{PLAYER}", "Pfew. That seems to have worked just fine. Pity my pickace was destroyed in the process."}, }, -- Player goes into prison YAWN_TIRED = { {"{PLAYER}", "<Yawn> I'm tired... I really have to sit down for a while."}, }, QUIET_CORNER = { {"{PLAYER}", "This seems like a quiet corner."}, }, REALLY_TIRED = { {"{PLAYER}", "Djeezz... I'm really... tired..."}, }, DISCOVER_HUMAN = { {"{CAVEMAN}", "What the hack? A human?! I must inform the king immediately."}, }, INFORM_KING = { {"{CAVEMAN}", "Lord, do I have permission to speak?"}, {"{THE_LORD}", "What is it, you lowly caveman slave of mine?"}, {"{CAVEMAN}", "Thank you for letting me speak Lord. I found a human asleep to the south of here."}, {"{THE_LORD}", "Well, what have you done with him?"}, {"{CAVEMAN}", "Nothing, I thought I should tell you about it first..."}, {"{THE_LORD}", "No, you shouldn't have told me first you imbecile! Bring him to me immediately!"}, {"{CAVEMAN}", "Yes Lord, of course."}, }, KICK_FIRST = { {"{CAVEMAN}", "Wait! Let's make sure he doesn't wake up too soon."}, }, BRING_TO_KING = { {"{CAVEMAN}", "Now let's bring him to the king."}, }, BROUGHT_HUMAN = { {"{CAVEMAN}", "Lord, we've brought you the human."}, {"{THE_LORD}", "I can see that you moron."}, {"{CAVEMAN}", "What do you want us to do with him?"}, {"{THE_LORD}", "Hmmm... I'd like to eat him with breakfast. Until then, throw him into prison."}, {"{CAVEMAN}", "Yes Lord, of course."}, }, WHAT_THE = { {"{PLAYER}", "What the..."}, }, WHAT_HAPPENED = { {"{PLAYER}", "What happened? I'm in prison? I must have fallen asleep. Damn!"}, }, -- Player escapes from prison YEAH_RIGHT = { {"{PLAYER}", "Yeah, right. Like they'd forget to lock a prison door."}, }, NOT_LOCKED = { {"{PLAYER}", "Huh? It's not locked! These guys are really stupid!"}, }, WOW_ESCAPED = { {"{CAVEMAN}", "Wow, you escaped!"}, }, MUST_BE_STRONG = { {"{CAVEMAN}", "You must be very strong!"}, }, KING_IS_SLAVEDRIVER = { {"{PLAYER}", "Well, I guess there is no point in denying that."}, {"{CAVEMAN}", "You know, that big guy who commanded us to throw you into prison, he's a slavedriver to us!"}, {"{PLAYER}", "Ah."}, {"{CAVEMAN}", "You might be strong enough to face him in a fight, it would free us from his evil might!"}, {"{PLAYER}", "Hmm. I'd like to ask him to go first, and just see what happens."}, {"{CAVEMAN}", "Cool, we will be forever grateful!! The big bully is to the west, and then up north."}, }, -- Player reaches boss BOSS_AFTER_PRISON = { {"{PLAYER}", "Hello Lord of the Cavemen."}, {"{THE_LORD}", "WHAT? How did you escape from my prison!?"}, {"{PLAYER}", "I walked out really, though I did meet some resistance. But never mind that, I want to talk to you about something."}, {"{THE_LORD}", "If you must. But I'm not the talkative type, so make it quick."}, {"{PLAYER}", "It has come to my knowledge that you are an evil slavedriver. Would you be so kind to step off the throne and let these Cavemen free?"}, {"{THE_LORD}", "Over my fat body!"}, {"{PLAYER}", "I suppose that means no."}, {"{THE_LORD}", "Indeed! Now feel my power, I've had enough and you'll pay for your ignorance!"}, }, BOSS_BEATEN_1 = { {"{THE_LORD}", "Blurk! Bwah! Blleeeh! You are too much for me."}, {"{PLAYER}", "Well, I'm glad that's over with."}, {"{THE_LORD}", "Oh no, not so fast buddy. I might let you live for now, but I'll be back! Bigger, Badder and more Brutal than ever before! Muhahahaha!"}, }, BOSS_BEATEN_2 = { {"{PLAYER}", "Well, I'm not falling for such stupid jokes. Let's see what the Cavemen have to say."}, }, BOSS_BEATEN_3 = { {"{CAVEMEN}", "Hurray! Hurray! Hurray!"}, {"{PLAYER}", "Neat."}, }, -- Some tables with random texts. CDs = { {{"Frode", "Let's see if there's another CD of the Village People..."}}, }, Radio = { {{"Frode", "Cool music."}}, {{"Frode", "I like the Beach Boys's music."}}, {{"Frode", "Yeah! Great soundsystem!"}}, }, Refreshing = { {{"{PLAYER}", "Ah, refreshing."}}, {{"{PLAYER}", "I could use some of that."}}, {{"{PLAYER}", "That's much better."}}, }, Fire = { {{"{PLAYER}", "It's burning just fine."}}, {{"{PLAYER}", "It's too big to carry along. Besides, I'd only use it for evil."}}, {{"{PLAYER}", "Ouch! Fire hot."}}, {{"{PLAYER}", "Is this a logfire I see before me?"}}, }, Escape = { {{"{PLAYER}", "No way I can get out of this cave alive through this!"}}, {{"{PLAYER}", "Escaping through this would kill me for sure."}}, }, }; } --- NEW FILE: CaveObjects.lua --- -- -- Cave-specific objects -- import("Decoration.lua") CaveWaterfallExit = Decoration:subclass { name = "CaveWaterfallExit"; defaultproperties = { bCenterOnTile = false, animType = LinearAnimation, animSeq = extr_array(m_get_bitmap("cave_waterfall_exit.bmp"), 72, 48), animSpeed = 1 / 10, convTableKeyword = "Escape", }; } -- -- Top, Roof and Bottom, used for caves you can walk through -- CaveTunnelTop = Decoration:subclass { name = "CaveTunnelTop"; defaultproperties = { draw_mode = DM_ALPHA, bitmap = m_get_bitmap("cave_entrance2.tga"), offset_z = 48, offset_y = 24, obstacle = 0, }; } CaveRoof = Decoration:subclass { name = "CaveRoof"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("cave_roof.bmp"), offset_z = 48, offset_y = 48, obstacle = 0, }; } CaveTunnelBottom = Decoration:subclass { name = "CaveTunnelBottom"; defaultproperties = { draw_mode = DM_ALPHA, bitmap = m_get_bitmap("cave_entrance.tga"), offset_z = 48, offset_y = 28, obstacle = 0, }; } -- Spider web SpiderWeb = Decoration:subclass { name = "SpiderWeb"; defaultproperties = { draw_mode = DM_ALPHA, bitmap = m_get_bitmap("web.tga"), offset_y = 7, offset_x = 10, }; } SpiderWeb2 = Decoration:subclass { name = "SpiderWeb2"; defaultproperties = { draw_mode = DM_ALPHA, bitmap = m_get_bitmap("web2.tga"), offset_y = 7, offset_x = -10, } } -- -- The horizontal bridge elements -- CaveBridge1 = Decoration:subclass { name = "CaveBridge1"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("cavebridge1.bmp"), offset_x = 0, offset_y = -10, offset_z = -10, obstacle = 0, }; } CaveBridge2 = Decoration:subclass { name = "CaveBridge2"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("cavebridge2.bmp"), offset_x = 0, offset_y = 0, offset_z = 0, obstacle = 0, }; } -- Pile of rubble CavePileTop = Decoration:subclass { name = "CavePileTop"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("rubble_t.bmp"), offset_x = 24, offset_y = 5, offset_z = 0, obstacle = 1, w = 3, h = 2, }; } CavePileBottom = Decoration:subclass { name = "CavePileBottom"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("rubble_b.bmp"), offset_x = 24, offset_y = -10, offset_z = 0, obstacle = 1, w = 3, h = 2, }; } CavePile = Decoration:subclass { name = "CavePile"; activatedBy = function(self, instigator) if (picked_up_pick) then ActionController:addSequence({ ActionExModeOn(), ActionConversation(lang:getConv("USE_PICKAXE")), ActionFadeOutMap(100), ActionDestroyObject(self), ActionAddObject(CavePileTop, 16, 29), ActionAddObject(CavePileBottom, 16, 32), ActionFadeInMap(100), ActionConversation(lang:getConv("PICKAXE_WORKED")), ActionExModeOff(), }) else ActionController:addSequence({ ActionConversation(lang:getConv("PILE_WONT_BUDGE")), }) end end; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("cavepile.bmp"), offset_x = 24, offset_y = -12, offset_z = 0, obstacle = 1, w = 3, h = 5, bCanActivate = true, }; } -- Pick and howel CavePick = Decoration:subclass { name = "CavePick"; activatedBy = function(self, obj) picked_up_pick = 1 m_destroy_object(self) ActionController:addSequence({ ActionConversation(lang:getConv("PICKUP_PICKAXE")) }) end; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("cavepick.bmp"), obstacle = 1, offset_x = 0, offset_y = -10, offset_z = -10, bCanActivate = true, }; } --- NEW FILE: CaveTriggers.lua --- -- cave_triggers.lua -- Cave-specified triggers -- By Georg Muntingh CaveFallingAsleep = Actor:subclass { name = "CaveFallingAsleep"; event_stand_on = function(self, instigator) local player = m_get_player() if (instigator ~= m_get_player()) then -- Some monster that wandered too far away is moving into this critical area, -- so get rid of him. instigator:take_damage(100) return end ActionController:addSequence({ -- The player gets tired and is going to get some rest in a quiet corner. ActionConversation(lang:getConv("YAWN_TIRED")), ActionExModeOn(), ActionWalk(player, DIR_LEFT, 7), ActionChangeDirection(player, DIR_DOWN), ActionWait(25), ActionConversation(lang:getConv("QUIET_CORNER")), ActionWait(25), ActionSetVariable(m_get_player(), "tick_time", 0), -- DISABLELNG PLAYER TICK! ActionChangeBitmap(m_get_player(), m_get_bitmap("frode_sit1.tga")), ActionWait(25), ActionConversation(lang:getConv("REALLY_TIRED")), ActionWait(25), ActionChangeBitmap(m_get_player(), m_get_bitmap("frode_sit2.tga")), ActionWait(100), -- The player has fallen asleep, time passes... ActionFadeOutMap(50), ActionWait(50), ActionFadeInMap(50), -- Suddenly, a caveman arrives and notices the player. He runs away, to warn -- his leader as soon as possible. ActionWalk(caveman1, DIR_DOWN, 5), ActionChangeDirection(caveman1, DIR_LEFT), ActionWait(50), ActionSetVariable(caveman1, "speed", 5.4), ActionWalk(caveman1, DIR_LEFT, 3), ActionWait(50), ActionConversation(lang:getConv("DISCOVER_HUMAN")), ActionAddSequence({ ActionWalk(caveman1, DIR_RIGHT, 3), }), ActionFadeOutMap(56), -- The caveman arrives at his leader. His leader sends him back to fetch the -- human straight away. ActionChangeMap("data/maps/cave3.map"), ActionSetVariable(camera, "target", caveman1), ActionSetVariable(caveman1, "offset_x", 0), ActionSetPosition(caveman1, 35, 16, DIR_UP), ActionAddSequence({ ActionFadeInMap(50), }), ActionWalk(caveman1, DIR_UP, 3), ActionConversation(lang:getConv("INFORM_KING")), ActionAddSequence({ ActionFadeOutMap(56), }), ActionWalk(caveman1, DIR_DOWN, 3), -- Two cavemen arrive at the player, cast a spell on him and take him back -- to the king ActionChangeMap("data/maps/cave2.map"), ActionSetPosition(caveman1, 24, 4, DIR_DOWN), ActionSetPosition(caveman2, 24, 3, DIR_DOWN), ActionSetVariable(caveman2, "speed", 5.4), ActionAddSequence({ ActionAddSequence({ ActionFadeInMap(50), }), ActionWalk(caveman1, DIR_DOWN, 5), ActionWalk(caveman1, DIR_LEFT, 5), }), ActionWalk(caveman2, DIR_DOWN, 6), ActionWalk(caveman2, DIR_LEFT, 4), ActionWait(50), ActionConversation(lang:getConv("KICK_FIRST")), ActionWait(50), ActionSetVariable(caveman1,"attacking", 1), ActionCallFunction(SpawnSparkyHit, 18, 10, player.offset_x, player.offset_y, player.offset_z + 24), ActionWait(40), ActionSetVariable(caveman1,"attacking", 0), ActionWait(10), ActionConversation(lang:getConv("BRING_TO_KING")), ActionFadeOutMap(50), -- The two cavemen and the player arrive at the king. The king tells the -- cavemen he wants the human in his prison. ActionSetPosition(camera_handle, 35, 12), ActionSetVariable(camera, "target", camera_handle), ActionChangeMap("data/maps/cave3.map"), ActionSetPosition(caveman1, 34, 13, DIR_UP), ActionSetPosition(m_get_player(), 35, 13), ActionSetPosition(caveman2, 36, 13, DIR_UP), ActionChangeBitmap(m_get_player(), m_get_bitmap("frode_sit2.tga")), ActionFadeInMap(50), ActionConversation(lang:getConv("BROUGHT_HUMAN")), ActionFadeOutMap(50), -- The player finds himself locked in a prison. ActionWait(50), ActionSetVariable(camera, "target", m_get_player()), ActionSetPosition(m_get_player(), 80, 20), ActionFadeInMap(50), ActionWait(50), ActionChangeBitmap(m_get_player(), m_get_bitmap("frode_sit1.tga")), ActionWait(50), ActionSetVariable(m_get_player(), "tick_time", 1), -- ENABLEING PLAYER TICK! ActionChangeDirection(m_get_player(), DIR_DOWN), ActionConversation(lang:getConv("WHAT_THE")), ActionWalk(m_get_player(), DIR_RIGHT, 2), ActionWalk(m_get_player(), DIR_DOWN, 4), ActionConversation(lang:getConv("WHAT_HAPPENED")), -- Prepare caveman for next sequence (when escaping from prison) ActionSetPosition(caveman1, 67, 34, DIR_DOWN), ActionSetPosition(caveman2, 69, 34, DIR_DOWN), ActionExModeOff(), ActionShowMapName(m_get_bitmap("cave_title_3.bmp")), }) end; } CaveNoticeStrong = Actor:subclass { name = "CaveNoticeStron"; event_stand_on = function(self, instigator) if (instigator ~= m_get_player()) then instigator:take_damage(100) return end ActionController:addSequence({ -- The player arrives at two cavemen guards. They are impressed by -- his escape and tell him the story about their slavedriver, asking -- the player to kill him. ActionExModeOn(), ActionDestroyObject(self), ActionWait(50), ActionChangeDirection(caveman1, DIR_RIGHT), ActionChangeDirection(caveman2, DIR_LEFT), ActionWait(50), ActionChangeDirection(m_get_player(), DIR_LEFT), ActionConversation(lang:getConv("WOW_ESCAPED")), ActionChangeDirection(m_get_player(), DIR_RIGHT), ActionConversation(lang:getConv("MUST_BE_STRONG")), ActionWait(50), ActionChangeDirection(m_get_player(), DIR_DOWN), ActionWait(100), ActionConversation(lang:getConv("KING_IS_SLAVEDRIVER")), ActionChangeDirection(caveman1, DIR_DOWN), ActionChangeDirection(caveman2, DIR_DOWN), ActionExModeOff(), }) end; } --- NEW FILE: Caveman.lua --- -- -- Caveman classes -- By Bjorn Lindeijer import("Enemy.lua") import("AnimationFunctions.lua") Caveman = Character:subclass { name = "Caveman"; defaultproperties = { draw_mode = DM_MASKED, speed = 2, charAnim = extr_char_anim(m_get_bitmap("caveman.bmp")), }; } -- -- The caveman enemy object -- EnemyCaveman = Enemy:subclass { name = "EnemyCaveman"; setState = function(self, state) self.state = state if (self.state == AI_ATTACK) then self.attacking = 1 else self.attacking = 0 end self:updateBitmap() end; died = function(self, killer) Enemy.died(self, killer) self.offset_y = self.offset_y + 3 end; attack = function(self, obj) if (obj) then SpawnSparkyHit(obj.x, obj.y, obj.offset_x, obj.offset_y, obj.offset_z + 24) end end; defaultproperties = { experience = 17, draw_mode = DM_MASKED, speed = 2, charAnim = extr_char_anim(m_get_bitmap("caveman.bmp")), deathBitmap = m_get_bitmap("caveman_dead.bmp"), }; } -- -- The caveman slave object -- CavemanSlave = Character:subclass { name = "CavemanSlave"; defaultproperties = { draw_mode = DM_MASKED, speed = 2, charAnim = extr_char_anim(m_get_bitmap("caveman_slave.bmp")), }; } -- -- A dead slave -- SlaveDead = Character:subclass { name = "SlaveDead"; defaultproperties = { draw_mode = DM_MASKED, bitmap = m_get_bitmap("slave_dead.bmp"), }; } --- NEW FILE: ConversationWindow.lua --- -- -- This file contains the conversation windows class. -- -- By Bjorn Lindeijer import("Interaction.lua") -- Receives a single string and returns array of tokens. -- Ex: "Hello world!" -> {"Hello", "world!"} tokenize = function(str) local tokens = {} local str_len = string.len(str) local start = 1 while (start < str_len) do from, to, token = string.find(str, "%s?([^%s]*)", start) start = to + 1 table.insert(tokens, token) end return tokens end detokenize = function(tokens) token_cnt = table.getn(tokens) if (token_cnt > 0) then local string = tokens[1] local n = 2 while (n <= token_cnt) do string = string.." "..tokens[n] n = n + 1 end return string else return "" end end CB_CLOSED = 0 CB_READY = 1 CB_WRITING = 2 CB_SCROLLING = 3 CB_WAITING = 4 CB_SCALING = 5 ConversationWindow = Interaction:subclass { name = "ConversationWindow"; init = function(self) -- Get and set some sizes self.font = "font_sansserif8.pcx" m_set_font(self.font) self.space_width, self.line_height = m_text_size(" ") local w, h = m_screen_size() self.x = w / 4 self.y = h - h / 4 self.w = w / 2 self.h = h / 2 - h / 3 + 5 - 2 self.nr_lines = math.floor(self.h / self.line_height) end; write_line = function(self, string) table.insert(self.lines_todo, string) if (self.state == CB_CLOSED) then self.state = CB_SCALING ActionController:addSequence{ ActionExModeOn(), ActionTweenVariable(self, "width", self.appear_time, 1), ActionTweenVariable(self, "height", self.appear_time, 1), ActionSetVariable(self, "state", CB_READY), } -- grab control over the player --m_set_ex_mode(1) --self.state = CB_READY end end; tick = function(self) if (self.state == CB_CLOSED) then return elseif (self.state == CB_READY and table.getn(self.lines_todo) > 0) then if (table.getn(self.lines) < self.nr_lines) then -- There is space, start writing the line. -- We need the correct font set when calculating how big the text is m_set_font(self.font) local tokens = tokenize(self.lines_todo[1]) local new_line = tokens[1] table.remove(tokens, 1) while (table.getn(tokens) > 0 and m_text_size(new_line.." "..tokens[1]) < self.w) do new_line = new_line.." "..tokens[1] table.remove(tokens, 1) end -- Continue indicates if writing should continue after this line -- or if it should show a blinking square (end of sentence) if (table.getn(tokens) > 0) then self.continue = 1 self.lines_todo[1] = detokenize(tokens) else self.continue = nil table.remove(self.lines_todo, 1) end table.insert(self.lines, new_line) self.curr_char = 1 self.state = CB_WRITING else -- No line left, scroll up two lines. if (self.continue) then self:set_state(CB_WAITING) else self.state = CB_SCROLLING end end elseif (self.state == CB_READY) then -- Ready and no lines left todo ActionController:addSequence{ ActionSetVariable(self, "state", CB_SCALING), ActionTweenVariable(self, "height", self.appear_time, 0), ActionTweenVariable(self, "width", self.appear_time, 0), ActionSetVariable(self, "state", CB_CLOSED), ActionExModeOff(), } --self.state = CB_CLOSED -- return control to the player --m_set_ex_mode(0) elseif (self.state == CB_SCROLLING) then if (self.scroll < (self.nr_lines - 1) * self.line_height) then self.scroll = self.scroll + 1 else for n = 1,(self.nr_lines - 1) do table.remove(self.lines, 1) end self.scroll = 0 self.state = CB_READY end elseif (self.state == CB_WRITING) then local current_string = self.lines[table.getn(self.lines)] local length = string.len(current_string) if (self.curr_char < length) then self.curr_char = self.curr_char + 0.5 else -- This line has finished, either wait for key or continue -- with next line. if (self.continue) then self.state = CB_READY else self:set_state(CB_WAITING) end end elseif (self.state == CB_WAITING) then if (self.blink == 1) then -- Set appropriate blinking bitmap if (self.blink_bitmap) then self.blink_bitmap = nil else if (self.continue) then self.blink_bitmap = m_get_bitmap("arrow.bmp") else self.blink_bitmap = m_get_bitmap("square.bmp") end end end self.blink = self.blink + 1 if (self.blink > 20) then self.blink = 1 end end end; keyType = function(self, key) if (key == "action" and self.state == CB_WAITING) then if (self.continue) then -- Scroll up self.state = CB_SCROLLING else self.state = CB_READY end return true end return false end; postRender = function(self, canvas) if (self.state == CB_CLOSED) then return end local screen_w, screen_h = m_screen_size() m_set_font(self.font) if (self.state ~= CB_SCALING) then -- Draw the shadow of the text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) for n = 1, table.getn(self.lines) do m_set_color(0, 0, 0) m_set_cursor(self.x + 1, self.y + (n - 1) * self.line_height - self.scroll + 1) if (n == table.getn(self.lines)) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else m_draw_text(self.lines[n]) end end end -- Draw the box m_set_clip(0, 0, screen_w - 1, screen_h - 1) guiTheme:drawBox( (self.x + self.w / 2) - (self.w * self.width) / 2 - 4, (self.y + self.h / 2) - (self.h * self.height) / 2 - 4, self.w * self.width + 8, self.h * self.height + 8 ) if (self.state ~= CB_SCALING) then -- Draw the blinking icon if (self.state == CB_WAITING and self.blink_bitmap) then local w, h = m_bitmap_size(self.blink_bitmap) m_set_cursor(self.x + self.w - w, self.y + self.h - h) canvas:drawIcon(self.blink_bitmap, 1) end -- Draw the lines of text m_set_clip(self.x, self.y, self.x + self.w - 1, self.y + self.h - 1) for n = 1, table.getn(self.lines) do m_set_color(guiTheme:getTextColor()) m_set_cursor(self.x, self.y + (n - 1) * self.line_height - self.scroll) if (n == table.getn(self.lines)) then m_draw_text(string.sub(self.lines[n], 1, self.curr_char)) else m_draw_text(self.lines[n]) end end end local w, h = m_screen_size() m_set_clip(0, 0, w - 1, h - 1) end; set_state = function(self, state) self.state = state if (self.state == CB_WAITING) then self.blink = 2 if (self.continue) then self.blink_bitmap = m_get_bitmap("arrow.bmp") else self.blink_bitmap = m_get_bitmap("square.bmp") end end end; defaultproperties = { bRequiresTick = true, lines = {}, lines_todo = {}, state = CB_CLOSED, scroll = 0, curr_char = 1, continue = nil, blink = 1, width = 0, height = 0, appear_time = 15, }; } --- NEW FILE: DgeMapSwitches.lua --- -- -- Here we define some player sequences. -- By Georg Muntingh Buiten_Naar_Bos = {} function Buiten_Naar_Bos:event_stand_on(obj) local player = m_get_player() if obj ~= player or m_get_ex_mode() == 1 then return end ActionController:addSequence({ ActionExModeOn(), ActionWalk(player, DIR_RIGHT, 2), ActionChangeMap("data/maps/bos.map"), ActionSetPosition(player, -1, player.y + 6, DIR_RIGHT), ActionAddSequence({ ActionWalk(player, DIR_RIGHT, 3), ActionExModeOff(), }), ActionFadeInMusic("data/music/KR-UT2003-Menu.ogg", 50, 0), ActionFadeInMap(50), }) ActionController:addSequence({ ActionFadeOutMusic(50, 0), ActionFadeOutMap(50), }) end Bos_Naar_Buiten = {} function Bos_Naar_Buiten:event_stand_on(obj) local player = m_get_player() if obj ~= player or m_get_ex_mode() == 1 then return end ActionController:addSequence({ ActionExModeOn(), ActionWalk(player, DIR_LEFT, 2), ActionChangeMap("data/maps/buiten.map"), ActionSetPosition(player, 85, player.y - 6, DIR_LEFT), ActionAddSequence({ ActionWalk(player, DIR_LEFT, 3), ActionExModeOff(), }), ActionFadeInMusic("data/music/KR-UT2003-Menu.ogg", 50, 0), ActionFadeInMap(50), }) ActionController:addSequence({ ActionFadeOutMusic(50, 0), ActionFadeOutMap(50), }) end Buiten_Naar_Tent1 = {} function Buiten_Naar_Tent1:activatedBy(instigator) local player = m_get_player() if instigator ~= player or player.dir ~= DIR_UP then return end local text_table = { {{"Frode", "A small tent for Georg and Laurens"}}, {{"Frode", "It's a mess inside."}}, } repeat n = math.random(table.getn(text_table)) until (n ~= self.prev_random) self.prev_random = n ActionController:addSequence({ ActionFadeOutMap(50), ActionChangeMap("data/maps/tent1.map"), ActionSetPosition(player, 7, 9, DIR_UP), ActionFadeInMap(50), ActionConversation(text_table[n]), }) end Buiten_Naar_Tent2 = {} function Buiten_Naar_Tent2:activatedBy(instigator) local player = m_get_player() if instigator ~= player or player.dir ~= DIR_UP then return end local text_table = { {{"Frode", "Small tent for Chris and Margje"}}, {{"Frode", "It's a terrible mess inside."}}, } repeat n = math.random(table.getn(text_table)) until (n ~= self.prev_random) self.prev_random = n ActionController:addSequence({ ActionFadeOutMap(50), ActionChangeMap("data/maps/tent1.map"), ActionSetPosition(player, 21, 10, DIR_UP), ActionFadeInMap(50), ActionConversation(text_table[n]), }) end Tent1_Naar_Buiten = {} function Tent1_Naar_Buiten:event_stand_on(instigator) local player = m_get_player() if instigator ~= player then return end ActionController:addSequence({ ActionExModeOn(), ActionFadeOutMap(50), ActionChangeMap("data/maps/buiten.map"), ActionSetPosition(player, 28, 21, DIR_DOWN), ActionFadeInMap(50), ActionExModeOff(), }) end Tent2_Naar_Buiten = {} function Tent2_Naar_Buiten:event_stand_on(instigator) local player = m_get_player() if instigator ~= player then return end ActionController:addSequence({ ActionExModeOn(), ActionFadeOutMap(50), ActionChangeMap("data/maps/buiten.map"), ActionSetPosition(player, 22, 21, DIR_DOWN), ActionFadeInMap(50), ActionExModeOff(), }) end Cave1_Naar_Cave2 = Actor:subclass { name = "Cave1_Naar_Cave2"; event_stand_on = function(self, obj) local player = m_get_player() if obj ~= player or m_get_ex_mode() == 1 then return end ActionController:addSequence({ ActionExModeOn(), ActionAddSequence({ ActionWalk(player, DIR_LEFT, 1), }), ActionFadeOutMap(50), ActionChangeMap("data/maps/cave2.map"), ActionShowMapName(m_get_bitmap("cave_title_2.bmp")), ActionSetPosition(player, 64, player.y + 57, DIR_LEFT), ActionAddSequence({ ActionWalk(player, DIR_LEFT, 2), ActionExModeOff(), }), ActionFadeInMap(50), }) end; } Cave2_Naar_Cave1 = Actor:subclass { name = "Cave2_Naar_Cave1"; event_stand_on = function(self, obj) local player = m_get_player() if obj ~= player or m_get_ex_mode() == 1 then return end ActionController:addSequence({ ActionExModeOn(), ActionAddSequence({ ActionWalk(player, DIR_RIGHT, 1), }), ActionFadeOutMap(50), ActionChangeMap("data/maps/cave1.map"), ActionShowMapName(m_get_bitmap("cave_title_1.bmp")), ActionSetPosition(player, -1, player.y - 57, DIR_RIGHT), ActionAddSequence({ ActionWalk(player, DIR_RIGHT, 2), ActionExModeOff(), }), ActionFadeInMap(50), }) end; } --- NEW FILE: Dummy.lua --- import("Actor.lua") Dummy = Actor:subclass { name = "Dummy"; defaultproperties = { bitmap = nil,-- m_get_bitmap("zaklamp.bmp"), }; } --- NEW FILE: Game.lua --- -- -- This file defines some global functions for the game. -- By Bjorn Lindeijer import("Object.lua") import("ConversationWindow.lua") import("GuiTheme.lua") Game = Object:subclass { name = "Game"; init = function(self) -- Initialize stuff MusicControl:init() guiTheme = self.guiThemeClass() -- WARNING: Bad design, introducing a global variable! convBox = self.conversationWindowClass() -- WARNING: I have no shame! if (self.textProviderClass ~= nil) then self.textProvider = self.textProviderClass() end local width, height = m_screen_size() --self.viewPort = Viewport( -- (width - 320) * 0.5, -- (height - 240) * 0.5, -- 320, 240 --) self.viewPort = Viewport(0, 0, width, height) self.canvas = Canvas() self.interactionMaster = InteractionMaster(self.viewPort) interactionMaster = self.interactionMaster -- Make a nice global variable! -- Create HUD if a HUD class was given if (self.hudClass) then self.hud = self.hudClass() self.interactionMaster:addInteraction(self.hud) hud = self.hud -- Yeah, make it global! end -- Add the conversation box self.interactionMaster:addInteraction(convBox) -- Create menu if a menu class was given if (self.mainMenuClass) then self.mainMenu = self.mainMenuClass() self.interactionMaster:addInteraction(self.mainMenu) end end; getText = function(self, id) if (self.textProvider) then return self.textProvider:getText(id, self.lang) end end; -- -- This function is called every game update, right before all objects get -- updated. -- event_logic_update = function(self) ActionController:update() MusicControl:update() self.interactionMaster:processTick() if (playerController and m_get_ex_mode() == 0) then m_update_input(playerController) playerController:playerTick() end end; -- -- This function is called right after the map and objects have been rendered -- by the engine. It is meant to draw stuff on the screen that is not actually -- present on the map, like text boxes and info displays. -- -- Here's a general set of functions that can be used for positioning and -- drawing on the screen. The draw functions should generally only be used -- within this function call. -- -- function m_get_cursor() // returns x, y -- function m_set_cursor(x, y) -- function m_text_size(text) // returns width, height -- function m_bitmap_size(bitmap) // returns width, height -- function m_screen_size() // returns width, height -- function m_draw_text(text) -- function m_draw_bitmap(bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) -- function m_draw_viewport(x, y, w, h, target) -- event_render = function(self) self.interactionMaster:processPreRender() if (not show_main_menu and self.viewPort) then self.viewPort:render() end -- Set HUD to invisible while main menu is shown if (self.hud) then self.hud.bVisible = not show_main_menu end if (map_fade ~= nil and map_fade.alpha ~= nil and map_fade.alpha > 0) then local w,h = m_screen_size() m_set_alpha(map_fade.alpha) m_set_cursor(0,0) self.canvas:drawRect(m_get_bitmap("pixel_black.bmp"), w, h) m_set_alpha(255) end self.interactionMaster:processPostRender(self.canvas) end; event_keypress = function(self, key) --m_message(key.." key has been pressed!") if (self.interactionMaster:processKeyType(key)) then return true end if (key == "esc") then if (self.ingameMenuClass) then self.interactionMaster:addInteraction(self.ingameMenuClass()) else m_quit_game() end return true end end; defaultproperties = { startupSequence = {}, conversationWindowClass = ConversationWindow, guiThemeClass = GuiTheme, hudClass = nil, playerClass = nil, mainMenuClass = nil, ingameMenuClass = nil, textProviderClass = nil, textProvider = nil, mainMenu = nil, viewPort = nil, lang = "en", } } -- -- Below here some ugly leftovers -- game = { game_over = 0, game_over_alpha = 0, } camera = { target = nil, } -- -- A helper function used by scripts that want to show a conversation. -- function write_conversation(data) local conversation = {} for index, value in pairs(data) do local name = value[1] -- WARNING: Only works for BBRpg! --[[ if (name == "{PLAYER}") then player = playerSwitcher:getCurrentHost() if (player) then name = player.name end end ]] table.insert(conversation, name..": \""..value[2].."\"") end local n = table.getn(conversation) convBox.lines = {} convBox.lines_todo = {} convBox.state = CB_CLOSED convBox.scroll = 0 convBox.curr_char = 1 convBox.continue = nil for i = 1, n do convBox:write_line(conversation[i]) end end -- -- Another helper function to make it easier to choose a random thing to say, unequal -- to what was said last time. -- function get_new_n(old_n, max_n) local n if (max_n > 1) then repeat n = math.random(max_n) until (n ~= old_n) else n = max_n end return n end --- NEW FILE: Guard.lua --- import("Character.lua") Guard = Character:subclass { name = "Guard"; defaultproperties = { draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("cop.bmp"), 23, 40), dir = DIR_UP, speed = 3, }; } --- NEW FILE: IngameMenu.lua --- -- -- The ingame menu -- By Bjorn Lindeijer import("GuiMenu.lua") IngameMenu = GuiMenu:subclass { name = "IngameMenu"; init = function(self) GuiMenu.init(self) self:addMenuItem(GuiMenuItem(lang:getVar("CONTINUE"), function() self.master:removeInteraction(self); end)) self:addMenuItem(GuiMenuItem(lang:getVar("LANGUAGE"), function() self.master:addInteraction(LanguageMenu(self)); self.master:removeInteraction(self); end)) self:addMenuItem(GuiMenuItem(lang:getVar("QUIT"), function() self.master:removeInteraction(self); m_quit_game() end)) end; keyType = function(self, key) if (GuiMenu.keyType(self, key)) then return true end if (key == "esc") then self.master:removeInteraction(self) return true end end; defaultproperties = { } } --- NEW FILE: Interaction.lua --- -- -- Interactions are the foundation for any subsystem that requires interaction -- with the player (such as a menu). One InteractionMaster is used to handle -- all the interactions. -- -- By Bjorn Lindeijer import("Object.lua") Interaction = Object:subclass { name = "Interaction"; -- Tick function, disabled by default but can be activated by setting -- bRequiresTick to true. tick = function(self) end; -- Receives a key description string, should return true when key was -- used by this interaction. keyType = function(self, key) return false end; -- A notification that the current level has changed together with the -- name of the level (the map path, but this should change) levelChange = function(self, level) end; -- A chance to change something just before rendering takes place (requires bVisible) preRender = function(self) end; -- A chance to put something on the screen (requires bVisible) postRender = function(self, canvas) end; -- Sets the focus on this interaction setFocus = function(self) self.master.setFocusTo(self, self.viewportOwner); end; -- Changes the interactionmaster setInteractionMaster = function(self, master) self.master = master end; defaultproperties = { bActive = true, -- Is this interaction Getting Input bVisible = true, -- Is this interaction being Displayed bRequiresTick = false, -- Does this interaction require game Tick master = nil, -- The interaction master viewportOwner = nil, -- Owner of the viewport, ie. the player }; } --- NEW FILE: InteractionMaster.lua --- -- -- The InteractionMaster controls the entire interaction system. It's -- job is to take input, postRender and tick calls and route them to -- individual interactions. -- -- By Bjorn Lindeijer import("Object.lua") InteractionMaster = Object:subclass { name = "InteractionMaster"; init = function(self, viewport) self.viewport = viewport end; addInteraction = function(self, interaction) table.insert(self.globalInteractions, 1, interaction) interaction:setInteractionMaster(self) end; removeInteraction = function(self, interaction) local interactionArray local iIndex interactionArray = self.globalInteractions -- Search for the Interaction iIndex = -1; for i = 1, table.getn(interactionArray) do if (interactionArray[i] == interaction) then iIndex = i end end -- Whas it found? if (iIndex < 0) then m_message("Attempt to remove non-existing interaction.") else interactionArray[iIndex]:setInteractionMaster(nil) table.remove(interactionArray, iIndex) end end; setFocusTo = function(self, interaction, viewportOwner) local interactionArray local temp local i, iIndex --if (ViewportOwner ~= nil) then -- InteractionArray = ViewportOwner.LocalInteractions --else interactionArray = self.globalInteractions --end if (table.getn(interactionArray) == 0) then m_message("Attempt to setFocusTo with an empty interactions array."); return end -- Search for the Interaction iIndex = -1; for i = 1, table.getn(interactionArray) do if (interactionArray[i] == interaction) then iIndex = i end end -- Was it found? if (iIndex < 0) then m_message("Attempt to set focus to a non-existing interaction ("..interaction..").") return elseif (iIndex == 1) then return -- Already has focus end -- Move it to the top. temp = interactionArray[iIndex] for i = iIndex, 2, -1 do interactionArray[i] = interactionArray[i-1] end interactionArray[1] = temp interactionArray[1].bActive = true -- Give it Input interactionArray[1].bVisible = true -- Make it visible end; -- -- The process functions take the events to the interactions. -- processTick = function(self) local ia = self.globalInteractions for i = 1, table.getn(ia) do if (ia[i].bRequiresTick) then ia[i]:tick() end end end; processPreRender = function(self) local ia = self.globalInteractions for i = 1, table.getn(ia) do if (ia[i].bVisible) then ia[i]:preRender() end end end; processPostRender = function(self, canvas) local ia = self.globalInteractions for i = table.getn(ia), 1, -1 do if (ia[i].bVisible) then ia[i]:postRender(canvas) end end end; processKeyType = function(self, key) local ia = self.globalInteractions for i = 1, table.getn(ia) do if (ia[i].bActive) then if (ia[i]:keyType(key)) then return true -- No further processing when key is used end end end return false end; processLevelChange = function(self, level) local ia = self.globalInteractions for i = 1, table.getn(ia) do ia[i]:levelChange(level) end end; defaultproperties = { globalInteractions = {}, viewport = nil, }; } --- NEW FILE: LanguageMenu.lua --- -- A menu to choose your language LanguageMenu = GuiMenu:subclass { name = "LanguageMenu"; init = function(self, parentMenu) GuiMenu.init(self) self.parentMenu = parentMenu self:addMenuItem(GuiMenuItem(BBRpgLang.defaultproperties.languageName, function() lang = BBRpgLang() self.master:addInteraction(_G[parentMenu.name]()) self.master:removeInteraction(self) end)) self:addMenuItem(GuiMenuItem(BBRpgLangDutch.defaultproperties.languageName, function() lang = BBRpgLangDutch() self.master:addInteraction(_G[parentMenu.name]()) self.master:removeInteraction(self) end)) end; keyType = function(self, key) if (GuiMenu.keyType(self, key)) then return true end if (key == "esc") then -- Return without switching language self.master:addInteraction(self.parentMenu) self.master:removeInteraction(self) return true end end; defaultproperties = { }; } --- NEW FILE: MainMenu.lua --- -- -- Het hoofdmenu -- By Bjorn Lindeijer import("GuiMenu.lua") MainMenu = GuiMenu:subclass { name = "MainMenu"; init = function(self) GuiMenu.init(self) local oldspeed = elwood.speed local dummy = cityMap:spawn(Dummy, 113.5, 109.5) local quickStartSequence = { ActionFadeOutMusic(50), ActionFadeOutMap(50), ActionWait(50), ActionSetVariable(_G, "show_main_menu", nil), ActionCallFunction(jake.addToInventory, jake, cityMap.walkieTalkie), ActionCallFunction(elwood.addToInventory, elwood, cityMap.walkieTalkie), ActionSetPosition(elwood, 94, 73, DIR_UP, cityMap), ActionSetPosition(jake, 93, 73, DIR_UP, cityMap), ActionSetCameraTarget(elwood, false), ActionPlaySong(cityMap.musicFilename, 100), ActionFadeInMap(100), ActionExModeOff(), } local startSequence = { ActionFadeOutMusic(50), ActionFadeOutMap(50), ActionWait(50), ActionCallFunction(jake.addToInventory, jake, cityMap.walkieTalkie), ActionSetVariable(_G, "show_main_menu", nil), ActionPlaySong("data/music/2.ogg", 100), ActionFadeInMap(100), ActionShowMapName(m_get_bitmap("prison.tga")), ActionWait(300), ActionConversation(lang:getConv("Intro1")), ActionWait(25), ActionWalkPath(jailMap.guard, "DLD"), ActionSetVariable(elwood, "dir", DIR_DOWN), ActionWait(25), ActionSetVariable(jailMap.guard, "dir", DIR_UP), ActionConversation(lang:getConv("Intro2")), ActionWalkPath(jailMap.guard, "D2"), ActionCallFunction(door1.event_bumped_into, door1), ActionWait(door1.period * 100), ActionWalkPath(elwood, "D"), ActionAddSequence{ ActionSetVariable(elwood, "speed", jailMap.guard.speed), ActionWalkPath(elwood, "D6R9D13L19D14R9"), ActionSetVariable(elwood, "speed", oldspeed), }, ActionWalkPath(jailMap.guard,"D3R9D13L19D14R11"), ActionSetVariable(jailMap.guard, "dir", DIR_LEFT), ActionWait(50), ActionConversation(lang:getConv("Intro3")), ActionWalkPath(elwood, "D5"), ActionAddSequence{ ActionFadeOutMap(50), }, ActionWalkPath(elwood, "D3"), ActionCallFunction(elwood.setMap, elwood, cityMap), ActionSetPosition(elwood, 113, 107, DIR_DOWN), ActionAddSequence{ ActionFadeInMap(50), }, ActionWalkPath(elwood, "D3"), ActionConversation(lang:getConv("Intro4")), ActionSetCameraTarget(dummy, false), ActionTweenVariable(dummy, "y", 200, 114.5), ActionWait(50), ActionWalkPath(elwood, "D5"), ActionSetCameraTarget(elwood, false), ActionWalkPath(elwood, "D3"), ActionSetVariable(jake, "dir", DIR_RIGHT), ActionWalkPath(elwood, "D"), ActionSetVariable(elwood, "dir", DIR_LEFT), ActionConversation(lang:getConv("Intro5")), ActionAddSequence{ ActionWalkPath(elwood, "D5L5"), ActionSetVariable(elwood, "dir", DIR_RIGHT), ActionWait(15), ActionSetPosition(dummy, 108.5, 123), ActionSetCameraTarget(dummy, false), ActionSetPosition(elwood, 113, 108, DIR_DOWN), }, ActionWalkPath(jake, "D3L3"), ActionSetVariable(jake, "dir", DIR_RIGHT), ActionWait(15), ActionSetPosition(jake, 114, 108, DIR_DOWN), ActionWait(180), ActionConversation(lang:getConv("Intro5a")), ActionCallFunction(elwood.addToInventory, elwood, cityMap.walkieTalkie), ActionConversation(lang:getConv("Intro6")), ActionSetVariable(copcar, "tick_time", 5), ActionTweenVariable(copcar, "x", 250, 118, function(from, to, perc) perc = 1 - math.sin(perc * 0.5 * math.pi + 0.5 * math.pi) return from + (to - from) * perc end), ActionFadeOutMap(50), ActionSetPosition(dummy, 90.5, 75.5), ActionFadeInMap(50), ActionShowMapName(m_get_bitmap("suburbs.tga")), ActionSetPosition(copcar, 76, 77), ActionTweenVariable(copcar, "x", 250, 88, function(from, to, perc) perc = math.sin(perc * 0.5 * math.pi) return from + (to - from) * perc end), ActionSetVariable(copcar, "tick_time", 0), ActionWait(50), ActionSetPosition(elwood, 90, 78, DIR_DOWN), ActionWait(10), ActionSetPosition(elwood, 90, 78, DIR_RIGHT), ActionWait(30), ActionSetPosition(jake, 90, 76, DIR_UP), ActionWait(10), ActionSetPosition(jake, 90, 76, DIR_RIGHT), ActionConversation(lang:getConv("Intro7")), ActionSetCameraTarget(jake, false), ActionParallel{ ActionSequence{ ActionWait(30), ActionWalkPath(jake, "R3U3"), }, ActionWalkPath(elwood, "R4U5"), }, ActionWait(150), ActionSetVariable(jake, "dir", DIR_RIGHT), ActionWait(30), ActionSetVariable(elwood, "dir", DIR_LEFT), ActionConversation(lang:getConv("WhereKeys")), ActionSetPosition(dummy, 93.5, 72.5), ActionSetCameraTarget(dummy, false), ActionFadeOutMusic(50), ActionTweenVariable(dummy, "x", 50, 94.5), ActionPlaySong(cityMap.musicFilename, 10), ActionSetCameraTarget(elwood, false), ActionExModeOff(), } self:addMenuItem(GuiMenuItem(lang:getVar("PLAY"), function() self.master:removeInteraction(self); ActionController:addSequence(startSequence); end)) self:addMenuItem(GuiMenuItem(lang:getVar("QUICKPLAY"), function() self.master:removeInteraction(self); ActionController:addSequence(quickStartSequence); end)) self:addMenuItem(GuiMenuItem(lang:getVar("LANGUAGE"), function() self.master:addInteraction(LanguageMenu(self)); self.master:removeInteraction(self); end)) self:addMenuItem(GuiMenuItem(lang:getVar("QUIT"), function() self.master:removeInteraction(self); m_quit_game() end)) end; keyType = function(self, key) if (GuiMenu.keyType(self, key)) then return true end if (key == "esc") then -- Capture escape to prevent closing the menu return true end end; defaultproperties = { }; } --- NEW FILE: Map.lua --- -- -- The Map class -- By Bjorn Lindeijer import("Object.lua") Map = Object:subclass { name = "Map"; init = function(self, mapName) self.map = m_load_map(mapName) if (not self.map or type(self.map) ~= "userdata") then error("Error while loading map \"".. mapName.."\"!") end -- Call beginPlay on all actors in the map local objs = m_get_objects_on_map(self.map) for k,v in pairs(objs) do if (v:instanceOf(Actor)) then v:beginPlay() end end end; spawn = function(self, class, x, y, owner) return Actor:spawn(class, x, y, self, owner) end; defaultproperties = { map = nil, mapNameBitmap = nil, musicFilename = "", } } --- NEW FILE: MusicController.lua --- -- -- This file contains the music controller. It can be told to play and stop -- songs. As a bonus, it can also dynamically change the parameters of a -- channel over a period of time. Using this feature it can fade from one -- music to another. -- -- By Bjorn Lindeijer MC_NORMAL = 0 MC_FADE_IN = 1 MC_FADE_OUT = 2 MC_FADE_BETWEEN = 3 MusicControl = { state = MC_NORMAL, currentChannel = -1, fadeInChannel = 1, fadeProgress = 0, fadeTime = 0, } function MusicControl:init() self.channels = m_get_number_of_channels() or 0 end function MusicControl:update() if (self.state == MC_FADE_BETWEEN or self.state == MC_FADE_IN or self.state == MC_FADE_OUT) then self.fadeProgress = self.fadeProgress + 1 if (self.state == MC_FADE_BETWEEN) then if (self.fadeProgress > self.fadeTime or self.fadeTime <= 0) then self.state = MC_NORMAL self.fadeProgress = self.fadeTime m_stop_music(self.currentChannel) self.currentChannel = self.fadeInChannel m_adjust_channel(self.currentChannel, 255, 128, 1000) else m_adjust_channel(self.fadeInChannel, (self.fadeProgress / self.fadeTime) * 255, 128, 1000) m_adjust_channel(self.currentChannel, ((self.fadeTime - self.fadeProgress) / self.fadeTime) * 255, 128, 1000) end end if (self.state == MC_FADE_IN) then if (self.fadeProgress > self.fadeTime or self.fadeTime <= 0) then self.state = MC_NORMAL self.fadeProgress = self.fadeTime m_adjust_channel(self.currentChannel, 255, 128, 1000) else m_adjust_channel(self.currentChannel, (self.fadeProgress / self.fadeTime) * 255, 128, 1000) end end if (self.state == MC_FADE_OUT) then if (self.fadeProgress > self.fadeTime or self.fadeTime <= 0) then self.state = MC_NORMAL self.fadeProgress = self.fadeTime m_stop_music(self.currentChannel) self.currentChannel = -1 else m_adjust_channel(self.currentChannel, ((self.fadeTime - self.fadeProgress) / self.fadeTime) * 255, 128, 1000) end end end end function MusicControl:play_song(filename) self:stop_all_music() -- play this song on the first channel self.currentChannel = 0 self.currentSong = filename m_play_music(filename, self.currentChannel) m_adjust_channel(self.currentChannel, 255, 128, 1000) end function MusicControl:stop_all_music() -- stop music on all channels for i = 0,self.channels-1 do m_stop_music(i) end end function MusicControl:fade_to_song(filename, time) if (not (time > 0)) then self:play_song(filename) return end if (self.currentChannel == -1) then self:fade_in(filename, time) return end self.state = MC_FADE_BETWEEN self.fadeTime = time self.fadeProgress = 0 self.fadeInChannel = self.currentChannel + 1 if (self.fadeInChannel == self.channels) then self.fadeInChannel = 0 end -- Start playing music and set volume to 0 self.currentSong = filename m_play_music(filename, self.fadeInChannel) self:update() end function MusicControl:fade_out(time) if (self.currentChannel >= 0) then self.state = MC_FADE_OUT self.fadeTime = time self.fadeProgress = 0 else m_message("MusicControl:fade_out - Warning, no music to fade out") end end function MusicControl:fade_in(filename, time) self:play_song(filename) self.state = MC_FADE_IN self.fadeTime = time self.fadeProgress = 0 m_adjust_channel(self.currentChannel, 0, 128, 1000) end --- NEW FILE: PlayerSwitcher.lua --- -- This class makes it possible to switch between multiple player hosts -- and displays their information on the screen. -- -- By Bjorn Lindeijer import("Interaction.lua") PlayerSwitcher = Interaction:subclass { name = "PlayerSwitcher"; init = function(self, playerController, cameraTarget) self.playerHosts = {} self.playerController = playerController self.cameraTarget = cameraTarget -- Health bar images self.hb_empty = m_get_bitmap("healthbar_empty.bmp") self.hb_full = m_get_bitmap("healthbar_full.bmp") self.hb_w, self.hb_h = m_bitmap_size(self.hb_full) -- Experience bar images self.eb_empty = m_get_bitmap("expbar_empty.bmp") self.eb_full = m_get_bitmap("expbar_full.bmp") self.eb_w, self.eb_h = m_bitmap_size(self.eb_full) end; addPlayerHost = function(self, playerHost) if (not playerHost) then error("Attempt to add non-existing player host!") end table.insert(self.playerHosts, playerHost) if (self.currentHost == 0) then self:selectPlayerHost(playerHost) end end; removePlayerHost = function(self, playerHost) local iIndex = self:hostIndex(playerHost) if (iIndex < 0) then m_message("Attempt to remove non-existing player host.") else table.remove(self.playerHosts, iIndex) if (iIndex == self.currentHost) then if (self.currentHost > table.getn(self.playerHosts)) then self.currentHost = 1 end if (table.getn(self.playerHosts) > 0) then self:selectPlayerHost(self.playerHosts[self.currentHost]) else self.playerController:unPossess() self.currentHost = 0 end end end end; selectPlayerHost = function(self, playerHost) local iIndex = self:hostIndex(playerHost) if (iIndex < 0) then m_message("Attempt to select non-existing player host.") else self.playerController:possess(playerHost) self.currentHost = iIndex self.cameraTarget:setTarget(playerHost) end end; getCurrentHost = function(self) if (self.currentHost > 0) then return self.playerHosts[self.currentHost] end; end; hostIndex = function(self, playerHost) local iIndex -- Search for the Interaction iIndex = -1; for i = 1, table.getn(self.playerHosts) do if (self.playerHosts[i] == playerHost) then iIndex = i end end return iIndex end; keyType = function(self, key) if (key == "tab" and table.getn(self.playerHosts) > 0 and m_get_ex_mode() == 0) then local prevHost = self:getCurrentHost() if (m_get_shift()) then self.currentHost = self.currentHost - 1 if (self.currentHost < 1) then self.currentHost = table.getn(self.playerHosts) end else self.currentHost = self.currentHost + 1 if (self.currentHost > table.getn(self.playerHosts)) then self.currentHost = 1 end end local nextHost = self:getCurrentHost() if (prevHost.map == nextHost.map) then -- Switch player instantly self:selectPlayerHost(self.playerHosts[self.currentHost]) else local musicOut = ActionFadeOutMusic(50) local musicIn = ActionPlaySong(nextHost.myMap.musicFilename, 50) if (nextHost.myMap.musicFilename == MusicControl.currentSong) then musicOut = ActionWait(0) musicIn = ActionWait(0) end -- Switch player after fading out and fade in afterwards ActionController:addSequence{ ActionSetVariable(self, "bActive", false), musicOut, ActionFadeOutMap(50), ActionCallFunction(self.selectPlayerHost, self, self.playerHosts[self.currentHost]), musicIn, ActionFadeInMap(50), ActionSetVariable(self, "bActive", true), } end return true; end; end; tick = function(self) self.cameraTarget:tick() end; preRender = function(self) self.cameraTarget:preRender() end; postRender = function(self, canvas) -- Draw information about each player -- and highlight the selected player for i = 1, table.getn(self.playerHosts) do local player = self.playerHosts[i] local health_perc = player.health / player.maxHealth local experience_perc = player.experience / player.nextLevelExperience local x = 16 + (self.hb_w + 16) * (i - 1) local y = 16 local invHeight = 19 if (table.getn(player.inventory) == 0) then invHeight = 0 end canvas:setDrawMode(DM_TRANS) -- Draw selection block if (i == self.currentHost) then guiTheme:drawBox(x - 3, y - 2, self.hb_w + 6, 14 + 5 + invHeight) end -- Draw the health bar canvas:setAlpha(128) canvas:setCursor(x, y) canvas:drawIcon(self.hb_empty) canvas:setCursor(x, y) canvas:drawPattern(self.hb_full, self.hb_w * health_perc, self.hb_h) -- Draw the experience bar ... [truncated message content] |
From: <b_l...@us...> - 2004-01-13 19:23:07
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv29553 Added Files: Enemy.lua Hud.lua Rat.lua Log Message: Any problems here? --- NEW FILE: Enemy.lua --- import("Character.lua") Enemy = Character:subclass { name = "Enemy"; --== Commands ==-- attack = function(self) if (self.bAttacking == false and self.walking == 0 and self.charging == 0) then self:log("attacking.") self.bAttacking = true -- See if there is something at the attacked location local ax, ay = self.x, self.y if (self.dir == DIR_LEFT) then ax = ax - 1 end if (self.dir == DIR_RIGHT) then ax = ax + 1 end if (self.dir == DIR_UP) then ay = ay - 1 end if (self.dir == DIR_DOWN) then ay = ay + 1 end local attackedObjs = m_get_objects_at(ax, ay, self.map) local damage = self.attackMinDam + math.random(self.attackMaxDam - self.attackMinDam) -- Deal damage for index, object in attackedObjs do if (object:instanceOf(Actor)) then object:takeDamage(damage, self) end end -- Enable next attack after attackTime + chargeTime game ticks ActionController:addSequence{ ActionWait(self.attackTime), ActionSetVariable(self, "bAttacking", false), ActionSetVariable(self, "charging", self.chargeTime), } end end; --== Notifications ==-- died = function(self, killer, damageType, location) -- Let character adapt to dead status Character.died(self, killer, damageType, location) -- Give players experience if (killer and killer:instanceOf(Player)) then killer:gainExperience(self.experience) end -- Fade away ActionController:addSequence({ ActionWait(100), ActionSetVariable(self, "draw_mode", DM_TRANS), ActionTweenVariable(self, "alpha", 200, 0), ActionDestroyObject(self), }) -- Enemies don't need tick when dead self.tick_time = 0 end; defaultproperties = { experience = 0, attackTime = 50, chargeTime = 100, charging = 0, attackMinDam = 0, attackMaxDam = 5, bAttacking = false, deathBitmap = nil, controllerClass = AIController, }; } --- NEW FILE: Hud.lua --- -- -- This file contains the code for putting the HUD on the screen. -- By Bjorn Lindeijer import("Interaction.lua") -- -- The actual HUD. -- Hud = Interaction:subclass { name = "Hud"; init = function(self) -- Screen size self.screen_w, self.screen_h = m_screen_size() -- Health bar images self.hb_empty = m_get_bitmap("healthbar_empty.bmp") self.hb_full = m_get_bitmap("healthbar_full.bmp") self.hb_w, self.hb_h = m_bitmap_size(self.hb_full) -- Experience bar images self.eb_empty = m_get_bitmap("expbar_empty.bmp") self.eb_full = m_get_bitmap("expbar_full.bmp") self.eb_w, self.eb_h = m_bitmap_size(self.eb_full) -- Game over image self.game_over = m_get_bitmap("game_over.bmp") self.game_over_s = m_get_bitmap("game_over_s.bmp") self.go_w, self.go_h = m_bitmap_size(self.game_over) end; -- A chance to put something on the screen (requires bVisible) postRender = function(self, canvas) --[[ local player = m_get_player() local health_perc = player.health / player.maxHealth local experience_perc = player.experience / player.nextLevelExperience -- Draw the health bar m_set_alpha(128) m_set_cursor(16, 16) draw_icon(self.hb_empty) m_set_cursor(16, 16) draw_pattern(self.hb_full, self.hb_w * health_perc, self.hb_h) -- Draw the experience bar m_set_cursor(16, 27) draw_icon(self.eb_empty) m_set_cursor(16, 27) draw_pattern(self.eb_full, self.eb_w * experience_perc, self.eb_h) m_set_alpha(255) ]] -- Map name if (self.map_name ~= nil and self.map_name_alpha > 0) then local w, h = m_bitmap_size(self.map_name) local x, y = (self.screen_w - w)/2, (self.screen_h - h)/6 * 5 local alpha = self.map_name_alpha -- Take map fading into account if (map_fade ~= nil and map_fade.alpha ~= nil and map_fade.alpha > 0) then alpha = alpha * (255 - map_fade.alpha) / 255 end canvas:setCursor(x, y); canvas:setAlpha(0.75 * alpha); canvas:drawIcon(self.map_name) canvas:setCursor(0, y - 10); canvas:setAlpha(alpha); canvas:drawRect(m_get_bitmap("pixel_black.bmp"), self.screen_w, 1) canvas:setCursor(0, y - 10); canvas:setAlpha(0.25 * alpha); canvas:drawRect(m_get_bitmap("pixel_black.bmp"), self.screen_w, h + 20) canvas:setCursor(0, y + h + 10); canvas:setAlpha(alpha); canvas:drawRect(m_get_bitmap("pixel_black.bmp"), self.screen_w, 1) end -- Draw gameover screen stuff if (game.game_over and game.game_over_alpha and game.game_over_alpha > 0) then canvas:setAlpha(0.25 * game.game_over_alpha) canvas:setCursor((self.screen_w - self.go_w)/2 + 6, (self.screen_h - self.go_h)/3 + 4) canvas:drawIcon(self.game_over_s) canvas:setAlpha(game.game_over_alpha) canvas:setCursor((self.screen_w - self.go_w)/2, (self.screen_h - self.go_h)/3) canvas:drawIcon(self.game_over) end end; defaultproperties = { count = 0, map_name_alpha = 0, } } --- NEW FILE: Rat.lua --- -- -- A rat. -- -- bodged by Hedde Bosman import("Player.lua") import("AdvAIRandom.lua") import("Shadow.lua") RatShadow = Shadow:subclass { name = "RatShadow"; defaultproperties = { offset_z = -3, bitmap = m_get_bitmap("rat_s.tga"), }; } Rat = Enemy:subclass { name = "Rat"; bPlaceable = true; defaultproperties = { attackMinDam = 0, attackMaxDam = 2, maxHealth = 20, speed = 4, experience = 12, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("rat.bmp"), 16, 16), deathBitmap = m_get_bitmap("rat_dead.bmp"), nature = NEUTRAL, controllerClass = AdvAIRandom, shadowClass = RatShadow, hitEffectHeight = 0, }; } |
From: <b_l...@us...> - 2004-01-13 19:21:43
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv29271 Added Files: Lang.lua Spring.lua Log Message: Would these work? --- NEW FILE: Lang.lua --- -- -- Contains all the stuff that is being said in the game -- By Bjorn Lindeijer -- -- This object holds written text, to easy translation of the game. Variables -- starting with a 'c' are conversations. -- import("Object.lua") Lang = Object:subclass { name = "Lang"; getConv = function(self, convName) local conv = self.convs[convName] if (conv) then -- Replace variables return conv else m_message("Warning: no such conversation ("..convName..")") return {} end end; getVar = function(self, varName) local var = self.vars[varName] if (var) then return var else m_message("Warning: no such variable ("..varName..")") return "" end end; vars = {}; convs = {}; } --- NEW FILE: Spring.lua --- -- -- The spring by Frode -- import("Decoration.lua") import("Animation.lua") import("lang.lua") Spring = Decoration:subclass { name = "Spring"; activatedBy = function(self, instigator) Decoration.activatedBy(self, instigator) if (instigator.health < instigator.maxHealth) then ActionController:addSequence({ ActionTweenVariable(instigator, "health", 2*(instigator.maxHealth - instigator.health), instigator.maxHealth), }) end end; defaultproperties = { animType = LinearAnimation, animSeq = extr_array(m_get_bitmap("spring.bmp"), 48, 72), animSpeed = 1 / 8, w = 2, h = 1, bCanActivate = true, bCenterOnTile = false, bCenterBitmap = false, convTableKeyword = "Refreshing", }; } |
From: <b_l...@us...> - 2004-01-13 19:20:12
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv28751 Modified Files: Action.lua Pawn.lua Added Files: Player.lua Torch.lua Turtle.lua Viewport.lua Log Message: More scripts. --- NEW FILE: Player.lua --- -- -- The player character is defined here. -- By Bjorn Lindeijer import("Character.lua") import("AnimationFunctions.lua") -- (Player) character states CHR_ATTACK = 1 CHR_HIT = 2 CHR_READY = 3 CHR_DEAD = 4 Player = Character:subclass { name = "Player"; init = function(self) self:derive_attributes() Character.init(self) end; derive_attributes = function(self) -- Derived attributes self.maxHealth = 15 + 2*self.endurance self.speed = 4/95 * self.agility + 53/19 -- Player speed in tiles/second self.charge_time = (-40/95 * self.agility + 60 + 40/19) self.attack_speed = self.charge_time/2 -- Hack to play faster self.speed = self.speed * 1.4 --self.attack_speed = self.attack_speed * 0.5 --self.charge_time = self.charge_time * 0.5 --self.maxHealth = self.maxHealth * 100 end; attack = function(self) if (self.state == CHR_HIT) then return elseif (self.state == CHR_READY and self.walking == 0 and self.charging == 0) then self.state = CHR_ATTACK -- See if there is a monster at the attacked location local ax, ay = self.x, self.y if (self.dir == DIR_LEFT) then ax = ax - 1 end if (self.dir == DIR_RIGHT) then ax = ax + 1 end if (self.dir == DIR_UP) then ay = ay - 1 end if (self.dir == DIR_DOWN) then ay = ay + 1 end local attacked_objs = m_get_objects_at(ax, ay, self.map) for index, object in attacked_objs do if (object:instanceOf(Actor)) then local damage = (self.attack_min_dam + math.random(self.attack_max_dam - self.attack_min_dam))*(self.strength/95 + 18/19) object:takeDamage(damage, self) end end ActionController:addSequence{ ActionExModeOn(), ActionSetState(self, CHR_ATTACK), ActionPlaySample("bbsfx_hit1.wav"), ActionWait(self.attack_speed), ActionSetState(self, CHR_READY), ActionSetVariable(self, "charging", self.charge_time), ActionExModeOff(), } end end; setState = function(self, state) self.state = state self.bAttacking = (self.state == CHR_ATTACK) self:updateBitmap() end; tick = function(self) if (self.charging > 0) then self.charging = self.charging - 1 end Character.tick(self) end; died = function(self, killer, damageType, location) Character.died(self, killer, damageType, location) if (killer) then self:log("Killed by "..killer:toString()..".") else self:log("Commited suicide.") end ActionController:addSequence({ ActionExModeOn(), ActionWait(200), ActionSetVariable(game, "game_over", 1), ActionAddSequence({ ActionTweenVariable(game, "game_over_alpha", 300, 255, 0), }), }) end; event_bumped_into = function(self, obj) -- Players move away for other players who try to enter this tile if (obj:instanceOf(Player)) then self:moveAway() end end; gainExperience = function(self, xp) self.experience = self.experience + xp if (self.experience >= self.nextLevelExperience) then self.endurance = self.endurance + 5 self.nextLevelExperience = 2.5 * self.nextLevelExperience self:derive_attributes() end end; defaultproperties = { sleepBitmap = nil, strength = 5, dexterity = 5, agility = 5, endurance = 5, experience = 0, nextLevelExperience = 31, attack_min_dam = 5, attack_max_dam = 10, charging = 0, state = CHR_READY, draw_mode = DM_ALPHA, tick_time = 1, travel = 1, -- Player can travel to other maps charAnim = extr_char_anim(m_get_bitmap("frode.tga")), }; } --- NEW FILE: Torch.lua --- -- -- A torch by Frode -- import("Decoration.lua") import("Animation.lua") import("lang.lua") Torch = Decoration:subclass { name = "Torch"; defaultproperties = { animType = LinearAnimation, animSeq = { m_get_bitmap("torch1.bmp"), m_get_bitmap("torch2.bmp"), m_get_bitmap("torch3.bmp"), m_get_bitmap("torch4.bmp"), m_get_bitmap("torch5.bmp"), m_get_bitmap("torch6.bmp"), }, animSpeed = 1 / 10, draw_mode = DM_MASKED, convTableKeyword = "Fire", }; } --- NEW FILE: Turtle.lua --- -- Turtle Turtle = Enemy:subclass { name = "Turtle"; bPlaceable = true; defaultproperties = { attackMinDam = 1, attackMaxDam = 4, maxHealth = 50, speed = 1, experience = 20, offset_y = 4, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("turtle.bmp"), 26, 14), deathBitmap = m_get_bitmap("turtle_dead.bmp"), nature = AGGRESSIVE, controllerClass = AdvAIRandom, hitEffectHeight = 0, }; } --- NEW FILE: Viewport.lua --- import("Object.lua") Viewport = Object:subclass { name = "Viewport"; init = function(self, x, y, w, h) self.x = x or self.x self.y = y or self.y self.w = w or self.w self.h = h or self.h end; mapToScreen = function(self, x, y, z) if (not self.target or not self.target.map) then return end if (not z) then z = 0 end return m_map_to_screen( x, y, z, self.x, self.y, self.w, self.h, self.target.x, self.target.y, self.target.map ) end; screenToMap = function(self, x, y) if (not self.target or not self.target.map) then return end return m_screen_to_map( x, y, self.x, self.y, self.w, self.h, self.target.x, self.target.y, self.target.map ) end; render = function(self) if (not self.target or not self.target.map) then return end if (self.target) then m_draw_viewport( self.x, self.y, self.w, self.h, self.target.x, self.target.y, self.target.map ) end end; defaultproperties = { x = 0, y = 0, w = 0, h = 0, target = nil, }; } Index: Action.lua =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/scripts/Action.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Action.lua 1 Jun 2003 00:14:17 -0000 1.2 --- Action.lua 13 Jan 2004 19:20:08 -0000 1.3 *************** *** 4,19 **** -- actions for your own sequences. -- ! -- All actions have a finished() function indicating whether they ! -- are finished. Non-instant actions also have an exec() function ! -- that will be called every game tick until their finished() ! -- function returns 1. -- -- A summaration of the available action types follows: -- -- ActionSequence(sequence) -- ActionAddSequence(sequence) -- ActionCallFunction(f, ...) -- ActionSetVariable(table, key, value) ! -- ActionTweenVariable(table, key, time, to [, from]) -- ActionWait(duration) -- --- 4,18 ---- -- actions for your own sequences. -- ! -- All actions have an exec() function that will be called every ! -- game tick until it has returned true. -- -- A summaration of the available action types follows: -- -- ActionSequence(sequence) + -- ActionParallel(sequence) -- ActionAddSequence(sequence) -- ActionCallFunction(f, ...) -- ActionSetVariable(table, key, value) ! -- ActionTweenVariable(table, key, time, to [, from, func]) -- ActionWait(duration) -- *************** *** 21,28 **** --- 20,29 ---- -- ActionChangeDirection(actor, new_direction) -- ActionWalk(actor, direction, amount [,col]) + -- ActionWalkPath(actor, path [,col]) -- ActionConversation(conversation) -- ActionExModeOn() -- ActionExModeOff() -- ActionPlaySong(filename, fadeTime [, wait]) + -- ActionPlaySample(filename) -- ActionFadeOutMusic(fadeTime [, wait]) -- ActionFadeInMusic(filename, fadeTime [, wait]) *************** *** 30,41 **** -- ActionFadeOutMap(time) -- ActionSetState(object, state) ! -- ActionSetPosition(actor, x, y [, dir]) ! -- ActionChangeMap(filename) -- ActionDestroyObject(object) -- ActionAddObject({name|class}, x, y) -- ActionQuitGame() -- ActionShowMapName(bitmap) -- ! -- By Bjørn Lindeijer --- 31,42 ---- -- ActionFadeOutMap(time) -- ActionSetState(object, state) ! -- ActionSetPosition(actor, x, y [,dir[,map]]) -- ActionDestroyObject(object) -- ActionAddObject({name|class}, x, y) -- ActionQuitGame() -- ActionShowMapName(bitmap) + -- ActionSetCameraTarget(target [, tween]) -- ! -- By Bjorn Lindeijer *************** *** 51,55 **** -- The exec function will be called every game tick until it returns true. ! exec = function(self) end; } --- 52,56 ---- -- The exec function will be called every game tick until it returns true. ! exec = function(self) return true; end; } *************** *** 84,87 **** --- 85,127 ---- } + ActionParallel = Action:subclass + { + name = "ActionParallel"; + + init = function(self, actions) + m_message("ActionParallel initializing with ".. table.getn(actions) .." actions.") + self.actions = {} + + -- Add all actions to the list of actions to execute. + local i + for i = 1, table.getn(actions) do + if (actions[i] and actions[i]:instanceOf(Action)) then + -- Create an action execution environment for this action + local execEnv = {} + setmetatable(execEnv, {__index = actions[i]}) + + -- Insert the action execution environment in the actions array + table.insert(self.actions, execEnv) + else + m_message("ActionParallel: action not an instance of Action (".. actions[i].name ..")") + end + end + end; + + exec = function(self) + local i + + -- Execute all running actions + for i = 1, table.getn(self.actions) do + if (i <= table.getn(self.actions) and self.actions[i]:exec()) then + m_message("ActionParallel finished executing "..self.actions[i].name) + table.remove(self.actions, i) + i = i - 1 + end + end + + return table.getn(self.actions) == 0 + end; + } -- Add a sequence to the sequence controller *************** *** 114,118 **** exec = function(self) ! self.f(expand(self.arg)) return true end; --- 154,158 ---- exec = function(self) ! self.f(unpack(self.arg)) return true end; *************** *** 145,154 **** name = "ActionTweenVariable"; ! init = function(self, table, key, time, to, from) self.table = table self.key = key self.time = time self.to = to ! self.from = from self.count = 0 --- 185,201 ---- name = "ActionTweenVariable"; ! init = function(self, table, key, time, to, from, func) self.table = table self.key = key self.time = time self.to = to ! if (type(from) == "number") then self.from = from end ! if (type(from) == "function") then self.func = from end ! if (type(func) == "function") then self.func = func end ! if (not self.func) then ! self.func = function(from, to, perc) ! return from + perc * (to - from) ! end ! end self.count = 0 *************** *** 157,166 **** exec = function(self) if (not self.from) then self.from = self.table[self.key] end ! self.count = self.count + 1 if (self.count <= self.time) then ! self.table[self.key] = self.from + ((self.count / self.time) * (self.to - self.from)) else ! self.table[self.key] = self.to end --- 204,214 ---- exec = function(self) if (not self.from) then self.from = self.table[self.key] end ! if (not self.from) then return true end ! self.count = self.count + 1 if (self.count <= self.time) then ! self.table[self.key] = self.func(self.from, self.to, (self.count / self.time)) else ! self.table[self.key] = self.func(self.from, self.to, 1) end *************** *** 219,223 **** self.direction = direction self.amount = amount ! self.col = (col ~= nil and col ~= 0) end; --- 267,272 ---- self.direction = direction self.amount = amount ! self.col = col ! if (col == 0) then self.col = false end end; *************** *** 237,240 **** --- 286,320 ---- + -- Order characters around using a path string + + ActionWalkPath = ActionSequence:subclass + { + name = "ActionWalkPath"; + + init = function(self, object, path, col) + if (type(object) ~= "table") then error("Invalid object passed to ActionWalkPath") end + if (type(path) ~= "string") then error("Invalid string passed to ActionWalkPath") end + + self.actions = {} + + for w in string.gfind(path, "[UDLR]%d*") do + local dir = string.sub(w,1,1) + if (dir == "U") then dir = DIR_UP end + if (dir == "R") then dir = DIR_RIGHT end + if (dir == "D") then dir = DIR_DOWN end + if (dir == "L") then dir = DIR_LEFT end + + local amount = tonumber(string.sub(w,2)) + if (not amount or amount == 0) then amount = 1 end + + table.insert(self.actions, ActionWalk(object, dir, amount, col)) + end + + self.i = 1 + end; + } + + + -- Show conversations within a sequence *************** *** 253,257 **** self.started = true end ! return (ConvBox.state == CB_CLOSED and self.started) end; } --- 333,337 ---- self.started = true end ! return (convBox.state == CB_CLOSED and self.started) end; } *************** *** 283,286 **** --- 363,368 ---- table.remove(exModeArray, table.getn(exModeArray)) --m_message("Exclusive mode turned off (".. table.getn(exModeArray) ..")") + else + m_set_ex_mode(0) end return true *************** *** 289,309 **** - -- Change to another map - - ActionChangeMap = Action:subclass - { - name = "ActionChangeMap"; - - init = function(self, filename) - self.filename = filename - end; - - exec = function(self) - m_load_map(self.filename) - return true - end; - } - - -- Fading in and out --- 371,374 ---- *************** *** 333,349 **** name = "ActionSetPosition"; ! init = function(self, obj, x, y, dir) self.x = x self.y = y self.dir = dir self.obj = obj end; exec = function(self) ! self.obj.x = self.x ! self.obj.y = self.y ! if self.dir ~= nil then self.obj.dir = self.dir end --- 398,417 ---- name = "ActionSetPosition"; ! init = function(self, obj, x, y, dir, map) self.x = x self.y = y self.dir = dir self.obj = obj + self.map = map end; exec = function(self) ! self.obj:setPosition(self.x, self.y) ! if (self.dir) then self.obj.dir = self.dir + if (self.map) then + self.obj:setMap(self.map) + end end *************** *** 376,379 **** --- 444,459 ---- } + ActionPlaySample = ActionCallFunction:subclass + { + name = "ActionPlaySample"; + + init = function(self, filename) + if (not filename) then + error("Error: ActionPlaySample created without a filename") + end + ActionCallFunction.init(self, m_play_sample, filename) + end; + } + ActionFadeOutMusic = Action:subclass *************** *** 474,478 **** m_add_object(self.x, self.y, self.objname) else ! spawn(self.x, self.y, self.objname) end return true --- 554,558 ---- m_add_object(self.x, self.y, self.objname) else ! Actor:spawn(self.objname, self.x, self.y) end return true *************** *** 503,522 **** init = function(self, bitmap) self.bitmap = bitmap end; exec = function(self) ! -- Make sure no other ActionShowMapName sequence is taking place ! ActionController:removeSequence(show_map_seq) - -- Start a new show_map_seq = ActionController:addSequence{ ! ActionWait(50), ! ActionSetVariable(HUD, "map_name", self.bitmap), ! ActionTweenVariable(HUD, "map_name_alpha", 100, 255, 0), ! ActionWait(200), ! ActionTweenVariable(HUD, "map_name_alpha", 100, 0, 255), } return true end; --- 583,623 ---- init = function(self, bitmap) + if (not bitmap) then + self:log("Warning: no valid bitmap for showing map name!") + end self.bitmap = bitmap end; exec = function(self) ! --[[ ! local mapInt = BBRpgMapname() ! ! mapInt.bitmap = self.bitmap show_map_seq = ActionController:addSequence{ ! ActionCallFunction(interactionMaster.addInteraction, interactionMaster, mapInt), ! ActionTweenVariable(mapInt, "perc", 50, 1, 0), ! ActionWait(100), ! ActionTweenVariable(mapInt, "perc", 50, 0, 1), ! ActionCallFunction(interactionMaster.removeInteraction, interactionMaster, mapInt), } + ]] + + return true + end; + } + + ActionSetCameraTarget = Action:subclass + { + name = "ActionSetCameraTarget"; + + init = function(self, target, tween) + self.target = target + self.tween = tween + end; + + exec = function(self) + gameCameraTarget:setTarget(self.target, self.tween) return true end; Index: Pawn.lua =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/scripts/Pawn.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Pawn.lua 1 Jun 2003 17:27:24 -0000 1.2 --- Pawn.lua 13 Jan 2004 19:20:08 -0000 1.3 *************** *** 1,113 **** ! -- ! -- A base class for anything that walks like a character ! -- By Bjørn Lindeijer ! ! import("Actor.lua") ! ! ! Pawn = Actor:subclass ! { ! name = "Pawn"; ! ! init = function(self) ! self.health = self.maxHealth ! ! -- Create the default controller, if present ! if (not self.controller and self.controllerClass) then ! self.controller = self.controllerClass() ! self.controller:possess(self) ! end ! end; ! ! tick = function(self) ! Actor.tick(self) ! if (self.controller) then ! self.controller:tick() ! end ! end; ! ! ! --== BEING POSSESSED ==-- ! ! possessedBy = function(self, controller) ! self.controller = controller ! end; ! ! unPossessed = function(self) ! self.controller = nil ! end; ! ! ! --== TAKING DAMAGE ==-- ! ! takeDamage = function(self, damage, instigator, damageType, momentum, location) ! if (damage > 0) then ! local actualDamage = damage ! self.health = self.health - damage ! ! if (self.health <= 0) then ! -- Pawn died ! local killer ! if (instigator) then ! killer = instigator.controller ! end ! self:died(killer, damageType, location) ! else ! if (self.controller) then ! self.controller:notifyTakeDamage(actualDamage, instigator, damageType, momentum, location); ! end ! end ! ! self:makeNoise(15) ! end ! end; ! ! died = function(self, killer, damageType, location) ! -- Become bleeding body and fade away (implement in subclass) ! end; ! ! ! --== MOVING ==-- ! ! walk = function(self, dir, no_collision) ! if (self.walking == 0) then ! if (no_collision) then ! m_walk_obj_nocol(self, dir) ! else ! m_walk_obj(self, dir) ! end ! if (self.walking ~= 0) then ! self:makeNoise(10) ! end ! end ! end; ! ! attack = function(self) ! -- Implement in subclass ! end; ! ! -- Making noise will cause surrounding Pawns to hear the noise with ! -- hearedLoudness = max(0.1, loudness / (distanceInTiles ^ 2)) ! makeNoise = function(self, loudness) ! end; ! ! hearNoise = function(self, loudness, noiseMaker) ! if (self.controller) then ! self.controller:notifyHearNoise(loadness, noiseMaker) ! end ! end; ! ! ! defaultproperties = { ! -- The Controller possessing this Pawn ! controller = nil, ! ! maxHealth = 100, ! speed = 3, ! offset_y = -6, ! draw_mode = DM_ALPHA, ! obstacle = 1, ! ! controllerClass = nil, ! }; ! } --- 1,167 ---- ! -- ! -- A base class for anything that walks like a character ! -- By Bjorn Lindeijer ! ! import("Actor.lua") ! import("BloodSplat.lua") ! ! ! Pawn = Actor:subclass ! { ! name = "Pawn"; ! ! init = function(self) ! self.health = self.maxHealth ! ! -- Create the default controller, if present ! if (not self.controller and self.controllerClass) then ! self.controller = self.controllerClass() ! self.controller:possess(self) ! end ! ! Actor.init(self) ! end; ! ! tick = function(self) ! Actor.tick(self) ! if (self.controller) then ! self.controller:tick() ! end ! end; ! ! ! ! --== BEING POSSESSED ==-- ! ! possessedBy = function(self, controller) ! self.controller = controller ! end; ! ! unPossessed = function(self) ! self.controller = nil ! end; ! ! ! --== TAKING DAMAGE ==-- ! ! takeDamage = function(self, damage, instigator, damageType, momentum, location) ! self:log("takes "..damage.." damage") ! if (damage > 0) then ! local actualDamage = damage ! self.health = self.health - actualDamage ! ! -- Some blood flying around maybe? ! if (not self.bDead and self.hitEffectClass) then ! local obj = self:spawn(self.hitEffectClass, self.x, self.y) ! obj.offset_z = obj.offset_z + self.hitEffectHeight ! end ! ! -- A scream perhaps? ! if (table.getn(self.hitSounds) > 0) then ! local sampleFile = self.hitSounds[math.random(table.getn(self.hitSounds))] ! m_play_sample(sampleFile) ! end ! ! if (self.health <= 0 and not self.bDead) then ! -- Pawn died ! self:died(instigator, damageType, location) ! elseif (self.controller) then ! self.controller:notifyTakeDamage(actualDamage, instigator, damageType, momentum, location); ! end ! ! self:makeNoise(15) ! end ! end; ! ! died = function(self, killer, damageType, location) ! self.bDead = true ! -- Become bleeding body and fade away (implement in subclass) ! end; ! ! ! --== MOVING ==-- ! ! walk = function(self, dir, no_collision) ! if (self.walking == 0) then ! if (no_collision) then ! m_walk_obj_nocol(self, dir) ! else ! m_walk_obj(self, dir) ! end ! if (self.walking ~= 0) then ! self:makeNoise(10) ! end ! end ! end; ! ! -- Ask this pawn to move away, he'll move away if possible ! moveAway = function(self) ! if (not self.bSleeping and self.walking == 0) then ! local dir = self:randomFreeTileAround() ! if (dir) then ! self:walk(dir) ! end ! end ! end; ! ! ! attack = function(self) ! -- Implement in subclass ! end; ! ! -- Making noise will cause surrounding Pawns to hear the noise with ! -- hearedLoudness = max(0.1, min(loudness, loudness / (distanceInTiles ^ 2))) ! makeNoise = function(self, loudness) ! m_make_noise(self, loudness) ! end; ! ! hearNoise = function(self, loudness, noiseMaker) ! --self:log("Heared noise with loudness "..loudness.." from "..noiseMaker:toString()) ! if (self.controller) then ! self.controller:notifyHearNoise(loudness, noiseMaker) ! end ! end; ! ! -- This actor bumps into an obstacle ! event_bump_into = function(self, obj) ! if (self.controller) then ! self.controller:notifyBumpInto(obj) ! end ! end; ! ! -- Another actor bumps into this actor ! event_bumped_into = function(self, obj) ! if (self.controller) then ! self.controller:notifyBumpedInto(obj) ! end ! end; ! ! -- This actor finishes its current walking step ! event_walk_finished = function(self) ! if (self.controller) then ! self.controller:notifyWalkFinished(obj) ! end ! end; ! ! ! defaultproperties = { ! bSleeping = false, ! bDead = false, ! ! -- The Controller possessing this Pawn ! controller = nil, ! ! maxHealth = 100, ! speed = 3, ! --offset_y = -6, ! draw_mode = DM_ALPHA, ! obstacle = 1, ! bCenterBitmap = true, ! ! hitSounds = {}, ! hitEffectClass = BloodSplat, ! hitEffectHeight = 24, ! controllerClass = nil, ! bCenterOnTile = true, ! }; ! } |
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv27411 Modified Files: AIController.lua Character.lua Added Files: AdvAIRandom.lua BloodSplat.lua CameraTarget.lua Canvas.lua Crocodile.lua Log Message: Scripts stuff, we'll get there. --- NEW FILE: AdvAIRandom.lua --- -- An controller which makes its Pawn walk around randomly, scared, aggressive, neutral or moody... -- -- Bodged by Hedde Bosman import("Controller.lua") SCARED = 1 NEUTRAL = 2 AGGRESSIVE = 3 MOODY = 4 AdvAIRandom = Controller:subclass { name = "AdvAIRandom"; init = function(self) self.waitTime = math.random(100) + 10 end; -- == depending on this nature choose a target (to be scared of) ==- setTargetWithNature = function(self, nature, target) if ((nature == NEUTRAL) or (nature == AGGRESSIVE)) then self.target = target; self.scaring = nil; elseif (nature == SCARED) then self.target = nil; self.scaring = target; elseif (nature == MOODY) then self:setTargetWithNature(self.nature_tmp, target) else self:log("What am i? Who am i? How did i get here? What's that i'm hearing? Hmmm lets call it wind...") end; end; -- == -- == notifiers == -- == -- -- notifyBumpInto = function(self, obj) -- Pause for some time and choose another direction if (self.pawn.bAttacking == false) then self.waitTime = math.random(100) + 10 end end; notifyWalkFinished = function(self) if (self.distanceToWalk <= 0 and self.pawn.bAttacking == false) then -- Reached his goal, pause and choose new goal. if (self.target or self.scaring) then -- korte wachttijd, anders staat ie na elke tile even (te lang) stil self.waitTime = math.random(4) + 1 else self.waitTime = math.random(100) + 2 end; else -- Walking to goal, keep walking. self.distanceToWalk = self.distanceToWalk - 1 self.pawn:walk(self.pawn.dir) end; end; -- == do shizzle depending on nature, and possibly mood == -- notifyHearNoise = function(self, loudness, noiseMaker) if (self.pawn:distanceTo(noiseMaker) < 8) then self.pawn.tick_time = 1; end; if (self.pawn:distanceTo(noiseMaker) >= 8) then self.pawn.tick_time = 150; end; if (noiseMaker and noiseMaker:instanceOf(Player)) then if (self.pawn.nature ~= NEUTRAL) then self:setTargetWithNature(self.pawn.nature, noiseMaker) end; end; end; notifyTakeDamage = function(self, damage, instigator, damageType, momentum, location) if (instigator and instigator:instanceOf(Player)) then self:setTargetWithNature(self.pawn.nature, instigator); end; end; -- check if we can go in 'dir'-ection ... if not, choose any other, but not 'notdir' goingDirection = function(self, dir, notdir) local dirs = self.pawn:freeTilesAround() for v in dirs do if (v == dir) then return dir end; end; for v in dirs do if (v ~= notdir) then return v; end; end; return dir end; -- timebom tick = function(self) if (self.pawn.bDead) then return end if (self.pawn.charging > 0) then self.pawn.charging = self.pawn.charging - 1 end if (self.waitTime > 0) then self.waitTime = self.waitTime - 1; if (self.pawn.nature == MOODY) then -- this one is shifting moods... do new mood, and state how long it has that mood self.moodTime = self.moodTime -1 if (self.moodTime <= 0) then self.target = nil self.scaring = nil self.moodTime = 500 + math.random(1000) self.nature_tmp = math.random(3) end; end; if (self.waitTime <= 0 and self.pawn.bAttacking == false) then -- Check for targets and their distances if (self.target) then playerDist = self.pawn:distanceTo(self.target) elseif (self.scaring) then -- bangmakerij playerDist = self.pawn:distanceTo(self.scaring) else playerDist = 100 end; if (playerDist == 1 and self.target) then self.pawn.dir = self.pawn:directionTo(self.target) self.pawn:attack() self.waitTime = self.pawn.attackTime + self.pawn.chargeTime + 10 else if (self.target or self.scaring) then -- direct loopafstand bij vijand of bangmaker self.distanceToWalk = 0 else -- anders random loopafstand self.distanceToWalk = -1 + math.random(3) end; if (self.target and playerDist < 5) then -- hot persuit mode self.pawn.dir = self:goingDirection(self.pawn:directionTo(self.target), nil); elseif (self.scaring and playerDist < 15) then -- scared; will run in opposit direction local tmpdir = self.pawn:directionTo(self.scaring) self.pawn.dir = self:goingDirection(self:reverseDirection(tmpdir), tmpdir); else -- walk around self.scaring = nil; self.target = nil; self.pawn.dir = self.pawn:randomFreeTileAround() end; self.pawn:walk(self.pawn.dir) end; end end; end; defaultproperties = { tick_time = 0, waitTime = 20, distanceToWalk = 0, nature = NEUTRAL, nature_tmp = NEUTRAL, moodTime = 500, target = nil, scaring = nil, }; } --- NEW FILE: BloodSplat.lua --- -- -- Some bloody splats -- BloodSplat = Actor:subclass { name = "BloodSplat"; init = function(self) self:playAnim(LinearAnimation(self.animSeq)) end; animEnd = function(self) self:destroy() end; defaultproperties = { animSeq = extr_array(m_get_bitmap("blood_splat.bmp"), 16, 16), tick_time = 7, bCenterBitmap = true, } } BloodSplatGreen = BloodSplat:subclass { name = "BloodSplatGreen"; defaultproperties = { animSeq = extr_array(m_get_bitmap("blood_splat_green.bmp"), 16, 16), } } BloodSplatYellow = BloodSplat:subclass { name = "BloodSplatGreen"; defaultproperties = { animSeq = extr_array(m_get_bitmap("blood_splat_yellow.bmp"), 16, 16), } } --- NEW FILE: CameraTarget.lua --- import("Object.lua") CameraTarget = Object:subclass { name = "CameraTarget"; setTarget = function(self, target, tween) if (tween == nil) then tween = true end if (not self.target or self.target.map ~= target.map or not tween) then self.fromX = target.x self.fromY = target.y self.x = target.x self.y = target.y self.progress = 100 else self.fromX = self.x self.fromY = self.y end self.target = target self.map = self.target.map self.progress = 0 end; tick = function(self) if (self.progress < 100) then self.progress = self.progress + 2 end end; preRender = function(self) self.map = self.target.map if (self.progress < 100) then local p = math.sin((self.progress / 100) * 0.5 * math.pi) self.x = self.fromX + (self.target.x - self.fromX) * p self.y = self.fromY + (self.target.y - self.fromY) * p else self.x = self.target.x self.y = self.target.y end end; defaultproperties = { x = 0, y = 0, map = nil, target = nil, travel = 1, tweenAction = nil, progress = 0, }; } --- NEW FILE: Canvas.lua --- -- -- A helper class to draw the HUD on. -- import("Object.lua") Canvas = Object:subclass { name = "Canvas"; drawBitmap = function(self, bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) m_draw_bitmap(bitmap, dest_w, dest_h, src_x, src_y, src_w, src_h) end; drawPattern = function(self, bitmap, dest_w, dest_h, org_x, org_y, scale) if (scale) then local cur_x, cur_y = m_get_cursor() m_draw_bitmap(bitmap, dest_w, dest_h, (cur_x - org_x) / scale, (cur_y - org_y) / scale, dest_w / scale, dest_h / scale) elseif (org_x and org_y) then local cur_x, cur_y = m_get_cursor() m_draw_bitmap(bitmap, dest_w, dest_h, cur_x - org_x, cur_y - org_y, dest_w, dest_h) else m_draw_bitmap(bitmap, dest_w, dest_h, 0, 0, dest_w, dest_h) end end; drawIcon = function(self, bitmap, scale) local bitmap_w, bitmap_h = m_bitmap_size(bitmap) if (not scale or scale == 1) then m_draw_bitmap(bitmap, bitmap_w, bitmap_h, 0, 0, bitmap_w, bitmap_h) else m_draw_bitmap(bitmap, bitmap_w * scale, bitmap_h * scale, 0, 0, bitmap_w, bitmap_h) end end; drawRect = function(self, bitmap, rect_x, rect_y) local bitmap_w, bitmap_h = m_bitmap_size(bitmap) m_draw_bitmap(bitmap, rect_x, rect_y, 0, 0, bitmap_w, bitmap_h) end; moveCursor = function(self, dx, dy) local x, y = self:getCursor() self:setCursor(x + dx, y + dy) end; setCursor = function(self, x, y) m_set_cursor(x, y) end; getCursor = function(self) return m_get_cursor() end; setAlpha = function(self, alpha) return m_set_alpha(alpha) end; setDrawMode = function(self, drawMode) m_set_drawmode(drawMode) end; } --- NEW FILE: Crocodile.lua --- -- -- A Crocodile. -- -- Temporarily blindly copied from Hedde Bosman's rat by Georg Muntingh! import("Player.lua") import("AdvAIRandom.lua") import("Enemy.lua") Crocodile = Enemy:subclass { name = "Crocodile"; bPlaceable = true; defaultproperties = { attackMinDam = 3, attackMaxDam = 5, maxHealth = 40, speed = 3, experience = 25, offset_y = 6, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("croc.bmp"), 24, 24), deathBitmap = m_get_bitmap("croc_dead.bmp"), nature = AGGRESSIVE, controllerClass = AdvAIRandom, hitEffectHeight = 0, }; } Index: AIController.lua =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/scripts/AIController.lua,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AIController.lua 1 Jun 2003 17:27:24 -0000 1.1 --- AIController.lua 13 Jan 2004 19:15:29 -0000 1.2 *************** *** 1,5 **** -- ! -- Controls the behaviour of a Pawn ! -- By Bjørn Lindeijer import("Controller.lua") --- 1,5 ---- -- ! -- Controls the behaviour of an enemy Pawn ! -- By Bjorn Lindeijer import("Controller.lua") *************** *** 11,40 **** tick = function(self) ! if (self.pawn.charge > 0) then self.pawn.charge = self.pawn.charge - 1 end ! -- Switch to ready from walking ! if (self.pawn.state == AI_WALKING and self.pawn.walking == 0) then ! self.pawn:setState(AI_READY) end ! -- When an AI is ready, it's waiting for something to happen to take action ! if (self.pawn.state == AI_READY) then ! -- Check if player is drawing near ! local playerDist = playerDistance(self.pawn) ! local player = m_get_player() ! if (playerDist < 5 and player.state ~= CHR_DEAD) then -- Chase or attack? ! if (playerDist <= self.pawn.attack_range) then -- Attack on charged ! if (self.pawn.charge == 0 and self.pawn.walking == 0) then ! self.pawn.dir = playerDirection(self.pawn) self.pawn:attack() end else ! self.pawn:walk(playerDirection(self.pawn)) end end end end; } --- 11,58 ---- tick = function(self) ! if (self.pawn.charging > 0) then self.pawn.charging = self.pawn.charging - 1 end ! if (self.target and (self.target.map ~= self.pawn.map or self.target.bDead)) then ! -- Abort target ! self.target = nil end ! -- When my pawn is ready, it's waiting for something to happen to take action ! if (self.pawn.bAttacking == false and self.target) then ! -- Check if target is drawing near ! local targetDist = self.pawn:distanceTo(self.target) ! local targetDir = self.pawn:directionTo(self.target) ! if (targetDist < 5) then -- Chase or attack? ! if (targetDist == 1) then -- Attack on charged ! if (self.pawn.charging == 0 and self.pawn.walking == 0) then ! self.pawn.dir = targetDir self.pawn:attack() end else ! -- TODO: Enhance walking to target algorithm ! if (self.pawn.walking == 0) then ! self.pawn:walk(targetDir) ! end end + elseif (targetDist > 15) then + -- Abort target + self.target = nil end end end; + + notifyHearNoise = function(self, loudness, noiseMaker) + if (noiseMaker:instanceOf(Player) and (not self.target or self.pawn:distanceTo(self.target) > self.pawn:distanceTo(noiseMaker))) then + self.target = noiseMaker + end + end; + + notifyTakeDamage = function(self, damage, instigator, damageType, momentum, location) + if (instigator) then + self.target = instigator + end + end; } Index: Character.lua =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/scripts/Character.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Character.lua 1 Jun 2003 17:27:24 -0000 1.4 --- Character.lua 13 Jan 2004 19:15:29 -0000 1.5 *************** *** 1,57 **** ! -- ! -- A character is a pawn with a specific animation scheme ! -- By Bjørn Lindeijer ! ! import("Pawn.lua") ! ! ! Character = Pawn:subclass ! { ! name = "Character"; ! ! init = function(self, char) ! Pawn.init(self) ! self:updateBitmap() ! end; ! ! updateBitmap = function(self) ! local ani = self.charAnim ! if (ani) then ! if (self.attacking == 1) then ! self.bitmap = ani[self.dir + 1 + 3 * 4] ! else ! if (self.walking == 0 or self.walking < 50) then ! self.bitmap = ani[self.dir + 1] ! else ! self.bitmap = ani[self.dir + 1 + (self.leg_used + 1) * 4] ! end ! end ! end ! end; ! ! event_walk_start = function(self) ! self.leg_used = 1 - self.leg_used ! end; ! ! event_walk_finished = function(self) ! self:updateBitmap() ! end; ! ! event_dir_change = function(self) ! self:updateBitmap() ! end; ! ! tick = function(self) ! Pawn.tick(self) ! self:updateBitmap() ! end; ! ! ! defaultproperties = { ! leg_used = 0, ! tick_time = 1, ! walking = 0, ! charAnim = nil, ! }; ! } ! --- 1,187 ---- ! -- ! -- A character is a pawn with a specific animation scheme ! -- By Bjorn Lindeijer ! ! import("Pawn.lua") ! import("Shadow.lua") ! ! ! Character = Pawn:subclass ! { ! name = "Character"; ! ! init = function(self, char) ! self.inventory = {} ! ! self:updateBitmap() ! ! Pawn.init(self) ! end; ! ! beginPlay = function(self) ! Actor.beginPlay(self) ! ! if (self.shadowClass) then ! self.shadow = self:spawn(self.shadowClass, self.x, self.y) ! end ! end; ! ! updateBitmap = function(self) ! local ani = self.charAnim ! if (ani) then ! if (self.bAttacking) then ! self.bitmap = ani[self.dir + 1 + 3 * 4] ! -- Begin hack for the BBRpg ! elseif (self.bWalkieTalkie) then ! self.bitmap = self.talkieBitmap ! -- End hack for the BBRpg ! else ! if (self.walking == 0 or self.walking < 50) then ! self:setBitmap(ani[self.dir + 1]) ! else ! self:setBitmap(ani[self.dir + 1 + (self.leg_used + 1) * 4]) ! end ! end ! end ! end; ! ! ! event_walk_start = function(self) ! self.leg_used = 1 - self.leg_used ! end; ! ! event_walk_finished = function(self) ! Pawn.event_walk_finished(self) ! self:updateBitmap() ! ! -- Check for snow tiles ! local tile = m_get_tile_at(self.map, self.x - 0.5, self.y - 0.5) ! for k,v in pairs(self.snowTiles) do ! if (v == tile) then ! local snowFeet = self:spawn(SnowFeet) ! snowFeet:setDirection(self.dir) ! break ! end ! end ! end; ! ! event_dir_change = function(self) ! self:updateBitmap() ! end; ! ! tick = function(self) ! Pawn.tick(self) ! if (self.bSleeping and self.health < self.maxHealth) then ! self.health = math.min(self.health + 0.0001 * self.maxHealth, self.maxHealth) ! end ! self:updateBitmap() ! end; ! ! died = function(self, killer, damageType, location) ! Pawn.died(self, killer, damageType, location) ! self.charAnim = nil ! self:setBitmap(self.deathBitmap) ! ! -- There is no shadow after death ! if (self.shadow) then ! self.shadow:destroy() ! self.shadow = nil ! end ! end; ! ! destroyed = function(self) ! -- Set bDead to prevent AI's from chasing destroyed characters ! self.bDead = true ! ! Pawn.destroyed(self) ! ! if (self.shadow) then ! self.shadow:destroy() ! self.shadow = nil ! end ! end; ! ! setMap = function(self, map) ! Pawn.setMap(self, map) ! if (self.shadow) then ! self.shadow:setMap(map) ! end ! end; ! ! addToInventory = function(self, obj) ! -- To be implemented?: Check if there is place in the inventory. ! ! table.insert(self.inventory, obj) ! ! -- Make the object irrelevant on the map (not perfect) ! obj.bitmap = nil ! obj.obstacle = 0 ! obj.bCanActivate = false ! obj.bCarried = true ! end; ! ! -- The loop should probably stop when he finds such an object. ! removeFromInventory = function(self, obj) ! for i,v in ipairs(self.inventory) do ! if (v == obj) then ! table.remove(self.inventory, i) ! end ! end ! end; ! ! hasObject = function(self, obj) ! for k,v in pairs(self.inventory) do ! if (v == obj) then return true end ! end ! end; ! ! hasObjectType = function(self, class) ! for k,v in pairs(self.inventory) do ! if (v:instanceOf(class)) then return true end ! end ! end; ! ! ! defaultproperties = { ! snowTiles = { ! --"tiles_subcity.000", ! "tiles_subcity.001", ! --"tiles_subcity.002", ! "tiles_subcity.012", ! --"tiles_subcity.013", ! --"tiles_subcity.014", ! "tiles_subcity.016", ! "tiles_subcity.017", ! "tiles_subcity.018", ! "tiles_subcity.021", ! --"tiles_subcity.028", ! "tiles_subcity.029", ! "tiles_subcity.030", ! --"tiles_subcity.032", ! "tiles_subcity.033", ! --"tiles_subcity.034", ! "tiles_subcity.037", ! --"tiles_subcity.045", ! --"tiles_subcity.046", ! "tiles_subcity.063", ! "tiles_subcity.079", ! "tiles_subcity.092", ! "tiles_subcity.125", ! "tiles_subcity.144", ! "tiles_subcity.145", ! "tiles_subcity.147", ! "tiles_subcity.161", ! }, ! inventory = nil, ! leg_used = 0, ! tick_time = 1, ! walking = 0, ! charAnim = nil, ! shadow = nil, ! shadowClass = Shadow, ! deathBitmap = nil, ! ! bAttacking = false, ! bWalkieTalkie = false, ! }; ! } |
From: <b_l...@us...> - 2004-01-13 19:11:34
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv25722 Added Files: EnemyGuard.lua Log Message: Added this script. --- NEW FILE: EnemyGuard.lua --- import("Player.lua") EnemyGuard = Enemy:subclass { name = "EnemyGuard"; bPlaceable = true; defaultproperties = { speed = 3, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("cop.bmp"), 23, 40), experience = 0, attackTime = 50, chargeTime = 100, charging = 0, attackMinDam = 0, attackMaxDam = 5, maxHealth = 70, bDead = false, bAttacking = false, deathBitmap = m_get_bitmap("cop_dead.bmp"), }; } EnemyGuard2 = Enemy:subclass { name = "EnemyGuard2"; bPlaceable = true; defaultproperties = { speed = 3, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("cop2.bmp"), 23, 40), experience = 0, attackTime = 50, chargeTime = 100, charging = 0, attackMinDam = 0, attackMaxDam = 5, maxHealth = 70, bDead = false, bAttacking = false, deathBitmap = m_get_bitmap("cop_dead.bmp"), }; } EnemyGuard3 = Enemy:subclass { name = "EnemyGuard3"; bPlaceable = true; defaultproperties = { speed = 3, draw_mode = DM_MASKED, charAnim = extr_char_anim(m_get_bitmap("cop3.bmp"), 23, 40), experience = 0, attackTime = 50, chargeTime = 100, charging = 0, attackMinDam = 0, attackMaxDam = 5, maxHealth = 70, bDead = false, bAttacking = false, deathBitmap = m_get_bitmap("cop3_dead.bmp"), }; } |
From: <b_l...@us...> - 2004-01-13 19:06:51
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv24427 Added Files: Cave1.lua Cave2.lua Cave3.lua CaveAdventure.lua Log Message: Added even more scripts. --- NEW FILE: Cave1.lua --- -- -- The first cave map, with the cave entrance. -- import("Map.lua") Cave1 = Map:subclass { name = "Cave1"; init = function(self) Map.init(self, "data/maps/cave1.map") self:spawn(Spring, 56, 30 + 1) local radio = self:spawn(Radio, 54, 3 + 1) radio.offset_y = radio.offset_y + 15 -- Spider webs self:spawn(SpiderWeb, 44, 3 + 1) self:spawn(SpiderWeb, 51, 17 + 1) self:spawn(SpiderWeb, 32, 49 + 1) self:spawn(SpiderWeb, 2, 68 + 1) self:spawn(SpiderWeb, 21, 6 + 1) self:spawn(SpiderWeb2, 62, 33 + 1) self:spawn(SpiderWeb2, 62, 61 + 1) self:spawn(SpiderWeb2, 10, 23 + 1) self:spawn(SpiderWeb2, 10, 3 + 1) -- Hostile creatures self:spawn(EnemySpider, 9, 7 + 1) self:spawn(EnemyPoisonSpiderQueen, 26, 64 + 1) self:spawn(EnemySpider, 32, 66 + 1) self:spawn(EnemySpider, 53, 58 + 1) self:spawn(EnemySpider, 49, 59 + 1) self:spawn(EnemySpider, 30, 11 + 1) self:spawn(EnemySpider, 27, 15 + 1) self:spawn(EnemySpider, 7, 29 + 1) self:spawn(EnemySpider, 10, 32 + 1) self:spawn(EnemySpider, 46, 21 + 1) self:spawn(EnemyPoisonSpiderQueen, 61, 34 + 1) self:spawn(EnemySpider, 60, 35 + 1) self:spawn(EnemySpider, 49, 42 + 1) self:spawn(EnemySpider, 42, 30 + 1) self:spawn(EnemySpider, 33, 31 + 1) self:spawn(EnemySpider, 45, 40 + 1) self:spawn(EnemySpider, 33, 30 + 1) self:spawn(EnemySpider, 25, 27 + 1) self:spawn(EnemySpider, 25, 18 + 1) self:spawn(EnemySpider, 23, 45 + 1) self:spawn(EnemySpider, 5, 51 + 1) self:spawn(EnemySpider, 9, 31 + 1) self:spawn(EnemySpider, 7, 15 + 1) self:spawn(EnemySpider, 40, 70 + 1) self:spawn(EnemyPoisonSpider, 43, 46 + 1) self:spawn(EnemyPoisonSpiderQueen, 25, 9 + 1) self:spawn(EnemyPoisonSpider, 21, 16 + 1) self:spawn(EnemyPoisonSpider, 8, 35 + 1) self:spawn(EnemyPoisonSpider, 9, 53 + 1) self:spawn(EnemyPoisonSpider, 5, 55 + 1) self:spawn(EnemyPoisonSpider, 51, 61 + 1) self:spawn(EnemyPoisonSpider, 7, 5 + 1) self:spawn(EnemyPoisonSpider, 32, 31 + 1) self:spawn(EnemyPoisonSpider, 22, 19 + 1) self:spawn(EnemyPoisonSpider, 27, 18 + 1) self:spawn(EnemyPoisonSpider, 3, 15 + 1) self:spawn(EnemyPoisonSpider, 4, 17 + 1) self:spawn(EnemyPoisonSpiderQueen, 7, 68 + 1) self:spawn(EnemyPoisonSpider, 49, 68 + 1) self:spawn(EnemyPoisonSpider, 37, 68 + 1) -- Torches self:spawn(Torch, 51, 56 + 1) self:spawn(Torch, 58, 30 + 1) self:spawn(Torch, 53, 22 + 1) self:spawn(Torch, 22, 7 + 1) self:spawn(Torch, 29, 7 + 1) self:spawn(Torch, 20, 16 + 1) self:spawn(Torch, 29, 18 + 1) self:spawn(Torch, 5, 56 + 1) self:spawn(Torch, 29, 63 + 1) -- Flowing waterfall self:spawn(CaveWaterfallExit, 50.5, 3 + 1) -- The tunnel self:spawn(CaveTunnelBottom, 8, 67 + 1) self:spawn(CaveTunnelTop, 8, 59 + 1) for i = 59, 65 do obj = self:spawn(CaveRoof, 8, i + 1) end obj.offset_y = obj.offset_y - 1 -- The bridge self:spawn(CaveBridge1, 45, 68 + 1) self:spawn(CaveBridge2, 45, 68 + 1) -- Pile of rubble self:spawn(CavePile, 16, 32 + 1) -- Pick self:spawn(CavePick, 27, 8 + 1) -- Map transitions obj = self:spawn(Cave1_Naar_Cave2, 0, 7 + 1) obj.h = 4 end; } --- NEW FILE: Cave2.lua --- -- -- The second cave map -- import("Map.lua") Cave2 = Map:subclass { name = "Cave2"; init = function(self) Map.init(self, "data/maps/cave2.map") self:spawn(Spring, 44, 7) self:spawn(Spring, 6, 42) -- Spider webs self:spawn(SpiderWeb, 19, 7) self:spawn(SpiderWeb, 1, 45) self:spawn(SpiderWeb, 30, 49) self:spawn(SpiderWeb, 43, 6) self:spawn(SpiderWeb2, 7, 7) self:spawn(SpiderWeb2, 32, 27) self:spawn(SpiderWeb2, 61, 18) -- Torches self:spawn(Torch, 6, 8) self:spawn(Torch, 9, 17) self:spawn(Torch, 28, 16) self:spawn(Torch, 27, 9) self:spawn(Torch, 23, 46) self:spawn(Torch, 14, 28) self:spawn(Torch, 3, 43) self:spawn(Torch, 25, 61) self:spawn(Torch, 48, 54) self:spawn(Torch, 52, 54) self:spawn(Torch, 59, 31) self:spawn(Torch, 45, 16) -- The (friendly) cavemen caveman1 = self:spawn(Caveman, 24, 4); caveman1.travel = 1; caveman2 = self:spawn(Caveman, 24, 3); caveman2.travel = 1; -- Hostile creatures self:spawn(EnemySpider, 58, 35) self:spawn(EnemySpider, 54, 34) self:spawn(EnemySpider, 41, 32) self:spawn(EnemySpider, 54, 46) self:spawn(EnemySpider, 43, 46) self:spawn(EnemySpider, 12, 59) self:spawn(EnemySpider, 28, 28) self:spawn(EnemySpider, 25, 19) self:spawn(EnemySpider, 24, 16) self:spawn(EnemySpider, 10, 30) self:spawn(EnemySpider, 22, 33) self:spawn(EnemySpider, 55, 22) self:spawn(EnemySpider, 54, 20) self:spawn(EnemySpider, 52, 22) self:spawn(EnemyPoisonSpider, 56, 36) self:spawn(EnemyPoisonSpider, 42, 34) self:spawn(EnemyPoisonSpider, 44, 33) self:spawn(EnemyPoisonSpider, 52, 45) self:spawn(EnemyPoisonSpider, 42, 47) self:spawn(EnemyPoisonSpider, 40, 46) self:spawn(EnemyPoisonSpider, 24, 61) self:spawn(EnemyPoisonSpider, 23, 63) self:spawn(EnemyPoisonSpider, 13, 57) self:spawn(EnemyPoisonSpider, 11, 58) self:spawn(EnemyPoisonSpider, 29, 27) self:spawn(EnemyPoisonSpider, 30, 28) self:spawn(EnemyPoisonSpider, 23, 18) self:spawn(EnemyPoisonSpider, 26, 17) self:spawn(EnemyPoisonSpider, 9, 31) self:spawn(EnemyPoisonSpider, 10, 32) self:spawn(EnemyPoisonSpider, 20, 32) self:spawn(EnemyPoisonSpider, 57, 20) self:spawn(EnemyCaveman, 47, 54); self:spawn(EnemyCaveman, 47, 56); self:spawn(EnemyCaveman, 54, 11); self:spawn(EnemyCaveman, 57, 11); self:spawn(EnemyCaveman, 31, 62); self:spawn(EnemyCaveman, 33, 62); self:spawn(EnemyCaveman, 10, 53); self:spawn(EnemyCaveman, 8, 53); obj = self:spawn(EnemyCaveman, 6, 16); obj.dir = DIR_LEFT self:spawn(EnemyCaveman, 5, 15); obj = self:spawn(EnemyCaveman, 4, 16); obj.dir = DIR_RIGHT -- Tunnel 1 self:spawn(CaveTunnelTop, 32, 57) self:spawn(CaveRoof, 32, 57) self:spawn(CaveRoof, 32, 58) self:spawn(CaveRoof, 32, 59) self:spawn(CaveTunnelBottom, 32, 61) -- Tunnel 2 self:spawn(CaveTunnelTop, 25, 11) self:spawn(CaveRoof, 25, 11) self:spawn(CaveTunnelBottom, 25, 13) -- Tunnel 3 self:spawn(CaveRoof, 24, 0) self:spawn(CaveRoof, 24, 1) self:spawn(CaveRoof, 24, 2) self:spawn(CaveRoof, 24, 3) self:spawn(CaveRoof, 24, 4) self:spawn(CaveTunnelBottom, 24, 6) -- The bridge self:spawn(CaveBridge1, 50, 55) self:spawn(CaveBridge2, 50, 55) -- Falling asleep self:spawn(CaveFallingAsleep, 25, 10) -- Map transitions obj = self:spawn(Cave2_Naar_Cave1, 63, 64) obj.h = 4 end; } --- NEW FILE: Cave3.lua --- -- -- The third cave map, with the boss. -- import("Map.lua") Cave3 = Map:subclass { name = "Cave3"; init = function(self) Map.init(self, "data/maps/cave3.map") self:spawn(Spring, 12, 12) -- Torches self:spawn(Torch, 30, 9) self:spawn(Torch, 40, 9) self:spawn(Torch, 30, 16) self:spawn(Torch, 40, 16) self:spawn(Torch, 8, 34) self:spawn(Torch, 79, 34) self:spawn(Torch, 64, 27) self:spawn(Torch, 95, 27) self:spawn(Torch, 33, 18) self:spawn(Torch, 33, 23) self:spawn(Torch, 33, 28) self:spawn(Torch, 33, 33) self:spawn(Torch, 37, 18) self:spawn(Torch, 37, 23) self:spawn(Torch, 37, 28) self:spawn(Torch, 37, 33) -- Cavemen obj = self:spawn(Caveman, 33, 20) obj.dir = DIR_RIGHT cavem1 = obj obj = self:spawn(Caveman, 33, 25) obj.dir = DIR_RIGHT cavem2 = obj obj = self:spawn(Caveman, 33, 30) obj.dir = DIR_RIGHT cavem3 = obj obj = self:spawn(Caveman, 37, 20) obj.dir = DIR_LEFT cavem4 = obj obj = self:spawn(Caveman, 37, 25) obj.dir = DIR_LEFT cavem5 = obj obj = self:spawn(Caveman, 37, 30) obj.dir = DIR_LEFT cavem6 = obj caveman_guard1 = self:spawn(EnemyCaveman, 80, 27) caveman_guard1.dir = DIR_RIGHT caveman_guard1:setState(AI_WAITING) caveman_guard2 = self:spawn(EnemyCaveman, 84, 27) caveman_guard2.dir = DIR_LEFT caveman_guard2:setState(AI_WAITING) caveman_guard3 = self:spawn(EnemyCaveman, 79, 27) caveman_guard3.dir = DIR_DOWN caveman_guard3:setState(AI_WAITING) caveman_guard4 = self:spawn(EnemyCaveman, 85, 27) caveman_guard4.dir = DIR_DOWN caveman_guard4:setState(AI_WAITING) -- Fences in prison self:spawn(FenceL, 66, 25) self:spawn(Fence1, 67, 25) self:spawn(FenceG2, 68, 25) self:spawn(Fence2, 69, 25) self:spawn(FenceR, 70, 25) self:spawn(FenceL, 73, 25) self:spawn(Fence2, 74, 25) self:spawn(FenceG2, 75, 25) self:spawn(Fence1, 76, 25) self:spawn(FenceR, 77, 25) self:spawn(FenceL, 80, 25) self:spawn(Fence2, 81, 25) self:spawn(FenceG, 82, 25) self:spawn(Fence2, 83, 25) self:spawn(FenceR, 84, 25) self:spawn(FenceL, 87, 25) self:spawn(Fence1, 88, 25) self:spawn(FenceG2, 89, 25) self:spawn(Fence1, 90, 25) self:spawn(FenceR, 91, 25) self:spawn(CaveTunnelTop, 35, 40) static_boss = self:spawn(CaveBoss, 35, 11) self:spawn(CaveNoticeStrong, 68, 34) obj = self:spawn(BossFightTrigger, 35, 12) obj.offset_y = -6 boss_block = self:spawn(BossBlock, 33, 18) end; } --- NEW FILE: CaveAdventure.lua --- import("Game.lua") import("Player.lua") CaveAdventure = Game:subclass { name = "CaveAdventure"; init = function(self) -- Create language object lang = CaveLang() -- WARNING: Bad design, introducing global variable -- Call superfunction Game.init(self) -- Load tile bitmaps m_import_tile_bmp("cave.bmp", 24, 24, 0) -- Load the maps cave1Map = Cave1() cave2Map = Cave2() cave3Map = Cave3() -- Spawn the player if (self.playerClass) then player = cave1Map:spawn(self.playerClass, -1, -1) playerController = PlayerController() playerController:possess(player) self.viewPort.target = player end --camera_handle = m_add_object(0, 0, "CameraHandle") --camera_handle.travel = 1 -- Show startup screen show_main_menu = 1 main_menu_bg = { bm = m_get_bitmap("menu.bmp"), alpha = 0, } main_title = { bm = m_get_bitmap("cave.tga"), y = -50, } main_start = { bm = m_get_bitmap("start.tga"), y = 300, } ActionController:addSequence{ ActionExModeOn(), ActionTweenVariable(main_menu_bg, "alpha", 200, 255), ActionTweenVariable(main_title, "y", 200, 184), ActionTweenVariable(main_start, "y", 100, 220), } -- Define startup sequence self.startupSequence = { ActionFadeOutMap(50), ActionSetVariable(_G, "show_main_menu", nil), ActionSetPosition(player, 50, 5, DIR_DOWN), -- Normal start position in cave 1 --ActionSetPosition(m_get_player(), 25, 15, DIR_UP), -- Just before sequence in cave 2 --ActionSetPosition(m_get_player(), 35, 19, DIR_UP), -- Just before starting boss fight in cave 3 --ActionSetPosition(m_get_player(), 4, 5, DIR_LEFT), -- Near cave 1 exit to cave 2 ActionPlaySong("data/music/Cave.ogg", 100), ActionFadeInMap(100), --ActionConversation(lang:getConv("INTRO")), ActionExModeOff(), ActionShowMapName(m_get_bitmap("cave_title_1.bmp")), } end; event_render = function(self) local width, height = m_screen_size() if (show_main_menu) then m_set_cursor(0,0) m_set_alpha(main_menu_bg.alpha) self.canvas:drawIcon(main_menu_bg.bm) self.canvas:setAlpha(255) m_set_drawmode(DM_ALPHA) self.canvas:setCursor(10, main_title.y); self.canvas:drawIcon(main_title.bm) self.canvas:setCursor(82, main_start.y); self.canvas:drawIcon(main_start.bm) m_set_drawmode(DM_MASKED) end Game.event_render(self) end; event_keypress = function(self, key) if (Game.event_keypress(self, key)) then return true end if (key == "action") then if (show_main_menu and not started) then started = 1 ActionController:addSequence(self.startupSequence) return true end end end; defaultproperties = { playerClass = Player } } |
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv23103 Added Files: AI.lua AIBoss.lua AIRandom.lua GuiBox.lua GuiMenu.lua GuiMenuItem.lua GuiTheme.lua GuiWidget.lua Log Message: Added some more scripts. --- NEW FILE: AI.lua --- -- -- Our 'magnificent' AI implementation -- -- Common states for an AI monster AI_WAITING = 1 AI_WALKING = 2 AI_ATTACK = 3 AI_DEAD = 4 AI_HIT = 5 AI_READY = 6 CommonAI = {} function CommonAI:event_init() self.state = AI_READY self.tick_time = 1 self.charge = 0 self.charge_time = 200 self.attack_time = 50 self.attack_range = 3 self.attack_min_dam = 1 self.attack_max_dam = 3 self.health = 25 self.maxHealth = self.health end function CommonAI:tick() if (self.charge > 0) then self.charge = self.charge - 1 end -- Switch to ready from walking if (self.state == AI_WALKING and self.walking == 0) then self:setState(AI_READY) end -- When an AI is ready, it's waiting for something to happen to take action if (self.state == AI_READY) then -- Check if player is drawing near playerDist = playerDistance(self) local player = m_get_player() if (playerDist < 5 and player.state ~= CHR_DEAD) then -- Chase or attack? if (playerDist <= self.attack_range) then -- Attack on charged if (self.charge == 0 and self.walking == 0) then self:attack(playerDirection(self)) end else self:walk(playerDirection(self)) end end end end function CommonAI:attack(dir) --m_message("AI attacking!"); self.dir = dir self:setState(AI_ATTACK) local player = m_get_player() -- Handle attack (deal damage to player) player:takeDamage(self.attack_min_dam + math.random(self.attack_max_dam - self.attack_min_dam)) -- Spawn the hitting effect (ie. sparks) if (self.attack_object) then self:attack_object(player) end ActionController:addSequence{ ActionWait(self.attack_time), ActionSetState(self, AI_READY), ActionSetVariable(self, "charge", self.charge_time), } end function CommonAI:walk(dir) m_walk_obj(self, dir) self:setState(AI_WALKING) end function CommonAI:setState(state) self.state = state if (self.state == AI_ATTACK) then self.attacking = 1 else self.attacking = 0 end self:update_bitmap() if (self.state == AI_DEAD) then if (self.do_death) then self:do_death() else self.animation = nil ActionController:addSequence({ ActionWait(100), ActionSetVariable(self, "draw_mode", DM_TRANS), ActionTweenVariable(self, "alpha", 200, 0), ActionDestroyObject(self), }) end self.tick_time = 0 end end function CommonAI:take_damage(amount) if (self.state ~= AI_DEAD) then -- Should probably suspend a little when being hit --self:setState(AI_HIT) self.health = self.health - amount -- Spawn the getting hit effect (ie. blood) if (self.do_hit) then self:do_hit() else local obj = m_add_object(self.x, self.y, "BloodSplat") obj.offset_z = obj.offset_z + 12 end if (self.health <= 0) then self:setState(AI_DEAD) local player = m_get_player() player.experience = player.experience + self.experience if (player.experience >= player.nextLevelExperience) then player.endurance = player.endurance + 5 player.nextLevelExperience = 2.5 * player.nextLevelExperience player:derive_attributes() end end end end --- NEW FILE: AIBoss.lua --- -- -- A modified AI implementation for the boss -- -- Common states for the boss BAI_WAITING = 1 -- Initial state, doing nothing (a sequence will have to set it to BAI_READY BAI_WALKING = 2 -- Though the boss just floats BAI_ATTACK = 3 -- Attacking the player BAI_DEAD = 4 -- Dead BAI_HIT = 5 -- Getting hit by the player BAI_READY = 6 -- Basically in a loop to figure out what to do BAI_PHASE = 7 -- Teleporting to a better spot BossAI = {} function BossAI:event_init() --inherit(self, LinearAni) self.state = AI_READY self.tick_time = 1 self.charge = 0 self.charge_time = 200 self.attack_time = 50 self.attack_range = 3 self.attack_min_dam = 1 self.attack_max_dam = 3 self.health = 100 self.maxHealth = self.health self.teleport_interval = 200 self.teleport_countdown = 0 self.teleport_sequence = nil -- The area in which the boss can teleport self.area_min_x = 31 self.area_min_y = 9 self.area_max_x = 39 self.area_max_y = 16 -- Hovering self.offset_z = 0 self.goal_z = 12 self.count_z = 0 -- Shadow self.shadow = m_add_object(self.x, self.y, "BossShadow") self.shadow.offset_z = -24 end function BossAI:event_destroyed() -- Remove shadow m_destroy_object(self.shadow) end function BossAI:tick() -- Hover up if (self.count_z < self.goal_z) then self.count_z = self.count_z + 0.1 end if (self.count_z > self.goal_z) then self.count_z = self.count_z - 0.1 end self.offset_z = self.count_z -- Keep schadow along with me self.shadow.x = self.x self.shadow.y = self.y - 1 self.shadow.offset_x = self.offset_x self.shadow.offset_y = self.offset_y self.shadow.alpha = self.alpha -- Countdown charge if (self.charge > 0) then self.charge = self.charge - 1 end if (self.teleport_countdown > 0) then self.teleport_countdown = self.teleport_countdown - 1 end -- Switch to ready from walking (or, hovering) if (self.state == AI_WALKING and self.walking == 0) then self:setState(AI_READY) end -- When an boss is ready and player not dead, he's not waiting for something to happen to take action if (self.state == AI_READY and player.state ~= CHR_DEAD) then -- Check if player is drawing near (then, when teleport possible: teleport randomly away to a place not player occupied) playerDist = playerDistance(self) local player = m_get_player() if (playerDist < 2) then if (self.teleport_countdown == 0) then -- We can teleport away, so let's do it! -- Pick a math.random spot (TODO: make sure not close or on top of player) local tx = self.area_min_x + math.random(self.area_max_x - self.area_min_x) local ty = self.area_min_y + math.random(self.area_max_y - self.area_min_y) -- Do the teleport sequence self:setState(BAI_PHASE) self.teleport_sequence = ActionController:addSequence({ ActionSetVariable(self, "draw_mode", DM_TRANS), ActionTweenVariable(self, "alpha", 50, 0), ActionSetPosition(self, tx, ty), ActionTweenVariable(self, "alpha", 50, 255), ActionSetVariable(self, "draw_mode", DM_MASKED), ActionSetVariable(self, "teleport_countdown", math.random(self.teleport_interval) + 100), ActionSetState(self, BAI_READY), }) else -- We could try to hover away self:walk(reverseDirection(playerDirection(self))) end else -- Player not close, so let's cast a spell on him! (muhahaha) if (self.charge == 0) then self:attack(playerDirection(self)) else -- Not charged up, hover randomly! self:walk(math.random(4)) end end end end function BossAI:attack(dir) m_message("AI attacking!"); self.dir = dir self:setState(AI_ATTACK) local player = m_get_player() -- Handle attack (deal damage to player) player:takeDamage(self.attack_min_dam + math.random(self.attack_max_dam - self.attack_min_dam)) -- Spawn the hitting effect (ie. sparks) if (self.attack_object) then self:attack_object(player) end ActionController:addSequence{ ActionWait(self.attack_time), ActionSetState(self, AI_READY), ActionSetVariable(self, "charge", self.charge_time), } end function BossAI:walk(dir) m_walk_obj(self, dir) self:setState(AI_WALKING) end function BossAI:update_bitmap() end function BossAI:setState(state) self.state = state if (self.state == AI_ATTACK) then self.attacking = 1 else self.attacking = 0 end self:update_bitmap() if (self.state == AI_DEAD) then -- Get rid of any teleport sequences ActionController:removeSequence(self.teleport_sequence) --self.tick_time = 0 self:do_death() end end function BossAI:take_damage(amount) if (self.state ~= AI_DEAD) then -- Should probably suspend a little when being hit --self:setState(AI_HIT) self.health = self.health - amount -- Spawn the getting hit effect (ie. blood) if (self.do_hit) then self:do_hit() else local obj = m_add_object(self.x, self.y, "BloodSplat") obj.offset_z = obj.offset_z + 12 end if (self.health <= 0) then self:setState(AI_DEAD) end end end --- NEW FILE: AIRandom.lua --- -- An controller which makes its Pawn walk around randomly -- -- By Bjorn Lindeijer import("Controller.lua") AIRandom = Controller:subclass { name = "AIRandom"; init = function(self) self.waitTime = math.random(100) + 10 end; notifyBumpInto = function(self, obj) -- Pause for some time and choose another direction self.waitTime = math.random(100) + 10 end; notifyWalkFinished = function(self) if (self.distanceToWalk <= 0) then -- Reached his goal, pause and choose new goal. self.waitTime = math.random(100) + 10 else -- Walking to goal, keep walking. self.distanceToWalk = self.distanceToWalk - 1 self.pawn:walk(self.pawn.dir) end end; tick = function(self) if (self.waitTime > 0) then self.waitTime = self.waitTime - 1 if (self.waitTime <= 0) then -- Choose new goal and start walking towards it self.distanceToWalk = math.random(4) self.pawn.dir = math.random(4) - 1 self.pawn:walk(self.pawn.dir) end end end; defaultproperties = { distanceToWalk = 0, }; } --- NEW FILE: GuiBox.lua --- -- -- A box used for use around message windows and menus -- By Bjorn Lindeijer import("Object.lua") GuiBox = Object:subclass { name = "GuiBox"; init = function(x, y, w, h) self.x = x or 0 self.y = y or 0 self.w = w or 0 self.h = h or 0 end; draw = function() end; } --- NEW FILE: GuiMenu.lua --- -- By Bjorn Lindeijer import("Interaction.lua") GuiMenu = Interaction:subclass { name = "GuiMenu"; init = function(self) self.menuItems = {} end; addMenuItem = function(self, menuItem) if (not menuItem) then m_message("Warning: addMenuItem called without a menu item!") return end table.insert(self.menuItems, menuItem) menuItem.menu = self -- Adjust menu size self.h = self.h + menuItem:getHeight() + 1 self.w = math.max(self.w, menuItem:getWidth()) end; postRender = function(self, canvas) if (self.bCenter) then local sw, sh = m_screen_size() self.x = (sw - self.w) / 2 self.y = (sh - self.h) / 2 end m_set_font(guiTheme.font) canvas:setDrawMode(DM_TRANS) local curr = 0 for i = 1, table.getn(self.menuItems) do local tw, th = m_text_size(self.menuItems[i].text) m_set_color(0, 0, 0) m_set_cursor(self.x + (self.w - tw) / 2 + 1, self.y + curr + 1 + 1) m_draw_text(self.menuItems[i].text) curr = curr + self.menuItems[i]:getHeight() + 1 end guiTheme:drawBox(self.x - 2, self.y - 2, self.w + 4, self.h + 3) local curr = 0 for i = 1, table.getn(self.menuItems) do if (i == self.selected) then guiTheme:drawBox(self.x, self.y + curr, self.w, self.menuItems[i]:getHeight()) m_set_color(200, 200, 200) else m_set_color(175, 175, 175) end local tw, th = m_text_size(self.menuItems[i].text) m_set_cursor(self.x + (self.w - tw) / 2, self.y + curr + 1) m_draw_text(self.menuItems[i].text) curr = curr + self.menuItems[i]:getHeight() + 1 end end; keyType = function(self, key) if (key == "up") then self.selected = self.selected - 1 if (self.selected == 0) then self.selected = table.getn(self.menuItems) end m_play_sample("bbsfx_hit1.wav") return true elseif (key == "down") then self.selected = self.selected + 1 if (self.selected > table.getn(self.menuItems)) then self.selected = 1 end m_play_sample("bbsfx_hit1.wav") return true elseif (key == "action") then self.menuItems[self.selected].func() m_play_sample("bbsfx_hit1.wav") return true end end; setInteractionMaster = function(self, master) if (self.master and not master) then ActionController:addAction(ActionExModeOff()) elseif (not self.master and master) then ActionController:addAction(ActionExModeOn()) end Interaction.setInteractionMaster(self, master) end; defaultproperties = { menuItems = nil, h = 0, w = 0, x = 0, y = 0, bCenter = true, selected = 1, } } --- NEW FILE: GuiMenuItem.lua --- import("GuiWidget.lua") GuiMenuItem = GuiWidget:subclass { name = "GuiMenuItem"; init = function(self, text, func) self.text = text self.func = func m_set_font(guiTheme.font) self.w, self.h = m_text_size(self.text) self.w = self.w + 4 self.h = self.h + 2 end; setText = function(self, text) self.text = text m_set_font(guiTheme.font) self.w, self.h = m_text_size(self.text) self.w = self.w + 4 self.h = self.h + 2 if (self.menu) then -- Somehow adapt the size of the menu end end; getWidth = function(self) return self.w end; getHeight = function(self) return self.h end; defaultproperties = { text = "", func = nil, w = 0, h = 0, menu = nil, } } --- NEW FILE: GuiTheme.lua --- -- -- The GUI theme -- By Bjorn Lindeijer import("Object.lua") GuiTheme = Object:subclass { name = "GuiTheme"; init = function(self) self.cornerUL = m_create_sub_bitmap(self.bitmap, 1, 0, 2, 2) self.cornerUR = m_create_sub_bitmap(self.bitmap, 3, 0, 2, 2) self.cornerLL = m_create_sub_bitmap(self.bitmap, 1, 2, 2, 2) self.cornerLR = m_create_sub_bitmap(self.bitmap, 3, 2, 2, 2) self.borderU = m_create_sub_bitmap(self.bitmap, 9, 0, 2, 2) self.borderL = m_create_sub_bitmap(self.bitmap, 11, 0, 2, 2) self.borderR = m_create_sub_bitmap(self.bitmap, 11, 2, 2, 2) self.borderD = m_create_sub_bitmap(self.bitmap, 9, 2, 2, 2) self.bg = m_create_sub_bitmap(self.bitmap, 0, 0, 1, 1) self.shadow = m_create_sub_bitmap(self.bitmap, 0, 1, 1, 1) self.shadowUL = m_create_sub_bitmap(self.bitmap, 5, 0, 2, 2) self.shadowUR = m_create_sub_bitmap(self.bitmap, 7, 0, 2, 2) self.shadowLL = m_create_sub_bitmap(self.bitmap, 5, 2, 2, 2) self.shadowLR = m_create_sub_bitmap(self.bitmap, 7, 2, 2, 2) self.canvas = Canvas() end; drawBox = function(self, x, y, w, h) self.canvas:setDrawMode(DM_TRANS) -- Shadow local alpha = m_set_alpha(64) self:drawBoxEx( self.shadow, self.shadowUL, self.shadowUR, self.shadowLL, self.shadowLR, self.shadow, self.shadow, self.shadow, self.shadow, x+2, y+2, w, h ) -- The actual box m_set_alpha(128) self:drawBoxEx( self.bg, self.cornerUL, self.cornerUR, self.cornerLL, self.cornerLR, self.borderU, self.borderL, self.borderR, self.borderD, x, y, w, h ) m_set_alpha(alpha) end; drawLightBox = function(self, x, y, w, h) self.canvas:setDrawMode(DM_TRANS) local alpha = m_set_alpha(128) self:drawBoxEx( self.bg, self.cornerUL, self.cornerUR, self.cornerLL, self.cornerLR, self.borderU, self.borderL, self.borderR, self.borderD, x, y, w, h ) m_set_alpha(alpha) end; getTextColor = function(self) return 170, 170, 170 end; drawBoxEx = function(self, bg, ul, ur, ll, lr, bu, bl, br, bd, x, y, w, h) m_set_cursor(x, y) self.canvas:drawIcon(ul) self.canvas:drawRect(bu, w - (self.borderWidth * 2), self.borderWidth) self.canvas:drawIcon(ur) m_set_cursor(x, y + self.borderWidth) self.canvas:drawRect(bl, self.borderWidth, h - (self.borderWidth * 2)) self.canvas:drawRect(bg, w - (self.borderWidth * 2), h - (self.borderWidth * 2)) self.canvas:drawRect(br, self.borderWidth, h - (self.borderWidth * 2)) m_set_cursor(x, y + h - self.borderWidth) self.canvas:drawIcon(ll) self.canvas:drawRect(bd, w - (self.borderWidth * 2), self.borderWidth) self.canvas:drawIcon(lr) end; defaultproperties = { bitmap = m_get_bitmap("gui_green.bmp"), font = "font_sansserif8.pcx", borderWidth = 2, canvas = nil, }; } --- NEW FILE: GuiWidget.lua --- -- -- The base class for any GUI widget. -- By Bjorn Lindeijer import("Object.lua") GuiWidget = Object:subclass { name = "GuiWidget"; -- Querying the size of the widget getHeight = function(self) return 0 end; getWidth = function(self) return 0 end; getSize = function(self) return self:getWidth(), self:getHeight() end; } |
From: <b_l...@us...> - 2004-01-13 18:58:22
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv21295 Added Files: Effects.lua Log Message: Can I add Effects.lua? --- NEW FILE: Effects.lua --- -- -- Hair raizing sparks, explosions and other effects go in here. :) -- import("Actor.lua") import("AnimationFunctions.lua") -- -- ATTACKS -- function SpawnSparkyHit(x, y, offset_x, offset_y, offset_z) local obj --obj = m_add_object(x, y, "BigSpark"); --obj.offset_x = offset_x --obj.offset_y = offset_y --obj.offset_z = offset_z for i = 1, 10 do obj = m_add_object(x, y, "SmallSpark"); obj.fx = offset_x obj.fy = offset_y obj.fz = offset_z end end -- -- Object used for the effects go below here -- -- A small spark SmallSpark = {} function SmallSpark:event_init() self.bitmap = m_get_bitmap("spark_small.bmp") self.draw_mode = DM_ADD self.tick_time = 1 self.life_time = 50 + math.random(50) self.speed_x = (math.random(1000) / 1000 - 0.5) * 0.5 self.speed_y = (math.random(1000) / 1000 - 0.5) * 0.5 self.speed_z = (math.random(1000) / 1000 - 0.5) * 0.5 self.fx = 0.0 self.fy = 0.0 self.fz = 0.0 end function SmallSpark:tick() self.life_time = self.life_time - 1 self.alpha = math.max(0, math.min(255, 255 * self.life_time / 100)) self.fx = self.fx + self.speed_x self.fy = self.fy + self.speed_y self.fz = self.fz + self.speed_z self.speed_z = self.speed_z - 0.005 self.offset_x = self.fx self.offset_y = self.fy self.offset_z = self.fz --if (self.fz < 0 and self.speed_z < 0) then self.speed_z = -self.speed_z end if (self.life_time < 0) then m_destroy_object(self) end end -- -- A poison projectile -- PoisonProjectile = Actor:subclass { name = "PoisonProjectile"; init = function(self) self:loopAnim(LinearAnimation(self.animSeq)) end; defaultproperties = { draw_mode = DM_MASKED, animSeq = { m_get_bitmap("spit1.bmp"), m_get_bitmap("spit2.bmp"), }, tick_time = 10, }; } |
From: <b_l...@us...> - 2004-01-13 18:57:02
|
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv20863 Removed Files: animations.lua basic_types.lua cave_triggers.lua effects.lua gui.lua Log Message: More old scripts removed. --- animations.lua DELETED --- --- basic_types.lua DELETED --- --- cave_triggers.lua DELETED --- --- effects.lua DELETED --- --- gui.lua DELETED --- |
Update of /cvsroot/moeng/CaveAdventure/data/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv18613 Removed Files: ai.lua ai_boss.lua ai_char.lua boss.lua cave.lua cave_objects.lua caveman.lua conv_box.lua game.lua hud.lua input.lua lang.lua music_control.lua player.lua player_sequences.lua radio.lua rat.lua spring.lua torch.lua z.lua Log Message: Script merging in progress --- ai.lua DELETED --- --- ai_boss.lua DELETED --- --- ai_char.lua DELETED --- --- boss.lua DELETED --- --- cave.lua DELETED --- --- cave_objects.lua DELETED --- --- caveman.lua DELETED --- --- conv_box.lua DELETED --- --- game.lua DELETED --- --- hud.lua DELETED --- --- input.lua DELETED --- --- lang.lua DELETED --- --- music_control.lua DELETED --- --- player.lua DELETED --- --- player_sequences.lua DELETED --- --- radio.lua DELETED --- --- rat.lua DELETED --- --- spring.lua DELETED --- --- torch.lua DELETED --- --- z.lua DELETED --- |
From: <b_l...@us...> - 2004-01-13 18:40:14
|
Update of /cvsroot/moeng/CaveAdventure/src In directory sc8-pr-cvs1:/tmp/cvs-serv16663 Modified Files: sound.cpp Log Message: Do not close when MIDI cannot be found. Index: sound.cpp =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/src/sound.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sound.cpp 13 Jan 2004 17:18:07 -0000 1.1 --- sound.cpp 13 Jan 2004 18:40:10 -0000 1.2 *************** *** 102,106 **** play_looped_midi((MIDI*)found_object->dat, 0, -1); } else { ! console.log(CON_QUIT, CON_ALWAYS, "Could not find MIDI file in datafile (%s)", channels[channel].filename); } } else { --- 102,106 ---- play_looped_midi((MIDI*)found_object->dat, 0, -1); } else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Could not find MIDI file in datafile (%s)\n", channels[channel].filename); } } else { |
From: <b_l...@us...> - 2004-01-13 18:37:26
|
Update of /cvsroot/moeng/CaveAdventure/data/samples In directory sc8-pr-cvs1:/tmp/cvs-serv15883 Added Files: bbsfx_hit1.wav Log Message: Added sample --- NEW FILE: bbsfx_hit1.wav --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/moeng/CaveAdventure/data/bitmaps In directory sc8-pr-cvs1:/tmp/cvs-serv14579 Modified Files: rat.bmp rat_dead.bmp Added Files: almost_pi.bmp bank.bmp bb_startup.bmp bb_title_prison.bmp bed.bmp bed2.bmp bed2.tga bed_brian.bmp bed_elwood.bmp bed_jake.bmp blobshadow.tga boss.bmp car.bmp car2.bmp car2_s.bmp car_cop.bmp car_cop_s.bmp car_s.bmp clock.bmp controlpanel.bmp convergence.bmp cop.bmp cop2.bmp cop3.bmp cop3_dead.bmp cop_dead.bmp count_1.bmp count_2.bmp count_3.bmp count_4.bmp count_5.bmp count_6.bmp croc.bmp croc_dead.bmp crowbar.bmp deur_a.bmp deur_b.bmp door2.bmp door3.bmp door4.bmp dustbin.tga dustbin_snow1.bmp dustbin_snow2.bmp dustbin_snow2b.bmp dustbin_snow3.bmp elec_door.bmp elevator_buttons.bmp engines.bmp fence.bmp fence_h3.bmp fence_h5.bmp fence_h7.bmp fence_v7.bmp fence_v8.bmp flatscreen.bmp gui_white.bmp guitar.bmp jakesplace.tga junk.bmp junk_dead.bmp junk_sleep.bmp keyboard.bmp keyfob.bmp keyfob_inv.bmp ladder.bmp lamppost_e.bmp lamppost_snow_e.bmp lamppost_snow_w.bmp lamppost_w.bmp lee.bmp leesplace.tga lever.bmp map.bmp mess_pile.tga nitrofuel.bmp onderstel.bmp painting.bmp pile_of_paper.bmp pinetree.bmp plant1.bmp prison.tga prisoner1.bmp prisoner2.bmp prisoner3.bmp punk.bmp punk_dead.bmp putdeksel.bmp rat_s.tga restplace.tga rope.bmp sewagedrain.bmp sewer_tube.bmp sewerput.bmp sewers.tga sewers_map.bmp shower.bmp skimasks.bmp snow_feet0.bmp snow_feet1.bmp snow_feet2.bmp snow_feet3.bmp snowflake1.tga snowflake2.tga soap.bmp suburbs.tga table.tga talkie.bmp target.tga theend.tga toilet.bmp turtle.bmp turtle_dead.bmp tv.bmp wall_and_tube.bmp wall_jakes_place.bmp washstand.bmp waterplas.bmp wheel.bmp xmastree.bmp Log Message: Merged in some bitmaps --- NEW FILE: almost_pi.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bank.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bb_startup.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bb_title_prison.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed2.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed_brian.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed_elwood.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bed_jake.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: blobshadow.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: boss.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car2_s.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car_cop.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car_cop_s.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: car_s.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: clock.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: controlpanel.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: convergence.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cop.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cop2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cop3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cop3_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cop_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_1.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_4.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_5.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: count_6.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: croc.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: croc_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: crowbar.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: deur_a.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: deur_b.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: door2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: door3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: door4.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dustbin.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dustbin_snow1.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dustbin_snow2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dustbin_snow2b.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dustbin_snow3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: elec_door.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: elevator_buttons.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: engines.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence_h3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence_h5.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence_h7.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence_v7.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: fence_v8.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: flatscreen.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gui_white.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: guitar.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jakesplace.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: junk.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: junk_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: junk_sleep.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: keyboard.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: keyfob.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: keyfob_inv.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ladder.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lamppost_e.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lamppost_snow_e.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lamppost_snow_w.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lamppost_w.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lee.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: leesplace.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lever.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: map.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mess_pile.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nitrofuel.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: onderstel.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: painting.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pile_of_paper.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pinetree.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: plant1.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: prison.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: prisoner1.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: prisoner2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: prisoner3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: punk.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: punk_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: putdeksel.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rat_s.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: restplace.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rope.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sewagedrain.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sewer_tube.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sewerput.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sewers.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sewers_map.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: shower.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: skimasks.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow_feet0.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow_feet1.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow_feet2.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snow_feet3.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snowflake1.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: snowflake2.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: soap.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: suburbs.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: table.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: talkie.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: target.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: theend.tga --- (This appears to be a binary file; contents omitted.) --- NEW FILE: toilet.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: turtle.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: turtle_dead.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: tv.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wall_and_tube.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wall_jakes_place.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: washstand.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: waterplas.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wheel.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: xmastree.bmp --- (This appears to be a binary file; contents omitted.) Index: rat.bmp =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/bitmaps/rat.bmp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsT1DYYc and /tmp/cvscEoiVf differ Index: rat_dead.bmp =================================================================== RCS file: /cvsroot/moeng/CaveAdventure/data/bitmaps/rat_dead.bmp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsArBIxc and /tmp/cvsGCSwYe differ |
From: <b_l...@us...> - 2004-01-13 18:14:39
|
Update of /cvsroot/moeng/CaveAdventure/data/samples In directory sc8-pr-cvs1:/tmp/cvs-serv10890/samples Log Message: Directory /cvsroot/moeng/CaveAdventure/data/samples added to the repository |
Update of /cvsroot/moeng/CaveAdventure/src/shared In directory sc8-pr-cvs1:/tmp/cvs-serv32087/src/shared Added Files: console.cpp console.h engine.cpp engine.h object.cpp object.h tiled_map.cpp tiled_map.h Log Message: CaveAdventure engine and stuff update (not working yet due to outdated scripts) --- NEW FILE: console.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: console.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: engine.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: engine.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: object.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: object.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: tiled_map.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: tiled_map.h --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/moeng/CaveAdventure/src In directory sc8-pr-cvs1:/tmp/cvs-serv32087/src Added Files: canvas.cpp canvas.h common.h rpg.cpp rpg.h script.cpp script.h sound.cpp sound.h Log Message: CaveAdventure engine and stuff update (not working yet due to outdated scripts) --- NEW FILE: canvas.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: canvas.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: common.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rpg.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rpg.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: script.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: script.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sound.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sound.h --- (This appears to be a binary file; contents omitted.) |
From: <b_l...@us...> - 2004-01-13 17:18:12
|
Update of /cvsroot/moeng/CaveAdventure/src/editor In directory sc8-pr-cvs1:/tmp/cvs-serv32087/src/editor Added Files: agup.cpp agup.h agupitrn.h aphoton.cpp aphoton.h editor.cpp editor.h gui_procs.cpp gui_procs.h main.cpp script.cpp script.h Log Message: CaveAdventure engine and stuff update (not working yet due to outdated scripts) --- NEW FILE: agup.cpp --- /* agup.c * * This file is part of the Allegro GUI Un-uglification Project. * It provides "theming" ability. * * Peter Wang <tj...@us...> */ #include <allegro.h> #include "agup.h" #include "agupitrn.h" static AL_CONST struct agup_theme *theme; int agup_fg_color; int agup_bg_color; void agup_init(AL_CONST struct agup_theme *thm) { if ((theme = thm)) { theme->init(); agup_fg_color = *(theme->fg_color); agup_bg_color = *(theme->bg_color); } } void agup_shutdown(void) { if (theme) { theme->shutdown(); theme = NULL; } } #define MAKE_WRAPPER(wrapper, proc) \ int wrapper(int msg, DIALOG *d, int c) \ { \ return ((theme) && (theme->proc)) ? theme->proc(msg, d, c) : D_O_K; \ } MAKE_WRAPPER(d_agup_box_proc, box_proc); MAKE_WRAPPER(d_agup_shadow_box_proc, shadow_box_proc); MAKE_WRAPPER(d_agup_button_proc, button_proc); MAKE_WRAPPER(d_agup_push_proc, push_proc); MAKE_WRAPPER(d_agup_check_proc, check_proc); MAKE_WRAPPER(d_agup_radio_proc, radio_proc); MAKE_WRAPPER(d_agup_icon_proc, icon_proc); MAKE_WRAPPER(d_agup_edit_proc, edit_proc); MAKE_WRAPPER(d_agup_list_proc, list_proc); MAKE_WRAPPER(d_agup_text_list_proc, text_list_proc); MAKE_WRAPPER(d_agup_textbox_proc, textbox_proc); MAKE_WRAPPER(d_agup_slider_proc, slider_proc); MAKE_WRAPPER(d_agup_menu_proc, menu_proc); MAKE_WRAPPER(d_agup_window_proc, window_proc); --- NEW FILE: agup.h --- /* * This file is part of the Allegro GUI Un-uglification Project. */ #ifndef _agup_included_agup_h #define _agup_included_agup_h struct agup_theme; extern int agup_fg_color; extern int agup_bg_color; void agup_init(AL_CONST struct agup_theme *); void agup_shutdown(void); int d_agup_box_proc(int, DIALOG *, int); int d_agup_shadow_box_proc(int, DIALOG *, int); int d_agup_button_proc(int, DIALOG *, int); int d_agup_push_proc(int, DIALOG *, int); int d_agup_check_proc(int, DIALOG *, int); int d_agup_radio_proc(int, DIALOG *, int); int d_agup_icon_proc(int, DIALOG *, int); int d_agup_edit_proc(int, DIALOG *, int); int d_agup_list_proc(int, DIALOG *, int); int d_agup_text_list_proc(int, DIALOG *, int); int d_agup_textbox_proc(int, DIALOG *, int); int d_agup_slider_proc(int, DIALOG *, int); int d_agup_menu_proc(int, DIALOG *, int); int d_agup_window_proc(int, DIALOG *, int); #endif --- NEW FILE: agupitrn.h --- /* * This file is part of the Allegro GUI Un-uglification Project. */ #ifndef _agup_included_agupitrn_h #define _agup_included_agupitrn_h struct agup_theme { int *fg_color; int *bg_color; void (*init)(void); void (*shutdown)(void); int (*box_proc)(int, DIALOG *, int); int (*shadow_box_proc)(int, DIALOG *, int); int (*button_proc)(int, DIALOG *, int); int (*push_proc)(int, DIALOG *, int); int (*check_proc)(int, DIALOG *, int); int (*radio_proc)(int, DIALOG *, int); int (*icon_proc)(int, DIALOG *, int); int (*edit_proc)(int, DIALOG *, int); int (*list_proc)(int, DIALOG *, int); int (*text_list_proc)(int, DIALOG *, int); int (*textbox_proc)(int, DIALOG *, int); int (*slider_proc)(int, DIALOG *, int); int (*menu_proc)(int, DIALOG *, int); int (*window_proc)(int, DIALOG *, int); }; /* internal Allegro function, don't want aintern.h just for this */ #ifdef __cplusplus extern "C" #endif void _draw_textbox(char *, int *, int, int, int, int, int, int, int, int, int, int, int, int); #endif --- NEW FILE: aphoton.cpp --- /* aphoton.c * * This file is part of the Allegro GUI Un-uglification Project. * It emulates the look of the QNX Photon MicroGUI widget set. * * Eric Botcazou <ebo...@mu...> */ #include <allegro.h> #include "aphoton.h" #include "agupitrn.h" /*----------------------------------------------------------------------*/ /* Recommend fg/bg colors */ /*----------------------------------------------------------------------*/ [...1016 lines suppressed...] aphoton_shutdown, d_aphoton_box_proc, d_aphoton_shadow_box_proc, d_aphoton_button_proc, d_aphoton_push_proc, d_aphoton_check_proc, d_aphoton_radio_proc, d_aphoton_icon_proc, d_aphoton_edit_proc, d_aphoton_list_proc, d_aphoton_text_list_proc, d_aphoton_textbox_proc, d_aphoton_slider_proc, d_aphoton_menu_proc, d_aphoton_window_proc }; AL_CONST struct agup_theme *aphoton_theme = &the_theme; --- NEW FILE: aphoton.h --- /* * This file is part of the Allegro GUI Un-uglification Project. If you * are looking for Photon header files, you are looking in the wrong place. */ #ifndef _agup_included_aphoton_h #define _agup_included_aphoton_h extern int aphoton_fg_color; extern int aphoton_bg_color; void aphoton_init(void); void aphoton_shutdown(void); void photon_scrollbar(BITMAP *bmp, int x, int y, int w, int h, int vert, int pos, int len); void photon_container(BITMAP *bmp, int x, int y, int w, int h); extern int container_black, container_gray1, container_gray2; extern int scrollbar_gray1, scrollbar_gray2; int d_aphoton_box_proc(int, DIALOG *, int); int d_aphoton_shadow_box_proc(int, DIALOG *, int); int d_aphoton_button_proc(int, DIALOG *, int); int d_aphoton_push_proc(int, DIALOG *, int); int d_aphoton_check_proc(int, DIALOG *, int); int d_aphoton_radio_proc(int, DIALOG *, int); int d_aphoton_icon_proc(int, DIALOG *, int); int d_aphoton_edit_proc(int, DIALOG *, int); int d_aphoton_list_proc(int, DIALOG *, int); int d_aphoton_text_list_proc(int, DIALOG *, int); int d_aphoton_textbox_proc(int, DIALOG *, int); int d_aphoton_slider_proc(int, DIALOG *, int); int d_aphoton_menu_proc(int, DIALOG *, int); int d_aphoton_window_proc(int, DIALOG *, int); extern AL_CONST struct agup_theme *aphoton_theme; #endif --- NEW FILE: editor.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: editor.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gui_procs.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gui_procs.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: main.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: script.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: script.h --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/moeng/CaveAdventure In directory sc8-pr-cvs1:/tmp/cvs-serv32087 Added Files: COPYING Makefile.in README configure rpg.cfg Removed Files: COPYING.TXT RPG.cfg readme.txt Log Message: CaveAdventure engine and stuff update (not working yet due to outdated scripts) --- NEW FILE: COPYING --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) 19yy <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. --- NEW FILE: Makefile.in --- # # RPG makefile # # run "make" to compile the RPG and RPG Edit # run "make remake" to recompile everything # run "make clean" to clean up the object files # CC := @cc@ CPPFLAGS := @cppflags@ ENGINE_EXE := @engine_exe@ EDITOR_EXE := @editor_exe@ COMMON_OBJS := $(patsubst %.cpp, %.o, $(wildcard src/shared/*.cpp)) EDITOR_OBJS := $(patsubst %.cpp, %.o, $(wildcard src/editor/*.cpp)) ENGINE_OBJS := $(patsubst %.cpp, %.o, $(wildcard src/*.cpp)) COMMON_LIBS := @libs@ #COMMON_LIBS := -lalleg -llua -llualib ENGINE_LIBS := @libs_engine@ #ENGINE_LIBS := =lalogg -logg -lvorbis -lvorbisfile -lvorbisenc DATA_LUA := $(wildcard data/scripts/*.lua) DATA_BMP := $(wildcard data/bitmaps/*.bmp wildcard data/bitmaps/*.tga) DATA_FONT := $(wildcard data/bitmaps/font_*.*) DATA_MAP := $(wildcard data/maps/*.map) DATA_SAMPS := $(wildcard data/samples/*.wav) DATA_MIDIS := $(wildcard data/music/*.mid) .PHONY: default remake clean default: $(ENGINE_EXE) $(EDITOR_EXE) data.dat remake: clean default clean: rm -f src/*.o src/editor/*.o src/shared/*.o %.o: %.cpp $(CC) $(CPPFLAGS) -c $< -o $@ $(ENGINE_EXE): $(COMMON_OBJS) $(ENGINE_OBJS) $(CC) $(CPPFLAGS) -o $(ENGINE_EXE) $(COMMON_OBJS) $(ENGINE_OBJS) $(ENGINE_LIBS) $(COMMON_LIBS) $(EDITOR_EXE): $(COMMON_OBJS) $(EDITOR_OBJS) $(CC) $(CPPFLAGS) -o $(EDITOR_EXE) $(COMMON_OBJS) $(EDITOR_OBJS) $(COMMON_LIBS) # data.dat updater, vraagt de lijst vernieuwde datafiles op, loopt ze langs, kijkt waar ze bij horen # voegt ze toe aan de bij de groep behorende variabele en update dan de juiste groepen (door te # testen op niet lege variables data.dat: $(DATA_LUA) $(DATA_BMP) $(DATA_FONT) $(DATA_MAP) $(DATA_SAMPS) $(DATA_MIDIS) @list='$?'; \ for file in $$list; do \ if echo "$(DATA_LUA)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DELUAS="$$DELUAS $$file"; \ fi; \ if echo "$(DATA_BMP)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DEBMPS="$$DEBMPS $$file"; \ fi; \ if echo "$(DATA_FONT)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DEFONTS="$$DEFONTS $$file"; \ fi; \ if echo "$(DATA_MAP)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DEMAPS="$$DEMAPS $$file"; \ fi; \ if echo "$(DATA_SAMPS)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DESAMPS="$$DESAMPS $$file"; \ fi; \ if echo "$(DATA_MIDIS)" | grep "$$file" > /dev/null 2>/dev/null ; then \ DEMIDIS="$$DEMIDIS $$file"; \ fi; \ done;\ if test -n "$$DELUAS" ; then dat -a -k -t LUA data.dat $$DELUAS; fi; \ if test -n "$$DEBMPS" ; then dat -a -k -t BMP data.dat $$DEBMPS; fi; \ if test -n "$$DEFONTS" ; then dat -a -k -t FONT data.dat $$DEFONTS; fi; \ if test -n "$$DEMAPS" ; then dat -a -k -t MAP data.dat $$DEMAPS; fi; \ if test -n "$$DESAMPS" ; then dat -a -k -t SAMP data.dat $$DESAMPS; fi; \ if test -n "$$DEMIDIS" ; then dat -a -k -t MIDI data.dat $$DEMIDIS; fi; \ --- NEW FILE: README --- --------------------------------------- Moonlight Productions :: Cave Adventure --------------------------------------- Here is our second small RPG, a Cave Adventure. It's been made for the Spring 2003 MiniRPG compo. After washing down a river, Frode (the main character) fell down a waterfall and just managed to reach out for a branch that was hanging about halfway down. Incidently, swinging towards the rock side, there happens to be an entrance to a cave behind the wall of water. Frode has the choice between either falling drop dead on the rocks below the waterfall or entering the cave to face the perils within. Naturally, in the spirit of bold exploration, he enters the cave... Moonlight Productions (the part that worked on this game): Bjørn Lindeijer (engine, scripts, graphics) Georg Muntingh (maps, scripts, graphics) Frode Lindeijer (graphics) Jasper Muntingh (music) Have fun playing our game, we had great fun in making it! The game can be found on: http://www.rpgdx.net -------- Controls -------- To prevent you from wasting minutes searching for the right keys, we present them to you here. Arrow keys - Move your character Spacebar - Examine / Talk / Use / Activate / Continue dialogue Ctrl - Attack ESC - Open / Close menu ------------------------ The Moonlight RPG engine ------------------------ This RPG uses the Moonlight RPG engine, which is licensed under GPL and will be distributed seperately when it's mature enough. Its current specifications are: - Allegro for graphics, keyboard input and timers - AllegroOGG for OGG file playback - Using the Lua extension language for the scripting - Using object oriented, flexible tile engine - Comes with its own map/tile editor - Allows use of multiple tile bitmaps per map, and the other way around ------------------- Config file options ------------------- In RPG.cfg you can specify if you want to run the RPG fullscreen or windowed. You can also enable vsync there (might look smoother for some users). Further more, if you are running in windowed mode, you might want to enable the double size feature. You can also use this with the fullscreen mode if your videocard doesn't support 320x240 high/truecolor modes. If the game runs choppy, try reducing the colordepth to 16 or 15 bit. ------- History ------- January, -th -:-- (First post-contest release) - Added 24 and 32 bit colordepth support (32 enabled by default) - Added second layer to maps, above the objects - Added music - Added level name when entering level / Added menu system - Added experience/levelup system / Added inventory - Added new enemy type, Spider Queen - Added engine support for custom fonts / Added French translation - Added timestamps to logs - Added character shadows - Added placing objects in the editor - Improved Game Over screen - Improved GUI - Improved engine coordinate system - Improved scripts structure, now Object Oriented / Improved AI - Upgraded Lua from 4.0 to 5.0 - Fixed little bug in linear animations - Fixed color of damage splats on spiders - Now all maps are loaded at startup (remembers killed enemies) - Many more small changes April, 29th 2:00 (First public release) --- NEW FILE: configure --- #!/bin/sh # thanks to Smunt for some tips :) CC=g++ LIBS= LIBS_ENGINE= CPPFLAGS=-Wall # on windows set EXE_EXT to '.exe' EXE_EXT= ENGINE_EXE=rpg EDITOR_EXE=rpgedit SOUND=true LOG=/dev/null LOGERR=/dev/null # deze functie haalt dubbele argumenten uit de paramter # eg. CLEAN a a b c c d # echo $MYRETVAL # a b c d CLEAN () { MYRETVAL="" for arg do MYRETVAL=`echo "$MYRETVAL" | sed -e "s'$arg ''g"`"$arg " done } ###################################################################### # parse command line arguments ###################################################################### DEBUG=false for arg do case "$arg" in --help) echo " --with-libdir=PATH - add this libdir --with-include=PATH - add this includedir --disable-sound - disable sound support --debug - compile with debug code --log - save logs to configure.log configure.err " exit 0 ;; --with-libdir=*) LIBS="$LIBS -L"`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --with-include=*) CPPFLAGS="$CPPFLAGS -I"`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --disable-sound) SOUND=false ;; --debug) echo "Enabling debugging..."; DEBUG=true ;; --log) LOG=configure.log LOGERR=configure.err ;; esac done if $DEBUG ; then CPPFLAGS="$CPPFLAGS -g" else CPPFLAGS="$CPPFLAGS -O2" fi ###################################################################### # compiler check dmv versie opvragen # eerst g++, dan c++ en dan cpp # alle output naar /dev/null ###################################################################### echo -n "Checking for compiler... " echo "$CC --version" >$LOG echo "$CC --version" >$LOGERR if $CC --version >$LOG 2>$LOGERR ; then echo "g++" else CC=c++ echo "$CC --version" >>$LOG echo "$CC --version" >>$LOGERR if $CC --version >>$LOG 2>>$LOGERR ; then echo "c++" else CC=cpp echo "$CC --version" >>$LOG echo "$CC --version" >>$LOGERR if $CC --version >>$LOG 2>>$LOGERR ; then echo "cpp" else echo "*** No c++ compiler" exit 1; fi fi fi ###################################################################### # allegro-config check door versie op te vragen # bestaat deze, dan de LIBS en CPPFLAGS toevoegen ###################################################################### echo -n "Checking for allegro-config... " echo "allegro-config --version" >>$LOG echo "allegro-config --version" >>$LOGERR if allegro-config --version >>$LOG 2>>$LOGERR ; then LIBS="$LIBS `allegro-config --libs`" CPPFLAGS="$CPPFLAGS `allegro-config --cppflags`" echo "yes" else echo "no" echo "*** No allegro-config found. Please add the right directory to PATH or install allegro" echo "using -lalleg instead" LIBS="$LIBS -lalleg" fi echo "LIBS: $LIBS" >>$LOG echo "LIBS: $LIBS" >>$LOGERR ###################################################################### # ff kijken of het ook compiled ###################################################################### echo -n "Checking for allegro... " cat >conftest.cpp <<EOF #include <allegro.h> int main(int argc, char **argv) { allegro_init(); return 0; } END_OF_MAIN() // ^ some ALLEGRO macro EOF echo "$CC $CPPFLAGS conftest.cpp $LIBS -o /dev/null" >>$LOG echo "$CC $CPPFLAGS conftest.cpp $LIBS -o /dev/null" >>$LOGERR if $CC $CPPFLAGS conftest.cpp $LIBS -o /dev/null >>$LOG 2>>$LOGERR ; then echo "yes" else echo "no" echo "*** Allegro not working" exit 1 fi rm -f conftest* ###################################################################### # kijken of we ook kunnen lua scripten ###################################################################### echo -n "Checking for lua... " cat >conftest.cpp <<EOF #include <allegro.h> extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } int main(int argc, char **argv) { lua_State *L = NULL; L = lua_open(); return 0; } END_OF_MAIN() EOF echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null" >>$LOG echo "$CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null" >>$LOGERR if $CC $CPPFLAGS conftest.cpp $LIBS -llua -llualib -o /dev/null >>$LOG 2>>$LOGERR ; then # gelukt LIBS="$LIBS -llua -llualib" echo "yes" else #niet gelukt echo "no" echo "*** Compiling of lua program failed" echo "*** Please install lua. http://www.lua.org" exit 1 fi rm -f conftest* echo "LIBS: $LIBS" >>$LOG echo "LIBS: $LIBS" >>$LOGERR ###################################################################### # sound check ###################################################################### if $SOUND ; then echo -n "Checking for alogg-config... " echo "alogg-config --version" >>$LOG echo "alogg-config --version" >>$LOGERR if alogg-config --version >>$LOG 2>>$LOGERR ; then LIBS_ENGINE="`alogg-config --libs` $LIBS_ENGINE" CPPFLAGS="$CPPFLAGS `alogg-config --cflags` -DENABLE_MUSIC" echo "yes" else echo "no" echo "*** If you want sound install alogg. http://lyrian.free.fr/alogg/" SOUND=false fi fi echo "LIBS: $LIBS" >>$LOG echo "LIBS: $LIBS" >>$LOGERR echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOG echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOGERR # extra alogg check echo -n "Checking for alogg... " cat >conftest.cpp <<EOF #include <allegro.h> #include <alogg/alogg.h> int main(int argc, char **argv) { alogg_init(); return 0; } END_OF_MAIN() EOF echo "$CC $CPPFLAGS conftest.cpp -lalogg -logg -lvorbis -lvorbisfile -lvorbisenc $LIBS $LIBS_ENGINE -o /dev/null" >>$LOG echo "$CC $CPPFLAGS conftest.cpp -lalogg -logg -lvorbis -lvorbisfile -lvorbisenc $LIBS $LIBS_ENGINE -o /dev/null" >>$LOGERR if $CC $CPPFLAGS conftest.cpp -lalogg -logg -lvorbis -lvorbisfile -lvorbisenc $LIBS $LIBS_ENGINE -o /dev/null >>$LOG 2>>$LOGERR ; then # gelukt LIBS_ENGINE="-lalogg -logg -lvorbis -lvorbisfile -lvorbisenc $LIBS_ENGINE" CPPFLAGS="$CPPFLAGS -DENABLE_MUSIC" SOUND=true echo "yes" else #niet gelukt echo "no" echo "*** If you want sound install alogg. http://lyrian.free.fr/alogg/" fi rm -f conftest* echo "LIBS: $LIBS" >>$LOG echo "LIBS: $LIBS" >>$LOGERR echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOG echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOGERR ###################################################################### ###################################################################### ###################################################################### # dat was het voor vandaag, nog even een Makefile schrijven. ###################################################################### CLEAN $CPPFLAGS CPPFLAGS=$MYRETVAL CLEAN $LIBS LIBS=$MYRETVAL echo "LIBS: $LIBS" >>$LOG echo "LIBS: $LIBS" >>$LOGERR CLEAN $LIBS_ENGINE LIBS_ENGINE=$MYRETVAL echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOG echo "LIBS_ENGINE: $LIBS_ENGINE" >>$LOGERR sed "s,@cc@,$CC,; s'@cppflags@'$CPPFLAGS'; s'@libs@'$LIBS'; s'@libs_engine@'$LIBS_ENGINE'; s'@engine_exe@'$ENGINE_EXE'; s'@editor_exe@'$EDITOR_EXE';" Makefile.in > Makefile echo "" echo "Now type 'make' to compile" --- NEW FILE: rpg.cfg --- [Engine] Fullscreen=0 DoubleSize=0 VSync=0 DebugMode=0 DebugVerbose=0 ResolutionWidth=320 ResolutionHeight=240 ColorDepth=32 [Sound] EnableMusic=0 StreamChunkSize=32768 BufferSize=65536 --- COPYING.TXT DELETED --- --- RPG.cfg DELETED --- --- readme.txt DELETED --- |