DamageType...[Solved]

Everything about mods can be found here.

Moderator: Morax

DamageType...[Solved]

Postby Franck83 » 16 Nov 2017, 14:18

Hi all faf modders,

In my mod, i'm currently coding units Armors depending of the kind of Damages. For better damage type accuracy, i hooked the damagetable function passed to projectile and beams by switching :

Spoiler: show
By passing theses data, i can read damage.type on DoTakeDamages functions when the unit is hit.


from :
Code: Select all
self.DamageTable.DamageType = weaponBlueprint.DamageType

to :
Code: Select all
self.DamageTable.DamageType = weaponBlueprint.WeaponCategory

Because WeaponCategories are much accurate ('Missile', 'Artillery', 'Bomb', 'Kamikaze', 'Anti Air', 'Anti Navy', 'Direct Fire', 'Direct Fire Experimental'...), i can make specific armor depending of theses categories.

All works fine, i got some very cool armors, but, by hooking the DamageType, i must do some collateral damages, but i don't know the real impact. Maybe i can do some damage control and at the same time keeping my system.

It seems that some Damage functions are hard coded. I would like to overcharge the functions to add some parameters without touching the Damage.Type data.

But i don't know how ? Some ideas ?

Spoiler: show
You may ask why not using the internal armor system ?
Because i don't wanna touch unit bp for making mod virtually compatible with any kind of unit mods.
and i want more control on damage reduction (not only % absorbing).


I hope you understand me.
Last edited by Franck83 on 27 Dec 2017, 23:47, edited 1 time in total.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: DamageType...

Postby Franck83 » 16 Nov 2017, 22:15

I found a way to keep the vanilla damagetype function.

There are several vanilla damagetype : normal, overcharge, Death, Nuke, EMP, OtheTacticalBomb, FireBeetleExplosion, Deathnuke, TacticalMissile.

Since damagetype are very specific; I keep all vanilla damagetype and just replace 'normal' damagetype by other values ('Missile', 'Artillery', 'Bomb', 'Kamikaze', 'Anti Air', 'Anti Navy', 'Direct Fire', 'Direct Fire Experimental'...)

So we can do all theses kind of amors in modding without touching unit bp values:
- Armor for overcharge damages, Death damages, Nuke Damages, EMP Damages, OtheTacticalBomb Damages, Deathnuke Damages, TacticalMissile Damages, Other Missile Damages (we can do separate for land / Naval), Artillery Damages, Bomb Damages, Direct Fire Damages, Direct Fire Naval Damages, Direct Fire Experimental Damages...

This gives some fantastic epic possibilites in modding . Just so crazy :) !
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: DamageType...

Postby Uveso » 17 Nov 2017, 04:27

You can't add more arguments to the projectile.lua.DoDamage function or you will get this error:
WARNING: Error running OnImpact script in Entity [...]: Damage(instigator, target, amount, damageType) expected 5 args, but got 6

Also you can't change the damageType that you are getting from Unit.lua.OnDamage function.
And you "should not" change the numbers of arguments transported for any lua function.
Thats simply because if a mod hooks your function, it will crash because it will expect x numbers of arguments.

The only way i see is the projectile.lua.DoDamage function.
Inside this function you know the weapon and the unit that will be hit.
Then you need to hook weapon.lua to insert the new WeaponCategory into the damageTable

This way you have all data here to change the damageamount.

I did a small mod to show how it works:
It only uses non-destructive hooks and will work with any mod etc.
HookUnitMod-v1.0.zip
(17.87 KiB) Downloaded 90 times


[Edit] I am not sure that you simply can replace 'normal' damagetypes. Aren't they used from the engine (ForgedAlliance.exe) ?
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: DamageType...

Postby Franck83 » 17 Nov 2017, 10:45

Ty Uveso for your deep look and the example file. This is professional level help !
This is a critical brainstorming for very cool armors mods.

Yeah, you re right sad for adding args...

Otherwise, I went to the same way by hooking weapon.lua and projectile.lua.
For beams weapons, we need to hook the SetDamageTable in collisionBeam.lua too.

However, this way has some limitation, because of the DamageArea function. If there is a radius, this way will apply to all targets in the radius the initial target armors stats, not all target armors stats.

That's why i went to hook damagetype values, because there are passed to damagearea args.

I suspect damagetype values to be used essentially in armor (essentially overcharge). I think that there might be a more ambitious initial use of armors by GPG. Maybe some time and budget constraints. Time and testing will tell us.

Anyway, ty a lot for your help.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: DamageType...

Postby Franck83 » 17 Nov 2017, 21:09

I did a 40 min 4 iax Rush stress test. Just one error not linked to damagetype. So maybe some gameplay modifications but no crash.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: DamageType...

Postby Franck83 » 27 Dec 2017, 23:46

Just found finally a much better way to pass any kind of data without any destructive action.

We just need to register all projectiles with an id so i can read any kind of custom data from all the sim way (weaponfire -> projectile -> onDamage -> dotakedamage). This is just amazing for modding because we can store on the projectile for example fx, instigator info, dodge informations, buffs, customs buffs, datatables...

In the following screenshot i read a LOG from Unit.DoTakeDamage custom data (instigator attackrating, weapon label, weapon category, custom buffs...) passed from Weapon.GetDamageTable.

Image

That solve my problem and close this post.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest