aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/melee/_melee.gnut
blob: 035caf9ec2eeac5ca0d3560722e89c3a0b0a0e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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()
}