HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Individual Unit Custom Values

11-20-2003, 11:25 PM#1
Garu
I apologize for my copious posts recently, but I'm rather eager to make a dent in the map I'm working on.

Anyways, for this question I should explain what I want to do in my map. I would like to assign every (living) unit in the map a "happiness" value. Depending on this happiness value, the unit would receive either bonuses or penalties, such as to movement rate, attack speed, and damage. Every time interval I would like to have a trigger that goes through each unit and modifies the happiness value of that unit based on a variety of criteria (health, unit-type, proximity to "happiness promoting" buildings, total population, certain auras, etc.). It would also update the effects placed on that unit due to it's happiness.

It looks as though I could do this using each units custom value and an array, but I have no idea as to how I would go about setting this up. Also, if there are between 500 and 2000 units on the map, would this cause problems? Would it cause unplayable slowdown? If that method wouldn't work, I suppose I could do this the other way around. Instead of each unit checking for criteria, have each criteria check to see which units it should affect. The first way the unit would check to see which buildings its near, whereas with this method the building would check which units are near it. I'd rather do it the first way, though, as that seems like it would be cleaner and smoother. I would really appreciate any help on this rather complicated setup. Any advice at all would help me a lot.
11-21-2003, 02:03 PM#2
AIAndy
Well, some parallel arrays for the info you need and using the custom value to store the position of that unit's data in the array should work quite fine.
The amount of performance that costs depends a lot on how often you update the data. You might need to spread the updating over time depending on the amount of checks you have to do for the data. What sides to compute the changes from depends a lot on the number of units/buildings that are affected and the number of buildings/units that do effect. There are a lot of things you can do to improve the performance. But all that depends on how your special map is set up and how much effort you want to put into it.