Combustion temperatures and potential for hot spots/detonation (pinging) increase significantly with load on the engine. As you are going up hill the load increases because the power required to move the vehicle up the hill increases, the steeper the hill the greater the load. If you run the engine speed up while standing still it takes very little throttle opening but starting moving the truck and the throttle opening to ahcieve that same engine rpm increases. Going up the hil requires even more throttle opening to achieve that engine rpm because the load is increasing. If you get to wide open throttle and cannot achieve that same engine rpm you have reached the power limitation of the engine.
Hot spots can be from combustion chamber deposits or over heated exhaust valves, generally because they are not sealing (the seal also allows heat transfer from the valve to the head). Sometimes a piece of carbon from a chamber deposit gets caught in between the exhaust valve and the seat preventing the valve from sealing resulting in a hot spot and resulting detonation.
You may be able to determine if it is fuel (octane) related by adding an octane booster but as others have said the more times you experience detonation in the process of sorting it out the greater risk of major damage to the engine.