Is it possible to make that code affect only the terrain in a area around the unit?
Yes it is possible and I have seen this before but I can't recall correctly. I think I saw it in a thread on wc3c...
I'll try to find it but last time it took me quite some time to find the thread since it was a really old one. :S
I'll try to search for terms like terrainDNCFiles. I think that was the model which contained the day and night model for the entire terrain.
I think the unitDNCFile was the file that made a light source around units. I can't recall correctly. If it is then you might be abled to alter the unitDNCFile.
If there is anyone who could elaborate on this subject it would be highly appreciated
I would like to know too. I'll try to search for a solution in the meanwhile.
EDIT: here is a thread discussing the matter:
http://www.wc3c.net/showthread.php?t=98815
but it's not the same thread as the one I saw before. That one was a tutorial on how to do it. I'll try to find it.
EDIT2: hmm this might be usefull:
http://warcraft.ingame.de/maps/mappedia/Jass:SetDayNightModels
Open some of these up with a MPQ browser, export it and import it in your map. Look at how the model looks like.
You can also edit them with Magos before importing.
EDIT3: What if you did this?
JASS:
call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "")
EDIT4: Wait, you want to have an area around the unit that is black right :S?? I don't really get why you would want to do this but okay xD
For the light sources, I guess you are using the Ultimate Terraining Map? There are quite some light sources in there that can be usefull when using this method...