share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
changeset 14230 8edbdd3a1fe7
parent 13987 2d1df39c8642
child 14324 5da99c43b96f
equal deleted inserted replaced
14229:e590fb0f2567 14230:8edbdd3a1fe7
   450 		end
   450 		end
   451 	end
   451 	end
   452 end
   452 end
   453 
   453 
   454 function SpawnRandomCrate(x,y,strength)
   454 function SpawnRandomCrate(x,y,strength)
   455 	local tot=table.maxn(CS.WEAPONS_SUPPORT)+table.maxn(CS.WEAPONS_DAMAGE)
   455 	local tot=#CS.WEAPONS_SUPPORT + #CS.WEAPONS_DAMAGE
   456 	local rand=GetRandom(tot)+1
   456 	local rand=GetRandom(tot)+1
   457 
   457 
   458 	if(rand>table.maxn(CS.WEAPONS_SUPPORT))
   458 	if(rand > #CS.WEAPONS_SUPPORT)
   459 	then
   459 	then
   460 		local weapon=rand-table.maxn(CS.WEAPONS_SUPPORT)
   460 		local weapon = rand - #CS.WEAPONS_SUPPORT
   461 
   461 
   462 		while(wepNotValidBorder(CS.WEAPONS_DAMAGE[weapon][1])==false)
   462 		while(wepNotValidBorder(CS.WEAPONS_DAMAGE[weapon][1])==false)
   463 		do
   463 		do
   464 			if(weapon>=table.maxn(CS.WEAPONS_DAMAGE))
   464 			if(weapon >= #CS.WEAPONS_DAMAGE)
   465 			then
   465 			then
   466 				weapon=0
   466 				weapon=0
   467 			end
   467 			end
   468 			weapon = weapon+1
   468 			weapon = weapon+1
   469 		end
   469 		end
   580 	local wepout=nil
   580 	local wepout=nil
   581 	local rand_weaponset_power=mypower
   581 	local rand_weaponset_power=mypower
   582 
   582 
   583 	if(rand_weaponset_power < power)
   583 	if(rand_weaponset_power < power)
   584 	then
   584 	then
   585 		local numberofweapons=table.maxn(weptype)
   585 		local numberofweapons = #weptype
   586 
   586 
   587 		local random_weapon = math.abs(GetRandom(numberofweapons)+1)
   587 		local random_weapon = math.abs(GetRandom(numberofweapons)+1)
   588 
   588 
   589 		while((weptype[random_weapon][4]>TotalRounds and getdelayedweps==false) or rand_weaponset_power+weptype[random_weapon][6]>power
   589 		while((weptype[random_weapon][4]>TotalRounds and getdelayedweps==false) or rand_weaponset_power+weptype[random_weapon][6]>power
   590 				or (wepNotValidBorder(weptype[random_weapon][1])==false) or GetAmmoCount(hog,weptype[random_weapon][1])>=100
   590 				or (wepNotValidBorder(weptype[random_weapon][1])==false) or GetAmmoCount(hog,weptype[random_weapon][1])>=100
   907 
   907 
   908 	--default icon
   908 	--default icon
   909 	continentinfo[4]={}
   909 	continentinfo[4]={}
   910 	if(icon==1000)
   910 	if(icon==1000)
   911 	then
   911 	then
   912 		local mid=table.maxn(CS.WEAPONS_DAMAGE)
   912 		local mid = #CS.WEAPONS_DAMAGE
   913 		local max=mid+table.maxn(CS.WEAPONS_SUPPORT)
   913 		local max = mid + #CS.WEAPONS_SUPPORT
   914 		local ic=(string.byte(string) % max)+1
   914 		local ic=(string.byte(string) % max)+1
   915 
   915 
   916 		if(ic>mid)
   916 		if(ic>mid)
   917 		then
   917 		then
   918 			ic=CS.WEAPONS_SUPPORT[ic-mid][1]
   918 			ic=CS.WEAPONS_SUPPORT[ic-mid][1]
  1231 			CS.SELECT_CONTINENT_CHECK=false
  1231 			CS.SELECT_CONTINENT_CHECK=false
  1232 			SetInputMask(bor(GetInputMask(), bnot(gmWeapon)))
  1232 			SetInputMask(bor(GetInputMask(), bnot(gmWeapon)))
  1233 
  1233 
  1234 			if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1234 			if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1235 			then
  1235 			then
  1236 				CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(table.maxn(CS.CONTINENT_INFORMATION))+1
  1236 				CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(#CS.CONTINENT_INFORMATION)+1
  1237 				SetContinentWeapons()
  1237 				SetContinentWeapons()
  1238 			end
  1238 			end
  1239 			local currCont=CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]
  1239 			local currCont=CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]
  1240 			local checkDefCont=CS.CONTINENT_INFORMATION[currCont][4][2]
  1240 			local checkDefCont=CS.CONTINENT_INFORMATION[currCont][4][2]
  1241 
  1241 
  1587 	end
  1587 	end
  1588 	if(GetHogLevel(CurrentHedgehog)==0 and CS.SELECT_CONTINENT_CHECK==true and (GetCurAmmoType() == amSkip or GetCurAmmoType() == amNothing))
  1588 	if(GetHogLevel(CurrentHedgehog)==0 and CS.SELECT_CONTINENT_CHECK==true and (GetCurAmmoType() == amSkip or GetCurAmmoType() == amNothing))
  1589 	then
  1589 	then
  1590 		CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)] + direction
  1590 		CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)] + direction
  1591 
  1591 
  1592 		if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]> table.maxn(CS.CONTINENT_INFORMATION))
  1592 		if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]> #CS.CONTINENT_INFORMATION)
  1593 		then
  1593 		then
  1594 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=1
  1594 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=1
  1595 		end
  1595 		end
  1596 		if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]<=0)
  1596 		if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]<=0)
  1597 		then
  1597 		then
  1598 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=table.maxn(CS.CONTINENT_INFORMATION)
  1598 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)] = #CS.CONTINENT_INFORMATION
  1599 		end
  1599 		end
  1600 		SetContinentWeapons()
  1600 		SetContinentWeapons()
  1601 
  1601 
  1602 		PlaySound(sndSwitchHog)
  1602 		PlaySound(sndSwitchHog)
  1603 	end
  1603 	end
  1685 		CS.SELECT_CONTINENT_CHECK=false
  1685 		CS.SELECT_CONTINENT_CHECK=false
  1686 		EndTurnCS(0)
  1686 		EndTurnCS(0)
  1687 		PlaySound(sndPlaced)
  1687 		PlaySound(sndPlaced)
  1688 		if(CurrentHedgehog and CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1688 		if(CurrentHedgehog and CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1689 		then
  1689 		then
  1690 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(table.maxn(CS.CONTINENT_INFORMATION))+1
  1690 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(#CS.CONTINENT_INFORMATION)+1
  1691 			SetContinentWeapons()
  1691 			SetContinentWeapons()
  1692 			HideMission()
  1692 			HideMission()
  1693 			ShowContinentLabel(0)
  1693 			ShowContinentLabel(0)
  1694 		else
  1694 		else
  1695 			ShowContinentLabel()
  1695 			ShowContinentLabel()
  1706 	--if you picked a weaponset from the weaponmenu (icon)
  1706 	--if you picked a weaponset from the weaponmenu (icon)
  1707 	if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1707 	if(CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]==0)
  1708 	then
  1708 	then
  1709 		if(GetCurAmmoType()==amSwitch)
  1709 		if(GetCurAmmoType()==amSwitch)
  1710 		then
  1710 		then
  1711 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(table.maxn(CS.CONTINENT_INFORMATION))+1
  1711 			CS.TEAM_CONTINENT[GetHogTeamName(CurrentHedgehog)]=GetRandom(#CS.CONTINENT_INFORMATION)+1
  1712 			SetContinentWeapons()
  1712 			SetContinentWeapons()
  1713 			SetWeapon(amSkip)
  1713 			SetWeapon(amSkip)
  1714 			PlaySound(sndMineTick)
  1714 			PlaySound(sndMineTick)
  1715 			CS.CONTINENT_LABEL_TIMER = 1
  1715 			CS.CONTINENT_LABEL_TIMER = 1
  1716 		else
  1716 		else