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

  <QuestScriptDef>
    <defName>WMH_Wraith_MonsterEncounterQuest</defName>
    <rootSelectionWeight>0.1</rootSelectionWeight>
    <rootMinPoints>0</rootMinPoints>
    <autoAccept>true</autoAccept>
    <canGiveRoyalFavor>true</canGiveRoyalFavor>
	<defaultChallengeRating>2</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 recently restricted entrance to their mass graves site due to bizzare lights and screams of torment. All clues point towards a group of Wraiths.\n\nWraiths suffer endless, indescribable pain. Filled with anger and a sense of having been wronged, they both envy the living and brim with overwhelming hatred for them. Their strong claw attacks can take out even the sturdiest of knights.\n\nMonster class traits: Being a Spectre, Wraith instill fear in nearby humans, directly affecting their mood.\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_Wraith_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>