Stranded: Alien Dawn

Stranded: Alien Dawn

Stranded: Alien Dawn Workshop
Explore other users workshop creations, upload, download and subscribe to new content
HumbleSage 2023 年 11 月 14 日 下午 2:53
Trait for Melee Hit Chance from Enemy
Trying to create a trait that reduces the chance for an enemy to hit. Can't seem to find it anywhere in the Effect/Modifier drop-downs. Help? Thanks in advance.
最后由 HumbleSage 编辑于; 2023 年 11 月 14 日 下午 3:05
< >
正在显示第 1 - 3 条,共 3 条留言
Mnementh 21 2023 年 11 月 27 日 上午 6:49 
Hi, HumbleSage!

You can't directly influence the hit chance of the attacker, as the chance is determined independently of the target. In other words, the hit chance is affected by the distance and visibility of the target, but the attacker isn't signaling the target with a message like, "I'm going to hit you with this chance."

However, you can modify the code responsible for calculating this chance. For example, add the following code to a code asset, and animals will have a half chance to hit Close combat specialists when they are less than 2 meters away:

function UnitAnimal:ModifyHitChance(hit_chance, target, weapon_def, target_dist) if target.HasTrait and target:HasTrait("CloseCombatSpecialist") and target_dist < 2 * guim then return hit_chance / 2 end return hit_chance end
最后由 Mnementh 编辑于; 2023 年 11 月 27 日 上午 7:14
injto4ka 30 2023 年 11 月 28 日 上午 4:16 
Actually there is one method contextual to the target, that could be used:
function AttackableObject:GetHitNegationChanceForWeapon(weapon_def)
Creating such override in Human (that would return the original method in any other case) would do the trick by negating most melee attacks:
function Human:GetHitNegationChanceForWeapon(weapon_def) local orig_chance = AttackableObject.GetHitNegationChanceForWeapon(self, weapon_def) if weapon_def.AttackType == "melee" then return orig_chance / 2 end return orig_chance end
This would allow it to be triggered to all attackers, not just towards animals.
最后由 injto4ka 编辑于; 2023 年 11 月 28 日 上午 4:17
HumbleSage 2023 年 11 月 28 日 下午 6:45 
Super suggestions. I'll give them a go!
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50