include library.utils; include library.create; include library.loot; trigger OnAttach() { sendSystemMessageTestingOnly( self, "orbtest script attached. Say 'GO' to start the test"); return SCRIPT_CONTINUE; } trigger OnSpeaking( string text ) { if ( text.equalsIgnoreCase("go") ) { if (utils.hasScriptVar(self,"testingOn")) { sendSystemMessageTestingOnly( self, "testing is already in progress... say 'STOP' to abort"); } else { if ( getConfigSetting("GameServer", "enableLevelUpLoot")!=null ) { sendSystemMessageTestingOnly( self, "testing in progress. Say 'STOP' to abort"); utils.setScriptVar(self,"testingOn", true); utils.setScriptVar(self,"spawnAttempts", 0); messageTo( self, "handleSpawnMob", null, 1, false ); } else { sendSystemMessageTestingOnly( self, "[GameServer] enableLevelUpLoot config not set! Testing aborted"); } } } else if ( text.equalsIgnoreCase("stop") ) { utils.removeScriptVar(self,"testingOn"); } return SCRIPT_CONTINUE; } messageHandler handleSpawnMob() { if (!utils.hasScriptVar(self,"testingOn")) { int spawnAttempts = utils.getIntScriptVar(self,"spawnAttempts"); sendSystemMessageTestingOnly( self, "testing aborted after " + (spawnAttempts*10) + " real kills"); return SCRIPT_CONTINUE; } int spawnAttempts = utils.getIntScriptVar(self,"spawnAttempts"); spawnAttempts++; utils.setScriptVar(self,"spawnAttempts", spawnAttempts); sendSystemMessageTestingOnly( self, "spawning mob " + spawnAttempts); location spawnLoc = getLocation(self); spawnLoc.x +=2; obj_id critter = create.object( "meatlump_cretin", spawnLoc ); params.put("critter",critter); messageTo( self, "handleKillCritter", params, .5f, false ); return SCRIPT_CONTINUE; } messageHandler handleKillCritter() { sendSystemMessageTestingOnly( self, "killing mob"); obj_id critter = params.getObjId( "critter" ); setHealth( critter, 0); messageTo( self, "handleCreateLoot", params, .5f, false ); return SCRIPT_CONTINUE; } messageHandler handleCreateLoot() { sendSystemMessageTestingOnly( self, "creating loot 10 times"); obj_id critter = params.getObjId( "critter" ); for ( int i = 0; i < 10; i++ ) { loot.addLoot( critter ); if (utils.hasScriptVar( critter, "orbCreated" )) break; } if ( utils.hasScriptVar( critter, "orbCreated" )) { int spawnAttempts = utils.getIntScriptVar(self,"spawnAttempts"); obj_id objOrb = utils.getObjIdScriptVar(critter, "orbCreated"); sendSystemMessageTestingOnly( self, "LEVEL UP ORB FOUND! It is Object Id "+objOrb); sendSystemMessageTestingOnly( self, "Total real kills to spawn: " + (spawnAttempts*10) ); utils.removeScriptVar(self,"testingOn"); } else { sendSystemMessageTestingOnly( self, "No orb found"); destroyObject( critter ); messageTo( self, "handleSpawnMob", null, 0, false ); } return SCRIPT_CONTINUE; }