1--[[ ___ ___ 2 ( ) ( ) 3___ .-. .-. ___ ___ | |_ .---. ___ .-. | |_ 4( ) ' ( )( ( __) / .-, ( ) ( __) 5| .-. .-. | | | | | | (__) ; || .-. .| | 6| | | | | | | | | | | ___ .'` || | | || | ___ 7| | | | | | | | | | |( / .'| || | | || |( ) 8| | | | | | | | | | | | | / | || | | || | | | 9| | | | | | | ; ' | ' | ; | ; || | | || ' | | 10| | | | | ' `-' / ' `-' ' `-' || | | |' `-' ; 11(___)(___)(___'.__.' `.__.`.__.'_(___)(___)`.__. 12 13 14---- Recommended settings: 15---- * one hedgehog per team (forced by game) 16---- * one team per clan 17---- * 'Small' one-island map 18 19--]] 20 21HedgewarsScriptLoad("/Scripts/Locale.lua") 22HedgewarsScriptLoad("/Scripts/Tracker.lua") 23HedgewarsScriptLoad("/Scripts/Params.lua") 24 25--[[ 26 MUTANT SCRIPT 27]] 28 29local hhs = {} 30local crates = {} 31local numhhs = 0 32local meh = false 33 34local gameOver=false 35 36local mutant = nil 37local mutant_base_health = 200 38local mutant_base_disease = 25 39local disease_timer = 2000 40 41local kill_reward = nil 42local mt_hurt=false 43 44local killsCounter = 0 45 46local team_fire_punishment = 3 47local mutant_kill_reward = 2 48 49local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine} 50 51local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport} 52 53local disease=0 54local timer=0 55 56local winScore = 15 57local hogsLimit = 1 58 59local teamsDead = {} 60local teamsDeleted = {} 61local hogLimitHit = false 62local cnthhs 63 64local circles = {} 65local circleFrame = -1 66 67-- Variables for custom achievements 68 69-- Most kills in 1 turn 70local recordKills = 0 71local recordKillsHogName = nil 72local recordKillsTeamName = nil 73 74-- Most suicides 75local recordSuicides = 0 76local recordSuicidesHogName = nil 77local recordSuicidesTeamName = nil 78 79-- Most skips 80local recordSkips = 0 81local recordSkipsHogName = nil 82local recordSkipsTeamName = nil 83 84-- Most crates collected 85local recordCrates = 0 86local recordCratesHogName = nil 87local recordCratesTeamName = nil 88 89-- Most deaths 90local recordDeaths = 0 91local recordDeathsHogName = nil 92local recordDeathsTeamName = nil 93 94-- Total killed hedgehogs 95local totalKills = 0 96 97-- Total damage 98local totalDamage = 0 99 100local mutantHat = "WhySoSerious" 101local feederHat = "poke_slowpoke" 102 103function rules() 104 105 local mineStr 106 if MinesTime < 0 then 107 mineStr = loc("Mines time: 0s-5s") 108 else 109 mineStr = string.format(loc("Mines explode after %d s."), div(MinesTime, 1000)) 110 end 111 local ruleSet = loc("Hedgehogs will be revived after their death.") .. "|" .. 112 mineStr .. "|" .. 113 loc("The first hedgehog to kill someone becomes the Mutant.") .. "|" .. 114 loc("The Mutant has super weapons and a lot of health.") .. "|" .. 115 loc("The Mutant loses health quickly, but gains health by killing.") .. "|" .. 116 " |" .. 117 loc("Score points by killing other hedgehogs.") .. "|" .. 118 loc("The hedgehog with least points (or most deaths) becomes the Bottom Feeder.") .. "|" .. 119 loc("The score and deaths are shown next to the team bar.") .. "|" .. 120 string.format(loc("Goal: Score %d points or more to win!"), winScore) .. "|" .. 121 " |" .. 122 loc("Scoring: ") .. "|" .. 123 loc("+2 for becoming the Mutant") .. "|" .. 124 loc("+1 to the Mutant for killing anyone") .. "|" .. 125 loc("+1 to the Bottom Feeder for killing anyone") .. "|" .. 126 loc("-1 to anyone for a suicide") 127 128 return ruleSet 129 130end 131 132function showStartingInfo() 133 134 ShowMission(loc("Mutant"), loc("A Hedgewars tag game"), rules(), -amWatermelon, 5000) 135 136end 137 138function onGameInit() 139 -- Sudden Death would be weird 140 WaterRise = 0 141 HealthDecrease = 0 142 -- Weapons must be reset for the Mutant mechanic to work 143 EnableGameFlags(gfResetWeps) 144 -- King Mode messes with game too much 145 DisableGameFlags(gfKing) 146end 147 148 149function limitHogsTeam(gear) 150 cnthhs = cnthhs + 1 151 if cnthhs > 1 then 152 hogLimitHit = true 153 SetEffect(gear, heResurrectable, 0) 154 setGearValue(gear, "excess", true) 155 DeleteGear(gear) 156 end 157end 158 159function limitHogsClan(gear) 160 hogLimitHit = true 161 SetEffect(gear, heResurrectable, 0) 162 setGearValue(gear, "excess", true) 163 DeleteGear(gear) 164end 165 166function onGameStart() 167 if ClansCount >= 2 then 168 SendHealthStatsOff() 169 SendAchievementsStatsOff() 170 end 171 SendRankingStatsOff() 172 trackTeams() 173 teamScan() 174 runOnHogs(saveStuff) 175 176 -- Enforce team and hog limits 177 hogLimitHit = false 178 179 -- Rule 1: One team per clan 180 if TeamsCount > ClansCount then 181 local usedClans = {} 182 for i=0, TeamsCount - 1 do 183 local teamName = GetTeamName(i) 184 local clanNumber = GetTeamClan(teamName) 185 if not usedClans[clanNumber] then 186 usedClans[clanNumber] = true 187 else 188 runOnHogsInTeam(limitHogsClan, teamName) 189 teamsDeleted[teamName] = true 190 setTeamValue(teamName, "Score", getTeamValue(teamName, "Score") -99999) 191 end 192 end 193 end 194 195 -- Rule 2: One hog per team 196 for i=0 , TeamsCount - 1 do 197 cnthhs = 0 198 runOnHogsInTeam(limitHogsTeam, GetTeamName(i)) 199 end 200 if hogLimitHit then 201 -- TODO: Update warning message to include excess teams as well 202 WriteLnToChat(loc("Only one hog per team allowed! Excess hogs will be removed.")) 203 end 204 trackTeams() 205 showStartingInfo() 206end 207 208 209 210function giveWeapons(gear) 211 if gear == mutant then 212 AddAmmo(gear, amRope) 213 for i=1, #mt_weapons do 214 AddAmmo(gear, mt_weapons[i]) 215 end 216 217 else 218 for i=1, #hh_weapons do 219 AddAmmo(gear,hh_weapons[i]) 220 end 221 end 222end 223 224function onAmmoStoreInit() 225 226 SetAmmo(amSkip, 9, 0, 0, 0) 227 SetAmmo(amRope,0,1,0,5) 228 SetAmmo(amSnowball,0,1,0,1) 229 230 for i=1, #hh_weapons do 231 SetAmmo(hh_weapons[i], 0, 0, 0, 1) 232 end 233 234 for i=1, #mt_weapons do 235 SetAmmo(mt_weapons[i], 0, 3, 0, 1) 236 end 237 238end 239 240function drawCircles() 241 for i = 0, #hhs do 242 if circles[hhs[i]] ~= nil then 243 DeleteVisualGear(circles[hhs[i]]) 244 circles[hhs[i]] = nil 245 end 246 247 if hhs[i] ~= CurrentHedgehog then 248 if mutant == nil then 249 circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) 250 SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) 251 elseif CurrentHedgehog == mutant then 252 circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) 253 SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) 254 elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then 255 circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) 256 SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070) 257 elseif hhs[i] == mutant then 258 circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false) 259 SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080) 260 end 261 end 262 end 263 circleFrame = 0 264end 265 266function onNewTurn() 267 268 killsCounter = 0 269 270 if mutant == nil and TotalRounds >= 0 then 271 AddCaption( loc("First killer will mutate"), capcolDefault, capgrpGameState ) 272 end 273 274 checkScore() 275 276 for i=0, TeamsCount-1 do 277 local teamName = GetTeamName(i) 278 if not teamsDeleted[teamName] then 279 SendStat(siClanHealth, getTeamValue(teamName, "Score"), teamName) 280 end 281 end 282 283 giveWeapons(CurrentHedgehog) 284 drawCircles() 285 setAIHints() 286 kill_reward= numhhs*10 287 288 if CurrentHedgehog == mutant then 289 mt_hurt=true 290 disease= mutant_base_disease - numhhs 291 else 292 mt_hurt=false 293 end 294 295 setGearValue(CurrentHedgehog, "Alive", true) 296 297end 298 299function countBodies() 300 if killsCounter == 2 then 301 AddCaption(loc("Double kill!"), capcolDefault, capgrpGameState ) 302 elseif killsCounter == 3 then 303 AddCaption(loc("Mega kill!"), capcolDefault, capgrpGameState ) 304 PlaySound(sndRegret) 305 elseif killsCounter == 4 then 306 AddCaption(loc("Ultra kill!"), capcolDefault, capgrpGameState ) 307 elseif killsCounter == 5 then 308 AddCaption(loc("Monster kill!"), capcolDefault, capgrpGameState ) 309 PlaySound(sndIllGetYou) 310 elseif killsCounter == 6 then 311 AddCaption(loc("Ludicrous kill!"), capcolDefault, capgrpGameState ) 312 PlaySound(sndNutter) 313 elseif killsCounter == 7 then 314 AddCaption(loc("Holy shit!"), capcolDefault, capgrpGameState ) 315 PlaySound(sndLaugh) 316 elseif killsCounter > 8 then 317 AddCaption(loc("Insanity!"), capcolDefault, capgrpGameState ) 318 end 319 320 if killsCounter > recordKills then 321 recordKills = killsCounter 322 recordKillsHogName = getGearValue(CurrentHedgehog, "Name") 323 recordKillsTeamName = GetHogTeamName(CurrentHedgehog) 324 end 325end 326 327function onGameTick() 328 329 if circleFrame > -1 then 330 for i = 0, #hhs do 331 if circles[hhs[i]] ~= nil and hhs[i]~= nil then 332 hhx, hhy = GetGearPosition(hhs[i]) 333 SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25)) 334 end 335 end 336 337 circleFrame = circleFrame + 0.06 338 339 if circleFrame >= 25 then 340 for i = 0, #hhs do 341 if circles[hhs[i]] ~= nil then 342 DeleteVisualGear(circles[hhs[i]]) 343 circles[hhs[i]] = nil 344 end 345 end 346 end 347 end 348 349 if (TurnTimeLeft==0 or band(GetState(mutant), gstHHDriven) == 0) and mt_hurt then 350 mt_hurt = false 351 end 352 353 -- Mutant's disease 354 -- Hurt Mutant during its turn time 355 -- Mutant's health is safe in ready phase 356 if mt_hurt and mutant~=nil and ReadyTimeLeft == 0 then 357 timer = timer + 1 358 if timer > disease_timer then 359 timer = 0 360 local h = GetHealth(mutant)-disease 361 SetHealth(mutant, h) 362 -- Low health warning 363 if h <= 75 then 364 PlaySound(sndPoisonMoan, mutant) 365 elseif h <= 150 then 366 PlaySound(sndPoisonCough, mutant) 367 end 368 local tag = AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true) 369 SetVisualGearValues(tag, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(mutant))) 370 if GetHealth(mutant)<=0 then 371 SetHealth(mutant,0) 372 mt_hurt= false 373 setGearValue(mutant,"SelfDestruct",true) 374 EndTurn() 375 end 376 end 377 end 378 379end 380 381--[[ 382Forces the special mutant/feeder names and hats only to be 383taken by those who deserved it. 384Names and hats will be changed (and ridiculed) if neccesary. 385]] 386function exposeIdentityTheft(gear) 387 local lon = string.lower(GetHogName(gear)) -- lowercase origina name 388 local name, hat 389 -- Change name if hog uses a reserved one 390 if lon == "mutant" or lon == string.lower(loc("Mutant")) then 391 SetHogName(gear, loc("Identity Thief")) 392 SetHogHat(gear, "Disguise") 393 elseif lon == "bottom feeder" or lon == string.lower(loc("Bottom Feeder")) then 394 -- Word play on "Bottom Feeder". Someone who is low on cotton. :D 395 -- Either translate literally or make up your ow word play 396 SetHogName(gear, loc("Cotton Needer")) 397 SetHogHat(gear, "StrawHat") 398 end 399 -- Strip hog off its special hat 400 if GetHogHat(gear) == mutantHat or GetHogHat(gear) == feederHat then 401 SetHogHat(gear, "NoHat") 402 end 403end 404 405function saveStuff(gear) 406 exposeIdentityTheft(gear) 407 setGearValue(gear,"Name",GetHogName(gear)) 408 setGearValue(gear,"Hat",GetHogHat(gear)) 409end 410 411function armageddon(gear) 412 SetState(gear, gstLoser) 413 SetEffect(gear, heResurrectable, 0) 414 SetHealth(gear, 0) 415end 416 417function renderScores() 418 for i=0, TeamsCount-1 do 419 local name = GetTeamName(i) 420 SetTeamLabel(name, string.format(loc("%d | %d"), getTeamValue(name, "Score"), getTeamValue(name, "DeadHogs"))) 421 end 422end 423 424function createEndGameStats() 425 SendStat(siGraphTitle, loc("Score graph")) 426 427 local teamsSorted = {} 428 for i=0, TeamsCount-1, 1 do 429 teamsSorted[i+1] = GetTeamName(i) 430 end 431 432 -- Achievements stuff 433 local achievements = 0 434 --- Most kills per turn 435 if recordKills >= 3 then 436 SendStat(siMaxStepKills, string.format("%d %s (%s)", recordKills, recordKillsHogName, recordKillsTeamName)) 437 achievements = achievements + 1 438 end 439 --- Most crates collected 440 if recordCrates >= 5 then 441 SendStat(siCustomAchievement, string.format(loc("%s (%s) was the greediest hedgehog and collected %d crates."), recordCratesHogName, recordCratesTeamName, recordCrates)) 442 achievements = achievements + 1 443 end 444 --- Most suicides 445 if recordSuicides >= 5 then 446 SendStat(siCustomAchievement, string.format(loc("%s (%s) hate life and suicided %d times."), recordSuicidesHogName, recordSuicidesTeamName, recordSuicides)) 447 achievements = achievements + 1 448 end 449 --- Most deaths 450 if recordDeaths >= 5 then 451 SendStat(siCustomAchievement, string.format(loc("Poor %s (%s) died %d times."), recordDeathsHogName, recordDeathsTeamName, recordDeaths)) 452 achievements = achievements + 1 453 end 454 --- Most skips 455 if recordSkips >= 3 then 456 SendStat(siMaxTurnSkips, string.format("%d %s (%s)", recordSkips, recordSkipsHogName, recordSkipsTeamName)) 457 achievements = achievements + 1 458 end 459 --- Total damage 460 if totalDamage >= 900 then 461 SendStat(siCustomAchievement, string.format(loc("%d damage was dealt in this game."), totalDamage)) 462 achievements = achievements + 1 463 end 464 --- Total kills 465 if totalKills >= 20 or (achievements <= 0 and totalKills >= 1) then 466 SendStat(siKilledHHs, tostring(totalKills)) 467 achievements = achievements + 1 468 end 469 470 -- Score and stats stuff 471 local showScore = "" 472 local rank = 0 473 local rankPlus = 1 474 local prevScore 475 table.sort(teamsSorted, function(team1, team2) return getTeamValue(team1, "Score") > getTeamValue(team2, "Score") end) 476 for i=1, TeamsCount do 477 local score = getTeamValue(teamsSorted[i], "Score") 478 local deaths = getTeamValue(teamsSorted[i], "DeadHogs") 479 if i == 1 or score < prevScore then 480 rank = rank + rankPlus 481 rankPlus = 1 482 prevScore = score 483 else 484 rankPlus = rankPlus + 1 485 end 486 SendStat(siPointType, "!POINTS") 487 SendStat(siTeamRank, rank) 488 SendStat(siPlayerKills, score, teamsSorted[i]) 489 490 showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teamsSorted[i], score, deaths) .. "|" 491 end 492 493 if getTeamValue(teamsSorted[1], "Score") == getTeamValue(teamsSorted[2], "Score") then 494 -- The first two teams have the same score! Round is drawn. 495 return nil 496 else 497 498 ShowMission(loc("Mutant"), 499 loc("Final result"), 500 string.format(loc("Winner: %s"), teamsSorted[1]) .. "| |" .. loc("Scores:") .. " |" .. 501 showScore, 4, 15000) 502 503 -- return winning team 504 return teamsSorted[1] 505 end 506end 507 508function checkScore() 509local lowest_score_team = nil 510local min_score=nil 511local winTeam = nil 512 513local only_low_score = true 514 515 for i=0, TeamsCount-1 do 516 local teamName = GetTeamName(i) 517 if not teamsDead[teamName] then 518 local curr_score = getTeamValue(teamName, "Score") 519 520 runOnHogsInTeam(removeFeeder, teamName) 521 522 if curr_score >= winScore then 523 gameOver = true 524 winTeam = teamName 525 end 526 527 if min_score==nil then 528 min_score= curr_score 529 lowest_score_team = teamName 530 else 531 if curr_score <= min_score then 532 if curr_score == min_score then 533 if getTeamValue(teamName, "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then 534 only_low_score = false 535 else 536 if getTeamValue(teamName, "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then 537 lowest_score_team = teamName 538 end 539 only_low_score = true 540 end 541 542 else 543 min_score= curr_score 544 lowest_score_team = teamName 545 only_low_score = true 546 end 547 end 548 end 549 end 550 end 551 552 if gameOver then 553 EndTurn(true) 554 555 for i=0, TeamsCount-1 do 556 local teamName = GetTeamName(i) 557 if teamName~=winTeam then 558 runOnHogsInTeam(armageddon, teamName) 559 end 560 end 561 562 createEndGameStats() 563 else 564 565 if only_low_score then 566 runOnHogsInTeam(setFeeder, lowest_score_team) 567 end 568 569 if meh == false then 570 meh = true 571 end 572 573 end 574end 575 576function backToNormal(gear) 577 SetHogName(gear, getGearValue(gear,"Name")) 578 SetHogHat(gear, 'NoHat') 579 SetHogHat(gear, getGearValue(gear,"Hat")) 580 setGearValue(mutant,"SelfDestruct",false) 581 mt_hurt=false 582 mutant=nil 583end 584 585function setAIHints() 586 for i = 0, #hhs do 587 if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then 588 SetGearAIHints(hhs[i], aihUsualProcessing) 589 else 590 SetGearAIHints(hhs[i], aihDoesntMatter) 591 end 592 end 593 for k,v in pairs(crates) do 594 if CurrentHedgehog == mutant and v ~= nil then 595 SetGearAIHints(v, aihDoesntMatter) 596 else 597 SetGearAIHints(v, aihUsualProcessing) 598 end 599 end 600end 601 602function removeFeeder(gear) 603 if gear~=nil then 604 setGearValue(gear,"Feeder",false) 605 if gear~= mutant then 606 SetHogName(gear, getGearValue(gear,"Name") ) 607 SetHogHat(gear, 'NoHat') 608 SetHogHat(gear, getGearValue(gear,"Hat")) 609 end 610 end 611end 612 613function setFeeder(gear) 614 if gear~= mutant and gear~= nil then 615 SetHogName(gear, loc("Bottom Feeder")) 616 SetHogHat(gear, feederHat) 617 setGearValue(gear,"Feeder", true) 618 end 619end 620 621function setMutantStuff(gear) 622 mutant = gear 623 624 SetHogName(gear, loc("Mutant")) 625 SetHogHat(gear, mutantHat) 626 SetHealth(gear, ( mutant_base_health + numhhs*25) ) 627 SetEffect(gear, hePoisoned, 1) 628 setGearValue(mutant,"SelfDestruct",false) 629 setGearValue(gear, "Feeder", false) 630 631 AddCaption(string.format(loc("%s has mutated! +2 points"), getGearValue(gear, "Name")), GetClanColor(GetHogClan(gear)), capgrpMessage) 632 633 if TurnTimeLeft > 0 then 634 EndTurn(true) 635 end 636 637 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 638 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 639 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 640 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 641 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 642 PlaySound(sndSuddenDeath) 643end 644 645function teamScan() 646 647 for j=0, TeamsCount-1 do 648 local teamName = GetTeamName(j) 649 teamsDead[teamName] = false 650 setTeamValue(teamName, "Score",0) 651 setTeamValue(teamName, "Suicides",0) 652 setTeamValue(teamName, "Skips",0) 653 setTeamValue(teamName, "Crates",0) 654 setTeamValue(teamName, "DeadHogs",0) 655 end 656 657 renderScores() 658 659 ---***--- 660end 661 662function set_Mutant_and_Score(gear) 663 664local curr_team = GetHogTeamName(CurrentHedgehog) 665 666 if gear == CurrentHedgehog then 667 if CurrentHedgehog == mutant then 668 PlaySound(sndHomerun) 669 if getGearValue(gear, "SelfDestruct")==false then 670 decreaseTeamValue(curr_team,"Score") 671 end 672 backToNormal(gear) 673 else 674 decreaseTeamValue(curr_team,"Score") 675 end 676 677 else 678 if gear == mutant then 679 backToNormal(mutant) 680 if curr_team ~=GetHogTeamName(gear) then 681 if getGearValue(CurrentHedgehog, "Alive") then 682 setMutantStuff(CurrentHedgehog) 683 setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) 684 end 685 else 686 setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) 687 increaseTeamValue(curr_team,"Suicides") 688 if(getTeamValue(curr_team, "Suicides") > recordSuicides) then 689 recordSuicides = getTeamValue(curr_team, "Suicides") 690 recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") 691 recordSuicidesTeamName = curr_team 692 end 693 AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) 694 end 695 else 696 if mutant==nil then 697 if curr_team ~=GetHogTeamName(gear) then 698 if getGearValue(CurrentHedgehog, "Alive") then 699 setMutantStuff(CurrentHedgehog) 700 setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward)) 701 else 702 increaseTeamValue(curr_team,"Score") 703 end 704 else 705 setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) 706 increaseTeamValue(curr_team,"Suicides") 707 if(getTeamValue(curr_team, "Suicides") > recordSuicides) then 708 recordSuicides = getTeamValue(curr_team, "Suicides") 709 recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name") 710 recordSuicidesTeamName = curr_team 711 end 712 AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) 713 end 714 else 715 if curr_team ~=GetHogTeamName(gear) then 716 if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then 717 HealHog(CurrentHedgehog, kill_reward) 718 AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) 719 increaseTeamValue(curr_team,"Score") 720 end 721 if getGearValue(CurrentHedgehog,"Feeder") then 722 increaseTeamValue(curr_team,"Score") 723 AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) 724 end 725 else 726 setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment)) 727 AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage) 728 end 729 end 730 end 731 end 732end 733 734function onGearResurrect(gear) 735if not gameOver then 736 if GetGearType(gear) == gtHedgehog then 737 738 increaseTeamValue(GetHogTeamName(gear), "DeadHogs") 739 totalKills = totalKills + 1 740 if(getTeamValue(GetHogTeamName(gear), "DeadHogs") > recordDeaths) then 741 recordDeaths = getTeamValue(GetHogTeamName(gear), "DeadHogs") 742 recordDeathsHogName = getGearValue(gear, "Name") 743 recordDeathsTeamName = GetHogTeamName(gear) 744 end 745 746 if gear==CurrentHedgehog then 747 setGearValue(CurrentHedgehog, "Alive", false) 748 end 749 set_Mutant_and_Score(gear) 750 if gear~=CurrentHedgehog then 751 killsCounter = killsCounter + 1 752 countBodies() 753 end 754 AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false) 755 PlaySound(sndWhack) 756 renderScores() 757 end 758end 759end 760 761function onGearDamage(gear, damage) 762 if not gameOver and GetGearType(gear) == gtHedgehog then 763 totalDamage = totalDamage + damage 764 end 765end 766 767function onSkipTurn() 768 -- Record skips for achievement 769 local team = GetHogTeamName(CurrentHedgehog) 770 increaseTeamValue(team, "Skips") 771 if(getTeamValue(team, "Skips") > recordSkips) then 772 recordSkips = getTeamValue(team, "Skips") 773 recordSkipsHogName = getGearValue(CurrentHedgehog, "Name") 774 recordSkipsTeamName = team 775 end 776end 777 778function onGearAdd(gear) 779 780 -- Catch hedgehogs for the tracker 781 if GetGearType(gear) == gtHedgehog then 782 trackGear(gear) 783 hhs[numhhs] = gear 784 numhhs = numhhs + 1 785 SetEffect(gear, heResurrectable, 1) 786 elseif GetGearType(gear) == gtCase then 787 crates[gear] = gear 788 elseif GetGearType(gear) == gtATFinishGame then 789 if not gameOver then 790 local winner = createEndGameStats() 791 if winner then 792 SendStat(siGameResult, string.format(loc("%s wins!"), winner)) 793 AddCaption(string.format(loc("%s wins!"), winner), capcolDefault, capgrpGameState) 794 end 795 gameOver = true 796 end 797 end 798end 799 800function checkEmptyTeam (teamName) 801 for i=0 , #hhs do 802 if hhs[i]~=nil then 803 if teamName == GetHogTeamName(hhs[i]) then 804 return false 805 end 806 end 807 end 808 return true 809end 810 811function onGearDelete(gear) 812 -- Remove hogs that are gone 813 if GetGearType(gear) == gtHedgehog then 814 numhhs = numhhs - 1 815 816 local found 817 for i=0, #hhs do 818 if hhs[i] == gear then 819 found = i 820 break 821 end 822 end 823 for i = found, #hhs - 1 do 824 hhs[i] = hhs[i + 1] 825 end 826 hhs[#hhs] = nil 827 828 local t_name = GetHogTeamName(gear) 829 if checkEmptyTeam(t_name) then 830 for i = 0, TeamsCount - 1 do 831 if GetTeamName(i) == t_name then 832 found = i 833 teamsDead[t_name] = true 834 break 835 end 836 end 837 end 838 if getGearValue(gear, "excess") ~= true and band(GetState(gear), gstDrowning) == 0 then 839 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) 840 end 841 trackDeletion(gear) 842 elseif GetGearType(gear) == gtCase then 843 crates[gear] = nil 844 -- Check if a crate has been collected 845 if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then 846 -- Update crate collection achievement 847 increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") 848 if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then 849 recordCrates = getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") 850 recordCratesHogName = getGearValue(CurrentHedgehog, "Name") 851 recordCratesTeamName = GetHogTeamName(CurrentHedgehog) 852 end 853 end 854 end 855end 856 857function onParameters() 858 parseParams() 859 winScore = tonumber(params["winscore"]) or winScore 860end 861 862--[[ 863S T A R R I N G 864 prof - Coding, implementing and evangelism 865 vos - Initial idea and script improvements 866 mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D 867--]] 868