//This library contains functions used to spawn events #include "quest_inc" //Define constants const int ENCOUNTER_TYPE_MINIBOSS = 1; const int ENCOUNTER_TYPE_FEW = 2; const int ENCOUNTER_TYPE_NORMAL = 3; const int ENCOUNTER_TYPE_MANY = 4; const int CREATURE_CLASS_NOBOOST = 0; const int CREATURE_CLASS_FIGHTER = 1; const int CREATURE_CLASS_CLERIC = 2; const int CREATURE_CLASS_MONSTER = 3; //Selects enemies possible to encounter and saves them on PC in strings: "sEnemyX" with X from 1 to 6 and "sAddX" with X from 1 to 4 void SelectEnemies(string sRegionString, int nLevel, object oPC, int nEncounterType); //Deletes enemy string variables created with the SelectEnemies() function void DeleteEnemyVar(object oPC); //Levels up a suitable creature and gives bonuses according to CREATURE_CLASS_* void LevelCreature(object oCreature, int nLevel, int nCreatureClass); //Adds special creature properties, such as werewolf night bonuses void AddSpecialCreatureProperties(object oCreature, int nLevel); //Spawns an event with a stored quest adventurer seeking revenge - there should be an external check to see if the PC has any NPCs stored void SpawnNemesisEvent(object oPC); //Spawns an event with a lost traveller asking for help void SpawnEscortEvent(object oPC); //Spawns an event with thugs demanding a tribute for passage void SpawnTributeEvent(object oPC); //Spawns an event with an ambush of regular enemies void SpawnAmbushEvent(object oPC); //Spawns an event with a famous adventurer void SpawnAdventurerEvent(object oPC); //Spawns an event with a demon invasion void SpawnDemonEvent(object oPC); //Spawns an event with a bullied merchant void SpawnBulliedEvent(object oPC); //Spawn an event with a travelling merchant void SpawnMerchantEvent(object oPC); //Spawn an event with a boss monster void SpawnBossEvent(object oPC); //Spawn an event with a friendly creature void SpawnFriendlyEvent(object oPC); //Spawn treasure suitable for a given PC in the inventory of the oObject void SpawnTreasure(object oPC, object oObject); //Spawn a chest, fill it with appropriate treasure and make it randomly locked/trapped/both object SpawnTreasureChest(object oPC, object oWaypoint); //Finish the event with a lost traveller asking for help - should be used in an OnEnter event of town areas void EndEscortEvent(object oPC); void SelectEnemies(string sRegionString, int nLevel, object oPC, int nEncounterType) { //Declare resref string variables string sEnemy1; string sEnemy2; string sEnemy3; string sEnemy4; string sEnemy5; string sEnemy6; string sAdd1; string sAdd2; string sAdd3; string sAdd4; //If the region is Green Coast (1) if (sRegionString == "1") { if (nLevel == 0) { sEnemy1 = "anc_rat"; //Rat } if (nLevel == 1) { sEnemy1 = "anc_goblin"; //Goblin (melee) sEnemy2 = "anc_goblinb"; //Goblin (ranged) } if (nLevel == 2) { if (Random(2) == 0) sEnemy1 = "anc_wolf"; //Wolf else { sEnemy1 = "anc_bandit"; //Bandit sEnemy2 = "anc_banditr"; //Bandit rogue sEnemy3 = "anc_bandita"; //Bandit archer } } if (nLevel == 3) { if (Random(3) == 0) { sEnemy1 = "anc_wererat"; //Wererat } else if (Random(2) == 0) { sEnemy1 = "anc_blackbear"; //Black bear sEnemy2 = "anc_boar"; //Boar } else { sEnemy1 = "anc_banditc"; //Bandit cleric sAdd1 = "anc_bandit"; //Bandit sAdd2 = "anc_banditr"; //Bandit rogue sAdd3 = "anc_bandita"; //Bandit archer } } if (nLevel == 4) { if (Random(3) == 0) { sEnemy1 = "anc_goblinelite"; //Goblin elite sEnemy2 = "anc_goblinshaman"; //Goblin shaman sEnemy3 = "anc_worg"; //Worg sAdd1 = "anc_goblin"; //Goblin (melee) sAdd2 = "anc_goblinb"; //Goblin (ranged) } else if (Random(2) == 0) { sEnemy1 = "anc_banditmage"; //Bandit mage sAdd1 = "anc_bandit"; //Bandit sAdd2 = "anc_banditr"; //Bandit rogue sAdd3 = "anc_bandita"; //Bandit archer sAdd4 = "anc_banditc"; //Bandit cleric } else { sEnemy1 = "anc_stinkbeetle"; //Stink beetle sAdd1 = "anc_blackbear"; //Black bear sAdd2 = "anc_boar"; //Boar } } if (nLevel == 5) { if (Random(2) == 0) { sEnemy1 = "anc_goblinrider"; //Goblin rider sAdd1 = "anc_goblinelite"; //Goblin elite sAdd2 = "anc_goblinshaman"; //Goblin shaman sAdd3 = "anc_worg"; //Worg } else sEnemy1 = "anc_troll"; //Troll } if (nLevel == 6) { sEnemy1 = "anc_werewolf"; //Werewolf } if (nLevel == 7) { sEnemy1 = "anc_gnoll"; //Gnoll } if (nLevel == 8) { if (Random(3) == 0) { sEnemy1 = "anc_stagbeetle"; //Stag beetle sAdd1 = "anc_stinkbeetle"; //Stink beetle sAdd2 = "anc_blackbear"; //Black bear sAdd3 = "anc_boar"; //Boar } else if (Random(2) == 0) { sEnemy1 = "anc_trollbers"; //Troll berserker sEnemy2 = "anc_trollcler"; //Troll shaman sAdd1 = "anc_troll"; //Troll } else { sEnemy1 = "anc_rakshasa"; //Rakshasa (male) sEnemy2 = "anc_rakshasaf"; //Rakshasa (female) } } if (nLevel == 9) { if (Random(2) == 0) { sEnemy1 = "anc_werewolfsh"; //Werewolf shaman sAdd1 = "anc_werewolf"; //Werewolf } else sEnemy1 = "anc_wboar"; //Wereboar } if (nLevel == 10) { sEnemy1 = "anc_gnollsh"; //Gnoll shaman sAdd1 = "anc_gnoll"; //Gnoll } if (nLevel == 11 || nLevel == 12) { if (Random(2) == 0) { sEnemy1 = "anc_hillgiant"; //Hill giant } else { sEnemy1 = "anc_hobgoblin"; //Hobgoblin (melee) sEnemy2 = "anc_hobgoblinr"; //Hobgoblin (ranged) } } if (nLevel == 13 || nLevel == 14) { if (Random(3) == 0) { sEnemy1 = "anc_hillgiantchi"; //Hill giant chieftain sAdd1 = "anc_hillgiant"; //Hill giant } else if (Random(2) == 0) { sEnemy1 = "anc_harpy"; //Harpy } else { sEnemy1 = "anc_bugbear"; //Bugbear } } if (nLevel == 15 || nLevel == 16) { sEnemy1 = "anc_hobgoblinsh"; //Hobgoblin shaman sAdd1 = "anc_hobgoblin"; //Hobgoblin (melee) sAdd2 = "anc_hobgoblinr"; //Hobgoblin (ranged) } if (nLevel == 17 || nLevel == 18) { if (Random(2) == 0) { sEnemy1 = "anc_bugbearsh"; //Bugbear shaman sEnemy2 = "anc_bugbearhero"; //Bugbear hero sAdd1 = "anc_bugbear"; //Bugbear } else { sEnemy1 = "anc_beetlemother"; //Hive mother sAdd1 = "anc_stagbeetle"; //Stag beetle } } if (nLevel == 19 || nLevel == 20) { sEnemy1 = "anc_raiter"; //Raiter } /*if (nLevel >= 21 && nLevel <= 23) { if (Random(3) == 0) { sEnemy1 = "anc_scale_werewo"; //Red werewolf (scaling) } else if (Random(2) == 0) { sEnemy1 = "anc_scale_bbearw"; //Bugbear elite (melee) sEnemy2 = "anc_scale_bbeara"; //Bugbear elite (ranged) sEnemy3 = "anc_scale_bbeahs"; //Bugbear high shaman } else { sEnemy1 = "anc_scale_bandth"; //Black Eye bandit sEnemy2 = "anc_scale_bandmb"; //Black Eye rider sEnemy3 = "anc_scale_bandar"; //Black Eye archer sEnemy4 = "anc_scale_bandro"; //Black Eye rogue sEnemy5 = "anc_scale_bandwi"; //Black Eye mage sEnemy6 = "anc_scale_bandcl"; //Black Eye cleric } }*/ if (nLevel >= 21) { if (nEncounterType != ENCOUNTER_TYPE_MINIBOSS) { if (Random(3) == 0) { sEnemy1 = "anc_scale_werewo"; //Red werewolf (scaling) } else if (Random(2) == 0) { sEnemy1 = "anc_scale_bbearw"; //Bugbear elite (melee) sEnemy2 = "anc_scale_bbeara"; //Bugbear elite (ranged) sEnemy3 = "anc_scale_bbeahs"; //Bugbear high shaman } else { sEnemy1 = "anc_scale_bandth"; //Black Eye bandit sEnemy2 = "anc_scale_bandmb"; //Black Eye rider sEnemy3 = "anc_scale_bandar"; //Black Eye archer sEnemy4 = "anc_scale_bandro"; //Black Eye rogue sEnemy5 = "anc_scale_bandwi"; //Black Eye mage sEnemy6 = "anc_scale_bandcl"; //Black Eye cleric } } else { if (Random(3) == 0) { sEnemy1 = "anc_scale_wereal"; //Red werewolf alpha (scaling) } else if (Random(2) == 0) { sEnemy1 = "anc_scale_bbeacw"; //Bugbear chieftain (melee) sEnemy2 = "anc_scale_bbeaca"; //Bugbear chieftain (ranged) sEnemy3 = "anc_scale_bbears"; //Bugbear archshaman } else { sEnemy1 = "anc_scale_bandof"; //Black Eye officer sEnemy2 = "anc_scale_bandca"; //Black Eye cavalryman sEnemy3 = "anc_scale_bandsn"; //Black Eye sniper sEnemy4 = "anc_scale_bandas"; //Black Eye assassin sEnemy5 = "anc_scale_bandam"; //Black Eye archmage sEnemy6 = "anc_scale_bandhp"; //Black Eye high priest } } } } //Save these enemies on the PC SetLocalString(oPC, "sEnemy1", sEnemy1); SetLocalString(oPC, "sEnemy2", sEnemy2); SetLocalString(oPC, "sEnemy3", sEnemy3); SetLocalString(oPC, "sEnemy4", sEnemy4); SetLocalString(oPC, "sEnemy5", sEnemy5); SetLocalString(oPC, "sEnemy6", sEnemy6); SetLocalString(oPC, "sAdd1", sAdd1); SetLocalString(oPC, "sAdd2", sAdd2); SetLocalString(oPC, "sAdd3", sAdd3); SetLocalString(oPC, "sAdd4", sAdd4); } void DeleteEnemyVar(object oPC) { DeleteLocalString(oPC, "sEnemy1"); DeleteLocalString(oPC, "sEnemy2"); DeleteLocalString(oPC, "sEnemy3"); DeleteLocalString(oPC, "sEnemy4"); DeleteLocalString(oPC, "sEnemy5"); DeleteLocalString(oPC, "sEnemy6"); DeleteLocalString(oPC, "sAdd1"); DeleteLocalString(oPC, "sAdd2"); DeleteLocalString(oPC, "sAdd3"); DeleteLocalString(oPC, "sAdd4"); } void ClearAndMove(object oNPC, object oExit) { object oGem = CreateItemOnObject(GenerateRandomGem(oNPC), oNPC); SetDroppableFlag(oGem, FALSE); SetPickpocketableFlag(oGem, TRUE); oGem = CreateItemOnObject(GenerateRandomGem(oNPC), oNPC); SetDroppableFlag(oGem, FALSE); SetPickpocketableFlag(oGem, TRUE); AssignCommand(oNPC, ClearAllActions()); //Get navigational waypoints based on the NPC's proximity to the area's "_s"/"_n" exit waypoints object oObject = GetFirstObjectInArea(GetArea(oNPC)); object oWaypointS; object oWaypointN; object oWaypointC; float fSouthDistance; float fNorthDistance; while (GetIsObjectValid(oObject)) { if (GetStringRight(GetTag(oObject), 1) == "s") { fSouthDistance = GetDistanceBetween(oNPC, oObject); } if (GetStringRight(GetTag(oObject), 1) == "n") { fNorthDistance = GetDistanceBetween(oNPC, oObject); } if (GetTag(oObject) == "anc_nav_s") { oWaypointS = oObject; } if (GetTag(oObject) == "anc_nav_n") { oWaypointN = oObject; } if (GetTag(oObject) == "anc_nav_c") { oWaypointC = oObject; } oObject = GetNextObjectInArea(GetArea(oNPC)); } //if there are northern and southern navigational waypoints... if (oWaypointS != OBJECT_INVALID && oWaypointN != OBJECT_INVALID) { //if the NPC's distance towards the southern wp is longer than towards the northern, it means he's in the northern end if (fSouthDistance > fNorthDistance) { AssignCommand(oNPC, ActionMoveToObject(oWaypointN, FALSE)); AssignCommand(oNPC, ActionMoveToObject(oWaypointC, FALSE)); AssignCommand(oNPC, ActionMoveToObject(oWaypointS, FALSE)); } else { AssignCommand(oNPC, ActionMoveToObject(oWaypointS, FALSE)); AssignCommand(oNPC, ActionMoveToObject(oWaypointC, FALSE)); AssignCommand(oNPC, ActionMoveToObject(oWaypointN, FALSE)); } } //if there is only a central navigational waypoint... else if (oWaypointC != OBJECT_INVALID) { AssignCommand(oNPC, ActionMoveToObject(oWaypointC, FALSE)); } //Then finally move to exit AssignCommand(oNPC, ActionMoveToObject(oExit, FALSE)); AssignCommand(oNPC, ActionDoCommand(DestroyObject(OBJECT_SELF))); } void AddSpecialCreatureProperties(object oCreature, int nLevel) { effect eCreatureBonus; if(GetTag(oCreature) == "anc_scale_werewo") { eCreatureBonus = EffectSkillIncrease(SKILL_LISTEN, nLevel); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-10), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_werewo" && GetIsNight() == TRUE) { eCreatureBonus = EffectACIncrease(2, AC_NATURAL_BONUS); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(2), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(2, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_CONCENTRATION, 13), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_LISTEN, nLevel-10), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-10), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_bbearw" || GetTag(oCreature) == "anc_scale_bbeara" || GetTag(oCreature) == "anc_scale_bbears") { eCreatureBonus = EffectSavingThrowIncrease(SAVING_THROW_ALL, 7); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_CONCENTRATION, 13), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_LISTEN, nLevel-10), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-10), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_bandth" || GetTag(oCreature) == "anc_scale_bandmb" || GetTag(oCreature) == "anc_scale_bandar") { eCreatureBonus = EffectACIncrease(2, AC_NATURAL_BONUS); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(2), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_LISTEN, nLevel-15), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-15), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_bandro") { int nBonus; if (GetResRef(oCreature) == GetTag(oCreature)) nBonus = 3; else nBonus = 6; eCreatureBonus = EffectAttackIncrease(nBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_bandcl") { eCreatureBonus = EffectSkillIncrease(SKILL_LISTEN, nLevel-15); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-15), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_DISCIPLINE, nLevel-18), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } if(GetTag(oCreature) == "anc_scale_bandwi") { eCreatureBonus = EffectACIncrease(17); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_LISTEN, nLevel-15), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_SPOT, nLevel-15), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectSkillIncrease(SKILL_DISCIPLINE, nLevel-18), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } } void LevelCreature(object oCreature, int nLevel, int nCreatureClass) { if (nLevel > 20) LevelHenchmanUpTo(oCreature, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oCreature), PACKAGE_INVALID); ForceRest(oCreature); effect eCreatureBonus; if (nCreatureClass == CREATURE_CLASS_MONSTER) { if (nLevel == 39 || nLevel == 40) //levels 39-40 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(15, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(12), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 37 || nLevel == 38) //levels 37-38 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(14, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(11), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 35 || nLevel == 36) //levels 35-36 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(13, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(9), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 33 || nLevel == 34) //levels 33-34 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(12, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(8), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 31 || nLevel == 32) //levels 31-32 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(12, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(6), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 29 || nLevel == 30) //levels 29-30 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(9, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(4), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 27 || nLevel == 28) //levels 27-28 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(8, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(4), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 25 || nLevel == 26) //levels 25-26 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(7, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(3), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 23 || nLevel == 24) //levels 23-24 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(6, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(2), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 21 || nLevel == 22) //levels 21-22 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(5, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(1), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectDamageIncrease(5, DAMAGE_TYPE_SLASHING), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } } if (nCreatureClass == CREATURE_CLASS_FIGHTER) { if (nLevel == 39 || nLevel == 40) //levels 39-40 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(12, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(12), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 37 || nLevel == 38) //levels 37-38 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(11, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(12), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 35 || nLevel == 36) //levels 35-36 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(10, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(10), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 33 || nLevel == 34) //levels 33-34 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(9, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(9), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 31 || nLevel == 32) //levels 31-32 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(9, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(7), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 29 || nLevel == 30) //levels 29-30 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(6, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(5), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 27 || nLevel == 28) //levels 27-28 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(5, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(5), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 25 || nLevel == 26) //levels 25-26 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(4, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(4), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 23 || nLevel == 24) //levels 23-24 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(3, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(3), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } else if (nLevel == 21 || nLevel == 22) //levels 21-22 { if (GetTag(oCreature) == GetResRef(oCreature)) eCreatureBonus = EffectACIncrease(12, AC_ARMOUR_ENCHANTMENT_BONUS); else eCreatureBonus = EffectACIncrease(17, AC_ARMOUR_ENCHANTMENT_BONUS); eCreatureBonus = EffectLinkEffects(EffectACIncrease(3, AC_DEFLECTION_BONUS), eCreatureBonus); eCreatureBonus = EffectLinkEffects(EffectAttackIncrease(3), eCreatureBonus); eCreatureBonus = SupernaturalEffect(eCreatureBonus); ApplyEffectToObject(DURATION_TYPE_PERMANENT, eCreatureBonus, oCreature); } } } void ScaleCreature(object oCreature, int nLevel) { int nCreatureClass; if (GetTag(oCreature) == "anc_scale_werewo") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bbearw") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bbeara") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bbears") nCreatureClass = CREATURE_CLASS_NOBOOST; if (GetTag(oCreature) == "anc_scale_bandth") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bandmb") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bandar") nCreatureClass = CREATURE_CLASS_MONSTER; if (GetTag(oCreature) == "anc_scale_bandro") nCreatureClass = CREATURE_CLASS_NOBOOST; if (GetTag(oCreature) == "anc_scale_bandwi") nCreatureClass = CREATURE_CLASS_NOBOOST; if (GetTag(oCreature) == "anc_scale_bandcl") nCreatureClass = CREATURE_CLASS_NOBOOST; LevelCreature(oCreature, nLevel, CREATURE_CLASS_MONSTER); AddSpecialCreatureProperties(oCreature, nLevel); } string SelectMain(string sEnemy1, string sEnemy2, string sEnemy3, string sEnemy4, string sEnemy5, string sEnemy6) { //Determine the number of enemy resrefs in use int nEnemyNum; string sReturn; if (sEnemy2 == "") nEnemyNum = 1; else if (sEnemy3 == "") nEnemyNum = 2; else if (sEnemy4 == "") nEnemyNum = 3; else if (sEnemy5 == "") nEnemyNum = 4; else if (sEnemy6 == "") nEnemyNum = 5; else nEnemyNum = 6; switch (Random(nEnemyNum)+1) { case 1: sReturn = sEnemy1; break; case 2: sReturn = sEnemy2; break; case 3: sReturn = sEnemy3; break; case 4: sReturn = sEnemy4; break; case 5: sReturn = sEnemy5; break; case 6: sReturn = sEnemy6; break; } return sReturn; } string SelectAdd(string sAdd1, string sAdd2, string sAdd3, string sAdd4) { //Determine the number of enemy resrefs in use int nEnemyNum; string sReturn; if (sAdd2 == "") nEnemyNum = 1; else if (sAdd3 == "") nEnemyNum = 2; else if (sAdd4 == "") nEnemyNum = 3; else nEnemyNum = 4; switch (Random(nEnemyNum)+1) { case 1: sReturn = sAdd1; break; case 2: sReturn = sAdd2; break; case 3: sReturn = sAdd3; break; case 4: sReturn = sAdd4; break; } return sReturn; } void SpawnNemesisEvent(object oPC) { object oArea = GetArea(oPC); string sDB = CharacterDB(oPC); int nPosition; int nSlotsOccupied = 0; //Select the NPC to spawn if (GetCampaignInt(sDB, "1_NPC_OCCUPIED") == TRUE) nSlotsOccupied++; if (GetCampaignInt(sDB, "2_NPC_OCCUPIED") == TRUE) nSlotsOccupied++; if (GetCampaignInt(sDB, "3_NPC_OCCUPIED") == TRUE) nSlotsOccupied++; if (nSlotsOccupied == 0) return; if (nSlotsOccupied == 3) nPosition = d3(); if (nSlotsOccupied == 2) { if (GetCampaignInt(sDB, "1_NPC_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 2; break; case 1: nPosition = 3; break; } } if (GetCampaignInt(sDB, "2_NPC_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 1; break; case 1: nPosition = 3; break; } } if (GetCampaignInt(sDB, "3_NPC_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 1; break; case 1: nPosition = 2; break; } } } if (nSlotsOccupied == 1) { if (GetCampaignInt(sDB, "1_NPC_OCCUPIED") == TRUE) nPosition = 1; if (GetCampaignInt(sDB, "2_NPC_OCCUPIED") == TRUE) nPosition = 2; if (GetCampaignInt(sDB, "3_NPC_OCCUPIED") == TRUE) nPosition = 3; } //Get waypoint string sAreaString = GetLocalString(OBJECT_SELF, "AreaString"); object oWaypoint = GetWaypointByTag("event_wp_" + sAreaString + "_1"); //Spawn the NPC and flag it as nemesis - the rest of the scripting should be done via the NPC's events object oNPC = SpawnStoredNPC(oPC, nPosition, GetLocation(oWaypoint)); SetPlotFlag(oNPC, TRUE); SetLocalInt(oNPC, "Nemesis", TRUE); TurnToFaceObject(oPC, oNPC); //Set boss battle music SetLocalInt(oArea, "Battle", MusicBackgroundGetBattleTrack(oArea)); if (GetStringLeft(sAreaString, 1) == "1") MusicBattleChange(oArea, TRACK_BATTLE_FORESTBOSS); } void SpawnEscortEvent(object oPC) { object oArea = GetArea(oPC); string sDB = CharacterDB(oPC); //Get waypoint string sAreaString = GetLocalString(OBJECT_SELF, "AreaString"); object oWaypoint = GetWaypointByTag("event_wp_" + sAreaString + "_1"); string sRace; string sGender; switch (Random(7)) { case 0: sRace = "hu"; break; case 1: sRace = "ha"; break; case 2: sRace = "el"; break; case 3: sRace = "he"; break; case 4: sRace = "ho"; break; case 5: sRace = "dw"; break; case 6: sRace = "gn"; break; } switch (Random(2)) { case 0: sGender = "_m"; break; case 1: sGender = "_f"; break; } string sResRef = "anc_npc_"+sRace+sGender; sGender = GetStringRight(sGender, 1); //This is for GenerateNPCName function //Spawn the client object oClient = CreateObject(OBJECT_TYPE_CREATURE, sResRef, GetLocation(oWaypoint)); SetPlotFlag(oClient, FALSE); SetLocalInt(oClient, "Lost", TRUE); int nLevel; if (GetHitDice(oPC) > 25) nLevel = GetHitDice(oPC) - 5; else nLevel = GetHitDice(oPC); LevelHenchmanUpTo(oClient, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oClient), PACKAGE_INVALID); //Generate NPC's name string sName = GenerateNPCName(sGender, sRace); //Generate NPC's last name string sLastName = GenerateNPCLastName(sRace); //Set the NPC's name and last name SetName(oClient, sName+" "+sLastName); SetLocalString(oClient, "Name", sName); SetLocalString(oClient, "LastName", sLastName); //Set the gold on the NPC (that they will give out as a reward) as an integer int nReward = Random(1000)+501; SetLocalInt(oClient, "Reward", nReward); } void SpawnTributeEvent(object oPC) { object oArea = GetArea(oPC); string sDB = CharacterDB(oPC); //Set the amount of gold thugs will want, based on a PC's level int nLevel = GetHitDice(oPC); int nTribute; if (nLevel < 5) nTribute = 500; if (nLevel >= 5 && nLevel <= 10) nTribute = 1000; if (nLevel >= 11 && nLevel <= 20) nTribute = 1500; if (nLevel > 20) nTribute = 2000; //SetLocalInt(oArea, "Tribute", nTribute); //Get waypoints string sAreaString = GetLocalString(OBJECT_SELF, "AreaString"); object oWaypoint; //Identify a region by the area string string sRegionString = GetStringLeft(sAreaString, 1); //Thug race depends on the region we're in string sThug; if (sRegionString == "1") sThug = "anc_roadbandit_h"; int nNumber; if (nLevel < 5) nNumber = 1; if (nLevel >= 5 && nLevel <= 25) nNumber = 2; if (nLevel >= 26 && nLevel <= 33) nNumber = 3; if (nLevel == 34 || nLevel == 35) nNumber = 4; if (nLevel == 36 || nLevel == 37) nNumber = 5; if (nLevel > 37) nNumber = 6; //Spawn thugs int i; object oCreature; for (i = 1; i <= nNumber; i++) { oWaypoint = GetWaypointByTag("event_wp_" + sAreaString + "_" + IntToString(i)); oCreature = CreateObject(OBJECT_TYPE_CREATURE, sThug, GetLocation(oWaypoint)); SetLocalInt(oCreature, "Tribute", nTribute); LevelHenchmanUpTo(oCreature, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oCreature), PACKAGE_INVALID); TurnToFaceObject(oPC, oCreature); } } //Spawns an event with an ambush of regular enemies void SpawnAmbushEvent(object oPC) { SetLocalInt(GetArea(oPC), "AmbushPrepared", TRUE); int nDC = GetHitDice(oPC); SetLocalInt(GetArea(oPC), "Level", nDC); if (nDC < 10) nDC = 10; int nSkillRoll; string sString; nSkillRoll = GetSkillRank(SKILL_SPOT, oPC) + d20(); if (nSkillRoll >= nDC) sString = "[Spot] Ambush detected!"; else { nSkillRoll = GetSkillRank(SKILL_LISTEN, oPC) + d20(); if (nSkillRoll >= nDC) sString = "[Listen] Ambush detected!"; } FloatingTextStringOnCreature(sString, oPC, FALSE); } //Spawns an event with a famous adventurer void SpawnAdventurerEvent(object oPC) { object oArea = GetArea(oPC); string sDB = GetLocalString(GetModule(), "DB"); int nPosition; int nSlotsOccupied = 0; //Select the NPC to spawn if (GetCampaignInt(sDB, "1_ADV_OCCUPIED") == TRUE) nSlotsOccupied++; if (GetCampaignInt(sDB, "2_ADV_OCCUPIED") == TRUE) nSlotsOccupied++; if (GetCampaignInt(sDB, "3_ADV_OCCUPIED") == TRUE) nSlotsOccupied++; if (nSlotsOccupied == 0) return; if (nSlotsOccupied == 3) nPosition = d3(); if (nSlotsOccupied == 2) { if (GetCampaignInt(sDB, "1_ADV_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 2; break; case 1: nPosition = 3; break; } } if (GetCampaignInt(sDB, "2_ADV_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 1; break; case 1: nPosition = 3; break; } } if (GetCampaignInt(sDB, "3_ADV_OCCUPIED") == FALSE) { switch (Random(2)) { case 0: nPosition = 1; break; case 1: nPosition = 2; break; } } } if (nSlotsOccupied == 1) { if (GetCampaignInt(sDB, "1_ADV_OCCUPIED") == TRUE) nPosition = 1; if (GetCampaignInt(sDB, "2_ADV_OCCUPIED") == TRUE) nPosition = 2; if (GetCampaignInt(sDB, "3_ADV_OCCUPIED") == TRUE) nPosition = 3; } //Get an exit waypoint at the other end of the area object oObject = GetFirstObjectInArea(oArea); object oWaypoint1; object oWaypoint2; object oWaypoint; object oExit; while (GetIsObjectValid(oObject)) { if (GetTag(oObject) == "NW_EXIT") { if (oWaypoint1 == OBJECT_INVALID) oWaypoint1 = oObject; else { oWaypoint2 = oObject; break; //no need for the loop to continue once we get both waypoints } } oObject = GetNextObjectInArea(oArea); } if (GetDistanceBetween(oPC, oWaypoint1) > GetDistanceBetween(oPC, oWaypoint2)) { oWaypoint = oWaypoint1; oExit = oWaypoint2; } else { oWaypoint = oWaypoint2; oExit = oWaypoint1; } //Spawn the adventurer object oNPC = SpawnAdventurerNPC(nPosition, GetLocation(oWaypoint)); SetLocalInt(oNPC, "Adventurer", TRUE); string sAreaString = GetLocalString(oArea, "AreaString"); object oEventWP = GetWaypointByTag("event_wp_"+sAreaString+"_1"); DelayCommand(3.0, ClearAndMove(oNPC, oExit)); //Set boss battle music SetLocalInt(oArea, "Battle", MusicBackgroundGetBattleTrack(oArea)); if (GetStringLeft(sAreaString, 1) == "1") MusicBattleChange(oArea, TRACK_BATTLE_FORESTBOSS); } //Spawns an event with a demon invasion void SpawnDemonEvent(object oPC) { object oArea = GetArea(oPC); string sAreaString = GetLocalString(oArea, "AreaString"); int nLevel = GetHitDice(oPC); SetLocalInt(oArea, "Level", nLevel); object oWaypoint = GetWaypointByTag("event_wp_"+sAreaString+"_1"); object oPortal = CreateObject(OBJECT_TYPE_PLACEABLE, "anc_demongate", GetLocation(oWaypoint)); object oWaypointDemon = GetWaypointByTag("rand_wp_"+sAreaString+"_1"); CreateObject(OBJECT_TYPE_CREATURE, "anc_demon_invade", GetLocation(oWaypointDemon)); //Set the portal's HP based on the player's level int nPortalHP = 15*nLevel; int nDamage = 1000-nPortalHP; ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nDamage), oPortal); } //Spawns an event with a bullied merchant void SpawnBulliedEvent(object oPC) { object oArea = GetArea(oPC); int nLevel = GetHitDice(oPC); string sAreaString = GetLocalString(oArea, "AreaString"); object oWaypoint1 = GetWaypointByTag("event_wp_"+sAreaString+"_1"); object oWaypoint2 = GetWaypointByTag("event_wp_"+sAreaString+"_2"); object oWaypoint3 = GetWaypointByTag("event_wp_"+sAreaString+"_3"); object oMerchant = CreateObject(OBJECT_TYPE_CREATURE, "anc_trmerch_"+GetStringLeft(sAreaString, 1), GetLocation(oWaypoint1)); LevelHenchmanUpTo(oMerchant, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oMerchant), PACKAGE_INVALID); ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectTemporaryHitpoints(GetHitDice(oMerchant)*2)), oMerchant); string sThug; if (GetStringLeft(sAreaString, 1) == "1") sThug = "anc_roadbandit_h"; object oThug1 = CreateObject(OBJECT_TYPE_CREATURE, sThug, GetLocation(oWaypoint2)); object oThug2 = CreateObject(OBJECT_TYPE_CREATURE, sThug, GetLocation(oWaypoint3)); LevelHenchmanUpTo(oThug1, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oThug1), PACKAGE_INVALID); LevelHenchmanUpTo(oThug2, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oThug2), PACKAGE_INVALID); SetIsTemporaryEnemy(oMerchant, oThug1); SetIsTemporaryEnemy(oMerchant, oThug2); SetIsTemporaryEnemy(oThug1, oMerchant); SetIsTemporaryEnemy(oThug2, oMerchant); //Set ints SetLocalInt(oArea, "MerchantTrouble", TRUE); SetLocalInt(oMerchant, "Reward", Random(300)+201); SetLocalInt(oMerchant, "Gold", Random(800)+201); SetLocalInt(oMerchant, "HiddenGold", Random(2)); if (GetLocalInt(oMerchant, "HiddenGold") == TRUE) SetLocalInt(oMerchant, "HiddenGold", Random(500)); } //Spawn an event with a travelling merchant void SpawnMerchantEvent(object oPC) { object oArea = GetArea(oPC); int nLevel = GetHitDice(oPC); string sAreaString = GetLocalString(oArea, "AreaString"); //Get an exit waypoint at the other end of the area object oObject = GetFirstObjectInArea(oArea); object oWaypoint1; object oWaypoint2; object oWaypoint; object oExit; while (GetIsObjectValid(oObject)) { if (GetTag(oObject) == "NW_EXIT") { if (oWaypoint1 == OBJECT_INVALID) oWaypoint1 = oObject; else { oWaypoint2 = oObject; break; //no need for the loop to continue once we get both waypoints } } oObject = GetNextObjectInArea(oArea); } if (GetDistanceBetween(oPC, oWaypoint1) > GetDistanceBetween(oPC, oWaypoint2)) { oWaypoint = oWaypoint1; oExit = oWaypoint2; } else { oWaypoint = oWaypoint2; oExit = oWaypoint1; } //Spawn a merchant object oMerchant = CreateObject(OBJECT_TYPE_CREATURE, "anc_trmerch_"+GetStringLeft(sAreaString, 1), GetLocation(oWaypoint)); LevelHenchmanUpTo(oMerchant, nLevel, CLASS_TYPE_INVALID, 0, GetCreatureStartingPackage(oMerchant), PACKAGE_INVALID); DelayCommand(3.0, ClearAndMove(oMerchant, oExit)); //Set ints SetLocalInt(oMerchant, "Gold", Random(800)+201); SetLocalInt(oMerchant, "HiddenGold", Random(2)); if (GetLocalInt(oMerchant, "HiddenGold") == TRUE) SetLocalInt(oMerchant, "HiddenGold", Random(500)); //50% chance of this merchant being mounted if (Random(2) == 0) return; SetPhenoType(3, oMerchant); SetCreatureTailType(30, oMerchant); } //Spawn an event with a boss monster void SpawnBossEvent(object oPC) { object oArea = GetArea(oPC); int nLevel = GetHitDice(oPC); string sAreaString = GetLocalString(oArea, "AreaString"); if (nLevel <= 10) return; int nPowerful = FALSE; string sBoss; if (nLevel > 30 && Random(10) < 8) nPowerful = TRUE; //Get waypoint object oWaypoint = GetWaypointByTag("event_wp_"+sAreaString+"_1"); //If the region is Green Coast if (GetStringLeft(sAreaString, 1) == "1") { if (nPowerful == TRUE) sBoss = "anc_phoenix"; else sBoss = "anc_manticore"; } //Spawn the boss object oBoss = CreateObject(OBJECT_TYPE_CREATURE, sBoss, GetLocation(oWaypoint)); TurnToFaceObject(oPC, oBoss); //Set boss battle music SetLocalInt(oArea, "Battle", MusicBackgroundGetBattleTrack(oArea)); if (GetStringLeft(sAreaString, 1) == "1") MusicBattleChange(oArea, TRACK_BATTLE_FORESTBOSS); } //Spawn an event with a friendly creature void SpawnFriendlyEvent(object oPC) { object oArea = GetArea(oPC); int nLevel = GetHitDice(oPC); string sAreaString = GetLocalString(oArea, "AreaString"); //Get waypoint object oWaypoint = GetWaypointByTag("event_wp_"+sAreaString+"_1"); string sCreature; //If the region is Green Coast if (GetStringLeft(sAreaString, 1) == "1") { sCreature = "anc_golddragon"; } //Spawn the creature object oCreature = CreateObject(OBJECT_TYPE_CREATURE, sCreature, GetLocation(oWaypoint)); TurnToFaceObject(oPC, oCreature); //Set boss battle music SetLocalInt(oArea, "Battle", MusicBackgroundGetBattleTrack(oArea)); if (GetStringLeft(sAreaString, 1) == "1") MusicBattleChange(oArea, TRACK_BATTLE_DRAGON); } //Spawns treasure in the inventory of the oObject void SpawnTreasure(object oPC, object oObject) { //Choose a random equipment piece (30% of the time it's something else) string sEqItem; if (Random(10) >= 3) sEqItem = GenerateRandomItem(oPC); else { switch (Random(3)) { case 0: sEqItem = GenerateRandomPotion(oPC); break; case 1: sEqItem = GenerateRandomGem(oPC); break; case 2: sEqItem = GenerateRandomMiscItem(); break; } } //Choose a random gem string sGemItem = GenerateRandomGem(oPC); //Choose two random miscellaneous items string sMisc1 = GenerateRandomMiscItem(); string sMisc2 = GenerateRandomMiscItem(); //Choose a random potion string sPotion = GenerateRandomPotion(oPC); //Make way for an extra fourth item string sExtra; switch (Random(10)) { case 0: sExtra = GenerateRandomItem(oPC); break; //10% chance for an extra equipment piece case 1: case 2: case 3: sExtra = GenerateRandomPotion(oPC); break; //30% chance for an extra potion case 4: case 5: case 6: sExtra = GenerateRandomGem(oPC); break; //30% chance for an extra gem default: sExtra = GenerateRandomMiscItem(); break; //30% chance for an extra miscellanoeus item } //Spawn all these items in the inventory CreateItemOnObject(sEqItem, oObject); CreateItemOnObject(sGemItem, oObject); CreateItemOnObject(sMisc1, oObject); CreateItemOnObject(sMisc2, oObject); CreateItemOnObject(sPotion, oObject); CreateItemOnObject(sExtra, oObject); //50% chance of spawning a rune if (Random(2) == 0) { CreateItemOnObject(GenerateRandomRune(oPC), oObject); } } //Spawn a chest, fill it with appropriate treasure and make it randomly locked/trapped/both object SpawnTreasureChest(object oPC, object oWaypoint) { //Variables int nChestNum = Random(5)+1; string sChestNum = IntToString(nChestNum); int nLevel = GetHitDice(oPC); int nLockDC = Random(nLevel)+21; int nTrapDC = Random(nLevel)+21; int nDetectDC = Random(nLevel)+11; //Spawn the chest WriteTimestampedLogEntry("Spawned chest: anc_tchest"+sChestNum); //TEST object oChest = CreateObject(OBJECT_TYPE_PLACEABLE, "anc_tchest"+sChestNum, GetLocation(oWaypoint)); //Spawn the treasure SpawnTreasure(oPC, oChest); //Lock it 50% of the time if (Random(2) == 0) { SetLockUnlockDC(oChest, nLockDC); SetLocked(oChest, TRUE); } //Trap it 65% of the time int nTrapType; if (Random(100)+1 <= 65) { SetTrapDisarmDC(oChest, nTrapDC); SetTrapDetectDC(oChest, nDetectDC); if (nLevel < 5) { switch (Random(7)) { case 0: nTrapType = TRAP_BASE_TYPE_MINOR_FIRE; break; case 1: nTrapType = TRAP_BASE_TYPE_MINOR_FROST; break; case 2: nTrapType = TRAP_BASE_TYPE_MINOR_SONIC; break; case 3: nTrapType = TRAP_BASE_TYPE_MINOR_ELECTRICAL; break; case 4: nTrapType = TRAP_BASE_TYPE_MINOR_HOLY; break; case 5: nTrapType = TRAP_BASE_TYPE_MINOR_NEGATIVE; break; case 6: nTrapType = TRAP_BASE_TYPE_MINOR_ACID; break; } } else if (nLevel < 10) { switch (Random(7)) { case 0: nTrapType = TRAP_BASE_TYPE_AVERAGE_FIRE; break; case 1: nTrapType = TRAP_BASE_TYPE_AVERAGE_FROST; break; case 2: nTrapType = TRAP_BASE_TYPE_AVERAGE_SONIC; break; case 3: nTrapType = TRAP_BASE_TYPE_AVERAGE_ELECTRICAL; break; case 4: nTrapType = TRAP_BASE_TYPE_AVERAGE_HOLY; break; case 5: nTrapType = TRAP_BASE_TYPE_AVERAGE_NEGATIVE; break; case 6: nTrapType = TRAP_BASE_TYPE_AVERAGE_ACID; break; } } else if (nLevel < 15) { switch (Random(7)) { case 0: nTrapType = TRAP_BASE_TYPE_STRONG_FIRE; break; case 1: nTrapType = TRAP_BASE_TYPE_STRONG_FROST; break; case 2: nTrapType = TRAP_BASE_TYPE_STRONG_SONIC; break; case 3: nTrapType = TRAP_BASE_TYPE_STRONG_ELECTRICAL; break; case 4: nTrapType = TRAP_BASE_TYPE_STRONG_HOLY; break; case 5: nTrapType = TRAP_BASE_TYPE_STRONG_NEGATIVE; break; case 6: nTrapType = TRAP_BASE_TYPE_STRONG_ACID; break; } } else if (nLevel < 20) { switch (Random(7)) { case 0: nTrapType = TRAP_BASE_TYPE_DEADLY_FIRE; break; case 1: nTrapType = TRAP_BASE_TYPE_DEADLY_FROST; break; case 2: nTrapType = TRAP_BASE_TYPE_DEADLY_SONIC; break; case 3: nTrapType = TRAP_BASE_TYPE_DEADLY_ELECTRICAL; break; case 4: nTrapType = TRAP_BASE_TYPE_DEADLY_HOLY; break; case 5: nTrapType = TRAP_BASE_TYPE_DEADLY_NEGATIVE; break; case 6: nTrapType = TRAP_BASE_TYPE_DEADLY_ACID; break; } } else { switch (Random(4)) { case 0: nTrapType = TRAP_BASE_TYPE_EPIC_FIRE; break; case 1: nTrapType = TRAP_BASE_TYPE_EPIC_FROST; break; case 2: nTrapType = TRAP_BASE_TYPE_EPIC_SONIC; break; case 3: nTrapType = TRAP_BASE_TYPE_EPIC_ELECTRICAL; break; } } CreateTrapOnObject(nTrapType, oChest); } return oChest; } void EndEscortEvent(object oPC) { int i = 1; object oEscorted; do { oEscorted = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, i); if (GetLocalInt(oEscorted, "EventEscorted") == TRUE) break; i++; } while (GetIsObjectValid(oEscorted)); SetLocalInt(oEscorted, "EscortSuccessful", TRUE); AssignCommand(oEscorted, ClearAllActions()); AssignCommand(oEscorted, ActionStartConversation(oPC, "", FALSE, TRUE)); }