share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
branchhedgeroid
changeset 15515 7030706266df
parent 15138 73d8cc72239e
equal deleted inserted replaced
7861:bc7b6aa5d67a 15515:7030706266df
       
     1 -------------------------------------------
       
     2 -- FRENZY
       
     3 -- a hedgewars mode inspired by Hysteria
       
     4 -------------------------------------------
       
     5 
       
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     7 
       
     8 local cTimer = 0
       
     9 local cn = 0
       
    10 
       
    11 local frenzyAmmos = {
       
    12 	amBazooka,
       
    13 	amGrenade,
       
    14 	amShotgun,
       
    15 	amFirePunch,
       
    16 	amMine,
       
    17 	amMolotov,
       
    18 	amBlowTorch,
       
    19 	amJetpack,
       
    20 	amTeleport,
       
    21 	amLowGravity
       
    22 }
       
    23 
       
    24 function showStartingInfo()
       
    25 
       
    26 	ruleSet = "" ..
       
    27 	loc("RULES:") .. " |" ..
       
    28 	loc("Each turn is only ONE SECOND!") .. "|" ..
       
    29 	loc("Use your ready time to think.")
       
    30 	if INTERFACE ~= "touch" then
       
    31 		ruleSet = ruleSet .. "|" ..
       
    32 		loc("Slot keys save time! (F1-F10 by default)") .. "| |"
       
    33 		for i=1, #frenzyAmmos do
       
    34 			ruleSet = ruleSet .. string.format(loc("Slot %d: %s"), i, GetAmmoName(frenzyAmmos[i])) .. "|"
       
    35 		end
       
    36 	end
       
    37 
       
    38 	ShowMission(loc("FRENZY"),
       
    39                 loc("A frenetic Hedgewars mini-game"),
       
    40                 ruleSet, -amMolotov, 4000)
       
    41 
       
    42 end
       
    43 
       
    44 function onGameInit()
       
    45 
       
    46 	if TurnTime > 8000 then
       
    47 		Ready = 8000
       
    48 	else
       
    49 		Ready = TurnTime
       
    50 	end
       
    51 
       
    52 	TurnTime = 1000
       
    53 
       
    54 	--These are the official settings, but I think I prefer allowing customization in this regard
       
    55 	--MinesNum = 8
       
    56 	--MinesTime = 3000
       
    57 	--MinesDudPercent = 30
       
    58 	--Explosives = 0
       
    59 
       
    60 	--Supposedly official settings
       
    61 	HealthCaseProb = 0
       
    62 	CrateFreq = 0
       
    63 
       
    64 	--Approximation of Official Settings
       
    65 	--SuddenDeathTurns = 10
       
    66 	--WaterRise = 47
       
    67 	--HealthDecrease = 0
       
    68 
       
    69 	for s=1, #frenzyAmmos do
       
    70 		SetAmmoSlot(frenzyAmmos[s], s)
       
    71 	end
       
    72 	SetAmmoSlot(amSkip, 10)
       
    73 end
       
    74 
       
    75 function onGameStart()
       
    76 	showStartingInfo()
       
    77 end
       
    78 
       
    79 function onSlot(sln)
       
    80 	cTimer = 8
       
    81 	cn = sln
       
    82 end
       
    83 
       
    84 function onGameTick()
       
    85 	if cTimer ~= 0 then
       
    86 		cTimer = cTimer -1
       
    87 		if cTimer == 1 then
       
    88 			ChangeWep(cn)
       
    89 			cn = 0
       
    90 			cTimer = 0
       
    91 		end
       
    92 	end
       
    93 end
       
    94 
       
    95 -- Keyboard slot shortcuts
       
    96 function ChangeWep(s)
       
    97 
       
    98 	if s >= 0 and s <= 9 then
       
    99 		SetWeapon(frenzyAmmos[s+1])
       
   100 	end
       
   101 
       
   102 end
       
   103 
       
   104 function onAmmoStoreInit()
       
   105 	-- Add frenzy ammos
       
   106 	for i=1, #frenzyAmmos do
       
   107 		SetAmmo(frenzyAmmos[i], 9, 0, 0, 0)
       
   108 	end
       
   109 	SetAmmo(amSkip, 9, 0, 0, 0)
       
   110 end