From 9a96d0bff56f1969c68bb52a2f33296095bdc67d Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Tue, 31 Aug 2021 23:14:58 +0100 Subject: move to new mod format --- .../mod/scripts/vscripts/melee/_melee.gnut | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Northstar.CustomServers/mod/scripts/vscripts/melee/_melee.gnut (limited to 'Northstar.CustomServers/mod/scripts/vscripts/melee/_melee.gnut') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/melee/_melee.gnut b/Northstar.CustomServers/mod/scripts/vscripts/melee/_melee.gnut new file mode 100644 index 000000000..035caf9ec --- /dev/null +++ b/Northstar.CustomServers/mod/scripts/vscripts/melee/_melee.gnut @@ -0,0 +1,89 @@ +global function Melee_Init + +//global function CodeCallback_NPCMeleeChargedPlayerOrNPC +global function CodeCallback_OnMeleeKilled +global function EnablePlantingOnEntity + +void function Melee_Init() +{ + MeleeShared_Init() +} + +//File is pretty sparse for now. In all honesty a lot of existing functionality in _melee_shared should +//belong here instead, but we'll wait until we try to do prediction (which requires running the same code +//on client and server) before we try to split up functionality in the different script files any better. + +/* +void function CodeCallback_NPCMeleeChargedPlayerOrNPC( entity ent, var damageInfo ) +{ + vector damageForce = DamageInfo_GetDamageForce( damageInfo ) + + if ( DamageInfo_GetDamage( damageInfo ) > 0 ) + { + vector dmgVelocity = damageForce + dmgVelocity.z *= 0.25 + + const float maxAdditionalVelocity = 1200.0 + if ( LengthSqr( dmgVelocity ) > ( maxAdditionalVelocity * maxAdditionalVelocity ) ) + { + dmgVelocity = Normalize( dmgVelocity ) + dmgVelocity *= maxAdditionalVelocity + } + + ent.SetVelocity( ent.GetVelocity() + dmgVelocity ) + } +} +*/ + +void function CodeCallback_OnMeleeKilled( entity target ) +{ + if ( !IsAlive( target ) ) + return + + target.ClearInvulnerable() + + int damageSourceId + if ( target.IsTitan() ) + { + // I don't think this branch ever gets hit. Titan executions do something else. + damageSourceId = eDamageSourceId.titan_execution + } + else + { + damageSourceId = eDamageSourceId.human_execution + } + + entity attacker + if ( IsValid( target.e.syncedMeleeAttacker ) ) + { + attacker = target.e.syncedMeleeAttacker + } + else if ( IsValid( target.e.lastSyncedMeleeAttacker ) ) + { + attacker = target.e.lastSyncedMeleeAttacker + } + else + { + attacker = null + } + + + int damageAmount = target.GetMaxHealth() + 1 + target.TakeDamage( damageAmount , attacker, attacker, { forceKill = true, damageType = DMG_MELEE_EXECUTION, damageSourceId = damageSourceId, scriptType = DF_NO_INDICATOR } ) +} + + +void function EnablePlantingOnEntity( entity titan ) +{ + entity parentEnt = titan.GetParent() + + if ( parentEnt == null ) + return + + if ( titan.GetGroundEntity() && titan.GetGroundEntity().HasPusherRootParent() ) + return + + titan.ClearParent() + PutEntityInSafeSpot( titan, parentEnt, null, parentEnt.GetOrigin(), titan.GetOrigin() ) + titan.Anim_EnablePlanting() +} -- cgit v1.2.3