3012 PlaceObject(x, y) |
3015 PlaceObject(x, y) |
3013 end |
3016 end |
3014 |
3017 |
3015 end |
3018 end |
3016 |
3019 |
|
3020 -- Barrel health tags, mine timer tags and health crate health tags |
|
3021 if showGearTags then |
|
3022 local actualValue -- internal value |
|
3023 local printedValue -- value exposed to HUD |
|
3024 for g, v in pairs(tagGears) do |
|
3025 local gt = GetGearType(g) |
|
3026 if v == -1 then |
|
3027 if gt == gtCase then |
|
3028 if(band(GetGearPos(g), 0x2) ~= 0) then |
|
3029 v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(g), true) |
|
3030 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0x808080FF) |
|
3031 tagGears[g] = v |
|
3032 else |
|
3033 tagGears[g] = nil |
|
3034 end |
|
3035 else |
|
3036 if gt == gtMine and GetHealth(g) == 0 then |
|
3037 local _, damage, health |
|
3038 _, _, _, _, _, _, _, _, _, _, _, damage = GetGearValues(g) |
|
3039 health = 36 - damage |
|
3040 v = AddVisualGear(0, 0, vgtHealthTag, health, true) |
|
3041 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0x808080FF) |
|
3042 tagGears[g] = v |
|
3043 end |
|
3044 end |
|
3045 end |
|
3046 -- Delete tag for drowning gears |
|
3047 if(band(GetState(g), gstDrowning) ~= 0) then |
|
3048 DeleteVisualGear(v) |
|
3049 tagGears[g] = nil |
|
3050 elseif(tagGears[g] ~= nil and tagGears[g] ~= -1) then |
|
3051 local tag, actualvalue, offset_x, offset_y |
|
3052 tag = GetState(v) |
|
3053 if(gt == gtExplosives) then |
|
3054 actualValue = GetHealth(g) |
|
3055 printedValue = actualValue |
|
3056 offset_y = -20 |
|
3057 offset_x = 0 |
|
3058 elseif(gt == gtAirMine) then |
|
3059 if(band(GetState(g), gstAttacking) ~= 0) then |
|
3060 actualValue = GetTimer(g) |
|
3061 printedValue = actualValue |
|
3062 else |
|
3063 local _ |
|
3064 _, _, actualValue = GetGearValues(g) |
|
3065 printedValue = actualValue |
|
3066 end |
|
3067 offset_y = 28 |
|
3068 offset_x = 16 |
|
3069 elseif(gt == gtCase) then |
|
3070 actualValue = GetHealth(g) |
|
3071 printedValue = actualValue |
|
3072 offset_y = -20 |
|
3073 offset_x = 1 |
|
3074 elseif(gt == gtMine) then |
|
3075 if(GetHealth(g) ~= 0) then |
|
3076 -- Non-dud: Show timer |
|
3077 actualValue = GetTimer(g) |
|
3078 printedValue = actualValue |
|
3079 offset_y = 28 |
|
3080 offset_x = 16 |
|
3081 else |
|
3082 -- Dud: Show health |
|
3083 local _ |
|
3084 _, _, _, _, _, _, _, _, _, _, _, actualValue = GetGearValues(g) |
|
3085 printedValue = 36 - actualValue |
|
3086 offset_y = -12 |
|
3087 offset_x = 0 |
|
3088 end |
|
3089 elseif(gt == gtSMine) then |
|
3090 actualValue = GetTimer(g) |
|
3091 printedValue = actualValue |
|
3092 offset_y = 28 |
|
3093 offset_x = 16 |
|
3094 end |
|
3095 --[[ The timer tag normally disappears near the water line, this is a really |
|
3096 ugly hack to adjust the position of the tag so it is always displayed. |
|
3097 FIXME: Find a better solution to fix this. ]] |
|
3098 if (GetY(g) + offset_y) > WaterLine and (GetY(g) + offset_y) < WaterLine + 30 then |
|
3099 offset_y = (WaterLine - GetY(g)) |
|
3100 end |
|
3101 local tint |
|
3102 if(gt == gtCase) then |
|
3103 tint = 0x80FF80FF |
|
3104 elseif(gt == gtExplosives or (gt == gtMine and GetHealth(g) == 0)) then |
|
3105 tint = 0x808080FF |
|
3106 elseif(band(GetState(g), gstAttacking) ~= 0) then |
|
3107 if(actualValue % 1000 > 500) then |
|
3108 tint = 0xFFA0A0FF |
|
3109 else |
|
3110 tint = 0xFF4040FF |
|
3111 end |
|
3112 else |
|
3113 tint = 0xFFFFFFFF |
|
3114 end |
|
3115 if(actualValue ~= tag) then |
|
3116 --[[ If timer/health changed, delete visual gear and add it again. |
|
3117 Changing the visual gear state does not have any effect, so we need this hack ]] |
|
3118 DeleteVisualGear(v) |
|
3119 v = AddVisualGear(GetX(g)+offset_x, GetY(g)+offset_y, vgtHealthTag, printedValue, true) |
|
3120 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, tint) |
|
3121 tagGears[g] = v |
|
3122 else |
|
3123 -- Just update position if the health did not change |
|
3124 SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, nil, nil, nil, 240000, tint) |
|
3125 end |
|
3126 end |
|
3127 end |
|
3128 end |
|
3129 |
3017 end |
3130 end |
3018 |
3131 |
3019 -------------------------------------------------- |
3132 -------------------------------------------------- |
3020 -- EVENT HANDLERS |
3133 -- EVENT HANDLERS |
3021 -------------------------------------------------- |
3134 -------------------------------------------------- |
3594 |
3707 |
3595 if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtGirder) then |
3708 if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtGirder) then |
3596 cGear = gear |
3709 cGear = gear |
3597 end |
3710 end |
3598 |
3711 |
|
3712 if showGearTags then |
|
3713 if ((GetGearType(gear) == gtMine and GetHealth(gear) ~= 0) or GetGearType(gear) == gtSMine) then |
|
3714 local v = AddVisualGear(0, 0, vgtHealthTag, GetTimer(gear), true) |
|
3715 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0xFFFFFFFF) |
|
3716 tagGears[gear] = v |
|
3717 elseif ((GetGearType(gear) == gtMine and GetHealth(gear) == 0)) then |
|
3718 local _, dmg |
|
3719 _, _, _, _, _, _, _, _, _, _, dmg = GetGearValues(gear) |
|
3720 local v = AddVisualGear(0, 0, vgtHealthTag, 36 - dmg, true) |
|
3721 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0xFFFFFFFF) |
|
3722 tagGears[gear] = v |
|
3723 elseif (GetGearType(gear) == gtAirMine) then |
|
3724 local _, wdTimer |
|
3725 _, _, wdTimer = GetGearValues(gear) |
|
3726 local v = AddVisualGear(0, 0, vgtHealthTag, wdTimer, true) |
|
3727 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0xFFFFFFFF) |
|
3728 tagGears[gear] = v |
|
3729 elseif (GetGearType(gear) == gtCase) then |
|
3730 tagGears[gear] = -1 |
|
3731 elseif (GetGearType(gear) == gtExplosives) then |
|
3732 local v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(gear), true) |
|
3733 SetVisualGearValues(v, nil, nil, 0, 0, nil, nil, nil, nil, 240000, 0xFFFFFFFF) |
|
3734 tagGears[gear] = v |
|
3735 end |
|
3736 end |
|
3737 |
3599 if isATrackedGear(gear) then |
3738 if isATrackedGear(gear) then |
3600 trackGear(gear) |
3739 trackGear(gear) |
3601 |
3740 |
3602 if GetGearType(gear) == gtPortal then |
3741 if GetGearType(gear) == gtPortal then |
3603 setGearValue(gear,"life",portalDistance) |
3742 setGearValue(gear,"life",portalDistance) |