<?xml version="1.0" encoding="utf-8" ?>
<Defs>

  <QuestScriptDef>
    <defName>ThreatReward_Raid_MiscReward</defName>
    <rootSelectionWeight>0.7</rootSelectionWeight>
    <rootMinPoints>0</rootMinPoints>
    <expireDaysRange>4~8</expireDaysRange>
    <questNameRules>
      <rulesStrings>
        <li>questName->[enemyFaction_pawnsPlural] of Fortune</li>
        <li>questName->[violence] of Fortune</li>
        <li>questName->[violence] for Hire</li>
        <li>questName->[violence] for Profit</li>
        <li>questName->Rewarded [violence]</li>
        <li>questName->Paid [violence]</li>
        <li>questName->Compensated [violence]</li>
        <li>questName(reward==royalFavor)->[enemyFaction_pawnsPlural] for Favor</li>
        <li>questName(reward==royalFavor)->[violence] for Favor</li>

        <li>violence->Violence</li>
        <li>violence->Battle</li>
        <li>violence->Combat</li>
        <li>violence->War</li>
        <li>violence->Fighting</li>
        <li>violence->Bloodshed</li>
        <li>violence->Attack</li>
        <li>violence->Defense</li>
        <li>violence->Conflict</li>
        <li>violence->Hostility</li>
        <li>violence->Warfare</li>

      </rulesStrings>
    </questNameRules>
    <questDescriptionRules>
      <rulesStrings>

        <!-- Note: 'Reward is joiner' (ThreatReward_Raid_Joiner) is done with a separate quest that's defined in vanilla -->

        <!-- Reward is item pods -->
        <li>questDescription(asker_factionLeader==True)->[asker_nameFull], [asker_faction_leaderTitle] of [asker_faction_name], wants you to help save one of [asker_possessive] caravans. The caravan is being hunted near [map_definite] by (*Threat)[numGroupsOf] [enemyFaction_pawnsPlural](/Threat) from [enemyFaction_name]. [asker_nameDef] wants you to signal the [enemyFaction_pawnsPlural] to draw them away from the caravan - and towards you.[endingCommon]</li>

        <!-- Reward is honor -->
        <li>questDescription(asker_royalInCurrentFaction==True)->[asker_nameFull], a [asker_royalTitleInCurrentFaction] of [asker_faction_name], is making a request of you.
\n(*Threat)[groupsOf](/Threat) from [enemyFaction_name] have been harassing [asker_possessive] caravans in the area. [asker_nameDef] asks that you send them a challenge message, attracting them to attack and eliminating the threat yourself.[endingCommon]</li>

        <li>groupsOf(raidCount==1,priority=1)->[enemyFaction_pawnsPlural]</li>
        <li>groupsOf->[numGroupsOf] [enemyFaction_pawnsPlural]</li>
        
        <li>endingCommon(helpersCount==0)->\n\n[pawnKindsParagraph]\n\nIf you accept, the [enemyFaction_pawnsPlural] will arrive in [firstRaidDelayTicks_duration].</li>
        <li>endingCommon(helpersCount>=1)->\n\n[pawnKindsParagraph][helpersParagraph]If you accept, the [enemyFaction_pawnsPlural] will arrive in [firstRaidDelayTicks_duration].</li>
      </rulesStrings>
    </questDescriptionRules>
    <root Class="QuestNode_Sequence">
      <nodes>
        <li Class="QuestNode_SubScript">
          <def>Util_RandomizePointsChallengeRating</def>
        </li>
        <li Class="QuestNode_SubScript">
          <def>Util_GetDefaultRewardValueFromPoints</def>
        </li>
        <li Class="QuestNode_GetMap" />

        <!-- Get asker -->
        <li Class="QuestNode_RandomNode">
          <nodes>
            <li Class="QuestNode_GetPawn">
              <storeAs>asker</storeAs>
              <selectionWeight>0.5</selectionWeight>
              <mustBeFactionLeader>true</mustBeFactionLeader>
              <allowPermanentEnemyFaction>false</allowPermanentEnemyFaction>
              <hostileWeight>0.15</hostileWeight>
            </li>
            <li Class="QuestNode_GetPawn">
              <storeAs>asker</storeAs>
              <selectionWeight>0.5</selectionWeight>
              <canGeneratePawn>true</canGeneratePawn>
              <allowPermanentEnemyFaction>false</allowPermanentEnemyFaction>
              <mustHaveRoyalTitleInCurrentFaction>true</mustHaveRoyalTitleInCurrentFaction>
              <hostileWeight>0.15</hostileWeight>
            </li>
          </nodes>
        </li>

        <!-- Helpers -->
        <li Class="QuestNode_SubScript">
          <def>Util_MaybeGenerateHelpers</def>
          <parms>
            <helpersChance>0.4</helpersChance>
            <sendArrivalLetter>true</sendArrivalLetter>
            <helpersLeaveAfterTicks>-1</helpersLeaveAfterTicks>
          </parms>
        </li>

        <!-- Raid(s) -->
        <li Class="QuestNode_GetRandomInRangeInt">
          <storeAs>raidCount</storeAs>
          <range>1~3</range>
        </li>
        <li Class="QuestNode_Set">
          <name>firstRaidDelayTicks</name>
          <value>$(roundToTicksRough(randInt(6000, 300000)))</value>
        </li>
        <li Class="QuestNode_GetFaction">
          <allowEnemy>true</allowEnemy>
          <mustBePermanentEnemy>true</mustBePermanentEnemy>
          <storeAs>enemyFaction</storeAs>
        </li>
        <li Class="QuestNode_Subscript">
          <def>Util_RaidDelayRepeatable</def>
          <parms>
            <points>$($points + $helpersPoints)</points>
          </parms>
        </li>
        
        <!-- End -->
        <li Class="QuestNode_AllSignals">
          <inSignals>
            <li>AllRaidsSent</li>
            <li>raid$($raidCountMinusOne)/lord.AllEnemiesDefeated</li>
          </inSignals>
          <node Class="QuestNode_Sequence">
            <nodes>
              <li Class="QuestNode_Delay">
                <delayTicks>300</delayTicks>
                <node Class="QuestNode_Sequence">
                  <nodes>
                    <li Class="QuestNode_HasRoyalTitleInCurrentFaction">
                      <pawn>$asker</pawn>
                      <node Class="QuestNode_GiveRewards">
                        <parms>
                          <allowGoodwill>true</allowGoodwill>
                          <allowRoyalFavor>true</allowRoyalFavor>
                        </parms>
                      </node>
                      <elseNode Class="QuestNode_GiveRewards">
                        <parms>
                          <thingRewardItemsOnly>true</thingRewardItemsOnly>
                        </parms>
                      </elseNode>
                    </li>
                    <li Class="QuestNode_End" />
                  </nodes>
                </node>
              </li>
            </nodes>
          </node>
        </li>
      </nodes>
    </root>
  </QuestScriptDef>

</Defs>