All of these modifications in code are hacks, use proper creature_template fields (unit flags and flags_extra)