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

  <QuestScriptDef>
    <defName>WMH_Fiend_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], has been attacked by a Fiend, a mountain of muscle and anger. They usually avoid human contact, but when hungry or endangered, they kill without difficulty.\n\nFiend is a walking mountain of muscle capped with horned, tooth-filled head. Is enormous size and strength allows it to take on an entire raiding party, whilst the third eye located in the center of their forehead is used to draw their prey into a state of hypnosis.\n\nMonster class traits: Being a Relict, Fiend 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_Fiend_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>