Advertisement
Guest User

TS2-Hogs Of Liberty

a guest
Dec 3rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. ----------------------------------
  2. -- THE SPECIALISTS 2 HOGS OF LIBERTY
  3. ----------------------------------
  4.  
  5. -- SCRIPT PARAMETER SYNTAX
  6. --[[
  7. With the script parameter, you can change the order of specialists per team.
  8.  
  9. == Changing the specialists for all teams ==
  10. In the script parameter, put:
  11.  
  12. t=XXXXXXXX
  13.  
  14. Where 'X' is a “specialist letter” (see below). Each letter stands for
  15. the role of a hedgehog in the team (in that order).
  16. If you leave out a letter, that hedgehog will be the default.
  17.  
  18. == Changing the specialists for on a per-team basis ==
  19. Same as above, but instead of “t”, you use “t1”, “t2”, ... “t8” for
  20. each of the teams (team 1 to team 8).
  21.  
  22. == Specialist letters ==
  23.  
  24. C = Coward
  25. T = Trimmer
  26. E = Expert
  27. M = Medic
  28. G = Guard
  29. H = Hunter
  30. A = Aviator
  31. S = Sportsman
  32.  
  33. == Examples ==
  34. Example 1:
  35.  
  36. t=EEEEHHHH
  37.  
  38. 4 experts and 4 hunters for all teams.
  39.  
  40. Example 2:
  41.  
  42. t1=CHTEMGAS,t2=HHHHHHHH
  43.  
  44. Team 1: coward, hunter, trimmer, expert, medic, guard, aviator, sportsman.
  45. Team 2: All-hunters team.
  46. All other teams use the default settings.
  47.  
  48. ]]
  49.  
  50. --------------------
  51. -- TODO
  52. --------------------
  53. -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
  54.  
  55.  
  56. HedgewarsScriptLoad("/Scripts/Locale.lua")
  57. HedgewarsScriptLoad("/Scripts/Tracker.lua")
  58. HedgewarsScriptLoad("/Scripts/Params.lua")
  59.  
  60. -- default team values
  61. local currTeamIdx = 0;
  62. local teamRoles = {
  63. {'C','T','E','M','G','H','A','S'},
  64. {'C','T','E','M','G','H','A','S'},
  65. {'C','T','E','M','G','H','A','S'},
  66. {'C','T','E','M','G','H','A','S'},
  67. {'C','T','E','M','G','H','A','S'},
  68. {'C','T','E','M','G','H','A','S'},
  69. {'C','T','E','M','G','H','A','S'},
  70. {'C','T','E','M','G','H','A','S'}
  71. };
  72.  
  73. local numhhs = 0
  74. local hhs = {}
  75.  
  76. local started = false
  77.  
  78. function onParameters()
  79. parseParams()
  80. -- All teams
  81. if params['t'] ~= nil then
  82. for i = 1, 8 do
  83. for j = 1, 8 do
  84. if string.len(params['t']) >= j then
  85. teamRoles[i][j] = string.upper(string.sub(params['t'],j,j));
  86. end
  87. end
  88. end
  89. end
  90. -- Specific team
  91. for i = 1, 8 do
  92. if params['t'..i] ~= nil then
  93. for j = 1, 8 do
  94. if string.len(params['t'..i]) >= j then
  95. teamRoles[i][j] = string.upper(string.sub(params['t'..i],j,j));
  96. end
  97. end
  98. end
  99. end
  100. end
  101.  
  102. function onNewAmmoStore(groupIndex, hogIndex)
  103.  
  104. SetAmmo(amSkip, 9, 0, 0, 0)
  105. groupIndex = groupIndex + 1
  106. hogIndex = hogIndex + 1
  107.  
  108. if teamRoles[groupIndex][hogIndex] == 'C' then
  109. SetAmmo(amIceGun, 1, 0, 0, 0)
  110. SetAmmo(amSeduction, 1, 0, 0, 0)
  111. SetAmmo(amKamikaze, 1, 0, 0, 0)
  112. elseif teamRoles[groupIndex][hogIndex] == 'T' then
  113. SetAmmo(amBlowTorch, 1, 0, 0, 0)
  114. SetAmmo(amCake, 1, 0, 0, 0)
  115. SetAmmo(amMolotov, 1, 0, 0, 0)
  116. elseif teamRoles[groupIndex][hogIndex] == 'E' then
  117. SetAmmo(amPortalGun, 1, 0, 0, 0)
  118. SetAmmo(amDrill, 1, 0, 0, 0)
  119. SetAmmo(amLaserSight, 1, 0, 0, 0)
  120. elseif teamRoles[groupIndex][hogIndex] == 'M' then
  121. SetAmmo(amRope, 3, 0, 0, 0)
  122. SetAmmo(amSwitch, 1, 0, 0, 0)
  123. SetAmmo(amResurrector, 1, 0, 0, 0)
  124. elseif teamRoles[groupIndex][hogIndex] == 'G' then
  125. SetAmmo(amAirMine, 2, 0, 0, 0)
  126. SetAmmo(amGirder, 1, 0, 0, 0)
  127. SetAmmo(amInvulnerable, 1, 0, 0, 0)
  128. elseif teamRoles[groupIndex][hogIndex] == 'H' then
  129. SetAmmo(amJetpack, 1, 0, 0, 0)
  130. SetAmmo(amExtraDamage, 1, 0, 0, 0)
  131. SetAmmo(amSniperRifle, 1, 0, 0, 0)
  132. elseif teamRoles[groupIndex][hogIndex] == 'A' then
  133. SetAmmo(amPickHammer, 1, 0, 0, 0)
  134. SetAmmo(amBirdy, 1, 0, 0, 0)
  135. SetAmmo(amParachute, 9, 0, 0, 0)
  136. elseif teamRoles[groupIndex][hogIndex] == 'S' then
  137. SetAmmo(amBaseballBat, 2, 0, 0, 0)
  138. SetAmmo(amLowGravity, 1, 0, 0, 0)
  139. SetAmmo(amExtraTime, 1, 0, 0, 0)
  140. end
  141.  
  142. end
  143.  
  144. function CreateTeam()
  145.  
  146. currTeam = ""
  147. lastTeam = ""
  148. z = 0
  149.  
  150. for i = 0, (numhhs-1) do
  151.  
  152. currTeam = GetHogTeamName(hhs[i])
  153.  
  154. if currTeam == lastTeam then
  155. z = z + 1
  156. else
  157. z = 1
  158. currTeamIdx = currTeamIdx + 1;
  159. end
  160.  
  161. -- Scale health of each hog with “initial health” setting from game scheme.
  162. -- 100 = default health
  163. -- 200 = double health for all hogs
  164. -- 50 = half health for all hogs
  165. local function scaleHealth(health)
  166. local newHealth = div(health * InitHealth, 100)
  167. -- At least 1 health
  168. if newHealth <= 0 then
  169. newHealth = 1
  170. end
  171. return newHealth
  172. end
  173.  
  174. if teamRoles[currTeamIdx][z] == 'C' then
  175.  
  176. SetHogName(hhs[i],loc("Coward"))
  177. SetHogHat(hhs[i], "barrelhider")
  178. SetHealth(hhs[i], scaleHealth(130))
  179.  
  180. elseif teamRoles[currTeamIdx][z] == 'T' then
  181.  
  182. SetHogHat(hhs[i], "chef")
  183. SetHogName(hhs[i],loc("Trimmer"))
  184. SetHealth(hhs[i], scaleHealth(80))
  185.  
  186. elseif teamRoles[currTeamIdx][z] == 'E' then
  187.  
  188. SetHogName(hhs[i],loc("Expert"))
  189. SetHogHat(hhs[i], "pirate_eyepatch")
  190. SetHealth(hhs[i], scaleHealth(110))
  191.  
  192. elseif teamRoles[currTeamIdx][z] == 'M' then
  193.  
  194. SetHogName(hhs[i],loc("Medic"))
  195. SetHogHat(hhs[i], "fr_apple")
  196. SetHealth(hhs[i], scaleHealth(250))
  197.  
  198. elseif teamRoles[currTeamIdx][z] == 'G' then
  199.  
  200. SetHogName(hhs[i],loc("Guard"))
  201. SetHogHat(hhs[i], "policecap")
  202. SetHealth(hhs[i], scaleHealth(160))
  203.  
  204. elseif teamRoles[currTeamIdx][z] == 'H' then
  205.  
  206. SetHogName(hhs[i],loc("Hunter"))
  207. SetHogHat(hhs[i], "RobinHood")
  208. SetHealth(hhs[i], scaleHealth(140))
  209.  
  210. elseif teamRoles[currTeamIdx][z] == 'A' then
  211.  
  212. SetHogName(hhs[i],loc("Aviator"))
  213. SetHogHat(hhs[i], "tf_scout")
  214. SetHealth(hhs[i], scaleHealth(90))
  215.  
  216. elseif teamRoles[currTeamIdx][z] == 'S' then
  217.  
  218. SetHogName(hhs[i],loc("Sportsman"))
  219. SetHogHat(hhs[i], "footballhelmet")
  220. SetHealth(hhs[i], scaleHealth(120))
  221.  
  222. end
  223.  
  224. lastTeam = GetHogTeamName(hhs[i])
  225.  
  226. end
  227.  
  228. end
  229.  
  230. function onGameInit()
  231. -- Force-disable harmful game flags
  232. DisableGameFlags(gfSharedAmmo, gfKing)
  233. -- Force-enable game-critical game flags
  234. EnableGameFlags(gfPerHogAmmo, gfResetWeps)
  235. -- NOTE: For your game scheme, these game flags are recommended: gfResetWeps, gfPlaceHog, gfSwitchHog, gfInfAttack
  236.  
  237. -- No weapon crates
  238. HealthCaseProb = 100
  239.  
  240. -- Instructions
  241. Goals = loc("The Other Specialists: Each hedgehog starts with its own weapon set")
  242. end
  243.  
  244. function onGameStart()
  245.  
  246. CreateTeam()
  247. trackTeams()
  248.  
  249. end
  250.  
  251.  
  252. function onNewTurn()
  253.  
  254. started = true
  255. AddCaption(string.format(loc("Prepare yourself, %s!"), GetHogName(CurrentHedgehog)))
  256.  
  257. end
  258.  
  259. function onGearAdd(gear)
  260.  
  261. if GetGearType(gear) == gtHedgehog then
  262. hhs[numhhs] = gear
  263. numhhs = numhhs + 1
  264. elseif (GetGearType(gear) == gtCake) and (started == true) then
  265. SetGearValues (gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 55)
  266. end
  267.  
  268. if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
  269. trackGear(gear)
  270. end
  271.  
  272. end
  273.  
  274. function onGearDelete(gear)
  275. if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
  276. trackDeletion(gear)
  277. end
  278. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement