scripting:samples:dronetraining
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:samples:dronetraining [2023/05/15 15:38] – mit | scripting:samples:dronetraining [2025/05/28 18:58] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| - | Function AddGameSelectOSD() | + | |
| + | Event( " | ||
| { | { | ||
| osdcreate(OSDBUILDING," | osdcreate(OSDBUILDING," | ||
| - | osdaddat(EXITBUTTON, | + | osdadd(EXITBUTTON, |
| osdactivate() | osdactivate() | ||
| - | } | ||
| - | |||
| - | Event( " | ||
| - | { | ||
| - | AddGameSelectOSD() | ||
| } | } | ||
| </ | </ | ||
| Line 74: | Line 70: | ||
| // It uses the $gPlayerKey[WaveNum] to determine which level we're on and then the baseIndex tells us where in | // It uses the $gPlayerKey[WaveNum] to determine which level we're on and then the baseIndex tells us where in | ||
| // each ' | // each ' | ||
| + | // (Of course, we could do away with all this nonsense if the script language supported more than just integer arrays, but thats for another time :] ) | ||
| // | // | ||
| Function GetTableMinMaxVal( $baseIndex ) | Function GetTableMinMaxVal( $baseIndex ) | ||
| Line 90: | Line 87: | ||
| } | } | ||
| - | // ------------------------------- | + | |
| - | // | + | ///------------------------------------------------ |
| - | // Here we'll have some fun with entities. The calling function has worked out where to spawn a new enemy, | + | // The custom StartGame event is triggered from the game access building defined separately |
| - | // So here we calculate some of its properties and then create the actual entity | + | //------------------------------------ |
| - | //--- | + | Event( " |
| - | Function SpawnBadGuy( $xpos, $ypos ) | + | { |
| + | // Delete all entities | ||
| + | EntityDeleteAll( $gPlayerID ); | ||
| + | |||
| + | $gPlayerKey[NumEntitiesAlive] = 0 | ||
| + | $gPlayerKey[WaveNum] = 1 | ||
| + | $gPlayerKey[NumKills] = 0 | ||
| + | |||
| + | SpawnMoreBadGuys() | ||
| + | } | ||
| + | |||
| + | /// | ||
| + | // SpawnMoreBadGuys | ||
| + | // | ||
| + | // | ||
| + | //--------------------------------------------- | ||
| + | Function SpawnMoreBadGuys( ) | ||
| { | { | ||
| $waveNum = $gPlayerKey[WaveNum] | $waveNum = $gPlayerKey[WaveNum] | ||
| + | *notifylarge %PLAYER% Wave $waveNum | ||
| - | $targetLeadPercentage | + | $loop = 0 |
| - | $moveSpeed = GetTableMinMaxVal( 4 ) | + | |
| - | $moveAcc = GetTableMinMaxVal( 6 ) | + | |
| - | + | ||
| - | // Create an entity that is managed locally (i.e. is effectively just run for the one player) | + | |
| - | // with a HUNT behaviour. (This means the entity will attempt to hunt down the local player). | + | |
| - | // Note that the entity does not actually get sent to the player until we add it to the world, later in this function | + | |
| - | $mhTestEntity = EntityCreate( $gPlayerID, " | + | |
| - | // Note, currently all entity graphics need to be present in the game's main web content folder on the CDN | + | $waveTable |
| - | EntitySetModel( | + | $waveTable *= $kSizeOfWavesStruct |
| - | EntitySetPosition( $mhTestEntity, | + | $numEntitiesToSpawn |
| - | + | ||
| - | // Behaviour Control flags | + | |
| - | // FaceTarget | + | |
| - | EntitySetValue( | + | |
| - | // AttackProx = Start attacking when within the ProxRange | + | |
| - | EntitySetValue( | + | |
| - | // DieOnTargetDeath | + | |
| - | EntitySetValue( | + | |
| - | + | ||
| - | // Parameters and values | + | |
| - | // ZOffset = Vertical position offset above the ground | + | |
| - | EntitySetValue( | + | |
| - | // ProxRange | + | |
| - | EntitySetValue( | + | |
| - | $targetDist = $waveNum * 200 | + | |
| - | $targetDist | + | |
| - | // Distance from the target the entity will try to maintain | + | |
| - | EntitySetValue( $mhTestEntity, | + | |
| - | // Who the target is.. | + | |
| - | EntitySetValue( $mhTestEntity, | + | |
| - | EntitySetValue( $mhTestEntity, | + | |
| - | // Basically this sets how good the entity is at aiming | + | |
| - | EntitySetValue( $mhTestEntity, | + | |
| - | $health = $waveNum * 25 | + | while ( $loop < $numEntitiesToSpawn ) |
| - | $health += 100 | + | { |
| - | // Health = how much damage this entity can take before dieing | + | SpawnRandomHunter( 15000, 25000 ) |
| - | EntitySetValue( $mhTestEntity, " | + | |
| - | // Set Speed and acceleration (Determined by the level settings table) | + | $loop += 1 |
| - | EntitySetValue( | + | } |
| - | EntitySetValue( $mhTestEntity, | + | |
| - | + | $gPlayerKey[NumEntitiesAlive] += $numEntitiesToSpawn | |
| - | // Now all set.. add the entity to the world | + | |
| - | EntityAddToWorld( | + | |
| } | } | ||
| Line 207: | Line 188: | ||
| - | ///------------------------------------------------ | + | |
| - | // SpawnMoreBadGuys | + | // ------------------------------- |
| - | // Called at the start of each 'wave'/ | + | // |
| - | // | + | // Here we'll have some fun with entities. |
| - | //--------------------------------------------- | + | // So here we calculate some of its properties and then create the actual entity |
| - | Function SpawnMoreBadGuys( ) | + | //--- |
| + | Function SpawnBadGuy( $xpos, $ypos ) | ||
| { | { | ||
| $waveNum = $gPlayerKey[WaveNum] | $waveNum = $gPlayerKey[WaveNum] | ||
| - | *notifylarge %PLAYER% Wave $waveNum | ||
| - | $loop = 0 | + | $targetLeadPercentage |
| + | $moveSpeed = GetTableMinMaxVal( 4 ) | ||
| + | $moveAcc = GetTableMinMaxVal( 6 ) | ||
| + | |||
| + | // Create an entity that is managed locally (i.e. is effectively just run for the one player) | ||
| + | // with a HUNT behaviour. (This means the entity will attempt to hunt down the local player). | ||
| + | // Note that the entity does not actually get sent to the player until we add it to the world, later in this function | ||
| + | $mhTestEntity = EntityCreate( $gPlayerID, " | ||
| - | $waveTable | + | // Note, currently all entity graphics need to be present in the game's main web content folder on the CDN |
| - | $waveTable *= $kSizeOfWavesStruct | + | EntitySetModel( |
| - | $numEntitiesToSpawn | + | EntitySetPosition( $mhTestEntity, |
| + | |||
| + | // Behaviour Control flags | ||
| + | // FaceTarget | ||
| + | EntitySetValue( | ||
| + | // AttackProx = Start attacking when within the ProxRange | ||
| + | EntitySetValue( | ||
| + | // DieOnTargetDeath | ||
| + | EntitySetValue( | ||
| + | |||
| + | // Parameters and values | ||
| + | // ZOffset = Vertical position offset above the ground | ||
| + | EntitySetValue( | ||
| + | // ProxRange | ||
| + | EntitySetValue( | ||
| + | $targetDist = $waveNum * 200 | ||
| + | $targetDist | ||
| + | // Distance from the target the entity will try to maintain | ||
| + | EntitySetValue( $mhTestEntity, | ||
| + | // Who the target is.. | ||
| + | EntitySetValue( $mhTestEntity, | ||
| + | EntitySetValue( $mhTestEntity, | ||
| + | // Basically this sets how good the entity is at aiming | ||
| + | EntitySetValue( $mhTestEntity, | ||
| - | while ( $loop < $numEntitiesToSpawn ) | + | $health = $waveNum * 25 |
| - | { | + | $health += 100 |
| - | SpawnRandomHunter( 15000, 25000 ) | + | // Health = how much damage this entity can take before dieing |
| + | EntitySetValue( $mhTestEntity, " | ||
| - | $loop += 1 | + | // Set Speed and acceleration (Determined by the level settings table) |
| - | } | + | EntitySetValue( |
| - | + | EntitySetValue( $mhTestEntity, | |
| - | $gPlayerKey[NumEntitiesAlive] += $numEntitiesToSpawn | + | |
| + | // Now all set.. add the entity to the world | ||
| + | EntityAddToWorld( | ||
| } | } | ||
| + | |||
| + | |||
| + | |||
| /// | /// | ||
| Line 251: | Line 268: | ||
| /// | /// | ||
| // GameEnd is triggered from RobocrowDeath Event and displays final score etc | // GameEnd is triggered from RobocrowDeath Event and displays final score etc | ||
| + | |||
| + | Event (" | ||
| + | { | ||
| + | if ( $gPlayerKey[DroneGameMode] == 1 ) | ||
| + | { | ||
| + | *event %PLAYER% GameEnd | ||
| + | } | ||
| + | } | ||
| + | |||
| // | // | ||
| Event( " | Event( " | ||
| Line 274: | Line 300: | ||
| } | } | ||
| - | Event (" | ||
| - | { | ||
| - | if ( $gPlayerKey[DroneGameMode] == 1 ) | ||
| - | { | ||
| - | *event %PLAYER% GameEnd | ||
| - | } | ||
| - | } | ||
| - | |||
| - | |||
| - | /// | ||
| - | // The custom StartGame event is triggered from the game access building defined separately | ||
| - | // | ||
| - | Event( " | ||
| - | { | ||
| - | // Delete all entities for the current player | ||
| - | EntityDeleteAll( $gPlayerID ); | ||
| - | |||
| - | $gPlayerKey[NumEntitiesAlive] = 0 | ||
| - | $gPlayerKey[WaveNum] = 1 | ||
| - | $gPlayerKey[NumKills] = 0 | ||
| - | |||
| - | SpawnMoreBadGuys() | ||
| - | } | ||
| </ | </ | ||
scripting/samples/dronetraining.1684165132.txt.gz · Last modified: (external edit)
