Jump to content

Help with script


SamuraiOkame

Recommended Posts

Can someone tell me how to remove the quest requirement from this script so that the arena stone works all of the time

 

Scriptname aoah_ArenaStone extends ObjectReference

{Summons enemies in the Areane of Ancient Heros. }

 

 

Spell Property summonEffect Auto

FormList Property enemyFormList Auto

LeveledItem Property enemyPotion Auto

ObjectReference[] Property listOfSpawnPoints Auto

int Property spawnAtPlayerRatio = 10 Auto

int Property maxActiveEnemiesAtStart = 1 Auto

int Property maxActiveEnemiesTotal = 8 Auto

int Property enemiesPerArenaLevel = 8 Auto

bool Property levelNotificationOn = false Auto

Quest Property aoah_ArenaQuest Auto

bool Property activeForArenaQuest = false Auto

int Property arenaQuestCompleteLevel = 5 Auto

 

 

int enemiesCreatedTotal = 0

Actor[] listOfActiveEnemies

int lastWriteIndex = -1

bool arenaIsActive = false

 

 

; Initializations

Event onInit()

 

if( maxActiveEnemiesTotal > 20 )

maxActiveEnemiesTotal = 20

endIf

 

if( maxActiveEnemiesAtStart > maxActiveEnemiesTotal )

maxActiveEnemiesAtStart = maxActiveEnemiesTotal

endIf

 

listOfActiveEnemies = new Actor[ 20 ]

 

EndEvent

 

 

; Aborts the arena fight.

Function AbortArena()

 

killEnemies()

Utility.Wait(1)

deleteEnemies()

Utility.Wait(2)

arenaIsActive = false

 

EndFunction

 

 

EVENT OnActivate( ObjectReference akActionRef )

 

;if (( akActionRef == Game.GetPlayer() )||( !activeForArenaQuest ))

if( !arenaIsActive )

arenaIsActive = true

ProcessArenaActions()

arenaIsActive = false

endIf

;endIf

 

EndEVENT

 

 

; Function that processes the arena actions, like spawning and manage enemies.

Function ProcessArenaActions()

 

enemiesCreatedTotal = 0

 

int maxActiveEnemies = maxActiveEnemiesAtStart

int enemiesToCreateInThisLevel = enemiesPerArenaLevel

int arenaLevel = 1

PrintArenaLevel( arenaLevel )

 

while( arenaIsActive )

 

int activeEnemies = GetNumberOfActiveEnemies()

 

if( activeEnemies < maxActiveEnemies )

 

if( SpawnArenaEnemy( GetNextSpawnPoint(), GetActorBaseToSpawn(), GetEnemyLevelToSpawn( arenaLevel )))

 

enemiesToCreateInThisLevel -= 1

activeEnemies += 1

 

if( enemiesToCreateInThisLevel <= 0 )

 

enemiesToCreateInThisLevel = enemiesPerArenaLevel + ( arenaLevel * 2 )

 

arenaLevel += 1

PrintArenaLevel( arenaLevel )

 

if( maxActiveEnemies < maxActiveEnemiesTotal )

maxActiveEnemies += 1

endIf

 

if( activeForArenaQuest )

if( arenaLevel >= arenaQuestCompleteLevel )

if( aoah_ArenaQuest.getStage() < 1100 )

aoah_ArenaQuest.SetObjectiveCompleted(1000)

aoah_ArenaQuest.SetObjectiveDisplayed(1100)

aoah_ArenaQuest.setStage(1100)

endif

endif

endif

 

endIf

 

Utility.Wait( 0.75 * activeEnemies )

 

endIf

 

endIf

 

Utility.Wait( 0.25 )

 

endWhile

 

deleteEnemies()

 

EndFunction

 

 

; Random ActorBase from the list of possible enemies.

ActorBase Function GetActorBaseToSpawn()

return enemyFormList.getat( Utility.RandomInt( 0, enemyFormList.getSize() - 1 )) as ActorBase

EndFunction

 

 

; Spawns a new enemy.

bool Function SpawnArenaEnemy( ObjectReference spawnPoint, ActorBase enemyBase, int enemyLevel )

 

int index = GetNextFreeEnemyIndex()

if(( index >= 0 )&&( index < listOfActiveEnemies.length ))

 

Actor newEnemy = spawnPoint.PlaceActorAtMe( enemyBase, enemyLevel )

listOfActiveEnemies[ index ] = newEnemy

enemiesCreatedTotal += 1

summonEffect.Cast( newEnemy, newEnemy )

newEnemy.addItem( enemyPotion, 1, true )

Utility.Wait( 0.5 )

newEnemy.StartCombat( Game.GetPlayer() )

 

return true

 

endIf

 

return false

 

EndFunction

 

 

; Random ObjectRefernece where the next enemy spawns.

ObjectReference Function GetNextSpawnPoint()

 

if( Utility.RandomInt( 1, spawnAtPlayerRatio ) == 1 )

return Game.GetPlayer()

endIf

 

return listOfSpawnPoints[ Utility.RandomInt( 0, listOfSpawnPoints.length ) ]

 

EndFunction

 

 

; Counts the active actors in the array of enemies.

int Function GetNumberOfActiveEnemies()

 

int index = 0

int enemyAlive = 0

 

while( index < listOfActiveEnemies.length )

 

Actor enemy = listOfActiveEnemies[ index ]

index += 1

 

if( enemy.isEnabled() )

enemyAlive += 1

endIf

 

endWhile

 

;Debug.Notification( "Enemies: alive=" + enemyAlive )

 

return enemyAlive

 

EndFunction

 

 

; Gets the next free index in the array of enemies.

int Function GetNextFreeEnemyIndex()

 

int count = 0

while( count < listOfActiveEnemies.length )

count +=1

lastWriteIndex += 1

if( lastWriteIndex >= listOfActiveEnemies.length )

lastWriteIndex = 0

endIf

if( !listOfActiveEnemies[ lastWriteIndex ].isEnabled() )

return lastWriteIndex

endIf

endWhile

return -1

 

EndFunction

 

 

; Creates a random level for the enemy to be created.

; 2% boss, 10% hard, 43% medium, 45% easy.

; Limited by arena level, to prevent too hard enemies at the beginning.

int Function GetEnemyLevelToSpawn( int arenaLevel )

 

int bossLevel = 3

int hardLevel = 2

int mediumLevel = 1

int easyLevel = 0

int randomNumber = Utility.RandomInt( 0, 99 )

 

int spawnLevel = easyLevel

 

if( randomNumber < 2 )

spawnLevel = bossLevel

elseif ( randomNumber < 12 )

spawnLevel = hardLevel

elseif ( randomNumber < 55 )

spawnLevel = mediumLevel

else

spawnLevel = easyLevel

endIf

 

if( spawnLevel >= arenaLevel )

spawnLevel = arenaLevel - 1

endIf

if( spawnLevel < 0 )

spawnLevel = 0

endIf

 

return spawnLevel

 

EndFunction

 

 

; Deletes the arena enemies.

Function DeleteEnemies()

 

int index = 0

while( index < listOfActiveEnemies.length )

listOfActiveEnemies[ index ].Delete()

index += 1

endWhile

enemiesCreatedTotal = 0

 

EndFunction

 

 

; Kills the arena enemies.

Function KillEnemies()

 

int index = 0

while( index < listOfActiveEnemies.length )

listOfActiveEnemies[ index ].Kill()

index += 1

endWhile

 

EndFunction

 

 

; Notification of the current arena level.

Function PrintArenaLevel( int level )

 

if( levelNotificationOn )

 

if( level <= 1 )

Debug.Notification( "Arena level " + level + ": Novice" )

elseIf( level == 2 )

Debug.Notification( "Arena level " + level + ": Apprentice" )

elseIf( level == 3 )

Debug.Notification( "Arena level " + level + ": Adept" )

elseIf( level == 4 )

Debug.Notification( "Arena level " + level + ": Expert" )

elseIf( level == 5 )

Debug.Notification( "Arena level " + level + ": Master" )

elseIf( level == 6 )

Debug.Notification( "Arena level " + level + ": Angle of Death" )

else

Debug.Notification( "Arena level " + level + ": God of War" )

endIf

 

endIf

 

EndFunction

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...