share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 11733 67049c8dedd1
parent 11732 e28b534188d3
child 11747 3182ee5be2b0
equal deleted inserted replaced
11732:e28b534188d3 11733:67049c8dedd1
     1 ---------------------------------------------------------
     1 ---------------------------------------------------------
     2 --- LE CONSTRUCTION MODE 0.8 (badly adapted from Hedge Editor 0.5)
     2 --- LE CONSTRUCTION MODE 0.7+ (badly adapted from Hedge Editor 0.5)
     3 ---------------------------------------------------------
     3 ---------------------------------------------------------
     4 -- a hedgewars gameplay mode by mikade
     4 -- a hedgewars gameplay mode by mikade
     5 -- special thanks to all who helped test and offered suggestions
     5 -- special thanks to all who helped test and offered suggestions
     6 -- additional thanks to sheepluva/nemo for adding some extra hooks
     6 -- additional thanks to sheepluva/nemo for adding some extra hooks
     7 
     7 
    75 
    75 
    76 --v0.7 (pushed to repo)
    76 --v0.7 (pushed to repo)
    77 -- added a cfg file
    77 -- added a cfg file
    78 -- removed another 903 lines of code we weren't using (lol)
    78 -- removed another 903 lines of code we weren't using (lol)
    79 
    79 
    80 --v0.8 (merged in repo)
    80 --v0.7+ (merged in repo)
    81 -- applied Wuzzy's patches:
    81 -- applied Wuzzy's patches:
    82 --   script parameters: initialenergy, energyperround, maxenergy
    82 --   script parameters: initialenergy, energyperround, maxenergy
    83 --   fix crate costs
    83 --   fix crate costs
    84 --   various minor tweaks and fixes
    84 --   various minor tweaks and fixes
    85 --   (see commits in official repo)
    85 --   (see commits in official repo)
       
    86 -- make Construction Mode play well together with fort mode (clan order = fort order)
    86 
    87 
    87 --------------------------------
    88 --------------------------------
    88 -- STRUCTURES LIST / IDEAS
    89 -- STRUCTURES LIST / IDEAS
    89 --------------------------------
    90 --------------------------------
    90 
    91 
   150 strucCirc = {}
   151 strucCirc = {}
   151 strucCircCol = {}
   152 strucCircCol = {}
   152 strucCircRadius = {}
   153 strucCircRadius = {}
   153 strucCircType = {}
   154 strucCircType = {}
   154 strucAltDisplay = {}
   155 strucAltDisplay = {}
       
   156 
       
   157 fortMode = false
   155 
   158 
   156 placedExpense = 0
   159 placedExpense = 0
   157 
   160 
   158 tempID = nil
   161 tempID = nil
   159 
   162 
  1531 	Explosives = 0
  1534 	Explosives = 0
  1532 	MinesNum = 0
  1535 	MinesNum = 0
  1533 
  1536 
  1534 	EnableGameFlags(gfInfAttack)
  1537 	EnableGameFlags(gfInfAttack)
  1535 
  1538 
       
  1539 	fortMode = GetGameFlag(gfForts)
       
  1540 
       
  1541 	-- if there are forts, let engine place the hogs on them
       
  1542 	if fortMode then
       
  1543 		EnableGameFlags(gfDivideTeams)
       
  1544 	end
  1536 
  1545 
  1537 	RedefineSubset()
  1546 	RedefineSubset()
  1538 
  1547 
  1539 end
  1548 end
  1540 
  1549 
  1541 function initialSetup(gear)
  1550 function initialSetup(gear)
  1542 
  1551 
  1543 	FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
  1552 	-- engine already placed hogs in fort mode
       
  1553 	if not fortMode then
       
  1554 		FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
       
  1555 	end
  1544 
  1556 
  1545 	-- for now, everyone should have this stuff
  1557 	-- for now, everyone should have this stuff
  1546 	AddAmmo(gear, amAirAttack, 100)
  1558 	AddAmmo(gear, amAirAttack, 100)
  1547 	AddAmmo(gear, amSwitch, 100)
  1559 	AddAmmo(gear, amSwitch, 100)
  1548 	AddAmmo(gear, amSkip, 100)
  1560 	AddAmmo(gear, amSkip, 100)
  1590 
  1602 
  1591 	tMapWidth = RightX - LeftX
  1603 	tMapWidth = RightX - LeftX
  1592 	tMapHeight = WaterLine - TopY
  1604 	tMapHeight = WaterLine - TopY
  1593 	clanInterval = div(tMapWidth,ClansCount)
  1605 	clanInterval = div(tMapWidth,ClansCount)
  1594 
  1606 
  1595 	for i = 1, ClansCount do
  1607 	-- define construction areas for each clan
  1596 
  1608 	-- if there are forts-based spawn locations, adjust areas around them
  1597 		clanBoundsSX[i-1] = LeftX+(clanInterval*i)-clanInterval+20
  1609 	for i = 0, ClansCount-1 do
  1598 		clanBoundsSY[i-1] = TopY
  1610 		local slot
  1599 		clanBoundsEX[i-1] = LeftX+(clanInterval*i)-20
  1611 		if fortMode then
  1600 		clanBoundsEY[i-1] = WaterLine
  1612 			slot = div(GetX(getFirstHogOfClan(i))-LeftX,clanInterval)
       
  1613 		else
       
  1614 			slot = i
       
  1615 		end
       
  1616 
       
  1617 		local color = GetClanColor(i)
       
  1618 
       
  1619 		clanBoundsSX[i] = LeftX+(clanInterval*slot)+20
       
  1620 		clanBoundsSY[i] = TopY
       
  1621 		clanBoundsEX[i] = LeftX+(clanInterval*slot)+clanInterval-20
       
  1622 		clanBoundsEY[i] = WaterLine
  1601 
  1623 
  1602 		--top and bottom
  1624 		--top and bottom
  1603 		AddWall(LeftX+(clanInterval*i)-clanInterval,TopY,clanInterval,margin,GetClanColor(i-1))
  1625 		AddWall(LeftX+(clanInterval*slot),TopY,clanInterval,margin,color)
  1604 		AddWall(LeftX+(clanInterval*i)-clanInterval,WaterLine-25,clanInterval,margin,GetClanColor(i-1))
  1626 		AddWall(LeftX+(clanInterval*slot),WaterLine-25,clanInterval,margin,color)
  1605 
  1627 
  1606 		--add a wall to the left and right
  1628 		--add a wall to the left and right
  1607 		AddWall(LeftX+(clanInterval*i)-clanInterval+20,TopY,margin,WaterLine,GetClanColor(i-1))
  1629 		AddWall(LeftX+(clanInterval*slot)+20,TopY,margin,WaterLine,color)
  1608 		AddWall(LeftX+(clanInterval*i)-20,TopY,margin,WaterLine,GetClanColor(i-1))
  1630 		AddWall(LeftX+(clanInterval*slot)+clanInterval-20,TopY,margin,WaterLine,color)
  1609 
  1631 
  1610 	end
  1632 	end
  1611 
  1633 
  1612 	runOnHogs(initialSetup)
  1634 	runOnHogs(initialSetup)
  1613 
  1635