Tarendai/Shard — pull request #48 by Garfonso (2014-02-22 14:06:50+00:00)
Title: add IDamage object and use that on UnitDamaged()

I do this as PR again, so we can discuss this.
This is a change of the API and Interface, so this should be reviewed a bit deeper.

The issue behind this is, that the Lua AI has no good way to determine what hit her. A player can get that from visuals. The AI can't really.
So I propose to add an IDamage object to the api with the following methods:
virtual float Damage(); //amount of damage inflicted
virtual Position Direction(); //direction where the damage originated from, if known (think laser beam)
virtual std::string DamageType(); //type of damage, i.e. laserbeam, canon, artillery, bombardment
virtual std::string WeaponType(); //name (or id?) of the weapon to get more info, if necessary.
virtual IUnit* Attacker(); //handle to the attacking unit, makes attacker parameter to UnitDamaged a bit superflous
virtual std::vector Effects(); //additional effects of the damage. Spring only knows paralyzed, it seems. Other engines might add other stuff, like for example parasites, poison, infectious stuff.

I tried to be engine agnostic with this change. So I hope you like it. ;) But please review it, I don't want to do changes that conflict with the philosophy behind Shard or so...
A possible modification could be to delete the attacker parameter to UnitDamaged and replace it with the damage object.

I added that and an implementation of the IDamage object for spring (CSpringDamage) and also altered all the lua files. Additionally this is the first test for boost::shared_pointers.

If you want to try it, you can do "git checkout origin/idamage" and recompile Shard. (If you want to make changes, create a new local branch with git checkout -b idamage --track origin/idamage).