share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
changeset 10979 a332a60df7ce
parent 10968 d2f9e25d1d79
child 11012 91cc6aef818c
equal deleted inserted replaced
10978:54a49174dbec 10979:a332a60df7ce
    59 -- should (more or less) work "out of the box" now
    59 -- should (more or less) work "out of the box" now
    60 -- generate map previews for level
    60 -- generate map previews for level
    61 -- randomly assign a map in the case of no map param
    61 -- randomly assign a map in the case of no map param
    62 -- no longer allow custom ammosets (ammo should be specified by map so that records can be valid, though we probably still need to completely limit gameflags)
    62 -- no longer allow custom ammosets (ammo should be specified by map so that records can be valid, though we probably still need to completely limit gameflags)
    63 
    63 
       
    64 --------------
       
    65 --0.9
       
    66 --------------
       
    67 -- added variable portal limiter (and effects) from Escape script
       
    68 -- allow variable ufoFuel (nil is default, 2000 is infinite)
       
    69 -- disallow specifying fuel in params (do this in TechMaps or HedgeEditor please)
       
    70 
    64 -----------------------------
    71 -----------------------------
    65 -- SCRIPT BEGINS
    72 -- SCRIPT BEGINS
    66 -----------------------------
    73 -----------------------------
    67 
    74 
    68 HedgewarsScriptLoad("/Scripts/Locale.lua")
    75 HedgewarsScriptLoad("/Scripts/Locale.lua")
   153 				{amSwitch,			"amSwitch",			0}
   160 				{amSwitch,			"amSwitch",			0}
   154 				}
   161 				}
   155 
   162 
   156 local activationStage = 0
   163 local activationStage = 0
   157 local jet = nil
   164 local jet = nil
   158 infUFO = nil
   165 portalDistance = 5000 -- 15
   159 
   166 ufoFuel = 0
   160 local fMod = 1000000 -- 1
   167 local fMod = 1000000 -- 1
   161 local roundLimit = 3
   168 local roundLimit = 3
   162 local roundNumber = 0
   169 local roundNumber = 0
   163 local firstClan = 10
   170 local firstClan = 10
   164 
   171 
   666 
   673 
   667 function onParameters()
   674 function onParameters()
   668 
   675 
   669 	parseParams()
   676 	parseParams()
   670 	mapID = tonumber(params["m"])
   677 	mapID = tonumber(params["m"])
   671 	infUFO = params["ufo"]
   678 
   672 
   679 	--ufoFuel = tonumber(params["ufoFuel"])
   673 	roundLimit = tonumber(params["rounds"])
   680 	roundLimit = tonumber(params["rounds"])
   674 
   681 
   675 	if (roundLimit == 0) or (roundLimit == nil) then
   682 	if (roundLimit == 0) or (roundLimit == nil) then
   676 		roundLimit = 3
   683 		roundLimit = 3
   677 	end
   684 	end
   807 		elseif specialPointsFlag[i] == 97 then
   814 		elseif specialPointsFlag[i] == 97 then
   808 			--PlaceStruc("reflectorshield")
   815 			--PlaceStruc("reflectorshield")
   809 		elseif specialPointsFlag[i] == 98 then
   816 		elseif specialPointsFlag[i] == 98 then
   810 			--PlaceStruc("weaponfilter")]]
   817 			--PlaceStruc("weaponfilter")]]
   811 
   818 
       
   819 		elseif specialPointsFlag[i] == 98 then
       
   820 			portalDistance = specialPointsX[i]
       
   821 			ufoFuel = specialPointsY[i]
       
   822 
   812 		-- Normal Girders
   823 		-- Normal Girders
   813 		elseif specialPointsFlag[i] == 100 then
   824 		elseif specialPointsFlag[i] == 100 then
   814 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 0, 4294967295, nil, nil, nil, lfNormal)
   825 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 0, 4294967295, nil, nil, nil, lfNormal)
   815 		elseif specialPointsFlag[i] == 101 then
   826 		elseif specialPointsFlag[i] == 101 then
   816 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 1, 4294967295, nil, nil, nil, lfNormal)
   827 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 1, 4294967295, nil, nil, nil, lfNormal)
   979 
   990 
   980 end
   991 end
   981 
   992 
   982 function onGameTick20()
   993 function onGameTick20()
   983 
   994 
   984 		if (jet ~= nil) and (infUFO == "true") then
   995 		if (jet ~= nil) and (ufoFuel ~= 0) then
   985 			SetHealth(jet, 2000)
   996 			if ufoFuel == 2000 then
   986 		end
   997 				SetHealth(jet, 2000)
       
   998 			end
       
   999 		end
       
  1000 
       
  1001 		runOnGears(PortalEffects)
   987 
  1002 
   988         -- airstrike detected, convert this into a potential waypoint spot
  1003         -- airstrike detected, convert this into a potential waypoint spot
   989         if cGear ~= nil then
  1004         if cGear ~= nil then
   990                 x,y = GetGearPosition(cGear)
  1005                 x,y = GetGearPosition(cGear)
   991         if x > -9000 then
  1006         if x > -9000 then
  1094 
  1109 
  1095         end
  1110         end
  1096 
  1111 
  1097 end
  1112 end
  1098 
  1113 
       
  1114 -- handle short range portal gun
       
  1115 function PortalEffects(gear)
       
  1116 
       
  1117 	if GetGearType(gear) == gtPortal then
       
  1118 
       
  1119 		tag = GetTag(gear)
       
  1120 		if tag == 0 then
       
  1121 			col = 0xfab02aFF -- orange ball
       
  1122 		elseif tag == 1 then
       
  1123 			col = 0x00FF00FF -- orange portal
       
  1124 		elseif tag == 2 then
       
  1125 			col = 0x364df7FF  -- blue ball
       
  1126 		elseif tag == 3 then
       
  1127 			col = 0xFFFF00FF  -- blue portal
       
  1128 		end
       
  1129 
       
  1130 		if (tag == 0) or (tag == 2) then -- i.e ball form
       
  1131 			tempE = AddVisualGear(GetX(gear), GetY(gear), vgtDust, 0, true)
       
  1132 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1133 			SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, 1, g9, col )
       
  1134 
       
  1135 			remLife = getGearValue(gear,"life")
       
  1136 			remLife = remLife - 1
       
  1137 			setGearValue(gear, "life", remLife)
       
  1138 
       
  1139 			if remLife == 0 then
       
  1140 
       
  1141 				tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, true)
       
  1142 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1143 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  1144 
       
  1145 				tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, true)
       
  1146 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1147 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  1148 
       
  1149 				tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, true)
       
  1150 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1151 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  1152 
       
  1153 				tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, true)
       
  1154 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1155 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  1156 
       
  1157 
       
  1158 				PlaySound(sndVaporize)
       
  1159 				DeleteGear(gear)
       
  1160 
       
  1161 			end
       
  1162 
       
  1163 		end
       
  1164 
       
  1165 	end
       
  1166 
       
  1167 end
       
  1168 
  1099 function onGearResurrect(gear)
  1169 function onGearResurrect(gear)
  1100 
  1170 
  1101         AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1171         AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1102 
  1172 
  1103         if gear == CurrentHedgehog then
  1173         if gear == CurrentHedgehog then
  1110 	if 	(GetGearType(gear) == gtHedgehog) or
  1180 	if 	(GetGearType(gear) == gtHedgehog) or
  1111 		(GetGearType(gear) == gtGrenade) or
  1181 		(GetGearType(gear) == gtGrenade) or
  1112 		(GetGearType(gear) == gtTarget) or
  1182 		(GetGearType(gear) == gtTarget) or
  1113 		(GetGearType(gear) == gtFlame) or
  1183 		(GetGearType(gear) == gtFlame) or
  1114 		(GetGearType(gear) == gtExplosives) or
  1184 		(GetGearType(gear) == gtExplosives) or
       
  1185 		(GetGearType(gear) == gtPortal) or
  1115 		(GetGearType(gear) == gtMine) or
  1186 		(GetGearType(gear) == gtMine) or
  1116 		(GetGearType(gear) == gtSMine) or
  1187 		(GetGearType(gear) == gtSMine) or
  1117 		(GetGearType(gear) == gtAirMine) or
  1188 		(GetGearType(gear) == gtAirMine) or
  1118 		(GetGearType(gear) == gtCase)
  1189 		(GetGearType(gear) == gtCase)
  1119 	then
  1190 	then
  1123 	end
  1194 	end
  1124 end
  1195 end
  1125 
  1196 
  1126 function onGearAdd(gear)
  1197 function onGearAdd(gear)
  1127 
  1198 
  1128         if isATrackedGear(gear) then
  1199        if isATrackedGear(gear) then
  1129 			trackGear(gear)
  1200 		trackGear(gear)
  1130 		end
  1201 
  1131 
  1202 		if GetGearType(gear) == gtPortal then
  1132 		if GetGearType(gear) == gtHedgehog then
  1203 			setGearValue(gear,"life",portalDistance)
  1133                 hhs[numhhs] = gear
  1204 		elseif GetGearType(gear) == gtHedgehog then
  1134                 numhhs = numhhs + 1
  1205             hhs[numhhs] = gear
  1135                 SetEffect(gear, heResurrectable, 1)
  1206             numhhs = numhhs + 1
  1136         end
  1207             SetEffect(gear, heResurrectable, 1)
  1137 
  1208 		end
  1138         if GetGearType(gear) == gtAirAttack then
  1209 
  1139                 cGear = gear
  1210 	end
  1140         elseif GetGearType(gear) == gtJetpack then
  1211 
  1141 			jet = gear
  1212 	if GetGearType(gear) == gtAirAttack then
  1142 		end
  1213        cGear = gear
       
  1214 	elseif GetGearType(gear) == gtJetpack then
       
  1215 		jet = gear
       
  1216 		if (ufoFuel ~= 0) then
       
  1217 			SetHealth(jet, ufoFuel)
       
  1218 		end
       
  1219 	end
       
  1220 
  1143 
  1221 
  1144 end
  1222 end
  1145 
  1223 
  1146 function onGearDelete(gear)
  1224 function onGearDelete(gear)
  1147 
  1225