Weapons
How to do stuff with weapons, the Redscript way
Weapon damage debugging
To see damage types and damage proccs, you can use AngeVil's script (gist) and copy it to e.g. Cyberpunk 2077/r6/scripts/debug_damage_types.reds:
You have to include the Logging functions for this to work!
@replaceMethod(DamageSystem)
private final func ApplyStatusEffectByApplicationRate(hitEvent: ref<gameHitEvent>, statType: gamedataStatType, effect: TweakDBID) -> Void {
let rand: Float;
let ss: ref<StatsSystem> = GameInstance.GetStatsSystem(hitEvent.target.GetGame());
let ses: ref<StatusEffectSystem> = GameInstance.GetStatusEffectSystem(hitEvent.target.GetGame());
let weapon: wref<WeaponObject> = hitEvent.attackData.GetWeapon();
let value: Float = ss.GetStatValue(Cast<StatsObjectID>(weapon.GetEntityID()), statType) / 100.00;
if hitEvent.target.IsPlayer() {
return;
};
if !FloatIsEqual(value, 0.00) {
rand = RandRangeF(0.00, 1.00);
if rand <= value {
if !this.IsImmune(hitEvent.target, effect, hitEvent.attackData) {
ses.ApplyStatusEffect(hitEvent.target.GetEntityID(), effect,GameObject.GetTDBID(hitEvent.attackData.GetInstigator()), hitEvent.attackData.GetInstigator().GetEntityID());
LogChannel(n"DEBUG",s"StatusEffect Applied: \(TDBID.ToStringDEBUG(effect))");
hitEvent.attackData.AddFlag(Equals(statType, gamedataStatType.StunApplicationRate) ? hitFlag.StunApplied : hitFlag.DotApplied, n"SETriggered");
};
};
};
}
@wrapMethod(DamageSystem)
private final func ProcessPipeline(hitEvent: ref<gameHitEvent>, cache: ref<CacheData>) -> Void {
let elecDmg: Float = hitEvent.attackComputed.GetAttackValue(gamedataDamageType.Electric);
let thermDmg: Float = hitEvent.attackComputed.GetAttackValue(gamedataDamageType.Thermal);
let chemDmg: Float = hitEvent.attackComputed.GetAttackValue(gamedataDamageType.Chemical);
let physDmg: Float = hitEvent.attackComputed.GetAttackValue(gamedataDamageType.Physical);
LogChannel(n"DEBUG",s"ProcessPipeline elecdmg: \(elecDmg), chemdmg: \(chemDmg), thermdmg: \(thermDmg), physdmg: \(physDmg)");
wrappedMethod(hitEvent,cache);
}Hiding (Parts of) a component when a weapon is equipped
Last updated