share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
changeset 10950 356c8fb7fb56
parent 10946 c6cf08ee999e
child 10959 1225f42f61e2
equal deleted inserted replaced
10948:18343f00c616 10950:356c8fb7fb56
     1 ------------------------------------------
     1 ------------------------------------------
     2 -- TECH RACER v0.6
     2 -- TECH RACER v0.7
     3 -----------------------------------------
     3 -----------------------------------------
     4 
     4 
     5 --------------
     5 --------------
     6 -- TO DO
     6 -- TO DO
     7 --------------
     7 --------------
    45 --------------
    45 --------------
    46 --0.6
    46 --0.6
    47 --------------
    47 --------------
    48 -- move 1 line of code :D (allows loading of HWMAP points to actually work)
    48 -- move 1 line of code :D (allows loading of HWMAP points to actually work)
    49 
    49 
       
    50 --------------
       
    51 --0.7
       
    52 --------------
       
    53 -- allow waypoints to be loaded automatically via TechMaps or HWMAP
       
    54 -- (temporarily?) remove ability to place waypoints manually
       
    55 -- break stuff?
       
    56 
    50 -----------------------------
    57 -----------------------------
    51 -- SCRIPT BEGINS
    58 -- SCRIPT BEGINS
    52 -----------------------------
    59 -----------------------------
    53 
    60 
    54 HedgewarsScriptLoad("/Scripts/Locale.lua")
    61 HedgewarsScriptLoad("/Scripts/Locale.lua")
   200 local wpY = {}
   207 local wpY = {}
   201 local wpCol = {}
   208 local wpCol = {}
   202 local wpActive = {}
   209 local wpActive = {}
   203 local wpRad = 450 --75
   210 local wpRad = 450 --75
   204 local wpCount = 0
   211 local wpCount = 0
   205 local wpLimit = 8
   212 local wpLimit = 20
   206 
   213 
   207 local usedWeapons = {}
   214 local usedWeapons = {}
   208 
   215 
   209 local roundN
   216 local roundN
   210 local lastRound
   217 local lastRound
   574 
   581 
   575 	runOnGears(RemoveGear)
   582 	runOnGears(RemoveGear)
   576 
   583 
   577 end
   584 end
   578 
   585 
       
   586 function CallBob(x,y)
       
   587 	if not racerActive then
       
   588         if wpCount == 0 or wpX[wpCount - 1] ~= x or wpY[wpCount - 1] ~= y then
       
   589 
       
   590             wpX[wpCount] = x
       
   591             wpY[wpCount] = y
       
   592             wpCol[wpCount] = 0xffffffff
       
   593             wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true)
       
   594 
       
   595             SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount])
       
   596 
       
   597             wpCount = wpCount + 1
       
   598 
       
   599             --AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount))
       
   600         end
       
   601     end
       
   602 end
       
   603 
       
   604 
       
   605 
   579 function HandleFreshMapCreation()
   606 function HandleFreshMapCreation()
   580 
   607 
   581 	-- the boom stage, boom girders, reset ammo, and delete other map objects
   608 	-- the boom stage, boom girders, reset ammo, and delete other map objects
   582 	if activationStage == 1 then
   609 	if activationStage == 1 then
   583 
   610 
   592 		-- these are from onParameters()
   619 		-- these are from onParameters()
   593 		if (mapID == nil) or (mapID == 0) then
   620 		if (mapID == nil) or (mapID == 0) then
   594 			LoadMap(2000)
   621 			LoadMap(2000)
   595 		else
   622 		else
   596 			LoadMap(mapID)
   623 			LoadMap(mapID)
       
   624 		end
       
   625 
       
   626 		for i = 0,(wpCount-1) do
       
   627 			DeleteVisualGear(wpCirc[i])
       
   628 		end
       
   629 		wpCount = 0
       
   630 
       
   631 		for i = 1, techCount-1 do
       
   632 			CallBob(techX[i],techY[i])
   597 		end
   633 		end
   598 
   634 
   599 		activationStage = 200
   635 		activationStage = 200
   600 		--runOnHogs(RestoreHog)
   636 		--runOnHogs(RestoreHog)
   601 
   637 
   830 		elseif specialPointsFlag[i] == 127 then
   866 		elseif specialPointsFlag[i] == 127 then
   831 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 3, 4294967295, nil, nil, nil, lfBouncy)
   867 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 3, 4294967295, nil, nil, nil, lfBouncy)
   832 
   868 
   833 		-- Waypoints
   869 		-- Waypoints
   834 		else -- 0 / no value
   870 		else -- 0 / no value
   835 			PlaceWayPoint(specialPointsX[i], specialPointsY[i])
   871 			CallBob(specialPointsX[i], specialPointsY[i])
   836 		end
   872 		end
   837 
   873 
   838 	end
   874 	end
   839 
   875 
   840 end
   876 end
   867                                 "", 4, 4000
   903                                 "", 4, 4000
   868                                 )
   904                                 )
   869 
   905 
   870         TryRepositionHogs()
   906         TryRepositionHogs()
   871 
   907 
   872 end
   908 		activationStage = 2
   873 
   909 		HandleFreshMapCreation()
   874 function PlaceWayPoint(x,y)
   910 
   875     if not racerActive then
   911 end
   876         if wpCount == 0 or wpX[wpCount - 1] ~= x or wpY[wpCount - 1] ~= y then
   912 
   877 
   913 
   878             wpX[wpCount] = x
       
   879             wpY[wpCount] = y
       
   880             wpCol[wpCount] = 0xffffffff
       
   881             wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true)
       
   882 
       
   883             SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount])
       
   884 
       
   885             wpCount = wpCount + 1
       
   886 
       
   887             AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount))
       
   888         end
       
   889     end
       
   890 end
       
   891 
   914 
   892 function onNewTurn()
   915 function onNewTurn()
   893 
   916 
   894         CheckForNewRound()
   917         CheckForNewRound()
   895         TryRepositionHogs()
   918         TryRepositionHogs()
   905 
   928 
   906 
   929 
   907         trackTime = 0
   930         trackTime = 0
   908 
   931 
   909         currCount = 0 -- hopefully this solves problem
   932         currCount = 0 -- hopefully this solves problem
   910         AddAmmo(CurrentHedgehog, amAirAttack, 0)
   933     --    AddAmmo(CurrentHedgehog, amAirAttack, 0)
   911         gTimer = 0
   934         gTimer = 0
   912 
   935 
   913         -- Set the waypoints to unactive on new round
   936         -- Set the waypoints to unactive on new round
   914         for i = 0,(wpCount-1) do
   937         for i = 0,(wpCount-1) do
   915                 wpActive[i] = false
   938                 wpActive[i] = false
   917                 SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
   940                 SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
   918         end
   941         end
   919 
   942 
   920         -- Handle Starting Stage of Game
   943         -- Handle Starting Stage of Game
   921         if (gameOver == false) and (gameBegun == false) then
   944         if (gameOver == false) and (gameBegun == false) then
   922                 if wpCount >= 3 then
   945                -- if wpCount >= 3 then
   923                         gameBegun = true
   946                         gameBegun = true
   924 						--activationStage = 200
   947 						--  --[[activationStage = 200]]
   925                         roundNumber = 0
   948                         roundNumber = 0
   926                         firstClan = GetHogClan(CurrentHedgehog)
   949                         firstClan = GetHogClan(CurrentHedgehog)
   927                         ShowMission(loc("RACER"),
   950                         ShowMission(loc("RACER"),
   928                         loc("GAME BEGUN!!!"),
   951                         loc("GAME BEGUN!!!"),
   929                         loc("Complete the track as fast as you can!"), 2, 4000)
   952                         loc("Complete the track as fast as you can!"), 2, 4000)
   930                 else
   953                 --else
   931                         ShowMission(loc("RACER"),
   954                 --        ShowMission(loc("RACER"),
   932                         loc("NOT ENOUGH WAYPOINTS"),
   955                 --        loc("NOT ENOUGH WAYPOINTS"),
   933                         loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   956                 --        loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   934                         AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   957                 --        AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   935 						SetWeapon(amAirAttack)
   958 				--		SetWeapon(amAirAttack)
   936                 end
   959                -- end
   937         end
   960         end
   938 
   961 
   939         if gameOver == true then
   962         if gameOver == true then
   940                 gameBegun = false
   963                 gameBegun = false
   941                 racerActive = false -- newadd
   964                 racerActive = false -- newadd
   967                 PlaySound(sndDenied)
   990                 PlaySound(sndDenied)
   968             elseif (y > WaterLine-50) then
   991             elseif (y > WaterLine-50) then
   969                 AddCaption(loc("Please place the way-point further from the waterline."))
   992                 AddCaption(loc("Please place the way-point further from the waterline."))
   970                 PlaySound(sndDenied)
   993                 PlaySound(sndDenied)
   971             else
   994             else
   972                 PlaceWayPoint(x, y)
   995                 CallBob(x, y)
   973                 if wpCount == wpLimit then
   996                 if wpCount == wpLimit then
   974                     AddCaption(loc("Race complexity limit reached."))
   997                     AddCaption(loc("Race complexity limit reached."))
   975                     DisableTumbler()
   998                     DisableTumbler()
   976                 end
   999                 end
   977             end
  1000             end