share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua
changeset 4551 05c32ee166b6
child 4590 d9fed5a816e9
equal deleted inserted replaced
4550:d300ea498486 4551:05c32ee166b6
       
     1 local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun,
       
     2             amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer,
       
     3             amBaseballBat, amAirAttack, amMineStrike, amTeleport, amMortar, amCake,
       
     4             amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun,
       
     5             amRCPlane, amSniperRifle, amMolotov, amBirdy, amBlowTorch,
       
     6             amGasBomb, amFlamethrower, amSMine, amHammer, amDrillStrike }
       
     7 
       
     8 local lastRound = -1
       
     9 local weapon = 0
       
    10 
       
    11 function onGameInit()
       
    12     GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack + gfPerHogAmmo))
       
    13 end
       
    14 
       
    15 function onAmmoStoreInit()
       
    16     SetAmmo(amSkip, 9, 0, 0, 0)
       
    17 
       
    18     SetAmmo(amParachute, 0, 1, 0, 1)
       
    19     SetAmmo(amGirder, 0, 1, 0, 2)
       
    20     SetAmmo(amSwitch, 0, 1, 0, 1)
       
    21     SetAmmo(amLowGravity, 0, 1, 0, 1)
       
    22     SetAmmo(amExtraDamage, 0, 1, 0, 1)
       
    23     SetAmmo(amInvulnerable, 0, 1, 0, 1)
       
    24     SetAmmo(amExtraTime, 0, 1, 0, 1)
       
    25     SetAmmo(amLaserSight, 0, 1, 0, 1)
       
    26     SetAmmo(amVampiric, 0, 1, 0, 1)
       
    27     SetAmmo(amJetpack, 0, 1, 0, 1)
       
    28     SetAmmo(amPortalGun, 0, 1, 0, 1)
       
    29     SetAmmo(amResurrector, 0, 1, 0, 1)
       
    30 
       
    31     for i, w in pairs(weapons) do
       
    32         SetAmmo(w, 0, 0, 0, 1)
       
    33     end
       
    34 end
       
    35 
       
    36 function onNewTurn()
       
    37     if lastRound ~= TotalRounds then
       
    38         weapon = GetRandom(table.maxn(weapons)) + 1
       
    39         lastRound = TotalRounds
       
    40     end
       
    41     AddAmmo(CurrentHedgehog, weapons[weapon])
       
    42 end