share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 12948 f85a040d0350
parent 12946 1a1a514aef2e
child 12949 4fa79a6a1883
equal deleted inserted replaced
12947:c8b7bc04eb4c 12948:f85a040d0350
       
     1 --[[-----------------------------------------------------
       
     2 -- CONSTRUCTION MODE --
     1 ---------------------------------------------------------
     3 ---------------------------------------------------------
     2 --- LE CONSTRUCTION MODE 0.7+ (badly adapted from Hedge Editor 0.5)
     4 A Hedgewars gameplay mode by mikade.
       
     5 Special thanks to all who helped test and offered suggestions.
       
     6 Additional thanks to sheepluva/nemo for adding some extra hooks.
       
     7 
       
     8 ---------------------
       
     9 -- STRUCTURES LIST --
       
    10 ---------------------
       
    11 
       
    12 * Healing Station: Heals hogs to 150 health
       
    13 * Teleportation Node: Allows teleporting to any other teleporter nodes
       
    14 * Bio-filter: Explodes enemy hogs
       
    15 * Respawner: If you have one of these, any slain hogs are resurrected here
       
    16 * Generator: Generates power (used to buy stuff)
       
    17 * Support Station: Allows purchasing crates
       
    18 * Construction Station: Allows purchasing girders, rubber, mines, sticky mines, barrels
       
    19 * Reflector Shield: Reflect projectiles
       
    20 * Weapon Filter: Removes all equipement of enemy hogs passing through this area
       
    21 
     3 ---------------------------------------------------------
    22 ---------------------------------------------------------
     4 -- a hedgewars gameplay mode by mikade
       
     5 -- special thanks to all who helped test and offered suggestions
       
     6 -- additional thanks to sheepluva/nemo for adding some extra hooks
       
     7 
       
     8 -- (to do)
       
     9 -- investigate loc not working on addcaptions
       
    10 -- check for parsecommands before porting to dev
       
    11 -- test onUpDown more extensively as it may need revision (check for amRubber etc)
       
    12 -- test localization of weapons and utils and stuff
       
    13 
       
    14 -- try posistion grenades in Harmer so it blows hogs away from the struc
       
    15 -- and don't explode too close to the struc
       
    16 
       
    17 -- additional/previous balance ideas
       
    18 -- based on your money?
       
    19 -- based on the number of strucs/gens you own?
       
    20 -- based on your existing arsenal?
       
    21 -- limit number of crates spawned per round perhaps (done)
       
    22 -- limit number of generators?
       
    23 
       
    24 ------------------------------------------------------------------------------
       
    25 -- SCRIPT PARAMETER
    23 -- SCRIPT PARAMETER
    26 ------------------------------------------------------------------------------
    24 ---------------------------------------------------------
    27 -- The script parameter can be used to configure the energy
    25 The script parameter can be used to configure the energy
    28 -- of the game. It is a comma-seperated list of key=value pairs, where each
    26 of the game. It is a comma-seperated list of key=value pairs, where each
    29 -- key is a word and each value is an integer between 0 and 4294967295.
    27 key is a word and each value is an integer between 0 and 4294967295.
    30 --
    28 
    31 -- Possible keys:
    29 Possible keys:
    32 --- initialenergy: Amount of energy that each team starts with (default: 550)
    30 * initialenergy:  Amount of energy that each team starts with (default: 550)
    33 ---                Note: Must be smaller than or equal to maxenergy
    31                   Note: Must be smaller than or equal to maxenergy
    34 --- energyperround: Amount of energy that each team gets per round (default: 50)
    32 * energyperround: Amount of energy that each team gets per round (default: 50)
    35 --- maxenergy: Maximum amount of energy each team can hold (default: 1000)
    33 * maxenergy:      Maximum amount of energy each team can hold (default: 1000)
    36 --- cratesperround: Maximum number of crates you can place per round (default: 5)
    34 * cratesperround: Maximum number of crates you can place per round (default: 5)
    37 
    35 
    38 -- For the previous 2 keys, you can use the value “inf” for an unlimited amount
    36 For the previous 2 keys, you can use the value “inf” for an unlimited amount.
    39 
    37 
    40 -- Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy
    38 Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy
    41 --          and sets the maximum energy to 2000.
    39          and sets the maximum energy to 2000.
    42 -- Example: “craterperround=inf” disables the crate placement limit.
    40 Example: “craterperround=inf” disables the crate placement limit.
    43 
    41 
    44 ------------------------------------------------------------------------------
    42 ---------------------------------------------------------
    45 --version history
    43 -- Ideas list --
    46 ------------------------------------------------------------------------------
    44 ---------------------------------------------------------
    47 --v0.1
    45 
    48 -- concept test
    46 * To make the weapon filter more attractive, make it vaporize flying saucers
    49 
    47   and also rope, and maybe incoming gears
    50 --v0.2
    48 
    51 -- improved documentation (in script and in game)
    49 * Make healing thing also cure poison?
    52 -- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka)
    50 * Maybe make poison more virulent and dangerous
    53 -- added variable weapon costs (based on the values from Vatten's Consumerism script)
    51 
    54 
    52 ]]
    55 -- added reflector shield (still needs work and balancing)
       
    56 -- added weapon-filter (probably ok)
       
    57 
       
    58 -- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance
       
    59 -- reduce max money to 1000
       
    60 
       
    61 --v0.3
       
    62 -- some /s removed
       
    63 
       
    64 --v0.4
       
    65 -- added support for per hog ammo (hopefully)
       
    66 
       
    67 --v0.5 (dev)
       
    68 -- added somewhat horribly implemented support for different structure sprites
       
    69 -- added override pictures for ammo menu
       
    70 -- added override message on wep select to aid understanding
       
    71 -- split menu into/between weps/parts: struc, crates, gears
       
    72 -- add a limit on crates per turn
       
    73 -- add a limit on extra time per turn
       
    74 -- add a test level
       
    75 -- restored rubber placement
       
    76 -- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol
       
    77 
       
    78 --v0.6 (dev)
       
    79 -- added magic dance
       
    80 
       
    81 --v0.7 (pushed to repo)
       
    82 -- added a cfg file
       
    83 -- removed another 903 lines of code we weren't using (lol)
       
    84 
       
    85 --v0.7+ (merged in repo)
       
    86 -- applied Wuzzy's patches:
       
    87 --   script parameters: initialenergy, energyperround, maxenergy
       
    88 --   fix crate costs
       
    89 --   various minor tweaks and fixes
       
    90 --   (see commits in official repo)
       
    91 -- make Construction Mode play well together with fort mode (clan order = fort order)
       
    92 
       
    93 --------------------------------
       
    94 -- STRUCTURES LIST / IDEAS
       
    95 --------------------------------
       
    96 
       
    97 --Healing Station: heals hogs to 150 life
       
    98 --Teleportation Node: allows teleporting to any other teleporter nodes
       
    99 --Bio-filter: explodes enemy hogs
       
   100 --Respawner: if you have one of these, any slain hogs are resurrected here :D
       
   101 --Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs)
       
   102 --Support Station: allows purchasing of weapons, utilities, and med-crates
       
   103 --Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels
       
   104 --Reflector Shield: reflect projectiles
       
   105 --Weapon Filter: kill all equipement of enemy hogs passing through this area.
       
   106 
       
   107 
       
   108 --to make the grill more attractive make it vaporize flying saucers
       
   109 --and also rope, and maybe incoming gears
       
   110 
       
   111 -- make healing thing also cure poison
       
   112 -- maybe make poison more virulent and dangerous
       
   113 
       
   114 --(not implemented / abandoned ideas)
       
   115 -- Core: allows construction of other structures.
       
   116 -- Automated Turret (think red drones from space invasion)
       
   117 -- Canon (gives access to 3 fireballs per turn while near)
       
   118 -- something that allows control of wind/water
       
   119 -- Gravity Field generator : triggers world gravity change
       
   120 
       
   121 -- structures consume power over time and
       
   122 -- maybe you can turn structures OFF/ON, manually to save power.
       
   123 
       
   124 -- hacking
       
   125 -- allow hacking of structures, either being able to use enemy structures,
       
   126 -- or turning a team's structures against them.
       
   127 
       
   128 -- pylons
       
   129 -- allow hogs to put down a pylon-like gear which then allows the core
       
   130 -- to place other structures/objects within the pylon's sphere of influence
       
   131 -- this would allow aggressive structure advancement
       
   132 
       
   133 -- resouce mining?
       
   134 -- you could designate something like mines, that you could get close to,
       
   135 -- "pick up", and then "drop" back at a central location to simulate
       
   136 -- resource mining. bit complicated/meh, normal power generators probably easier
       
   137 
       
   138 -- it would be cool to have a red mask we could apply over girders
       
   139 -- that would indicate they were Indestructible
       
   140 
    53 
   141 HedgewarsScriptLoad("/Scripts/Locale.lua")
    54 HedgewarsScriptLoad("/Scripts/Locale.lua")
   142 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    55 HedgewarsScriptLoad("/Scripts/Tracker.lua")
   143 HedgewarsScriptLoad("/Scripts/Params.lua")
    56 HedgewarsScriptLoad("/Scripts/Params.lua")
   144 
    57 
   145 ----------------------------------------------
    58 ----------------------------------------------
   146 -- STRUC CRAP
    59 -- STRUCTURES STUFF
   147 ----------------------------------------------
    60 ----------------------------------------------
   148 
    61 
   149 strucID = {}
    62 strucID = {}
   150 strucGear = {}
    63 strucGear = {}
   151 strucClan = {}
    64 strucClan = {}
   245 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
   158 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
   246 				)
   159 				)
   247 
   160 
   248 end
   161 end
   249 
   162 
   250 function onScreenResize()
       
   251 
       
   252 	-- redraw Tags so that their screen locations are updated
       
   253 	if (CurrentHedgehog ~= nil) then
       
   254 		DrawClanPowerTag()
       
   255 	end
       
   256 
       
   257 end
       
   258 
       
   259 function XYisInRect(px, py, psx, psy, pex, pey)
   163 function XYisInRect(px, py, psx, psy, pex, pey)
   260 
   164 
   261 	if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
   165 	if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
   262 		return(true)
   166 		return(true)
   263 	else
   167 	else
   319 		(GetGearType(gear) == gtMelonPiece)	or
   223 		(GetGearType(gear) == gtMelonPiece)	or
   320 		(GetGearType(gear) == gtEgg) or
   224 		(GetGearType(gear) == gtEgg) or
   321 		(GetGearType(gear) == gtDrill) or
   225 		(GetGearType(gear) == gtDrill) or
   322 		(GetGearType(gear) == gtBall) or
   226 		(GetGearType(gear) == gtBall) or
   323 		(GetGearType(gear) == gtExplosives) or
   227 		(GetGearType(gear) == gtExplosives) or
   324 			(GetGearType(gear) == gtFlame) or
   228 		(GetGearType(gear) == gtFlame) or
   325 			(GetGearType(gear) == gtPortal) or
   229 		(GetGearType(gear) == gtPortal) or
   326 			(GetGearType(gear) == gtDynamite) or
   230 		(GetGearType(gear) == gtDynamite) or
   327 			(GetGearType(gear) == gtSMine) or
   231 		(GetGearType(gear) == gtSMine) or
   328 		(GetGearType(gear) == gtKnife) or
   232 		(GetGearType(gear) == gtKnife) or
   329 		(GetGearType(gear) == gtJetpack) or -- test this and birdy plz
   233 		(GetGearType(gear) == gtJetpack) or
   330 		(GetGearType(gear) == gtBirdy) or -- test this and birdy plz
   234 		(GetGearType(gear) == gtBirdy) or
   331 		(GetGearType(gear) == gtSnowball) or
   235 		(GetGearType(gear) == gtSnowball) or
   332 		(GetGearType(gear) == gtMolotov)
   236 		(GetGearType(gear) == gtMolotov)
   333 	then
   237 	then
   334 		return(true)
   238 		return(true)
   335 	else
   239 	else
   389 		setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE?
   293 		setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE?
   390 	else
   294 	else
   391 		setGearValue(gear,"owner",10)
   295 		setGearValue(gear,"owner",10)
   392 	end
   296 	end
   393 
   297 
       
   298 end
       
   299 
       
   300 function isATrackedGear(gear)
       
   301 	if 	(GetGearType(gear) == gtHedgehog) or
       
   302 		(GetGearType(gear) == gtTarget) or
       
   303 		(GetGearType(gear) == gtCase)
       
   304 	then
       
   305 		return(true)
       
   306 	else
       
   307 		return(false)
       
   308 	end
   394 end
   309 end
   395 
   310 
   396 function AddStruc(pX,pY, pType, pClan)
   311 function AddStruc(pX,pY, pType, pClan)
   397 
   312 
   398 	sUID = sUID + 1
   313 	sUID = sUID + 1
   559 		DeleteGear(gear)
   474 		DeleteGear(gear)
   560 	end
   475 	end
   561 
   476 
   562 end
   477 end
   563 
   478 
   564 function onGearResurrect(gear)
       
   565 	AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
       
   566 	FindRespawner(gear)
       
   567 end
       
   568 
       
   569 
       
   570 function CheckTeleport(gear, tX, tY)
   479 function CheckTeleport(gear, tX, tY)
   571 
   480 
   572 	teleportOriginSuccessful = false
   481 	teleportOriginSuccessful = false
   573 	teleportDestinationSuccessful = false
   482 	teleportDestinationSuccessful = false
   574 
   483 
   623 		NR = (48/100*strucCircRadius[tempID])/2
   532 		NR = (48/100*strucCircRadius[tempID])/2
   624 	end
   533 	end
   625 
   534 
   626 	-- we're in business
   535 	-- we're in business
   627 	if dist <= NR*NR then
   536 	if dist <= NR*NR then
   628 
       
   629 
   537 
   630 		-- heal clan hogs
   538 		-- heal clan hogs
   631 		if strucType[tempID] == loc("Healing Station") then
   539 		if strucType[tempID] == loc("Healing Station") then
   632 
   540 
   633 			if GetGearType(gear) == gtHedgehog then
   541 			if GetGearType(gear) == gtHedgehog then
   907 		end
   815 		end
   908 	end
   816 	end
   909 
   817 
   910 end
   818 end
   911 
   819 
   912 
       
   913 function checkForSpecialWeapons()
   820 function checkForSpecialWeapons()
   914 
   821 
   915 	if (GetCurAmmoType() == amCMObjectPlacer) then
   822 	if (GetCurAmmoType() == amCMObjectPlacer) then
   916 		AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
   823 		AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
   917 	end
   824 	end
   918 
   825 
   919 	lastWep = GetCurAmmoType()
   826 	lastWep = GetCurAmmoType()
   920 
   827 
   921 end
   828 end
   922 
       
   923 ----------------------------------------------------------
       
   924 -- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS
       
   925 ----------------------------------------------------------
       
   926 -- experimental crap
       
   927 
       
   928 local landType = 0
       
   929 -----------------------------------------
       
   930 -- tracking vars for save slash load purposes
       
   931 -----------------------------------------
       
   932 
       
   933 local hhs = {}
       
   934 
   829 
   935 ---------------------------------
   830 ---------------------------------
   936 -- crates are made of this stuff
   831 -- crates are made of this stuff
   937 ---------------------------------
   832 ---------------------------------
   938 placeholder = 20
   833 local placeholder = 20
   939  atkArray =
   834 
   940 				{
   835 -- Weapons which shouldn't be aded:
   941 				{amBazooka, 	"amBazooka",		0, 2*placeholder},
   836 -- Air attack, napalm, drillstrike: Overwritten weapons for the Construction Mode tools
   942 				--{amBee, 		"amBee",			0, loc("Homing Bee"), 		4*placeholder},
   837 atkArray = {
   943 				{amMortar, 		"amMortar",			0, 1*placeholder},
   838 	{amBazooka, 		"amBazooka",		0, 2*placeholder},
   944 				{amDrill, 		"amDrill",			0, 3*placeholder},
   839 	--{amBee, 		"amBee",		0, 4*placeholder},
   945 				{amSnowball, 	"amSnowball",		0, 3*placeholder},
   840 	{amMortar, 		"amMortar",		0, 1*placeholder},
   946 
   841 	{amDrill, 		"amDrill",		0, 3*placeholder},
   947 				{amGrenade,		"amGrenade",		0, 2*placeholder},
   842 	{amSnowball, 		"amSnowball",		0, 3*placeholder},
   948 				{amClusterBomb,	"amClusterBomb",	0, 3*placeholder},
   843 
   949 				{amWatermelon, 	"amWatermelon",		0, 25*placeholder},
   844 	{amGrenade,		"amGrenade",		0, 2*placeholder},
   950 				{amHellishBomb,	"amHellishBomb",	0, 25*placeholder},
   845 	{amClusterBomb,		"amClusterBomb",	0, 3*placeholder},
   951 				{amMolotov, 	"amMolotov",		0, 3*placeholder},
   846 	{amWatermelon, 		"amWatermelon",		0, 25*placeholder},
   952 				{amGasBomb, 	"amGasBomb",		0, 3*placeholder},
   847 	{amHellishBomb,		"amHellishBomb",	0, 25*placeholder},
   953 
   848 	{amMolotov, 		"amMolotov",		0, 3*placeholder},
   954 				{amShotgun,		"amShotgun",		0, 2*placeholder},
   849 	{amGasBomb, 		"amGasBomb",		0, 3*placeholder},
   955 				{amDEagle,		"amDEagle",			0, 2*placeholder},
   850 
   956 				{amSniperRifle,	"amSniperRifle",	0, 3*placeholder},
   851 	{amShotgun,		"amShotgun",		0, 2*placeholder},
   957 				--{amSineGun, 	"amSineGun",		0, loc("Sine Gun"), 			6*placeholder},
   852 	{amDEagle,		"amDEagle",		0, 2*placeholder},
   958 				{amFlamethrower,"amFlamethrower",	0, 4*placeholder},
   853 	{amSniperRifle,		"amSniperRifle",	0, 3*placeholder},
   959 				{amIceGun, 		"amIceGun",			0, 15*placeholder},
   854 	--{amSineGun, 		"amSineGun",		0, 6*placeholder},
   960 
   855 	{amFlamethrower,	"amFlamethrower",	0, 4*placeholder},
   961 				{amFirePunch, 	"amFirePunch",		0, 3*placeholder},
   856 	{amIceGun, 		"amIceGun",		0, 15*placeholder},
   962 				{amWhip,		"amWhip",			0, 1*placeholder},
   857 
   963 				{amBaseballBat, "amBaseballBat",	0, 7*placeholder},
   858 	{amFirePunch, 		"amFirePunch",		0, 3*placeholder},
   964 				--{amKamikaze, 	"amKamikaze",		0, loc("Kamikaze"),			1*placeholder},
   859 	{amWhip,		"amWhip",		0, 1*placeholder},
   965 				{amSeduction, 	"amSeduction",		0, 1*placeholder},
   860 	{amBaseballBat, 	"amBaseballBat",	0, 7*placeholder},
   966 				{amHammer,		"amHammer",			0, 1*placeholder},
   861 	--{amKamikaze, 		"amKamikaze",		0, 1*placeholder},
   967 
   862 	{amSeduction, 		"amSeduction",		0, 1*placeholder},
   968 				{amMine, 		"amMine",			0, 1*placeholder},
   863 	{amHammer,		"amHammer",		0, 1*placeholder},
   969 				{amDynamite, 	"amDynamite",		0, 9*placeholder},
   864 
   970 				{amCake, 		"amCake",			0, 25*placeholder},
   865 	{amMine, 		"amMine",		0, 1*placeholder},
   971 				{amBallgun, 	"amBallgun",		0, 40*placeholder},
   866 	{amDynamite, 		"amDynamite",		0, 9*placeholder},
   972 				--{amRCPlane,		"amRCPlane",		0, loc("RC Plane"), 	25*placeholder},
   867 	{amCake, 		"amCake",		0, 25*placeholder},
   973 				{amSMine,		"amSMine",			0, 5*placeholder},
   868 	{amBallgun, 		"amBallgun",		0, 40*placeholder},
   974 
   869 	--{amRCPlane,		"amRCPlane",		0, 25*placeholder},
   975 				-- Careful! Some airborne attacks are overwritten by the special Construction Mode tools
   870 	{amSMine,		"amSMine",		0, 5*placeholder},
   976 
   871 
   977 				--{amAirAttack,	"amAirAttack",		0, loc("Air Attack"), 		10*placeholder},
   872 	--{amMineStrike,	"amMineStrike",		0, 15*placeholder},
   978 				--{amMineStrike,	"amMineStrike",		0, loc("Mine Strike"), 		15*placeholder},
   873 	--{amPiano,		"amPiano",		0, 40*placeholder},
   979 				--{amNapalm, 		"amNapalm",			0, loc("Napalm"), 		15*placeholder},
   874 
   980 				--{amPiano,		"amPiano",			0, loc("Piano Strike"), 	40*placeholder},
   875 	{amPickHammer,		"amPickHammer",		0, 2*placeholder},
   981 				--{amDrillStrike,	"amDrillStrike",	0, loc("Drill Strike"), 15*placeholder},
   876 	{amBlowTorch, 		"amBlowTorch",		0, 4*placeholder},
   982 
   877 	{amKnife,		"amKnife",		0, 2*placeholder},
   983 				{amPickHammer,		"amPickHammer",		0, 2*placeholder},
   878 
   984 				{amBlowTorch, 		"amBlowTorch",		0, 4*placeholder},
   879 	{amBirdy,		"amBirdy",		0, 7*placeholder},
   985 				{amKnife,		"amKnife",			0, 2*placeholder},
   880 
   986 
   881 	{amDuck,		"amDuck",		0, 2*placeholder}
   987 				{amBirdy,		"amBirdy",			0, 7*placeholder},
   882 }
   988 
   883 
   989 				{amDuck,		"amDuck",			0, 2*placeholder}
   884 -- Utilities which shouldn't be added:
   990 
   885 -- * Teleport: We have teleportation node
   991 				}
   886 -- * Switch: Always infinite
   992 
   887 -- * Girder, rubber: Requires construction station
   993  utilArray =
   888 -- * Resurrector: We have the resurrector structure for this
   994 				{
   889 
   995 				--{amGirder, 			"amGirder",			0, loc("Girder"), 		4*placeholder},
   890 -- Utilities which might be weird for this mode:
   996 				{amLandGun,		"amLandGun",		0, 5*placeholder},
   891 -- * Tardis: Randomly teleports hog, maybe even into enemy clan's area
   997 				--{amRubber, 			"amRubber",			0, loc("Rubber"), 	5*placeholder},
   892 utilArray = {
   998 
   893 	{amLandGun,		"amLandGun",		0, 5*placeholder},
   999 				{amRope, 			"amRope",	0, 7*placeholder},
   894 
  1000 				{amParachute, 		"amParachute",		0, 2*placeholder},
   895 	{amRope, 		"amRope",		0, 7*placeholder},
  1001 				--{amTeleport,		"amTeleport",		0, loc("Teleport"), 		6*placeholder},
   896 	{amParachute, 		"amParachute",		0, 2*placeholder},
  1002 				{amJetpack,			"amJetpack",	0, 8*placeholder},
   897 	{amJetpack,		"amJetpack",		0, 8*placeholder},
  1003 				{amPortalGun,		"amPortalGun",		0, 15*placeholder},
   898 	{amPortalGun,		"amPortalGun",		0, 15*placeholder},
  1004 
   899 
  1005 				{amInvulnerable,	"amInvulnerable",	0, 5*placeholder},
   900 	{amInvulnerable,	"amInvulnerable",	0, 5*placeholder},
  1006 				{amLaserSight,		"amLaserSight",		0, 2*placeholder},
   901 	{amLaserSight,		"amLaserSight",		0, 2*placeholder},
  1007 				{amVampiric,		"amVampiric",		0, 6*placeholder},
   902 	{amVampiric,		"amVampiric",		0, 6*placeholder},
  1008 				--{amResurrector, 	"amResurrector",	0, loc("Resurrector"), 		8*placeholder},
   903 
  1009 				--{amTardis, 			"amTardis",			0, loc("Time Box"), 			2*placeholder},
   904 	{amLowGravity, 		"amLowGravity",		0, 4*placeholder},
  1010 
   905 	{amExtraDamage, 	"amExtraDamage",	0, 6*placeholder},
  1011 				--{amSwitch,			"amSwitch",			0, loc("Switch Hog"), 		4*placeholder}
   906 	{amExtraTime,		"amExtraTime",		0, 8*placeholder}
  1012 				{amLowGravity, 		"amLowGravity",		0, 4*placeholder},
   907 }
  1013 				{amExtraDamage, 	"amExtraDamage",	0, 6*placeholder},
       
  1014 				{amExtraTime,		"amExtraTime",		0, 8*placeholder}
       
  1015 
       
  1016 				}
       
  1017 
   908 
  1018 ----------------------------
   909 ----------------------------
  1019 -- placement shite
   910 -- Placement stuff
  1020 ----------------------------
   911 ----------------------------
  1021 
   912 
  1022 local cGear = nil -- detects placement of girders and objects (using airattack)
   913 local cGear = nil -- detects placement of girders and objects (using airattack)
  1023 local curWep = amNothing
   914 local curWep = amNothing
  1024 
   915 
  1189 			AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1080 			AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1190 			PlaySound(sndDenied)
  1081 			PlaySound(sndDenied)
  1191 		end
  1082 		end
  1192 
  1083 
  1193 	else
  1084 	else
  1194 	    if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1085 		if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
  1195             AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1086 			AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
  1196         else
  1087 		else
  1197             AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume)
  1088 			AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume)
  1198         end
  1089 		end
  1199 		PlaySound(sndDenied)
  1090 		PlaySound(sndDenied)
  1200 	end
  1091 	end
  1201 
       
  1202 
  1092 
  1203 end
  1093 end
  1204 
  1094 
  1205 -- called when user changes primary selection
  1095 -- called when user changes primary selection
  1206 -- either via up/down keys
  1096 -- either via up/down keys
  1425 
  1315 
  1426 	AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate)
  1316 	AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate)
  1427 
  1317 
  1428 end
  1318 end
  1429 
  1319 
  1430 function onTimer(key)
       
  1431 	curWep = GetCurAmmoType()
       
  1432 
       
  1433 	-- Hacky workaround for object placer: Since this is based on the drill strike, it
       
  1434 	-- allows the 5 timer keys to be pressed, causing the announcer to show up
       
  1435 	-- This triggers code in 1 tick to send other message to mask the earlier one.
       
  1436 	checkForSpecialWeaponsIn = 1
       
  1437 
       
  1438 	if (curWep == amCMStructurePlacer) then
       
  1439 		-- Select structure directly in structure placer
       
  1440 		-- [Timer X] selects structures 1-5
       
  1441 		-- [Precise]+[Timer X] selects structures 6-10
       
  1442 
       
  1443 		local structureID = key
       
  1444 		local precise = band(GetGearMessage(CurrentHedgehog), gmPrecise) ~= 0
       
  1445 		if precise then
       
  1446 			structureID = structureID + 5
       
  1447 		end
       
  1448 		-- Check for valid pIndex
       
  1449 		if structureID <= #pMode then
       
  1450 			pIndex = structureID
       
  1451 			updateIndex()
       
  1452 		end
       
  1453 	elseif (curWep == amCMObjectPlacer) then
       
  1454 		-- [Timer X]: Set mine time 1-5
       
  1455 		if cat[cIndex] == "Mine Placement Mode" then
       
  1456 			local index = key + 1
       
  1457 			if key <= #pMode then
       
  1458 				pIndex = index
       
  1459 				updateIndex()
       
  1460 			end
       
  1461 		end
       
  1462 	end
       
  1463 
       
  1464 end
       
  1465 
       
  1466 function onSwitch()
       
  1467 	curWep = GetCurAmmoType()
       
  1468 	if (curWep == amCMObjectPlacer) then
       
  1469 		-- [Switch]: Set mine time to 0
       
  1470 		pIndex = 1
       
  1471 		updateIndex()
       
  1472 	end
       
  1473 end
       
  1474 
       
  1475 function onLeft()
       
  1476 	curWep = GetCurAmmoType()
       
  1477 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
       
  1478 		pIndex = pIndex - 1
       
  1479 		if pIndex == 0 then
       
  1480 			pIndex = #pMode
       
  1481 		end
       
  1482 		updateIndex()
       
  1483 	end
       
  1484 end
       
  1485 
       
  1486 function onRight()
       
  1487 	curWep = GetCurAmmoType()
       
  1488 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
       
  1489 		pIndex = pIndex + 1
       
  1490 		if pIndex > #pMode then
       
  1491 			pIndex = 1
       
  1492 		end
       
  1493 		updateIndex()
       
  1494 	end
       
  1495 end
       
  1496 
       
  1497 -- Should be called when the index of the mode was changed by the player.
  1320 -- Should be called when the index of the mode was changed by the player.
  1498 -- E.g. new weapon crate contents or structure type
  1321 -- E.g. new weapon crate contents or structure type
  1499 function updateIndex()
  1322 function updateIndex()
  1500 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
  1323 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
  1501 		showModeMessage()
  1324 		showModeMessage()
  1570 		--updateCost()
  1393 		--updateCost()
  1571 		HandleConstructionModeTools()
  1394 		HandleConstructionModeTools()
  1572 	end
  1395 	end
  1573 end
  1396 end
  1574 
  1397 
  1575 ---------------------------------------------------------
  1398 ---------------------
  1576 -- Cycle through primary categories (by changing cIndex)
  1399 -- PLAYER CONTROLS --
  1577 -- i.e 	mine, sticky mine, barrels
  1400 ---------------------
  1578 --		health/weapon/utility crate, placement of gears
  1401 
  1579 ---------------------------------------------------------
  1402 -- [Timer X]: Used as shortcut key for faster selection of stuff
       
  1403 function onTimer(key)
       
  1404 	curWep = GetCurAmmoType()
       
  1405 
       
  1406 	if (curWep == amCMStructurePlacer) then
       
  1407 		-- Select structure directly in structure placer
       
  1408 		-- [Timer X] selects structures 1-5
       
  1409 		-- [Precise]+[Timer X] selects structures 6-10
       
  1410 
       
  1411 		local structureID = key
       
  1412 		local precise = band(GetGearMessage(CurrentHedgehog), gmPrecise) ~= 0
       
  1413 		if precise then
       
  1414 			structureID = structureID + 5
       
  1415 		end
       
  1416 		-- Check for valid pIndex
       
  1417 		if structureID <= #pMode then
       
  1418 			pIndex = structureID
       
  1419 			updateIndex()
       
  1420 		end
       
  1421 	elseif (curWep == amCMObjectPlacer) then
       
  1422 		-- [Timer X]: Set mine time 1-5
       
  1423 		if cat[cIndex] == "Mine Placement Mode" then
       
  1424 			local index = key + 1
       
  1425 			if key <= #pMode then
       
  1426 				pIndex = index
       
  1427 				updateIndex()
       
  1428 			end
       
  1429 		end
       
  1430 	end
       
  1431 
       
  1432 	-- Hacky workaround for object placer: Since this is based on the drill strike, it
       
  1433 	-- allows the 5 timer keys to be pressed, causing the announcer to show up
       
  1434 	-- This triggers code in 1 tick to send other message to mask the earlier one.
       
  1435 	checkForSpecialWeaponsIn = 1
       
  1436 
       
  1437 end
       
  1438 
       
  1439 -- [Switch]: Set mine time to 0 (only in mine placement mode)
       
  1440 function onSwitch()
       
  1441 	curWep = GetCurAmmoType()
       
  1442 	if (curWep == amCMObjectPlacer) then
       
  1443 		pIndex = 1
       
  1444 		updateIndex()
       
  1445 	end
       
  1446 end
       
  1447 
       
  1448 -- [Left]/[Right]: Change submode (e.g. structure type) of any Construction Mode tool or rotate girder/rubber
       
  1449 function onLeft()
       
  1450 	curWep = GetCurAmmoType()
       
  1451 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
       
  1452 		pIndex = pIndex - 1
       
  1453 		if pIndex == 0 then
       
  1454 			pIndex = #pMode
       
  1455 		end
       
  1456 		updateIndex()
       
  1457 	end
       
  1458 end
       
  1459 function onRight()
       
  1460 	curWep = GetCurAmmoType()
       
  1461 	if (curWep == amGirder) or (curWep == amRubber) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
       
  1462 		pIndex = pIndex + 1
       
  1463 		if pIndex > #pMode then
       
  1464 			pIndex = 1
       
  1465 		end
       
  1466 		updateIndex()
       
  1467 	end
       
  1468 end
       
  1469 
       
  1470 -- [Up]/[Down]
       
  1471 -- Cycle through the primary categories
       
  1472 -- (by changing cIndex) i.e. mine, sticky mine,
       
  1473 -- barrels, health/weapon/utility crate.
  1580 function onUp()
  1474 function onUp()
  1581 
       
  1582 	curWep = GetCurAmmoType()
  1475 	curWep = GetCurAmmoType()
  1583 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1476 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1584 		if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1477 		if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1585 			rotateMode(-1)
  1478 			rotateMode(-1)
  1586 		end
  1479 		end
  1587 	end
  1480 	end
  1588 
  1481 
  1589 end
  1482 end
  1590 
       
  1591 function onDown()
  1483 function onDown()
  1592 
       
  1593 	curWep = GetCurAmmoType()
  1484 	curWep = GetCurAmmoType()
  1594 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1485 	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
  1595 		if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1486 		if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
  1596 			rotateMode(1)
  1487 			rotateMode(1)
  1597 		end
  1488 		end
  1598 	end
  1489 	end
  1599 
  1490 end
  1600 end
  1491 
  1601 
  1492 -- [Set weapon]/[Slot X]: Just update internal stuff
  1602 onSetWeapon = HandleConstructionModeTools()
  1493 onSetWeapon = HandleConstructionModeTools()
  1603 onSlot = onSetWeapon
  1494 onSlot = onSetWeapon
  1604 
  1495 
  1605 ----------------------------
  1496 ----------------------------
  1606 -- standard event handlers
  1497 -- standard event handlers
  1793 
  1684 
  1794 function onGameTick()
  1685 function onGameTick()
  1795 	HandleConstructionMode()
  1686 	HandleConstructionMode()
  1796 end
  1687 end
  1797 
  1688 
  1798 function isATrackedGear(gear)
  1689 function onScreenResize()
  1799 	if 	(GetGearType(gear) == gtHedgehog) or
  1690 	-- redraw Tags so that their screen locations are updated
  1800 		(GetGearType(gear) == gtTarget) or
  1691 	if (CurrentHedgehog ~= nil) then
  1801 		(GetGearType(gear) == gtCase)
  1692 		DrawClanPowerTag()
  1802 	then
  1693 	end
  1803 		return(true)
  1694 end
  1804 	else
  1695 
  1805 		return(false)
  1696 
  1806 	end
  1697 function onGearResurrect(gear)
       
  1698 	AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
       
  1699 	FindRespawner(gear)
  1807 end
  1700 end
  1808 
  1701 
  1809 -- track hedgehogs and placement gears
  1702 -- track hedgehogs and placement gears
  1810 function onGearAdd(gear)
  1703 function onGearAdd(gear)
  1811 
  1704