share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
changeset 8682 158d7b36b18e
parent 8043 da083f8d95e6
child 8692 935960dbc60e
equal deleted inserted replaced
8681:d0fc1dca739c 8682:158d7b36b18e
     1 --------------------------------
     1 --------------------------------
     2 -- HIGHLANDER / HOGS OF WAR
     2 -- HIGHLANDER / HOGS OF WAR
     3 -- version 0.3c
     3 -- version 0.4
     4 -- by mikade
     4 -- by mikade
     5 --------------------------------
     5 --------------------------------
     6 
     6 
     7 -----------
     7 -----------
     8 --0.1
     8 --0.1
    49 
    49 
    50 -- restructured some code
    50 -- restructured some code
    51 -- added napalm (whoops) to list of possible weapons you can get
    51 -- added napalm (whoops) to list of possible weapons you can get
    52 -- hogs no longer recieve airstrike-related weps on border maps
    52 -- hogs no longer recieve airstrike-related weps on border maps
    53 
    53 
    54 HedgewarsScriptLoad("/Scripts/Locale.lua")
    54 -----------
    55 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    55 --0.4
       
    56 -----------
       
    57 -- fix same name/blank weapon transfer bug (issue 541)
       
    58 -- show next hog ammo set in full (issue 312)
       
    59 -- allow mid-kill multi-shot weapon transfers (issue 503)
       
    60 -- allow users to configure hog health
       
    61 -- remove 'switched to' message
       
    62 -- remove some extraeneous code
       
    63 -- add more whitespace
       
    64 -- break everything
       
    65 
       
    66 -------------------------
       
    67 -- ideas for the future
       
    68 -------------------------
       
    69 -- add ice gun, structure
       
    70 -- allow switcher, resurrector
       
    71 -- add abuse
       
    72 -- nerf teleport
       
    73 -- allow more customization
       
    74 -- poison hogs using the default team? :/
       
    75 -- balance weapon distribution across entire team / all teams
       
    76 -- add other inequalities/bonuses like... ???
       
    77 -- some hogs start off with an extra 25 health?
       
    78 -- some hogs start off poisoned?
       
    79 -- some hogs start off with a rope and 2 drills but die after their turn?
       
    80 
       
    81 -------------------------------
       
    82 -- derp, script follows
       
    83 -------------------------------
       
    84 
       
    85 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
    86 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
    56 
    87 
    57 local airWeapons = 	{amAirAttack, amMineStrike, amNapalm, amDrillStrike --[[,amPiano]]}
    88 local airWeapons = 	{amAirAttack, amMineStrike, amNapalm, amDrillStrike --[[,amPiano]]}
    58 
    89 
    59 local atkArray = 	{
    90 local atkArray = 	{
    60 					amBazooka, amBee, amMortar, amDrill, --[[amSnowball,]]
    91 					amBazooka, amBee, amMortar, amDrill, --[[amSnowball,]]
    75 					--[[,amTardis, amResurrector, amSwitch]]
   106 					--[[,amTardis, amResurrector, amSwitch]]
    76 					}
   107 					}
    77 
   108 
    78 local wepArray = 	{}
   109 local wepArray = 	{}
    79 
   110 
    80 local currName
   111 local currHog
    81 local lastName
   112 local lastHog
    82 local started = false
   113 local started = false
    83 local switchStage = 0
   114 local switchStage = 0
    84 
   115 
       
   116 local lastWep = amNothing
       
   117 local shotsFired = 0
       
   118 
       
   119 function CheckForWeaponSwap()
       
   120 	if GetCurAmmoType() ~= lastWep then
       
   121 		shotsFired = 0
       
   122 	end
       
   123 	lastWep = GetCurAmmoType()
       
   124 end
       
   125 
       
   126 function onSlot()
       
   127 	CheckForWeaponSwap()
       
   128 end
       
   129 
       
   130 function onSetWeapon()
       
   131 	CheckForWeaponSwap()
       
   132 end
       
   133 
       
   134 function onHogAttack()
       
   135 	CheckForWeaponSwap()
       
   136 	shotsFired = shotsFired + 1
       
   137 end
       
   138 
    85 function StartingSetUp(gear)
   139 function StartingSetUp(gear)
    86 
   140 
    87 	for i = 1, #wepArray do
   141 	for i = 1, #wepArray do
    88 		setGearValue(gear,wepArray[i],0)
   142 		setGearValue(gear,wepArray[i],0)
    89 	end
   143 	end
    90 
   144 
    91 	setGearValue(gear,amKamikaze,1)
   145 	setGearValue(gear,amKamikaze,100)
       
   146 	setGearValue(gear,amSkip,100)
    92 
   147 
    93 	i = 1 + GetRandom(#atkArray)
   148 	i = 1 + GetRandom(#atkArray)
    94 	setGearValue(gear,atkArray[i],1)
   149 	setGearValue(gear,atkArray[i],1)
    95 
   150 
    96 	i = 1 + GetRandom(#utilArray)
   151 	i = 1 + GetRandom(#utilArray)
    97 	setGearValue(gear,utilArray[i],1)
   152 	setGearValue(gear,utilArray[i],1)
    98 
   153 
    99 	SetHealth(gear, 100)
       
   100 
       
   101 end
   154 end
   102 
   155 
   103 --[[function SaveWeapons(gear)
   156 --[[function SaveWeapons(gear)
   104 
   157 -- er, this has no 0 check so presumably if you use a weapon then when it saves  you wont have it
   105 	-
   158 
   106 	for i = 1, (#wepArray) do
   159 	for i = 1, (#wepArray) do
   107 		setGearValue(gear, wepArray[i], GetAmmoCount(gear, wepArray[i]) )
   160 		setGearValue(gear, wepArray[i], GetAmmoCount(gear, wepArray[i]) )
   108 		 --AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
   161 		 --AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
   109 	end
   162 	end
   110 
   163 
   114 
   167 
   115 	for i = 1, #wepArray do
   168 	for i = 1, #wepArray do
   116 		AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
   169 		AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
   117 	end
   170 	end
   118 
   171 
   119 
   172 end
   120 end
   173 
   121 
   174 -- this is called when a hog dies
   122 
       
   123 function TransferWeps(gear)
   175 function TransferWeps(gear)
   124 
   176 
   125 	if CurrentHedgehog ~= nil then
   177 	if CurrentHedgehog ~= nil then
   126 
   178 
   127 		for i = 1, #wepArray do
   179 		for i = 1, #wepArray do
   128 			val = getGearValue(gear,wepArray[i])
   180 			val = getGearValue(gear,wepArray[i])
   129 			if val ~= 0 then
   181 			if val ~= 0 then
       
   182 
   130 				setGearValue(CurrentHedgehog, wepArray[i], val)
   183 				setGearValue(CurrentHedgehog, wepArray[i], val)
   131 				AddAmmo(CurrentHedgehog, wepArray[i], val)
   184 
       
   185 				-- if you are using multi-shot weapon, gimme one more
       
   186 				if (GetCurAmmoType()  == wepArray[i]) and (shotsFired ~= 0) then
       
   187 					AddAmmo(CurrentHedgehog, wepArray[i], val+1)
       
   188 				-- assign ammo as per normal
       
   189 				else
       
   190 					AddAmmo(CurrentHedgehog, wepArray[i], val)
       
   191 				end
       
   192 
   132 			end
   193 			end
   133 		end
   194 		end
   134 
   195 
   135 	end
   196 	end
   136 
   197 
   137 end
   198 end
   138 
   199 
   139 function onGameInit()
   200 function onGameInit()
   140 	GameFlags = gfInfAttack + gfRandomOrder
   201 	GameFlags = gfInfAttack + gfRandomOrder + gfPerHogAmmo
   141 	HealthCaseProb = 100
   202 	HealthCaseProb = 100
   142 end
   203 end
   143 
   204 
   144 function onGameStart()
   205 function onGameStart()
   145 
       
   146 
   206 
   147 	ShowMission	(
   207 	ShowMission	(
   148 				loc("HIGHLANDER"),
   208 				loc("HIGHLANDER"),
   149 				loc("Not all hogs are born equal."),
   209 				loc("Not all hogs are born equal."),
   150 
   210 
   154 				"- " .. loc("Unlimited Attacks") .. "|" ..
   214 				"- " .. loc("Unlimited Attacks") .. "|" ..
   155 				"", 4, 4000
   215 				"", 4, 4000
   156 				)
   216 				)
   157 
   217 
   158 	if MapHasBorder() == false then
   218 	if MapHasBorder() == false then
   159         for i, w in pairs(airWeapons) do
   219        	for i, w in pairs(airWeapons) do
   160             table.insert(atkArray, w)
   220             table.insert(atkArray, w)
   161         end
   221         end
   162     end
   222 	end
   163 
   223 
   164 	for i, w in pairs(atkArray) do
   224 	for i, w in pairs(atkArray) do
   165         table.insert(wepArray, w)
   225         table.insert(wepArray, w)
   166 	end
   226 	end
   167 
   227 
   168 	for i, w in pairs(utilArray) do
   228 	for i, w in pairs(utilArray) do
   169         table.insert(wepArray, w)
   229         table.insert(wepArray, w)
   170 	end
   230 	end
   171 
   231 
       
   232 	table.insert(wepArray, amSkip)
       
   233 	table.insert(wepArray, amKamikaze)
       
   234 
   172 	runOnGears(StartingSetUp)
   235 	runOnGears(StartingSetUp)
   173 	runOnGears(ConvertValues)
   236 	runOnGears(ConvertValues)
   174 
   237 
   175 
   238 
   176 end
   239 end
   177 
   240 
   178 --function onNewTurn()
   241 function CheckForHogSwitch()
   179 --
   242 
       
   243 	if (CurrentHedgehog ~= nil) then
       
   244 
       
   245 		currHog = CurrentHedgehog
       
   246 
       
   247 		if currHog ~= lastHog then
       
   248 
       
   249 			-- re-assign ammo to this guy, so that his entire ammo set will
       
   250 			-- be visible during another player's turn
       
   251 			if lastHog ~= nil then
       
   252 				ConvertValues(lastHog)
       
   253 			end
       
   254 
       
   255 			-- give the new hog what he is supposed to have, too
       
   256 			ConvertValues(CurrentHedgehog)
       
   257 
       
   258 		end
       
   259 
       
   260 		lastHog = currHog
       
   261 
       
   262 	end
       
   263 
       
   264 end
       
   265 
       
   266 function onNewTurn()
       
   267 	CheckForHogSwitch()
       
   268 end
       
   269 
       
   270 --function onGameTick20()
       
   271 --CheckForHogSwitch()
       
   272 -- if we use gfPerHogAmmo is this even needed? Err, well, weapons reset, so... yes?
       
   273 -- orrrr, should we rather call the re-assignment of weapons onNewTurn()? probably not because
       
   274 -- then you cant switch hogs... unless we add a thing in onSwitch or whatever
       
   275 -- ye, that is probably better actually, but I'll add that when/if I add switch
   180 --end
   276 --end
   181 
       
   182 
       
   183 function onGameTick20()
       
   184 
       
   185 	if (CurrentHedgehog ~= nil) then
       
   186 
       
   187 		currName = GetHogName(CurrentHedgehog)
       
   188 
       
   189 		if (currName ~= lastName) then
       
   190 			AddCaption(loc("Switched to ") .. currName .. "!")
       
   191 			ConvertValues(CurrentHedgehog)
       
   192 		end
       
   193 
       
   194 		lastName = currName
       
   195 	end
       
   196 
       
   197 end
       
   198 
   277 
   199 --[[function onHogHide(gear)
   278 --[[function onHogHide(gear)
   200 	-- waiting for Henek
   279 	-- waiting for Henek
   201 end
   280 end
   202 
   281 
   224 	end
   303 	end
   225 
   304 
   226 end
   305 end
   227 
   306 
   228 function onAmmoStoreInit()
   307 function onAmmoStoreInit()
   229 	SetAmmo(amSkip, 9, 0, 0, 0)
   308 	-- no, you can't set your own ammo scheme
   230 	SetAmmo(amKamikaze, 9, 0, 0, 0)
   309 end
   231 	--SetAmmo(amSwitch, 9, 0, 0, 0) -------1
   310 
   232 end
       
   233