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

  <QuestScriptDef>
    <defName>WMH_Hym_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 undergone its third election in the last two weeks, with all the previous leaders commiting suicide. A contract has been given to take care of the Hym tormenting these people.\n\nHym avoids sinking its claws into their victims. Instead, it saps their strength directly, through inflicting suffering. Speaking in a voice only the victim hears, Hym drives him to commit acts of violence, aggression and self-harm. Those tormented by a Hym are incapable of restful sleep weeks after the Hym is gone.\n\nMonster class traits: Being a Spectre, Hym 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_Hym_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>