Modding:Tutorial/Recreating Hell's Arena/Source
From DoomRL Wiki
Revision as of 16:52, 8 April 2012 by Game Hunter (Talk | contribs)
--always declare the module_id global core.declare( "arena" , {} ) function arena.OnEnter() core.play_music("rounds_of_hell_part_1") --use some kick-ass music player:play_sound("preparetofight") --skulltag announcer! player.eq.weapon = item.new( "shotgun" ) --give the man a shotty --add 50 shotgun shells to inventory in a single "shell" item local shells = item.new( "shell" ) shells.ammo = 50 player.inv:add( shells ) Level.result(1) --sets up first wave --big announcement stuff ui.msg("A devilish voice announces:") ui.msg("\"Welcome to Hell's Arena, mortal!\"") ui.msg("\"You are either very foolish, or very brave. Either way I like it!\"") ui.msg("\"And so do the crowds!\"") player:play_sound("fight") ui.msg("Suddenly you hear screams everywhere! \"Blood! Blood! BLOOD!\"") ui.msg("The voice booms again, \"Kill all enemies and I shall reward thee!\"") player:play_sound("one") --create the first wave Level.summon("demon",3) --3 demons Level.summon("lostsoul",2) --2 lost souls Level.summon("cacodemon",DIFFICULTY-1) --0/1/2/3/4 cacodemons end function arena.OnKill() --randomized cheers from the crowd local temp = math.random(3) if temp == 1 then ui.msg("The crowds go wild! \"BLOOD! BLOOD!\"") elseif temp == 2 then ui.msg("The crowds cheer! \"Blood! Blood!\"") else ui.msg("The crowds cheer! \"Kill! Kill!\"") end end function arena.OnKillAll() if Level.result() == 1 then --if first wave completes --more talk ui.msg("The voice booms, \"Not bad mortal! For a weakling that you ") ui.msg("are, you show some determination.\""); ui.msg("You hear screams everywhere! \"More Blood! More BLOOD!\"") ui.msg("The voice continues, \"I can now let you go free, or") ui.msg("you may try to complete the challenge!\""); --player can choose to continue local choice = ui.msg_confirm("\"Do you want to continue the fight?\"") if choice then --player chose to continue core.play_music("rounds_of_hell_part_2") --second verse better than first player:play_sound("two") ui.msg("The voice booms, \"I like it! Let the show go on!\"") ui.msg("You hear screams everywhere! \"More Blood! More BLOOD!\"") Level.drop("chaingun") --sweet drop Level.summon("demon",3) --3 demons Level.summon("cacodemon",DIFFICULTY) --1/2/3/4/5 cacodemons --player chose to stop else ui.msg("The voice booms, \"Coward!\" ") ui.msg("You hear screams everywhere! \"Coward! Coward! COWARD!\"") end elseif Level.result() == 2 then --if second wave completes --even more talk ui.msg("The voice booms, \"Impressive mortal! Your determination") ui.msg("to survive makes me excited!\"") ui.msg("You hear screams everywhere! \"More Blood! More BLOOD!\"") ui.msg("\"I can let you go now, and give you a small reward, or") ui.msg("you can choose to fight the final challenge!\"") --player can choose to continue local choice = ui.msg_confirm("\"Do you want to continue the fight?\"") if choice then --player chosen to continue core.play_music("rounds_of_hell_part_3") --strongest music yet player:play_sound("three") ui.msg("The voice booms, \"Excellent! May the fight begin!!!\"") ui.msg("You hear screams everywhere! \"Kill, Kill, KILL!\"") --some more sweet loot Level.drop("shell",4) Level.drop("ammo",4) --spawns are a little more difficulty-dependent if DIFFICULTY <= 2 then --ITYTD and HNTR Level.summon("cacodemon",DIFFICULTY+1) elseif DIFFICULTY == 3 then --HMP Level.summon("knight",2) elseif DIFFICULTY >= 4 then --UV and N! Level.summon("baron",2) end else --player chose to stop ui.msg("The voice booms, \"Too bad, you won't make it far then...!\" ") ui.msg("You hear screams everywhere! \"Boooo...\"") --pointless loot Level.drop("shell",3) Level.drop("lmed") Level.drop("smed") end elseif Level.result() == 3 then --if third wave completes --finally done talking ui.msg("The voice booms, \"Congratulations mortal! A pity you came to") ui.msg("destroy us, for you would make a formidable hell warrior!\"") ui.msg("\"I grant you the title of Hell's Arena Champion!\"") ui.msg("\"And a promise is a promise... search the arena again...\"") --also pointless loot Level.drop("scglobe") Level.drop("barmor") Level.drop("lmed") end --increment level counter each time a wave completes Level.result(Level.result()+1) end function arena.OnExit() ui.msg_enter("The voice laughs, \"Flee mortal, flee! There's no hiding in hell!\"") --takes care of mortem text for "killed by something unknown..." if Level.result() < 4 then arena.result = "fled alive the trials at wave "..Level.result() else arena.result = "completed the trials" end end function arena.OnMortem() local kill = player.killedby --calls kill descriptions from beings if arena.result then kill = arena.result end player:mortem_print( " "..player.name..", level "..player.explevel.." " .." "..klasses[player.klass].name..", "..kill ) --e.g., "Cool Guy, level 1 Marine, fled alive the trials at wave 3" player:mortem_print(" in the Hell Arena...") end function arena.run() Level.name = "Hell Arena" --that IS what it's called Level.name_number = 0 --remove floor # Level.fill("rwall") --immortal border tiles local translation = { ['.'] = "floor", --gray floor [','] = "blood", --red floor (blood) ['#'] = "rwall", --red wall (bloodstone) ['>'] = "stairs" --gray (normal) stairs } --create map cell string (76x18) local map = [[ #######################.............................######################## ###########.....................................................############ #####..................................................................##### ##........................................................................## #..........................................................................# ............................................................................ ..................................,,,,,,.................................... ..,,,.............................,,,,,,,................................... ..,>,............................,,,,,,,,,.................................. ..,,,............................,,,,,,,,................................... ..................................,,,,,,.................................... ............................................................................ ............................................................................ #..........................................................................# ##........................................................................## #####..................................................................##### ###########.....................................................############ #######################.............................######################## ]] --create pillar cell string (6x5) local column = [[ ,..,., ,####. .####, .####. ,..,., ]] --puts map in non-border area Level.place_tile( translation, map, 2, 2 ) --adds random pillars and blood Level.scatter_put( area.new(5,3,68,15), translation, column, "floor",9+math.random(8)) Level.scatter( area.FULL_SHRINKED,"floor","blood",100) --all walls become indestructible Generator.set_permanence(area.FULL) --inserts player Level.player(38,10) end