802 --[[ |
802 --[[ |
803 : Adds either 1 (95% chance) or 2 (5% chance) random weapon(s) based on the hog variant. |
803 : Adds either 1 (95% chance) or 2 (5% chance) random weapon(s) based on the hog variant. |
804 : |
804 : |
805 : Has a 7% chance to be empty. |
805 : Has a 7% chance to be empty. |
806 ]]-- |
806 ]]-- |
807 function onWeaponCratePickup() |
807 function onWeaponCratePickup(crate) |
808 local factor = 1 * strength |
808 local factor = 1 * strength |
809 local msgColor = GetClanColor(GetHogClan(CurHog)) |
809 local msgColor = GetClanColor(GetHogClan(CurHog)) |
810 PlaySound(sndShotgunReload) |
810 PlaySound(sndShotgunReload) |
811 |
811 |
812 if GetRandom(100) < emptyCrateChance then |
812 if GetRandom(100) < emptyCrateChance then |
839 end |
839 end |
840 |
840 |
841 AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor) |
841 AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor) |
842 if IsHogLocal(CurHog) then |
842 if IsHogLocal(CurHog) then |
843 AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randAmmo), factor), msgColor, capgrpMessage) |
843 AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randAmmo), factor), msgColor, capgrpMessage) |
844 local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true) |
844 local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
845 SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor) |
845 SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor) |
846 end |
846 end |
847 end |
847 end |
848 --[[ |
848 --[[ |
849 : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant. |
849 : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant. |
850 : |
850 : |
851 : Has a 7% chance to be empty. |
851 : Has a 7% chance to be empty. |
852 ]]-- |
852 ]]-- |
853 function onUtilityCratePickup() |
853 function onUtilityCratePickup(crate) |
854 local factor = 1 * strength |
854 local factor = 1 * strength |
855 local msgColor = GetClanColor(GetHogClan(CurHog)) |
855 local msgColor = GetClanColor(GetHogClan(CurHog)) |
856 PlaySound(sndShotgunReload) |
856 PlaySound(sndShotgunReload) |
857 |
857 |
858 if GetRandom(100) < emptyCrateChance then |
858 if GetRandom(100) < emptyCrateChance then |
882 end |
882 end |
883 |
883 |
884 AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor) |
884 AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor) |
885 if IsHogLocal(CurHog) then |
885 if IsHogLocal(CurHog) then |
886 AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randUtility), factor), msgColor, capgrpMessage) |
886 AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randUtility), factor), msgColor, capgrpMessage) |
887 local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) +cratePickupGap, vgtAmmo, 0, true) |
887 local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true) |
888 SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor) |
888 SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor) |
889 end |
889 end |
890 end |
890 end |
891 |
891 |
892 function onPickupCrate(crate) |
892 function onPickupCrate(crate) |
893 local pos = GetGearPos(crate) |
893 local pos = GetGearPos(crate) |
894 |
894 |
895 -- Check if the crate is fake |
895 -- Check if the crate is fake |
896 if pos % posCaseDummy >= 1 then |
896 if pos % posCaseDummy >= 1 then |
897 if pos % posCaseDummy == posCaseAmmo then |
897 if pos % posCaseDummy == posCaseAmmo then |
898 onWeaponCratePickup() |
898 onWeaponCratePickup(crate) |
899 elseif pos % posCaseDummy == posCaseHealth then |
899 elseif pos % posCaseDummy == posCaseHealth then |
900 onHealthCratePickup() |
900 onHealthCratePickup() |
901 elseif pos % posCaseDummy == posCaseUtility then |
901 elseif pos % posCaseDummy == posCaseUtility then |
902 onUtilityCratePickup() |
902 onUtilityCratePickup(crate) |
903 end |
903 end |
904 end |
904 end |
905 end |
905 end |
906 |
906 |
907 function RandomTurnEvents() |
907 function RandomTurnEvents() |