Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gameStarted = false
- local HogList = {}
- local HogLifes = {}
- local HogLevel = {}
- local HogHealth = {}
- local HogAttack = {}
- local HogDefense = {}
- local HogSpeed = {}
- local HogExperience = {}
- local HogName = {}
- local HogClass1 = {}
- local HogClass2 = {}
- local HogClass3 = {}
- local HogLastHealth = {}
- local HogAmmo = {}
- local HogCurrentAmmo = {}
- local HogInit = {}
- local PreviousHedgehog
- local classes = {"Hedgehog", "Artilleryman", "Grenadier", "Gunslinger", "Fighter", "Scout", "Escavator", "Blazer",
- "Bombarder", "Glutton", "Trapper", "Demolitionist", "Hitter", "Infiltrator", "Engineer", "Sniper", "Incinerator",
- "Cannon Fodder", "Strategist", "Coordinator", "Infernal Grenadier", "Time Lord", "Sciencist", "Sacrifice", "Lifegiver"}
- local classAmmo = {["Artilleryman"] = {amBazooka, amMortar}, ["Grenadier"] = {amGrenade, amClusterBomb},
- ["Gunslinger"] = {amDEagle, amShotgun}, ["Fighter"] = {amWhip, amFirePunch},
- ["Scout"] = {amRope, amParachute, amSnowball}, ["Escavator"] = {amBlowTorch, amPickHammer},
- ["Blazer"] = {amFlamethrower, amMolotov}, ["Bombarder"] = {amAirAttack, amDrillStrike},
- ["Glutton"] = {amSeduction, amKnife, amGasBomb}, ["Trapper"] = {amMine, amSMine, amExtraDamage},
- ["Demolitionist"] = {amDynamite, amCake, amMinigun}, ["Hitter"] = {amBaseballBat, amHammer},
- ["Infiltrator"] = {amJetpack, amPortalGun, amBirdy}, ["Engineer"] = {amGirder, amRubber, amLandGun, amLowGravity},
- ["Sniper"] = {amSniperRifle, amLaserSight}, ["Incinerator"] = {amNapalm}, ["Cannon Fodder"] = {amKamikaze},
- ["Strategist"] = {amBee, amDrill, amDuck}, ["Coordinator"] = {amMineStrike, amRCPlane, amVampiric},
- ["Infernal Grenadier"] = {amWatermelon, amHellishBomb}, ["Time Lord"] = {amTeleport, amExtraTime, amTardis},
- ["Sciencist"] = {amBallgun, amSineGun, amIceGun}, ["Sacrifice"] = {amPiano},
- ["Lifegiver"] = {amInvulnerable, amResurrector}}
- local healthBonus = {"Fighter", "Glutton", "Cannon Fodder", "Coordinator", "Time Lord", "Lifegiver", "Scout", "Hitter"}
- local attackBonus = {"Gunslinger", "Blazer", "Sniper", "Incinerator", "Infernal Grenadier", "Demolitionist", "Infiltrator", "Sacrifice"}
- local defenseBonus = {"Artilleryman", "Escavator", "Sciencist", "Trapper", "Grenadier", "Engineer", "Strategist", "Bombarder"}
- local comboNames = {["FireDynamite"] = "Fiery Dynamite", ["TripleMissile"] = "Tripple Missiles", ["MortarPlane"] = "Mortar Plane",
- ["FireX3"] = "Longfire", ["ChainLightning"] = "Chained Sine", ["FieryBallgun"] = "Balls of Fire", ["MelonBallgun"] = "Melongun",
- ["CheeseHammer"] = "Cheesy Hammer", ["SuperSniper"] = "Amplified Sniper", ["1UP"] = "Kami of Life Stealing",
- ["TeleportTrap"] = "Teleporting Surprise", ["InfiniteTools"] = "Tool Master", ["Thorns"] = "Psi Thorns", ["DoubleMelon"] = "Melon Party",
- ["InfinitePiano"] = "Eternal Sonata", ["FreeKami"] = "Non-kamikaze Kamikaze", ["TeamVampirism"] = "OUR Health", ["InvBallgun"] = "Ballproof"}
- local classSelect = 1
- local classMin = 1
- local classMax = 1
- local actionsDone = 0
- local menu = false
- local createTag = false
- local requestUpdateAmmo = false
- local bonusHelpers = {}
- local bonusHelpersPersistent = {["FireX3"] = {}}
- function onGameInit()
- EnableGameFlags(gfInfAttack)
- end
- function onVisualGearAdd(gear)
- if not createTag and (GetVisualGearType(gear) == vgtHealthTag or GetVisualGearType(gear) == vgtSmallDamageTag) then
- DeleteVisualGear(gear)
- end
- end
- function onGearAdd(gear)
- if GetGearType(gear) == gtHedgehog then
- table.insert(HogList, gear)
- HogLifes[gear] = 2
- HogLevel[gear] = 1
- HogHealth[gear] = 100
- HogAttack[gear] = 0
- HogDefense[gear] = 0
- HogSpeed[gear] = 1
- HogExperience[gear] = 0
- HogAmmo[gear] = {}
- SetEffect(gear, heResurrectable, 1)
- end
- if (GetGearType(gear) == gtShell or GetGearType(gear) == gtDrill or GetGearType(gear) == gtMortar) and not bonusHelpers["Triple"] and HasCombo(CurrentHedgehog, "TripleMissile") then
- local x, y = GetGearPosition(gear)
- local vx, vy = GetGearVelocity(gear)
- local angle = math.atan(vx/vy)
- if vy>0 then
- angle = angle + math.pi
- end
- local speed = math.sqrt(vx*vx+vy*vy)
- bonusHelpers["Triple"] = true
- AddGear(x, y, GetGearType(gear), 0, -math.sin(angle + math.pi/32) * speed, -math.cos(angle + math.pi/32) * speed, 0)
- AddGear(x, y, GetGearType(gear), 0, -math.sin(angle - math.pi/32) * speed, -math.cos(angle - math.pi/32) * speed, 0)
- bonusHelpers["Triple"] = false
- end
- if GetGearType(gear) == gtAirBomb and HasCombo(CurrentHedgehog, "MortarPlane") then
- CopyPV(gear, AddGear(0, 0, gtMortar, 0, 0, 0, 0))
- DeleteGear(gear)
- end
- if GetGearType(gear) == gtBall then
- if HasCombo(CurrentHedgehog, "MelonBallgun") then
- local gera = AddGear(0, 0, gtMelonPiece, 75, 75, 75, 75)
- CopyPV(gear, gera)
- local x, y = GetGearPosition(gera);
- SetGearPosition(gera, x, y-16)
- DeleteGear(gear)
- end
- if bonusHelpers["InvBallgunCount"] then
- bonusHelpers["InvBallgunCount"] = bonusHelpers["InvBallgunCount"] + 1
- end
- end
- if GetGearType(gear) == gtSineGunShot and HasCombo(CurrentHedgehog, "ChainLightning") then
- if not bonusHelpers["ChainLightning"] then
- bonusHelpers["ChainLightning"]={["Sines"] = {}}
- end
- bonusHelpers["ChainLightning"]["Sines"][gear]=true
- end
- if GetGearType(gear) == gtFlame and HasCombo(CurrentHedgehog, "FireX3") and not bonusHelpers["FireX3"] then
- bonusHelpersPersistent["FireX3"][gear] = {GetTag(gear), 2}
- end
- if GetGearType(gear) == gtSniperRifleShot and HasCombo(CurrentHedgehog, "SuperSniper") then
- local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(gear)
- SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, Boom*10)
- end
- if GetGearType(gear) == gtMelonPiece and HasCombo(CurrentHedgehog, "DoubleMelon") and not bonusHelpers["BlockMelon"] then
- x, y = GetGearPosition(gear)
- dx, dy = GetGearVelocity(gear)
- bonusHelpers["BlockMelon"] = true
- local double = AddGear(x, y, gtMelonPiece, 0, dx + -2000 + GetRandom(4001), dy, 75)
- bonusHelpers["BlockMelon"] = false
- end
- if GetGearType(gear) == gtPiano and HasCombo(CurrentHedgehog, "InfinitePiano") then
- SetGearPos(gear, 10000)
- end
- end
- function onGearResurrect(gear)
- if GetGearType(gear) == gtHedgehog then
- local lostLife = true
- if band(GetState(gear), gstDrowning) ~= 0 and (not bonusHelpers["1UP"] or gear ~= bonusHelpers["1UP"]) then
- if HogLastHealth[gear] - 50 <= 0 then
- SetHealth(gear, HogHealth[gear])
- HogLifes[gear] = HogLifes[gear] - 1
- else
- lostLife = false
- SetHealth(gear, HogLastHealth[gear] - 50)
- end
- createTag = true
- SetTagColor(AddVisualGear(GetX(gear), GetY(gear), vgtHealthTag, math.min(HogLastHealth[gear], 50), true), 0xff0000ff)
- createTag = false
- if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
- AddExperience(CurrentHedgehog, math.min(HogLastHealth[gear], 50))
- end
- else
- SetHealth(gear, HogHealth[gear])
- HogLifes[gear] = HogLifes[gear] - 1
- end
- if HogLifes[gear] == 0 then
- SetEffect(gear, heResurrectable, 0)
- AddCaption(GetHogName(gear) .. ' has last life!', 0xff000000, capgrpMessage)
- elseif lostLife then
- AddCaption(GetHogName(gear) .. ' has ' .. HogLifes[gear] .. ' lifes left', 0xffff0000, capgrpMessage)
- end
- end
- end
- function onGearDelete(gear)
- if GetGearType(gear) == gtHedgehog then
- table.remove(HogList, gear)
- if bonusHelpers["1UP"] and GetHogClan(gear) ~= GetHogClan(bonusHelpers["1UP"]) then
- HogLifes[BonusHelpers["1UP"]] = HogLifes[bonusHelpers["1UP"]] + 1
- bonusHelpers["1UP"] = nil
- end
- if bonusHelpers["FreeKami"] and gear == BonusHelpers["FreeKami"] then
- HogLifes[BonusHelpers["FreeKami"]] = HogLifes[bonusHelpers["FreeKami"]] + 1
- end
- if CurrentHedgehog and GetGearType(gear) == gtHedgehog and GetHealth(gear) > 0 and GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
- AddExperience(CurrentHedgehog, math.floor(GetHealth(gear))) ----ew. -Damage
- end
- end
- if GetGearType(gear) == gtDynamite and HasCombo(CurrentHedgehog, "FireDynamite") then
- local x, y = GetGearPosition(gear);
- for i=0, 100, 1 do
- AddGear(x-50+GetRandom(101), y-50+GetRandom(101), gtFlame, 0, 0, 0, 1)
- end
- end
- if GetGearType(gear) == gtBall then
- if HasCombo(CurrentHedgehog, "FieryBallgun") then
- local x, y = GetGearPosition(gear);
- for i=0, 20, 1 do
- AddGear(x-20+GetRandom(41), y-20+GetRandom(41), gtFlame, 0, 0, 0, 1)
- end
- end
- if bonusHelpers["InvBallgunCount"] then
- bonusHelpers["InvBallgunCount"] = bonusHelpers["InvBallgunCount"] - 1
- if bonusHelpers["InvBallgunCount"] == 0 then
- SetEffect(CurrentHedgehog, heInvulnerable, bonusHelpers["InvBallgunCount"])
- bonusHelpers["InvBallgunCount"] = nil
- bonusHelpers["InvBallgun"] = nil
- end
- end
- end
- if GetGearType(gear) == gtSineGunShot and bonusHelpers["ChainLightning"] then
- bonusHelpers["ChainLightning"]["Sines"][gear]=nil
- if not next(bonusHelpers["ChainLightning"]["Sines"]) then
- bonusHelpers["ChainLightning"]=nil
- end
- end
- if GetGearType(gear) == gtFlame and bonusHelpersPersistent["FireX3"][gear] then
- if bonusHelpersPersistent["FireX3"][gear][2] > 0 then
- bonusHelpers["FireX3"]=true
- newg = AddGear(x, y, gtFlame, 0, 0, 0, 0)
- bonusHelpers["FireX3"]=false
- SetTag(newg, bonusHelpersPersistent["FireX3"][gear][1])
- CopyPV(gear, newg)
- bonusHelpersPersistent["FireX3"][newg] = {bonusHelpersPersistent["FireX3"][gear][1], bonusHelpersPersistent["FireX3"][gear][2] - 1}
- end
- bonusHelpersPersistent["FireX3"][gear]=nil
- end
- if GetGearType(gear) == gtHammer and HasCombo(CurrentHedgehog, "CheeseHammer") then
- dx = GetGearVelocity(CurrentHedgehog)
- x, y = GetGearPosition(gear)
- SetGearElasticity(AddGear(x + 15 + 30*dx, y + 20, gtGasBomb, 0, 0, 0, 1000), 9999)
- end
- if GetGearType(gear) == gtKamikaze and HasCombo(CurrentHedgehog, "1UP") then
- SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmDestroy)))
- SetGearPosition(CurrentHedgehog, 0, WaterLine + 1000)
- end
- if GetGearType(gear) == gtTeleport and HasCombo(CurrentHedgehog, "TeleportTrap") then
- x, y = GetGearPosition(gear)
- AddGear(x, y, gtMine, 0, 0, 0, 1)
- end
- end
- function onGearDamage(gear, damage)
- if GetGearType(gear) == gtHedgehog then
- local actualDamage = math.max(damage + HogAttack[CurrentHedgehog] - HogDefense[gear],0)
- actualDamage = math.floor(actualDamage + actualDamage * 0.1 + GetRandom(actualDamage * 0.2 + 1))
- if bonusHelpers["VampirismActive"] then
- SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog) - math.floor(damage * 0.8))
- HealHog(CurrentHedgehog, math.floor(actualDamage * 0.8), true, 0xff0000ff)
- if HasCombo(CurrentHedgehog, "TeamVampirism") then
- for index, hog in pairs(HogList) do
- if GetHogClan(hog) == GetHogClan(CurrentHedgehog) and hog ~= CurrentHedgehog then
- HealHog(hog, math.floor(actualDamage * 0.2), true, 0xff0000ff)
- end
- end
- end
- end
- SetHealth(gear, GetHealth(gear) + damage - actualDamage)
- if GetHealth(gear) <= -100 then
- AddCaption("OVERKILL!!!", 0xffff0000, capgrpAmmoinfo)
- damage = damage * 2
- end
- createTag = true
- SetTagColor(AddVisualGear(GetX(gear), GetY(gear), vgtHealthTag, actualDamage, true), 0xff0000ff)
- if HasCombo(gear, "Thorns") and GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
- local thorns = actualDamage/3
- SetTagColor(AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog)-30, vgtHealthTag, thorns, true), 0xff0000ff)
- SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog) - thorns)
- end
- createTag = false
- if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
- AddExperience(CurrentHedgehog, damage)
- end
- UpdateStats()
- end
- if GetGearType(gear) == gtHedgehog and GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) and bonusHelpers["ChainLightning"] then
- bonusHelpers["ChainLightning"][gear] = true
- local x, y = GetGearPosition(gear)
- local nearest = getNearestEnemy(x, y, 1000)
- if nearest then
- local x2, y2 = GetGearPosition(nearest)
- local angle = getAngle(x, y, x2, y2)
- AddGear(x, y, gtSineGunShot, 0, math.floor(-math.sin(angle) * 1000), math.floor(-math.cos(angle) * 1000), 0)
- end
- end
- end
- function AddExperience(hog, experience)
- createTag = true
- SetTagColor(AddVisualGear(GetX(hog), GetY(hog), vgtHealthTag, experience, true), 0xffff00ff)
- createTag = false
- HogExperience[hog] = HogExperience[hog] + experience
- if not HogName[hog] then
- HogName[hog] = GetHogName(hog)
- end
- while HogExperience[hog] >= HogLevel[hog]*50 do
- HogExperience[hog] = HogExperience[hog] - HogLevel[hog]*50
- HogLevel[hog] = HogLevel[hog] + 1
- HogHealth[hog] = HogHealth[hog] + 50
- for index, class in ipairs(healthBonus) do if HogClass1[hog] == class or HogClass2[hog] == class or HogClass3[hog] == class then
- HogHealth[hog] = HogHealth[hog] + 25
- end end
- HogAttack[hog] = HogAttack[hog] + 10
- for index, class in ipairs(attackBonus) do if HogClass1[hog] == class or HogClass2[hog] == class or HogClass3[hog] == class then
- HogAttack[hog] = HogAttack[hog] + 5
- end end
- HogDefense[hog] = HogDefense[hog] + 10
- for index, class in ipairs(defenseBonus) do if HogClass1[hog] == class or HogClass2[hog] == class or HogClass3[hog] == class then
- HogDefense[hog] = HogDefense[hog] + 5
- end end
- if HogLevel[hog] % 5 == 0 then
- HogSpeed[hog] = HogSpeed[hog] + 1
- end
- SetHealth(hog, HogHealth[hog])
- AddCaption(HogName[hog] .. ' reached level ' .. HogLevel[hog] .. '!', 0x00ff0000, capgrpMessage2)
- SetHogName(hog, HogName[hog] .. ' Lv. ' .. HogLevel[hog])
- end
- end
- function onAttack()
- if GetCurAmmoType() == amBallgun and HasCombo(CurrentHedgehog, "InvBallgun") then
- bonusHelpers["InvBallgun"] = GetEffect(CurrentHedgehog, heInvulnerable)
- bonusHelpers["InvBallgunCount"] = 0
- SetEffect(CurrentHedgehog, heInvulnerable, 1)
- end
- end
- function onUsedAmmo(ammoType)
- local free = {[amNothing] = true, [amSwitch] = true, [amParachute] = true, [amRope] = true, [amSnowball] = true, [amResurrector] = true,
- [amExtraDamage] = true, [amExtraTime] = true, [amLowGravity] = true, [amLaserSight] = true, [amVampiric] = true}
- if HasCombo(CurrentHedgehog, "InfiniteTools") then
- free[amGirder] = true
- free[amRubber] = true
- free[amPickHammer] = true
- free[amBlowTorch] = true
- free[amLandGun] = true
- end
- local inStore = FindIndex(HogCurrentAmmo[CurrentHedgehog], ammoType)
- if inStore then
- table.remove(HogCurrentAmmo[CurrentHedgehog], inStore)
- end
- if not free[ammoType] then
- actionsDone = actionsDone + 1
- UpdateStats()
- if actionsDone >= HogSpeed[CurrentHedgehog] then
- requestUpdateAmmo = true
- end
- end
- if ammoType == amKamikaze and HasCombo(CurrentHedgehog, "1UP") then
- bonusHelpers["1UP"] = CurrentHedgehog
- end
- if ammoType == amKamikaze and HasCombo(CurrentHedgehog, "FreeKami") then
- bonusHelpers["FreeKami"] = CurrentHedgehog
- end
- if ammoType == amVampiric then
- bonusHelpers["VampirismActive"] = true
- end
- end
- -- function DebugWriteTable(table) ----DEBUG
- -- local str = ""
- -- for index, e in ipairs(table) do
- -- str = str .. e .. " "
- -- end
- -- WriteLnToChat(str)
- -- end
- function onNewTurn()
- actionsDone = 0
- classSelect = 1
- HogInit = {}
- bonusHelpers = {}
- gameStarted = true
- end
- function onGameTick20()
- if requestUpdateAmmo then
- UpdateAmmo()
- requestUpdateAmmo = false
- end
- if CurrentHedgehog ~= PreviousHedgehog then
- if not CurrentHedgehog then
- return nil
- end
- UpdateStats()
- UpdateAmmo()
- end
- PreviousHedgehog = CurrentHedgehog
- for index, hog in ipairs(HogList) do
- local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(hog)
- HogLastHealth[hog] = GetHealth(hog) - Damage
- end
- if gameStarted and CanChangeClass(CurrentHedgehog) then
- if CanChangeClass(CurrentHedgehog) == 1 then
- classMin = 2
- classMax = 11
- elseif CanChangeClass(CurrentHedgehog) == 2 then
- classMin = 12
- classMax = 20
- elseif CanChangeClass(CurrentHedgehog) == 3 then
- classMin = 21
- classMax = 25
- end
- if classSelect < classMin then classSelect = classMin end
- if not menu then
- AddCaption("Hold Precise (Shift) to change class", GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
- else
- AddCaption((classSelect > classMin and "<< " or "") .. classes[classSelect] .. (classSelect < classMax and " >>" or ""), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
- AddCaption("Press Up to confirm", GetClanColor(GetHogClan(CurrentHedgehog)), capgrpVolume)
- end
- end
- end
- function onPrecise()
- if gameStarted then
- menu = true
- end
- end
- function onPreciseUp()
- menu = false
- end
- function onRight()
- if menu and classSelect < classMax and CanChangeClass(CurrentHedgehog) then
- classSelect = classSelect + 1
- end
- end
- function onLeft()
- if menu and classSelect > classMin and CanChangeClass(CurrentHedgehog) then
- classSelect = classSelect - 1
- end
- end
- function onUp()
- if menu and CanChangeClass(CurrentHedgehog) then
- if CanChangeClass() > 1 then
- HogSpeed[CurrentHedgehog] = HogSpeed[CurrentHedgehog] + 1
- end
- local oldCombos = GetAllCombos(CurrentHedgehog)
- SetHogClass(CurrentHedgehog)
- local newCombos = GetAllCombos(CurrentHedgehog)
- for combo, whatever in pairs(oldCombos) do
- newCombos[combo] = nil
- end
- UpdateStats()
- for class, weapons in pairs(classAmmo) do
- if class == GetHogClass(CurrentHedgehog) then
- for index, weapon in ipairs(weapons) do
- table.insert(HogAmmo[CurrentHedgehog], weapon)
- end
- break
- end
- end
- HogInit[CurrentHedgehog] = nil
- UpdateAmmo()
- AddCaption(GetHogName(CurrentHedgehog) .. "'s class changed to " .. GetHogClass(CurrentHedgehog), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
- for combo, whatever in pairs(newCombos) do
- AddCaption("Combo \"" .. comboNames[combo] .. "\" has been activated!", GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
- end
- end
- end
- -- function onDown() ----debug
- -- if menu then
- -- AddExperience(CurrentHedgehog, 5000)
- -- end
- -- end
- function UpdateStats()
- if CurrentHedgehog then
- ShowMission(GetHogName(CurrentHedgehog), GetHogClass(CurrentHedgehog),
- '|Lifes: ' ..HogLifes[CurrentHedgehog] ..
- '|Health: ' .. GetHealth(CurrentHedgehog) .. '/' .. HogHealth[CurrentHedgehog] ..
- '|Attack: ' .. HogAttack[CurrentHedgehog] ..
- '|Defense: ' .. HogDefense[CurrentHedgehog] ..
- '|Actions left: ' .. HogSpeed[CurrentHedgehog] - actionsDone ..
- '|' .. (HogLevel[CurrentHedgehog]*50-HogExperience[CurrentHedgehog]) .. ' to next level', 3, -1)
- end
- end
- function copyTable(oldTable)
- local newTable = {}
- for index, e in ipairs(oldTable) do
- table.insert(newTable, e)
- end
- return newTable
- end
- function UpdateAmmo()
- if CurrentHedgehog then
- for weapon = 0, AmmoTypeMax do
- AddAmmo(CurrentHedgehog, weapon, 0)
- end
- AddAmmo(CurrentHedgehog, amSkip, 100)
- AddAmmo(CurrentHedgehog, amSwitch, 100)
- if actionsDone >= HogSpeed[CurrentHedgehog] then
- AddCaption('No actions left', 0xff000000, capgrpAmmostate)
- return
- end
- if not HogInit[CurrentHedgehog] then
- HogCurrentAmmo[CurrentHedgehog] = copyTable(HogAmmo[CurrentHedgehog])
- HogInit[CurrentHedgehog] = true
- end
- for index, ammo in ipairs(HogCurrentAmmo[CurrentHedgehog]) do
- AddAmmo(CurrentHedgehog, ammo, 1)
- end
- end
- end
- function onAmmoStoreInit()
- for weapon = 0, AmmoTypeMax do
- SetAmmo(weapon, 0, 0, 0)
- end
- SetAmmo(amSkip, 9, 0, 0)
- SetAmmo(amSwitch, 9, 0, 0)
- end
- function GetHogClass(hedgehog)
- if HogClass3[hedgehog] then
- return HogClass3[hedgehog]
- elseif HogClass2[hedgehog] then
- return HogClass2[hedgehog]
- elseif HogClass1[hedgehog] then
- return HogClass1[hedgehog]
- else
- return "Hedgehog"
- end
- end
- function CanChangeClass(hedgehog)
- if not HogClass1[hedgehog] then
- return 1
- elseif HogLevel[hedgehog] >= 5 and not HogClass2[hedgehog] then
- return 2
- elseif HogLevel[hedgehog] >= 10 and not HogClass3[hedgehog] then
- return 3
- end
- end
- function SetHogClass(hedgehog)
- if not HogClass1[hedgehog] then
- HogClass1[hedgehog] = classes[classSelect]
- elseif not HogClass2[hedgehog] then
- HogClass2[hedgehog] = classes[classSelect]
- elseif not HogClass3[hedgehog] then
- HogClass3[hedgehog] = classes[classSelect]
- end
- end
- function HasCombo(hog, name)
- if name=="FireDynamite" then
- return (HogClass1[hog]=="Blazer" and HogClass2[hog]=="Demolitionist")
- elseif name=="TripleMissile" then
- return (HogClass1[hog]=="Artilleryman" and HogClass2[hog]=="Strategist")
- elseif name=="MortarPlane" then
- return (HogClass1[hog]=="Artilleryman" and HogClass3[hog]=="Coordinator")
- elseif name=="FireX3" then
- return (HogClass1[hog]=="Blazer" and HogClass2[hog]=="Incinerator")
- elseif name=="ChainLightning" then
- return (HogClass2[hog]=="Sniper" and HogClass3[hog]=="Sciencist")
- elseif name=="FieryBallgun" then
- return (HogClass1[hog]=="Blazer" and HogClass2[hog]=="Incinerator" and HogClass3[hog]=="Sciencist")
- elseif name=="MelonBallgun" then
- return (HogClass1[hog]=="Grenadier" and HogClass2[hog]=="Demolitionist" and HogClass3[hog]=="Sciencist")
- elseif name=="CheeseHammer" then
- return (HogClass1[hog]=="Glutton" and HogClass2[hog]=="Hitter")
- elseif name=="SuperSniper" then
- return (HogClass1[hog]=="Gunslinger" and HogClass2[hog]=="Sniper")
- elseif name=="1UP" then
- return (HogClass2[hog]=="Cannon Fodder")
- elseif name=="TeleportTrap" then
- return (HogClass2[hog]=="Trapper" and HogClass3[hog]=="Time Lord")
- elseif name=="InfiniteTools" then
- return (HogClass1[hog]=="Escavator" and HogClass2[hog]=="Engineer")
- elseif name=="Thorns" then
- return (HogClass2[hog]=="Trapper" and HogClass3[hog]=="Coordinator")
- elseif name=="DoubleMelon" then
- return (HogClass1[hog]=="Grenadier" and HogClass3[hog]=="Infernal Grenadier")
- elseif name=="InfinitePiano" then
- return (HogClass1[hog]=="Escavator" and HogClass3[hog]=="Sacrifice")
- elseif name=="FreeKami" then
- return (HogClass2[hog]=="Cannon Fodder" and HogClass3[hog]=="Lifegiver")
- elseif name=="TeamVampirism" then
- return (HogClass2[hog]=="Coordinator" and HogClass3[hog]=="Lifegiver")
- elseif name=="InvBallgun" then
- return (HogClass2[hog]=="Engineer" and HogClass3[hog]=="Sciencist")
- end
- end
- function getNearestEnemy(x, y, maxDistance)
- local nearest = maxDistance
- local choosen = nil
- for hog, whatevs in pairs(HogLifes) do
- if hog and GetHogClan(hog) ~= GetHogClan(CurrentHedgehog) and (not bonusHelpers["ChainLightning"] or not bonusHelpers["ChainLightning"][hog]) then
- local x2, y2 = GetGearPosition(hog)
- local dist = math.sqrt((x2-x)*(x2-x) + (y2-y)*(y2-y))
- if dist<nearest then
- nearest = dist
- choosen = hog
- end
- end
- end
- return choosen
- end
- function getAngle(x1, y1, x2, y2)
- local dx = x2-x1
- local dy = y2-y1
- if dy == 0 then
- dy = 1
- end
- local angle = math.atan(dx/dy)
- if dy>0 then
- angle = angle + math.pi
- end
- return angle
- end
- function SetTagColor(tag, color)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tag)
- SetVisualGearValues(tag, g1, g2, g3, g4, g5, g6, g7, g8, g9, color)
- end
- function GetAllCombos(hedgehog)
- combos = {}
- for combo, whatever in pairs(comboNames) do
- if HasCombo(hedgehog, combo) then
- combos[combo] = true
- end
- end
- return combos
- end
- function FindIndex(tab, element)
- if not tab then return nil end
- for index, e in ipairs(tab) do
- if e == element then return index end
- end
- return nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement