From 207facbc402f5639cbcd31f079214351ef605cf2 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Tue, 22 Jun 2021 14:30:49 +0100 Subject: initial commit after moving to new repo --- .../scripts/vscripts/mp/_score.nut | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Northstar.CustomServers/scripts/vscripts/mp/_score.nut (limited to 'Northstar.CustomServers/scripts/vscripts/mp/_score.nut') diff --git a/Northstar.CustomServers/scripts/vscripts/mp/_score.nut b/Northstar.CustomServers/scripts/vscripts/mp/_score.nut new file mode 100644 index 000000000..b8ea6074b --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/mp/_score.nut @@ -0,0 +1,133 @@ +untyped + +global function Score_Init + +global function AddPlayerScore +global function ScoreEvent_PlayerKilled +global function ScoreEvent_TitanDoomed +global function ScoreEvent_TitanKilled +global function ScoreEvent_NPCKilled + +global function ScoreEvent_SetEarnMeterValues +global function ScoreEvent_SetupEarnMeterValuesForMixedModes + +struct { + bool firstStrikeDone = false +} file + +void function Score_Init() +{ + +} + +void function AddPlayerScore( entity targetPlayer, string scoreEventName, entity associatedEnt = null, string noideawhatthisis = "", int pointValueOverride = -1 ) +{ + ScoreEvent event = GetScoreEvent( scoreEventName ) + + if ( !event.enabled ) + return + + var associatedHandle = 0 + if ( associatedEnt != null ) + associatedHandle = associatedEnt.GetEncodedEHandle() + + if ( pointValueOverride != -1 ) + event.pointValue = pointValueOverride + + float scale = targetPlayer.IsTitan() ? event.coreMeterScalar : 1.0 + float earnValue = event.earnMeterEarnValue * scale + float ownValue = event.earnMeterOwnValue * scale + + PlayerEarnMeter_AddEarnedAndOwned( targetPlayer, earnValue * scale, ownValue * scale ) + + Remote_CallFunction_NonReplay( targetPlayer, "ServerCallback_ScoreEvent", event.eventId, event.pointValue, event.displayType, associatedHandle, ownValue, earnValue ) + + if ( event.displayType & eEventDisplayType.CALLINGCARD ) // callingcardevents are shown to all players + { + foreach ( entity player in GetPlayerArray() ) + { + if ( player == targetPlayer ) // targetplayer already gets this in the scorevent callback + continue + + Remote_CallFunction_NonReplay( player, "ServerCallback_CallingCardEvent", event.eventId, associatedHandle ) + } + } + + if ( ScoreEvent_HasConversation( event ) ) + thread Delayed_PlayConversationToPlayer( event.conversation, targetPlayer, event.conversationDelay ) +} + +void function ScoreEvent_PlayerKilled( entity victim, entity attacker, var damageInfo ) +{ + AddPlayerScore( attacker, "KillPilot", victim ) + + if ( DamageInfo_GetCustomDamageType( damageInfo ) & DF_HEADSHOT ) + AddPlayerScore( attacker, "Headshot", victim ) + + if ( !file.firstStrikeDone ) + { + file.firstStrikeDone = true + AddPlayerScore( attacker, "FirstStrike", attacker ) + } + + if ( victim.IsTitan() ) + ScoreEvent_TitanKilled( victim, attacker, damageInfo ) +} + +void function ScoreEvent_TitanDoomed( entity titan, entity attacker, var damageInfo ) +{ + // will this handle npc titans with no owners well? i have literally no idea + + if ( titan.IsNPC() ) + AddPlayerScore( attacker, "DoomAutoTitan", titan ) + else + AddPlayerScore( attacker, "DoomTitan", titan ) +} + +void function ScoreEvent_TitanKilled( entity victim, entity attacker, var damageInfo ) +{ + // will this handle npc titans with no owners well? i have literally no idea + + if ( attacker.IsTitan() ) + AddPlayerScore( attacker, "TitanKillTitan", victim.GetTitanSoul().GetOwner() ) + else + AddPlayerScore( attacker, "KillTitan", victim.GetTitanSoul().GetOwner() ) +} + +void function ScoreEvent_NPCKilled( entity victim, entity attacker, var damageInfo ) +{ + AddPlayerScore( attacker, ScoreEventForNPCKilled( victim, damageInfo ), victim ) +} + + + +void function ScoreEvent_SetEarnMeterValues( string eventName, float earned, float owned, float coreScale = 1.0 ) +{ + ScoreEvent event = GetScoreEvent( eventName ) + event.earnMeterEarnValue = earned + event.earnMeterOwnValue = owned + event.coreMeterScalar = coreScale +} + +void function ScoreEvent_SetupEarnMeterValuesForMixedModes() // mixed modes in this case means modes with both pilots and titans +{ + // todo needs earn/overdrive values + // player-controlled stuff + ScoreEvent_SetEarnMeterValues( "KillPilot", 0.0, 0.05 ) + ScoreEvent_SetEarnMeterValues( "KillTitan", 0.0, 0.15 ) + ScoreEvent_SetEarnMeterValues( "TitanKillTitan", 0.0, 0.0 ) // unsure + ScoreEvent_SetEarnMeterValues( "PilotBatteryStolen", 0.0, 0.35 ) + + // ai + ScoreEvent_SetEarnMeterValues( "KillGrunt", 0.0, 0.02, 0.5 ) + ScoreEvent_SetEarnMeterValues( "KillSpectre", 0.0, 0.02, 0.5 ) + ScoreEvent_SetEarnMeterValues( "LeechSpectre", 0.0, 0.02 ) + ScoreEvent_SetEarnMeterValues( "KillStalker", 0.0, 0.02, 0.5 ) + ScoreEvent_SetEarnMeterValues( "KillSuperSpectre", 0.0, 0.1, 0.5 ) +} + +void function ScoreEvent_SetupEarnMeterValuesForTitanModes() +{ + // todo needs earn/overdrive values + +} \ No newline at end of file -- cgit v1.2.3