share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 10292 1c6639b49afc
parent 10289 c3a77ff02a23
child 10847 b68e35d6e376
equal deleted inserted replaced
10291:d9893b1b76a0 10292:1c6639b49afc
    65 -- 0.6
    65 -- 0.6
    66 -------
    66 -------
    67 
    67 
    68 -- remove hogs from racing area as per request
    68 -- remove hogs from racing area as per request
    69 
    69 
       
    70 -------
       
    71 -- 0.7
       
    72 -------
       
    73 
       
    74 -- switch to first available weapon if starting race with no weapon selected
       
    75 
    70 -----------------------------
    76 -----------------------------
    71 -- SCRIPT BEGINS
    77 -- SCRIPT BEGINS
    72 -----------------------------
    78 -----------------------------
    73 
    79 
    74 HedgewarsScriptLoad("/Scripts/Locale.lua")
    80 HedgewarsScriptLoad("/Scripts/Locale.lua")
   572                 else
   578                 else
   573                         ShowMission(loc("RACER"),
   579                         ShowMission(loc("RACER"),
   574                         loc("NOT ENOUGH WAYPOINTS"),
   580                         loc("NOT ENOUGH WAYPOINTS"),
   575                         loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   581                         loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   576                         AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   582                         AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   577             SetWeapon(amAirAttack)
   583                         SetWeapon(amAirAttack)
   578                 end
   584                 end
   579         end
   585         end
   580 
   586 
   581         if gameOver == true then
   587         if gameOver == true then
   582                 gameBegun = false
   588                 gameBegun = false
   594 function onGameTick20()
   600 function onGameTick20()
   595 
   601 
   596         -- airstrike detected, convert this into a potential waypoint spot
   602         -- airstrike detected, convert this into a potential waypoint spot
   597         if cGear ~= nil then
   603         if cGear ~= nil then
   598                 x,y = GetGearPosition(cGear)
   604                 x,y = GetGearPosition(cGear)
   599         if x > -9000 then
   605                 if x > -9000 then
   600             x,y = GetGearTarget(cGear)
   606                         x,y = GetGearTarget(cGear)
   601 
   607 
   602 
   608 
   603             if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
   609                         if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
   604                 AddCaption(loc("Please place the way-point in the open, within the map boundaries."))
   610                                 AddCaption(loc("Please place the way-point in the open, within the map boundaries."))
   605                 PlaySound(sndDenied)
   611                                 PlaySound(sndDenied)
   606             elseif (y > WaterLine-50) then
   612                         elseif (y > WaterLine-50) then
   607                 AddCaption(loc("Please place the way-point further from the waterline."))
   613                                 AddCaption(loc("Please place the way-point further from the waterline."))
   608                 PlaySound(sndDenied)
   614                                 PlaySound(sndDenied)
   609             else
   615                         else
   610                 PlaceWayPoint(x, y)
   616                                 PlaceWayPoint(x, y)
   611                 if wpCount == wpLimit then
   617                                 if wpCount == wpLimit then
   612                     AddCaption(loc("Race complexity limit reached."))
   618                                         AddCaption(loc("Race complexity limit reached."))
   613                     DisableTumbler()
   619                                         DisableTumbler()
   614                 end
   620                                 end
   615             end
   621                         end
   616         else
   622                 else
   617             DeleteGear(cGear)
   623                         DeleteGear(cGear)
   618         end
   624                 end
   619         SetGearPosition(cGear, -10000, 0)
   625         SetGearPosition(cGear, -10000, 0)
   620         end
   626         end
   621 
   627 
   622 
   628 
   623         -- start the player tumbling with a boom once their turn has actually begun
   629         -- start the player tumbling with a boom once their turn has actually begun
   636                                 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   642                                 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
   637                                 FollowGear(CurrentHedgehog)
   643                                 FollowGear(CurrentHedgehog)
   638 
   644 
   639                                 HideMission()
   645                                 HideMission()
   640 
   646 
       
   647                                 -- don't start empty-handed
       
   648                                 if (GetCurAmmoType() == amNothing) then
       
   649                                         SetNextWeapon()
       
   650                                 end
   641                         else
   651                         else
   642                                 -- still in placement mode
   652                                 -- still in placement mode
   643                         end
   653                         end
   644 
   654 
   645                 end
   655                 end
   646         end
   656         end
   647 
       
   648 
   657 
   649 
   658 
   650         -- has the player started his tumbling spree?
   659         -- has the player started his tumbling spree?
   651         if (CurrentHedgehog ~= nil) then
   660         if (CurrentHedgehog ~= nil) then
   652 
   661