diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-06-22 14:30:49 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-06-22 14:30:49 +0100 |
commit | 207facbc402f5639cbcd31f079214351ef605cf2 (patch) | |
tree | 4710b2a88dd64f3dfea1609d31a5de9141640951 /Northstar.CustomServers/scripts/vscripts/class | |
parent | c2d438568df6d98cf731807e30eaa7da31e5ea52 (diff) | |
download | NorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.tar.gz NorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.zip |
initial commit after moving to new repo
Diffstat (limited to 'Northstar.CustomServers/scripts/vscripts/class')
6 files changed, 949 insertions, 0 deletions
diff --git a/Northstar.CustomServers/scripts/vscripts/class/CHardPointEntity.nut b/Northstar.CustomServers/scripts/vscripts/class/CHardPointEntity.nut new file mode 100644 index 00000000..4eb97955 --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/CHardPointEntity.nut @@ -0,0 +1,15 @@ +untyped + +global function CodeCallback_RegisterClass_C_HardPointEntity + +function CodeCallback_RegisterClass_C_HardPointEntity() +{ + /*C_HardPointEntity.ClassName <- "C_HardPointEntity" + + + function C_HardPointEntity::Enabled() + { + return this.GetHardpointID() >= 0 + } + #document( "C_HardPointEntity::Enabled", "Returns true if this hardpoint is enabled" )*/ +} diff --git a/Northstar.CustomServers/scripts/vscripts/class/cai_basenpc.nut b/Northstar.CustomServers/scripts/vscripts/class/cai_basenpc.nut new file mode 100644 index 00000000..631e01fc --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/cai_basenpc.nut @@ -0,0 +1,272 @@ +untyped + +global function IsCrawling +global function CodeCallback_RegisterClass_CAI_BaseNPC +global function SetSpawnOption_AISettings +global function SetSpawnOption_Alert +global function SetSpawnOption_NotAlert +global function SetSpawnOption_Ordnance +global function SetSpawnOption_OwnerPlayer +global function SetSpawnOption_Sidearm +global function SetSpawnOption_SquadName +global function SetSpawnOption_Special +global function SetSpawnOption_Melee +global function SetSpawnOption_CoreAbility +global function SetSpawnOption_Antirodeo +global function SetSpawnOption_Titanfall +global function SetSpawnOption_TitanSoulPassive1 +global function SetSpawnOption_TitanSoulPassive2 +global function SetSpawnOption_TitanSoulPassive3 +global function SetSpawnOption_TitanSoulPassive4 +global function SetSpawnOption_TitanSoulPassive5 +global function SetSpawnOption_TitanSoulPassive6 +global function SetSpawnOption_Warpfall +global function SetSpawnOption_Weapon +global function SetSpawnOption_NPCTitan +global function SetSpawnOption_TitanLoadout + +function CodeCallback_RegisterClass_CAI_BaseNPC() +{ + #document( "SetSpawnOption_AISettings", "Specify AI Setting" ) + #document( "SetSpawnOption_Alert", "Enable spawn alerted" ) + #document( "SetSpawnOption_NotAlert", "Enable spawn alerted" ) + #document( "SetSpawnOption_Ordnance", "Specify spawn ordnance" ) + #document( "SetSpawnOption_OwnerPlayer", "This titan will be the auto titan of this player" ) + #document( "SetSpawnOption_SquadName", "Specify spawn squadname" ) + #document( "SetSpawnOption_Special", "Specify spawn tactical ability" ) + #document( "SetSpawnOption_Titanfall", "npc titan will spawn via titanfall" ) + #document( "SetSpawnOption_TitanSoulPassive1", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_TitanSoulPassive2", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_TitanSoulPassive3", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_TitanSoulPassive4", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_TitanSoulPassive5", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_TitanSoulPassive6", "Set this passive on the titan soul" ) + #document( "SetSpawnOption_Warpfall", "Titan or super spectre will spawn via warpsfall" ) + #document( "SetSpawnOption_Weapon", "Specify spawn weapon and mods" ) + #document( "SetSpawnOption_NPCTitan", "Spawn titan of type" ) + + + //printl( "Class Script: CAI_BaseNPC" ) + + CAI_BaseNPC.ClassName <- "CAI_BaseNPC" + CAI_BaseNPC.supportsXRay <- null + + CAI_BaseNPC.mySpawnOptions_aiSettings <- null + CAI_BaseNPC.mySpawnOptions_alert <- null + CAI_BaseNPC.mySpawnOptions_sidearm <- null + CAI_BaseNPC.mySpawnOptions_titanfallSpawn <- null + CAI_BaseNPC.mySpawnOptions_warpfallSpawn <- null + CAI_BaseNPC.mySpawnOptions_routeTD <- null + CAI_BaseNPC.mySpawnOptions_ownerPlayer <- null + CAI_BaseNPC.executedSpawnOptions <- null + + function CAI_BaseNPC::HasXRaySupport() + { + return ( this.supportsXRay != null ) + } + + function CAI_BaseNPC::ForceCombat() + { + this.FireNow( "UpdateEnemyMemory", "!player" ) + } + #document( CAI_BaseNPC, "ForceCombat", "Force into combat state by updating NPC's memory of the player." ) + + function CAI_BaseNPC::InCombat() + { + entity enemy = expect entity( this ).GetEnemy() + if ( !IsValid( enemy ) ) + return false + + return this.CanSee( enemy ) + } + #document( CAI_BaseNPC, "InCombat", "Returns true if NPC is in combat" ) +} + + + +function SetSpawnOption_AISettings( entity npc, setting ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.mySpawnOptions_aiSettings = setting +} + +function SetSpawnOption_Alert( entity npc ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.mySpawnOptions_alert = true +} + +function SetSpawnOption_NotAlert( entity npc ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.mySpawnOptions_alert = false +} + +void function SetSpawnOption_Weapon( entity npc, string weapon, array<string> mods = [] ) +{ + Assert( weapon != "", "Tried to assign no weapon as a spawn weapon" ) + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + + if ( npc.IsTitan() ) + { + npc.ai.titanSpawnLoadout.primary = weapon + npc.ai.titanSpawnLoadout.primaryMods = mods + } + else + { + NPCDefaultWeapon spawnoptionsweapon + spawnoptionsweapon.wep = weapon + spawnoptionsweapon.mods = mods + + npc.ai.mySpawnOptions_weapon = spawnoptionsweapon + } +} + +void function SetSpawnOption_Sidearm( entity npc, string weapon, array<string> mods = []) +{ + Assert( weapon != "", "Tried to assign no weapon as a spawn weapon" ) + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + + if ( !npc.IsTitan() ) + npc.mySpawnOptions_sidearm = { wep = weapon, mods = mods } +} + +void function SetSpawnOption_Ordnance( entity npc, string ordnance, array<string> mods = [] ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.ordnance = ordnance + npc.ai.titanSpawnLoadout.ordnanceMods = mods +} + +void function SetSpawnOption_Special( entity npc, string special, array<string> mods = [] ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.special = special + npc.ai.titanSpawnLoadout.specialMods = mods +} + +void function SetSpawnOption_Antirodeo( entity npc, string antirodeo, array<string> mods = [] ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.antirodeo = antirodeo + npc.ai.titanSpawnLoadout.antirodeoMods = mods +} + +void function SetSpawnOption_Melee( entity npc, string melee ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.melee = melee +} + +void function SetSpawnOption_CoreAbility( entity npc, string core ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.coreAbility = core +} + +function SetSpawnOption_SquadName( entity npc, squadName ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.kv.squadname = squadName +} + +function SetSpawnOption_Titanfall( entity npc ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + Assert( npc.IsTitan(), "npc is for titans only" ) + npc.mySpawnOptions_titanfallSpawn = true +} + +function SetSpawnOption_Warpfall( entity npc ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + Assert( npc.IsTitan() || npc.GetClassName() == "npc_super_spectre", "npc is for titans and superspectres only" ) + npc.mySpawnOptions_warpfallSpawn = true +} + +function SetSpawnOption_OwnerPlayer( entity npc, entity player ) +{ + Assert( IsValid( player ) ) + Assert( player.IsPlayer() ) + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.mySpawnOptions_ownerPlayer = player +} + +function SetSpawnOption_TitanSoulPassive1( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive1 = passive +} + +function SetSpawnOption_TitanSoulPassive2( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive2 = passive +} + +function SetSpawnOption_TitanSoulPassive3( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive3 = passive +} + +function SetSpawnOption_TitanSoulPassive4( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive4 = passive +} + +function SetSpawnOption_TitanSoulPassive5( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive5 = passive +} + +function SetSpawnOption_TitanSoulPassive6( entity npc, string passive ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout.passive6 = passive +} + +function SetSpawnOption_NPCTitan( entity npc, int type ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( npc.IsTitan(), npc + " is not a Titan!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.bossTitanType = type +} + + +function SetSpawnOption_TitanLoadout( entity npc, TitanLoadoutDef loadout ) +{ + Assert( IsValid( npc ) && npc.IsNPC(), npc + " is not an npc!" ) + Assert( npc.IsTitan(), npc + " is not a Titan!" ) + Assert( !npc.executedSpawnOptions, npc + " tried to set spawn options after npc was dispatchspawned." ) + npc.ai.titanSpawnLoadout = loadout +} + +bool function IsCrawling( entity npc ) +{ + return npc.ai.crawling +} + diff --git a/Northstar.CustomServers/scripts/vscripts/class/cbasecombatcharacter.nut b/Northstar.CustomServers/scripts/vscripts/class/cbasecombatcharacter.nut new file mode 100644 index 00000000..11018cea --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/cbasecombatcharacter.nut @@ -0,0 +1,28 @@ +untyped + +global function CodeCallback_RegisterClass_CBaseCombatCharacter + +function CodeCallback_RegisterClass_CBaseCombatCharacter() +{ + CBaseCombatCharacter.ClassName <- "CBaseCombatCharacter" + + RegisterSignal( "ContextAction_SetBusy" ) // signalled from ContextAction_SetBusy() in code + + + /* + CBaseCombatCharacter.__SetActiveWeaponByName <- CBaseCombatCharacter.SetActiveWeaponByName + function CBaseCombatCharacter::SetActiveWeaponByName( weapon ) + { + printt( "set active weapon " + weapon + " for " + this ) + return this.__SetActiveWeaponByName( weapon ) + } + + CBaseCombatCharacter.__TakeWeapon <- CBaseCombatCharacter.TakeWeapon + function CBaseCombatCharacter::TakeWeapon( weapon ) + { + // printt( "Take weapon " + weapon + " from " + this ) + return this.__TakeWeapon( weapon ) + } + + */ +} diff --git a/Northstar.CustomServers/scripts/vscripts/class/cbaseentity.nut b/Northstar.CustomServers/scripts/vscripts/class/cbaseentity.nut new file mode 100644 index 00000000..08d2b2e1 --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/cbaseentity.nut @@ -0,0 +1,229 @@ +untyped + +global function CodeCallback_RegisterClass_CBaseEntity + +//========================================================= +// CBaseEntity +// Properties and methods added here can be accessed on all script entities +//========================================================= + +#if DEV +table __scriptVarDelegate = {} +#endif + +function CodeCallback_RegisterClass_CBaseEntity() +{ + //printl( "Class Script: CBaseEntity" ) + + CBaseEntity.ClassName <- "CBaseEntity" + + // Script variables; initializing these to something other than "null" will cause them to be treated as a + // static variable on the class instead of a unique variable on each instance. + CBaseEntity.s <- null + + CBaseEntity.funcsByString <- null + + CBaseEntity.useFunction <- null // should match on server/client + + CBaseEntity._entityVars <- null + + CBaseEntity.invulnerable <- 0 + + // this replacement could just be made in the scripts where this call happens, + // but there's too many for me to replace right now + CBaseEntity.__KeyValueFromString <- CBaseEntity.SetValueForKey + CBaseEntity.__KeyValueFromInt <- CBaseEntity.SetValueForKey + + function CBaseEntity::constructor() + { + #if DEV + this.s = delegate __scriptVarDelegate : {} + #else + this.s = {} + #endif + + this.useFunction = UseReturnTrue // default use function + + this.funcsByString = {} + } + + #if DEV + function __scriptVarDelegate::_typeof() + { + return "ScriptVariableTable" + } + + disableoverwrite( __scriptVarDelegate ) + #endif + + /* + Do not delete, thanks. + + CBaseEntity.__SetOrigin <- CBaseEntity.SetOrigin + function CBaseEntity::SetOrigin( origin ) + { + if ( this.GetTargetName() == "xauto_1" ) + { + printl( "\n\n" ) + DumpStack() + } + this.__SetOrigin( origin ) + } + */ + + function CBaseEntity::_typeof() + { + return format( "[%d] %s: %s", this.entindex(), this.GetClassName(), this.GetTargetName() ) + } + + function CBaseEntity::Get( val ) + { + return this.GetValueForKey( val ) + } + + function CBaseEntity::Set( key, val ) + { + return this.SetValueForKey( key, val ) + } + + // This exists in code too and is only here for untyped entity variables + function CBaseEntity::WaitSignal( signalID ) + { + return WaitSignal( this, signalID ) + } + + // This exists in code too and is only here for untyped entity variables + function CBaseEntity::EndSignal( signalID ) + { + EndSignal( this, signalID ) + } + + // This exists in code too and is only here for untyped entity variables + function CBaseEntity::Signal( signalID, results = null ) + { + Signal( this, signalID, results ) + } + + function CBaseEntity::DisableDraw() + { + this.FireNow( "DisableDraw" ) + } + #document( "CBaseEntity::DisableDraw", "consider this the mega hide" ) + + function CBaseEntity::EnableDraw() + { + this.FireNow( "EnableDraw" ) + } + #document( "CBaseEntity::EnableDraw", "its back!" ) + + + // -------------------------------------------------------- + function CBaseEntity::Kill_Deprecated_UseDestroyInstead( time = 0 ) + { + EntFireByHandle( this, "kill", "", time, null, null ) + } + #document( "CBaseEntity::Kill_Deprecated_UseDestroyInstead", "Kill this entity: this function is deprecated because it has a one-frame delay; instead, call ent.Destroy()" ) + + // -------------------------------------------------------- + function CBaseEntity::Fire( output, param = "", delay = 0, activator = null, caller = null ) + { + Assert( type( output ) == "string", "output type " + type( output ) + " is not a string" ) + EntFireByHandle( this, output, string( param ), delay, activator, caller ) + } + #document( "CBaseEntity::Fire", "Fire an output on this entity, with optional parm and delay" ) + + function CBaseEntity::FireNow( output, param = "", activator = null, caller = null ) + { + Assert( type( output ) == "string" ) + EntFireByHandleNow( this, output, string( param ), activator, caller ) + } + #document( "CBaseEntity::FireNow", "Fire an output on this entity, with optional parm and delay (synchronous)" ) + + // -------------------------------------------------------- + function CBaseEntity::AddOutput( outputName, target, inputName, parameter = "", delay = 0, maxFires = 0 ) + { + local targetName = target + + if ( type( target ) != "string" ) + { + Assert( type( target ) == "instance" ) + targetName = target.GetTargetName() + Assert( targetName.len(), "AddOutput: targetted entity must have a name!" ) + } + Assert( targetName.len(), "Attemped to AddOutput on an unnamed target" ) + + local addOutputString = outputName + " " + targetName + ":" + inputName + ":" + parameter + ":" + delay + ":" + maxFires + //printl(" Added output string: " + addOutputString ) + + EntFireByHandle( this, "AddOutput", addOutputString, 0, null, null ) + } + #document( "CBaseEntity::AddOutput", "Connects an output on this entity to an input on another entity via code. The \"target\" can be a name or a named entity." ) + + /* + function MoveTo() + */ + + function CBaseEntity::MoveTo( dest, time, easeIn = 0, easeOut = 0 ) + { + if ( this.GetClassName() == "script_mover" ) + { + this.NonPhysicsMoveTo( dest, time, easeIn, easeOut ) + } + else + { + this.SetOrigin( dest ) + CodeWarning( "Used moveto on non script_mover: " + this.GetClassName() + ", " + this ) + } + } + #document( "CBaseEntity::MoveTo", "Move to the specified origin over time with ease in and ease out." ) + + /* + function RotateTo() + */ + + function CBaseEntity::RotateTo( dest, time, easeIn = 0, easeOut = 0 ) + { + if ( this.GetClassName() == "script_mover" ) + { + this.NonPhysicsRotateTo( dest, time, easeIn, easeOut ) + } + else + { + this.SetAngles( dest ) + CodeWarning( "Used rotateto on non script_mover: " + this.GetClassName() + ", " + this ) + } + } + #document( "CBaseEntity::RotateTo", "Rotate to the specified angles over time with ease in and ease out." ) + + function CBaseEntity::AddVar( varname, value ) + { + Assert( !( varname in this.s ), "Tried to add variable to " + this + " that already existed: " + varname ) + + this.s[ varname ] <- value + } + + function CBaseEntity::CreateStringForFunction( func ) + { + // this is a general purpose function that returns a string which, when executed, + // runs the given function on this entity. + // the function must be called (or the entity deleted) at some point to avoid leaking the new slot we make in this Table. + + Assert( type( func ) == "function" ) + + string newGuid = UniqueString() + this.funcsByString[newGuid] <- func + + return "_RunFunctionByString( \"" + newGuid + "\" )" + } + + function _RunFunctionByString( guid ) + { + local activator = this.activator + Assert( activator.funcsByString[guid] ) + + local func = activator.funcsByString[guid].bindenv( activator.scope() ) + delete activator.funcsByString[guid] + + func() + } +} diff --git a/Northstar.CustomServers/scripts/vscripts/class/cplayer.nut b/Northstar.CustomServers/scripts/vscripts/class/cplayer.nut new file mode 100644 index 00000000..b9f8f7eb --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/cplayer.nut @@ -0,0 +1,355 @@ +untyped + + +global function CodeCallback_RegisterClass_CPlayer +global function PlayerDropsScriptedItems +global function IsDemigod +global function EnableDemigod +global function DisableDemigod + +int __nextInputHandle = 0 + + +global struct PlayerSlowDownEffect +{ + float slowEndTime + float speedCap // max speed multiplier if this slow effect is active +} + +function CodeCallback_RegisterClass_CPlayer() +{ + //printl( "Class Script: CPlayer" ) + + CPlayer.ClassName <- "CPlayer" + CPlayer.hasSpawned <- null + CPlayer.hasConnected <- null + CPlayer.isSpawning <- null + CPlayer.isSpawningHotDroppingAsTitan <- false + CPlayer.disableWeaponSlots <- false + CPlayer.supportsXRay <- null + + CPlayer.lastTitanTime <- 0 + + CPlayer.globalHint <- null + CPlayer.playerClassData <- null + CPlayer.escalation <- null + CPlayer.pilotAbility <- null + CPlayer.titansBuilt <- 0 + CPlayer.spawnTime <- 0 + CPlayer.serverFlags <- 0 + CPlayer.watchingKillreplayEndTime <- 0.0 + CPlayer.cloakedForever <- false + CPlayer.stimmedForever <- false + + RegisterSignal( "OnRespawnPlayer" ) + RegisterSignal( "NewViewAnimEntity" ) + RegisterSignal( "PlayerDisconnected" ) + + function CPlayer::constructor() + { + CBaseEntity.constructor() + } + + function CPlayer::RespawnPlayer( ent ) + { + this.Signal( "OnRespawnPlayer", { ent = ent } ) + + // hack. Players should clear all these on spawn. + this.ViewOffsetEntity_Clear() + ClearPlayerAnimViewEntity( expect entity( this ) ) + this.spawnTime = Time() + + this.ClearReplayDelay() + this.ClearViewEntity() + + // titan melee can set these vars, and they need to clear on respawn: + this.SetOwner( null ) + this.kv.VisibilityFlags = ENTITY_VISIBLE_TO_EVERYONE + + + Assert( !this.GetParent(), this + " should not have a parent yet! - Parent: " + this.GetParent() ) + Assert( this.s.respawnCount <= 1 || IsMultiplayer(), "Tried to respawn in single player, see callstack" ) + this.Code_RespawnPlayer( ent ) + } + + /* + CPlayer.__SetTrackEntity <- CPlayer.SetTrackEntity + function CPlayer::SetTrackEntity( ent ) + { + printl( "\nTime " + Time() + " Ent " + ent ) + + DumpStack() + this.__SetTrackEntity( ent ) + } + */ + + function CPlayer::GetDropEntForPoint( origin ) + { + return null + } + + + function CPlayer::GetPlayerClassData( myClass ) + { + Assert( myClass in this.playerClassData, myClass + " not in playerClassData" ) + return this.playerClassData[ myClass ] + } + + + function CPlayer::InitMPClasses() + { + this.playerClassData = {} + + Titan_AddPlayer( this ) + Wallrun_AddPlayer( this ) + } + + + function CPlayer::InitSPClasses() + { + this.playerClassData = {} + SetTargetName( expect entity( this ), expect string( this.GetTargetName() + this.entindex() ) ) + + Titan_AddPlayer( this ) + } + + + // function SpawnAsClass() + function CPlayer::SpawnAsClass( className = null ) + { + if ( !className ) + { + className = this.GetPlayerClass() + } + + switch ( className ) + { + case level.pilotClass: + Wallrun_OnPlayerSpawn( this ) + break + + default: + Assert( 0, "Tried to spawn as unsupported " + className ) + } + } + + + function CPlayer::GiveScriptWeapon( weaponName, equipSlot = null ) + { + this.scope().GiveScriptWeapon( weaponName, equipSlot ) + } + + function CPlayer::OnDeathAsClass( damageInfo ) + { + switch ( this.GetPlayerClass() ) + { + case "titan": + Titan_OnPlayerDeath( expect entity( this ), damageInfo ) + break + + case level.pilotClass: + Wallrun_OnPlayerDeath( expect entity( this ), damageInfo ) + break + } + } + + function CPlayer::Disconnected() + { + this.Signal( "_disconnectedInternal" ) + svGlobal.levelEnt.Signal( "PlayerDisconnected" ) + + if ( HasSoul( expect entity( this ) ) ) + { + thread SoulDies( expect entity( this ).GetTitanSoul(), null ) + } + + entity titan = GetPlayerTitanInMap( expect entity( this ) ) + if ( IsAlive( titan ) && titan.IsNPC() ) + { + local soul = titan.GetTitanSoul() + if ( IsValid( soul ) && soul.followOnly ) + FreeAutoTitan( titan ) + else + titan.Die( null, null, { damageSourceId = eDamageSourceId.damagedef_suicide } ) + // titan.Die() + } + + PROTO_CleanupTrackedProjectiles( expect entity( this ) ) + + if ( this.globalHint != null ) + { + this.globalHint.Kill_Deprecated_UseDestroyInstead() + this.globalHint = null + } + } + + + function CPlayer::GetClassDataEnts() + { + local ents = [] + local added + + if ( this.playerClassData == null ) + return ents; + + foreach ( ent in this.playerClassData ) + { + added = false + + foreach ( newent in ents ) + { + if ( newent == ent ) + { + added = true + break + } + } + + if ( !added ) + ents.append( ent ) + } + + return ents + } + + + function CPlayer::CleanupMPClasses() + { + } + + function CPlayer::HasXRaySupport() + { + return ( this.supportsXRay != null ) + } + + function CPlayer::GiveExtraWeaponMod( mod ) + { + if ( this.HasExtraWeaponMod( mod ) ) + return + + local mods = this.GetExtraWeaponMods() + mods.append( mod ) + + this.SetExtraWeaponMods( mods ) + } + + + function CPlayer::HasExtraWeaponMod( mod ) + { + local mods = this.GetExtraWeaponMods() + foreach( _mod in mods ) + { + if ( _mod == mod ) + return true + } + return false + } + + + function CPlayer::TakeExtraWeaponMod( mod ) + { + if ( !this.HasExtraWeaponMod( mod ) ) + return + + local mods = this.GetExtraWeaponMods() + mods.fastremovebyvalue( mod ) + + this.SetExtraWeaponMods( mods ) + } + + function CPlayer::ClearExtraWeaponMods() + { + this.SetExtraWeaponMods( [] ) + } + + + function CPlayer::SetPlayerPilotSettings( settingsName ) + { + this.SetPlayerRequestedSettings( settingsName ) + } + + function CPlayer::RecordLastMatchContribution( contribution ) + { + // replace with code function + } + + function CPlayer::RecordLastMatchPerformance( matchPerformance ) + { + // replace with code function + } + + function CPlayer::RecordSkill( skill ) + { + // replace with code function + this.SetPersistentVar( "ranked.recordedSkill", skill ) + } + + function CPlayer::SetPlayerSettings( settings ) + { + local oldPlayerClass = CPlayer.GetPlayerClass() + + CPlayer.SetPlayerSettingsWithMods( settings, [] ) + + this.RunSettingsChangedFuncs( settings, oldPlayerClass ) + } + + function CPlayer::SetPlayerSettingsFromDataTable( pilotDataTable ) + { + local oldPlayerClass = CPlayer.GetPlayerClass() + + local settings = pilotDataTable.playerSetFile + + local mods = pilotDataTable.playerSetFileMods + + this.SetPlayerSettingsWithMods( settings, mods ) + + this.RunSettingsChangedFuncs( settings, oldPlayerClass ) + } + + function CPlayer::RunSettingsChangedFuncs( settings, oldPlayerClass ) + { + if ( IsAlive( expect entity( this ) ) && !this.IsTitan() && GetCurrentPlaylistVarFloat( "pilot_health_multiplier", 0.0 ) != 0.0 ) + { + float pilotHealthMultiplier = GetCurrentPlaylistVarFloat( "pilot_health_multiplier", 1.0 ) + int pilotMaxHealth = int( this.GetMaxHealth() * pilotHealthMultiplier ) + this.SetMaxHealth( pilotMaxHealth ) + this.SetHealth( pilotMaxHealth ) + } + + if ( this.IsTitan() ) + { + entity soul = expect entity ( this.GetTitanSoul() ) + local index = PlayerSettingsNameToIndex( settings ) + soul.SetPlayerSettingsNum( index ) + + foreach ( func in svGlobal.soulSettingsChangeFuncs ) + { + func( soul ) + } + } + } +} + +void function PlayerDropsScriptedItems( entity player ) +{ + foreach ( callbackFunc in svGlobal.onPlayerDropsScriptedItemsCallbacks ) + callbackFunc( player ) +} + +bool function IsDemigod( entity player ) +{ + return player.p.demigod +} + +void function EnableDemigod( entity player ) +{ + Assert( player.IsPlayer() ) + player.p.demigod = true +} + +void function DisableDemigod( entity player ) +{ + Assert( player.IsPlayer() ) + player.p.demigod = false +} + diff --git a/Northstar.CustomServers/scripts/vscripts/class/ctitansoul.nut b/Northstar.CustomServers/scripts/vscripts/class/ctitansoul.nut new file mode 100644 index 00000000..6f5ddb3e --- /dev/null +++ b/Northstar.CustomServers/scripts/vscripts/class/ctitansoul.nut @@ -0,0 +1,50 @@ +untyped + +global function CodeCallback_RegisterClass_CTitanSoul + +function CodeCallback_RegisterClass_CTitanSoul() +{ + CTitanSoul.ClassName <- "CTitanSoul" + + // all soul-specific vars should be created here + CTitanSoul.lastAttackInfo <- null + CTitanSoul.hijackProgress <- null + CTitanSoul.lastHijackTime <- null + CTitanSoul.capturable <- null + CTitanSoul.followOnly <- null + CTitanSoul.passives <- null + CTitanSoul.createTime <- null + CTitanSoul.rodeoRiderTracker <- null + CTitanSoul.doomedTime <- null + CTitanSoul.nextRegenTime <- 0.0 + CTitanSoul.nextHealthRegenTime <- 0.0 + CTitanSoul.rodeoReservedSlots <- null + + // the functions below should not change + + function CTitanSoul::constructor() + { + CBaseEntity.constructor() + + this.lastAttackInfo = { time = 0 } + this.passives = arrayofsize( GetNumPassives(), false ) + this.createTime = Time() + this.doomedTime = null + this.rodeoRiderTracker = {} // all players that rode this titan, so they cant get multiple score events + this.capturable = false + this.followOnly = false + this.rodeoReservedSlots = arrayofsize( PROTOTYPE_DEFAULT_TITAN_RODEO_SLOTS, null ) //hardcoded 3 slots for now! + } + + + // function SoulDeath() + function CTitanSoul::SoulDestroy() + { + // transfer the soul away from the last owner + entity titan = expect entity( this.GetTitan() ) + foreach ( func in svGlobal.soulTransferFuncs ) + { + func( expect entity( this ), null, titan ) + } + } +} |