I might be misunderstanding what you are saying in your first post, but if you wrap the global or local variable with int(), then it accepts the value, i.e. unit.targettedby = int(value).
As far as I know, it has always worked like this in C2. At least, that's how I have always had to do it.