<?xml version="1.0" encoding="utf-8" ?>
<Defs>

  <QuestScriptDef>
    <defName>WMH_Bearofleet_MonsterEncounterQuest</defName>
    <rootSelectionWeight>0.1</rootSelectionWeight>
    <rootMinPoints>0</rootMinPoints>
    <autoAccept>true</autoAccept>
    <canGiveRoyalFavor>true</canGiveRoyalFavor>
	<defaultChallengeRating>4</defaultChallengeRating>
    <questNameRules>
      <rulesStrings>
        <li>questName->[asker_nameDef]'s [monster] [contract]</li>
		<li>monster->monster</li>
        <li>monster->monster hunt</li>
        <li>monster->beast hunting</li>
        <li>monster->creature</li>
        <li>contract->contract</li>
        <li>contract->mission</li>
        <li>contract->arrangement</li>
        <li>contract->undertaking</li>
        <li>contract->holy task</li>
        
      </rulesStrings>
    </questNameRules>
    <questDescriptionRules>
      <rulesStrings>
        <li>questDescription->[asker_nameFull], [asker_faction_leaderTitle] of [asker_faction_name], put out a contract for a Bearofleet - an insane monstrosity devouring everything in the area. The only proof of its existence are several victims who managed to escape alive, only to die weeks later due to their gluttonous psychosis.\n\nBearofleets are genetic monstrosities created by the hubris of man. They were created by advanced genetic splicing of Aerofleet and Bear genetic material, and released into the wild, where their voracious appetite has proven to be a real challenge for small settlements. Their very presence instills a preternatural hunger in those who witness its bloated belly.\n\nMonster class traits: Being a Relict, Bearofleet contract provides much higher rewards.\n\n
		\nIf we succeed, [allRewardsDescriptions]</li>
      </rulesStrings>
    </questDescriptionRules>
    <root Class="QuestNode_Sequence">
      <nodes>
        
       
        <li Class="QuestNode_GetMap" />

        <li Class="QuestNode_GetPawn">
          <storeAs>asker</storeAs>
          <mustBeFactionLeader>true</mustBeFactionLeader>
          <allowPermanentEnemyFaction>false</allowPermanentEnemyFaction>
        </li>

        <li Class="QuestNode_GetSiteTile">
          <storeAs>siteTile</storeAs>
          <preferCloserTiles>true</preferCloserTiles>
        </li>

        <li Class="QuestNode_GetSitePartDefsByTagsAndFaction">
          <storeAs>sitePartDefs</storeAs>
          <storeFactionAs>siteFaction</storeFactionAs>
          <sitePartsTags>
            <li><tag>WMH_Bearofleet_MonsterEncounterCore</tag></li>
          </sitePartsTags>
          
        </li>

        <li Class="QuestNode_GetDefaultSitePartsParams">
          <tile>$siteTile</tile>
          <faction>$faction</faction>
          <sitePartDefs>$sitePartDefs</sitePartDefs>
          <storeSitePartsParamsAs>sitePartsParams</storeSitePartsParamsAs>
        </li>
        
        <li Class="QuestNode_GetSiteThreatPoints">
          <storeAs>sitePoints</storeAs>
          <sitePartsParams>$sitePartsParams</sitePartsParams>
        </li>
        <li Class="QuestNode_SubScript">
          <def>Util_GetDefaultRewardValueFromPoints</def>
          <parms>
            <!-- Use the actual threat points generated (some site parts define a minimum threshold) -->
            <points>$sitePoints</points>
          </parms>
        </li>

        <li Class="QuestNode_SubScript">
          <def>Util_GenerateSite</def>
        </li>
        
        <li Class="QuestNode_SpawnWorldObjects">
          <worldObjects>$site</worldObjects>
        </li>

        <li Class="QuestNode_WorldObjectTimeout">
          <worldObject>$site</worldObject>
          <isQuestTimeout>true</isQuestTimeout>
          <delayTicks>$(randInt(12,28)*60000)</delayTicks>
          <inSignalDisable>site.MapGenerated</inSignalDisable>
          <node Class="QuestNode_Sequence">
            <nodes>
              <li Class="QuestNode_Letter">
                <label>Quest expired: [resolvedQuestName]</label>
                <text>The monsters have left this area, and you won't hear from them until they have claimed their next victims. The quest [resolvedQuestName] has expired.</text>
              </li>
              <li Class="QuestNode_End">
                <outcome>Fail</outcome>
              </li>
            </nodes>
          </node>
        </li>

        <li Class="QuestNode_Signal">
          <inSignal>site.AllEnemiesDefeated</inSignal>
          <node Class="QuestNode_GiveRewards">
            <parms>
              <allowGoodwill>true</allowGoodwill>
              <allowRoyalFavor>true</allowRoyalFavor>
              <chosenPawnSignal>ChosenPawnForReward</chosenPawnSignal>
            </parms>
            <customLetterLabel>Payment arrived</customLetterLabel>
            <customLetterText>You have defeated the monsters!\n\nThe payment from [asker_faction_name] has arrived.</customLetterText>
            <nodeIfChosenPawnSignalUsed Class="QuestNode_Letter">
              <letterDef>ChoosePawn</letterDef>
              <label>[asker_faction_royalFavorLabel]</label>
              <text>These colonists participated in the epic hunt for the quest [resolvedQuestName]. [asker_definite] wants to know who should receive the [royalFavorReward_amount] [asker_faction_royalFavorLabel] favor for this service.</text>
              <useColonistsOnMap>$site</useColonistsOnMap>
              <chosenPawnSignal>ChosenPawnForReward</chosenPawnSignal>
            </nodeIfChosenPawnSignalUsed>
          </node>
        </li>
        <li Class="QuestNode_End">
          <inSignal>site.AllEnemiesDefeated</inSignal>
          <outcome>Success</outcome>
        </li>
      </nodes>
    </root>
  </QuestScriptDef>
</Defs>