<?xml version="1.0" encoding="utf-8" ?>
<Defs>

  <RitualBehaviorDef>
    <defName>Funeral</defName>
    <durationTicks>5000</durationTicks>
    <workerClass>RitualBehaviorWorker_Funeral</workerClass>
    <roles>
      <li Class="RitualRoleTag">
        <label>speaker</label>
        <id>moralist</id>
        <precept>IdeoRole_Moralist</precept>
        <tag>Moralist</tag>
        <maxCount>1</maxCount>
        <substitutable>true</substitutable>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFuneral</dutyDef>
          <speakerInteraction>Speech_Funeral</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_BesideThing" />
            </customPositions>
          </li>
        </roleBehaviors>
        <visualEffectDef>Funeral</visualEffectDef>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef Name="DateRitualBehavior">
    <defName>DateRitual</defName>
    <durationTicks>6250</durationTicks>
    <roles>
      <li Class="RitualRoleTag">
        <label>speaker</label>
        <tag>Leader</tag>
        <id>leader</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <substitutable>True</substitutable>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.3</percentage>
          </li>
        </endTriggers>
        <postAction Class="RitualStageAction_Message">
            <text>{0}: The speech is over, and the party is beginning.</text>
            <messageTypeDef>NeutralEvent</messageTypeDef>
        </postAction>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_DateRitual</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_BesideThing" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Party</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.7</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>LeaderSpeech</defName>
    <workerClass>RitualBehaviorWorker_Speech</workerClass>
    <durationTicks>5000</durationTicks>
    <letterTitle>{RITUAL_labelCap}</letterTitle>
    <letterText>{SPEAKER_labelShort} is giving a {RITUAL_labelIndef}.
      \nIf all goes well, listeners will feel inspired, and gain respect for {SPEAKER_labelShort}. If it goes poorly, the speech will do social damage. Positive effects are reduced for non-{IDEOMEMBERS}.</letterText>
    <roles>
      <li Class="RitualRoleTag">
        <label>speaker</label>
        <tag>Leader</tag>
        <id>speaker</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Vertical</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <spectatorsRequired>true</spectatorsRequired>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>speaker</roleId>
            <dutyDef>SpeakOnCell_Leader</dutyDef>
            <speakerInteraction>Speech_Leader</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_BesideThing" />
            </customPositions>
          </li>
        </roleBehaviors>
        <visualEffectDef>Speech</visualEffectDef>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>Trial</defName>
    <workerClass>RitualBehaviorWorker_Trial</workerClass>
    <durationTicks>5000</durationTicks>
    <roles>
      <li Class="RitualRoleTag">
        <label>judge</label>
        <tag>Leader</tag>
        <id>leader</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
      <li Class="RitualRoleForced">
        <label>convict</label>
        <id>convict</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <ignoreBleeding>true</ignoreBleeding>
      </li>
    </roles>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Horizontal</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <spectatorsRequired>true</spectatorsRequired>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>leader</li>
              <li>convict</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_BehindThingCenter" />
            </customPositions>
          </li>
          <li>
            <roleId>convict</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InFrontThingCenter"/>
            </customPositions>
          </li>
        </roleBehaviors>
        <highlightRolePawns>
          <li>convict</li>
          <li>leader</li>
        </highlightRolePawns>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Horizontal</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <spectatorsRequired>true</spectatorsRequired>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>SpeakOnCellNoSpeechBubbles</dutyDef>
            <customPositions>
              <li Class="RitualPosition_BehindThingCenter" />
            </customPositions>
          </li>
          <li>
            <roleId>convict</roleId>
            <dutyDef>StandOnCell</dutyDef>
          </li>
        </roleBehaviors>
        <highlightRolePawns>
          <li>convict</li>
          <li>leader</li>
        </highlightRolePawns>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>TrialPrisoner</defName>
    <workerClass>RitualBehaviorWorker_Trial</workerClass>
    <durationTicks>5000</durationTicks>
    <roles>
      <li Class="RitualRoleTag">
        <label>judge</label>
        <tag>Leader</tag>
        <id>leader</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
      <li Class="RitualRoleForced">
        <label>convict</label>
        <id>convict</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <ignoreBleeding>true</ignoreBleeding>
      </li>
    </roles>
    <stages>
      <li Class="RitualStage_InteractWithPrisoner">
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Horizontal</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>leader</takerId>
            <takeeId>convict</takeeId>
            <desc>Convicted prisoner is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>leader</pawnId>
          </li>
        </failTriggers>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>convict</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>DeliverPawnToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InFrontThingCenter"/>
            </customPositions>
          </li>
          <li>
            <roleId>convict</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Horizontal</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <spectatorsRequired>true</spectatorsRequired>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>SpeakOnCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_BehindThingCenter">
                <highlight>true</highlight>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>convict</roleId>
            <dutyDef>StandOnCell</dutyDef>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>TrialMentalState</defName>
    <workerClass>RitualBehaviorWorker_Trial</workerClass>
    <durationTicks>5000</durationTicks>
    <roles>
      <li Class="RitualRoleTag">
        <label>judge</label>
        <tag>Leader</tag>
        <id>leader</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
      <li Class="RitualRoleForced">
        <label>convict</label>
        <id>convict</id>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <addToLord>false</addToLord>
        <ignoreBleeding>true</ignoreBleeding>
        <allowNonAggroMentalState>true</allowNonAggroMentalState>
      </li>
    </roles>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <allowedSpectateSidesOverride>Horizontal</allowedSpectateSidesOverride>
        <spectateDistanceOverride>1</spectateDistanceOverride>
        <spectatorsRequired>true</spectatorsRequired>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>SpeakOnCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_BehindThingCenter" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>
  
  <RitualBehaviorDef Name="SacrificeBehaviorBase" Abstract="True" ParentName="DateRitualBehavior">
    <preceptRequirements><li Class="PreceptRequirement_Altar"/></preceptRequirements>
    <durationTicks>7500</durationTicks>
    <roles Inherit="False">
      <li Class="RitualRoleTag">
        <label>cutter</label>
        <id>moralist</id>
        <tag>Moralist</tag>
        <precept>IdeoRole_Moralist</precept>
        <required>True</required>
        <substitutable>true</substitutable>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="SacrificeBehaviorBase">
    <defName>SacrificePrisoner</defName>
    <workerClass>RitualBehaviorWorker_PrisonerSacrifice</workerClass>
    <roles>
      <li Class="RitualRolePrisoner">
        <label>sacrifice</label>
        <missingDesc>a prisoner</missingDesc>
        <id>prisoner</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <ignoreBleeding>true</ignoreBleeding>
      </li>
    </roles>
    <stages Inherit="False">
      <li Class="RitualStage_InteractWithPrisoner">
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDeliveredOrNotValid"/>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>moralist</takerId>
            <takeeId>prisoner</takeeId>
            <desc>Prisoner is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>moralist</pawnId>
          </li>
        </failTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>DeliverPawnToAltar</dutyDef>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.4</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Sacrifice</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li Class="RitualStage_InteractWithPrisoner">
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDead">
            <roleId>prisoner</roleId>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>Sacrifice</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
        <visualEffectDef>SacrificePrisoner</visualEffectDef>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.6</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Sacrifice</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="SacrificeBehaviorBase">
    <defName>SacrificeAnimal</defName>
    <roles>
      <li Class="RitualRoleAnimal">
        <label>sacrifice</label>
        <id>animal</id>
        <maxCount>1</maxCount>
        <minBodySize>0.75</minBodySize>
        <required>True</required>
        <missingDesc>an animal with body size of at least 0.8</missingDesc>
        <countsAsParticipant>False</countsAsParticipant>
        <ignoreBleeding>true</ignoreBleeding>
      </li>
    </roles>
    <stages Inherit="False">
      <li Class="RitualStage_InteractWithAnimal">
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDeliveredOrNotValid"/>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>moralist</takerId>
            <takeeId>animal</takeeId>
            <desc>Animal is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>moralist</pawnId>
          </li>
        </failTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>DeliverPawnToAltar</dutyDef>
          </li>
          <li>
            <roleId>animal</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.4</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Sacrifice</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>animal</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li Class="RitualStage_InteractWithAnimal">
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDead">
            <roleId>animal</roleId>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>Sacrifice</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>animal</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
        <visualEffectDef>SacrificeAnimal</visualEffectDef>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.6</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Sacrifice</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>
  
  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>DancePartyTech</defName>
    <workerClass>RitualBehaviorWorker_DancePartyTech</workerClass>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>PartyDance</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1.0</percentage>
          </li>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetThingMissing">
            <onlyIfTargetIsOfDef>LightBall</onlyIfTargetIsOfDef>
            <desc>Lightball is missing.</desc>
          </li>
          <li Class="StageFailTrigger_TargetUnpowered">
            <onlyIfTargetIsOfDef>LightBall</onlyIfTargetIsOfDef>
            <allowanceTicks>1000</allowanceTicks>
            <desc>Lightball is not powered.</desc>
          </li>
          <li Class="StageFailTrigger_NoPoweredLoudspeakers">
            <onlyIfTargetIsOfDef>LightBall</onlyIfTargetIsOfDef>
            <allowanceTicks>1000</allowanceTicks>
            <desc>No powered loudspeakers.</desc>
          </li>
        </failTriggers>
        <visualEffectDef>DanceParty</visualEffectDef>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>CelebrationPartyDanceDrum</defName>
    <workerClass>RitualBehaviorWorker_PartyDanceDrums</workerClass>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>PartyDance</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1.0</percentage>
          </li>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetThingMissing">
            <onlyIfTargetIsOfDef>Campfire</onlyIfTargetIsOfDef>
            <desc>Campfire is missing.</desc>
          </li>
          <li Class="StageFailTrigger_TargetNotLit">
            <onlyIfTargetIsOfDef>Campfire</onlyIfTargetIsOfDef>
            <desc>Campfire is not lit.</desc>
          </li>
          <li Class="StageFailTrigger_NoThingPresent">
            <onlyIfTargetIsOfDef>Campfire</onlyIfTargetIsOfDef>
            <thingDef>Drum</thingDef>
            <desc>No drums.</desc>
          </li>
        </failTriggers>
        <visualEffectDef>DrumParty</visualEffectDef>
      </li>
    </stages>
    <soundDefsPerEnhancerCount>
      <li>DanceParty_NoMusic</li>
      <li>Drum_Music_1</li>
      <li>Drum_Music_2</li>
      <li>Drum_Music_3</li>
      <li>Drum_Music_4</li>
      <li>Drum_Music_5</li>
      <li>Drum_Music_6</li>
    </soundDefsPerEnhancerCount>
    <maxEnhancerDistance>12</maxEnhancerDistance>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>CelebrationSkyLanterns</defName>
    <durationTicks>7500</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>PrepareSkyLanterns</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.6</percentage>
          </li>
        </endTriggers>
        <pawnLeaveAction Class="RitualStageAction_DropThing">
          <def>WoodLog</def>
          <count>4</count>
        </pawnLeaveAction>
        <interruptedAction Class="RitualStageAction_DropThing">
          <def>WoodLog</def>
          <count>4</count>
        </interruptedAction>
        <tickActionMaker Class="RitualStageAction_ReleaseLanterns">
          <woodCost>4</woodCost>
          <preliminaryTicks>0~90</preliminaryTicks>
        </tickActionMaker>
      </li>
      <li>
        <defaultDuty>SpectateDirectionSociallyActive</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.4</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>CelebrationTree</defName>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>SpectateSocial</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.6</percentage>
          </li>
        </endTriggers>
      </li>
      <li>
        <defaultDuty>PartyCloseWander</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.4</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>BurnCircle</defName>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>SpectateSocial</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>SmokeCircle</defName>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>SpectateSmokeCircle</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1.0</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>GladiatorDuel</defName>
    <workerClass>RitualBehaviorWorker_Duel</workerClass>
    <roles>
      <li Class="RitualRoleTag">
        <label>speaker</label>
        <tag>Leader</tag>
        <id>leader</id>
        <precept>IdeoRole_Leader</precept>
        <required>True</required>
        <substitutable>True</substitutable>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
      <li Class="RitualRolePrisonerOrSlave">
        <label>duelist</label>
        <categoryLabel>duelists</categoryLabel>
        <missingDesc>prisoners / slaves (duelists)</missingDesc>
        <id>duelist1</id>
        <mergeId>duelist</mergeId>
        <mustBeCapableToFight>true</mustBeCapableToFight>
        <required>True</required>
        <maxCount>1</maxCount>
        <ignoreBleeding>true</ignoreBleeding>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
      </li>
      <li Class="RitualRolePrisonerOrSlave">
        <label>duelist</label>
        <categoryLabel>duelists</categoryLabel>
        <missingDesc>prisoners / slaves (duelists)</missingDesc>
        <id>duelist2</id>
        <mergeId>duelist</mergeId>
        <required>True</required>
        <mustBeCapableToFight>true</mustBeCapableToFight>
        <maxCount>1</maxCount>
        <ignoreBleeding>true</ignoreBleeding>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
      </li>
      <li Class="RitualRoleColonist">
        <label>duelist escort</label>
        <categoryLabel>duelist escorts</categoryLabel>
        <missingDesc>non-downed colonists capable of hauling</missingDesc>
        <id>escorte1</id>
        <mergeId>escorte</mergeId>
        <required>True</required>
        <maxCount>1</maxCount>
      </li>
      <li Class="RitualRoleColonist">
        <label>duelist escort</label>
        <categoryLabel>duelist escorts</categoryLabel>
        <missingDesc>non-downed colonists capable of hauling</missingDesc>
        <id>escorte2</id>
        <mergeId>escorte</mergeId>
        <required>True</required>
        <maxCount>1</maxCount>
      </li>
    </roles>
    <spectatorsLabel>Spectators</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages>
      <!-- Duelists drop weapons -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <endTriggers>
          <li Class="StageEndTrigger_RolesUnarmed">
            <roleIds>
              <li>duelist1</li>
              <li>duelist2</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>DropWeapon</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>DropWeapon</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- People gather up -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>leader</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InCircle">
                <preferredRotation>North</preferredRotation>
                <distRange>1~3</distRange>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Duelists are taken -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>escorte1</pawnId>
            <targetId>duelist1</targetId>
          </li>
          <li>
            <pawnId>escorte2</pawnId>
            <targetId>duelist2</targetId>
          </li>
        </targets>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>escorte1</takerId>
            <takeeId>duelist1</takeeId>
            <desc>Duelist is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>escorte1</pawnId>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>escorte2</pawnId>
          </li>
        </failTriggers>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>escorte1</li>
              <li>escorte2</li>
            </roleIds>
            <clearTag>true</clearTag>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InCircle">
                <preferredRotation>North</preferredRotation>
                <distRange>1~3</distRange>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>escorte1</roleId>
            <dutyDef>DeliverPawnToCellIfAliveThenIdle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_DuelistStart">
                <distFromTarget>2</distFromTarget>
                <duelistIndex>0</duelistIndex>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>escorte2</roleId>
            <dutyDef>DeliverPawnToCellIfAliveThenIdle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_DuelistStart">
                <distFromTarget>2</distFromTarget>
                <duelistIndex>1</duelistIndex>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Leader speak on cell -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <ignoreDurationToFinishAfterStage>true</ignoreDurationToFinishAfterStage>
        <postAction Class="RitualStageAction_SoundOneshotOnTarget">
          <sound>GladiatorDuel_Start</sound>
        </postAction>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.33</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>SpeakOnCell</dutyDef>
            <speakerInteraction>Speech_Duel</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_InCircle">
                <preferredRotation>North</preferredRotation>
                <distRange>1~3</distRange>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Fight -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <visualEffectDef>Duel</visualEffectDef>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
          <li Class="StageEndTrigger_DuelEnded">
            <roleIds>
              <li>duelist1</li>
              <li>duelist2</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InCircle">
                <preferredRotation>North</preferredRotation>
                <distRange>1~3</distRange>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Duel</dutyDef>
          </li>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Duel</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Duelists drop weapons -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <endTriggers>
          <li Class="StageEndTrigger_RolesUnarmed">
            <roleIds>
              <li>duelist1</li>
              <li>duelist2</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>DropWeapon</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>DropWeapon</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Wait some time -->
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.05</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Duelists are brought back -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>escorte1</pawnId>
            <targetId>duelist1</targetId>
          </li>
          <li>
            <pawnId>escorte2</pawnId>
            <targetId>duelist2</targetId>
          </li>
        </targets>
        <defaultDuty>SpectateCircle</defaultDuty>
        <spectateDistanceOverride>5~7</spectateDistanceOverride>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>escorte1</li>
              <li>escorte2</li>
            </roleIds>
          </li>
        </endTriggers>
        <preAction Class="RitualStageAction_RemovePawnsFromLord"> <!-- This is required to keep pawns tucked in their bed. -->
          <roleIds>
            <li>duelist1</li>
            <li>duelist2</li>
          </roleIds>
        </preAction>
        <roleBehaviors>
          <li>
            <roleId>leader</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InCircle">
                <preferredRotation>North</preferredRotation>
                <distRange>3~3</distRange>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>escorte1</roleId>
            <dutyDef>DeliverPawnToBedIfAliveThenIdle</dutyDef>
          </li>
          <li>
            <roleId>escorte2</roleId>
            <dutyDef>DeliverPawnToBedIfAliveThenIdle</dutyDef>
          </li>
          <li>
            <roleId>duelist1</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
          <li>
            <roleId>duelist2</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>

    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef ParentName="DateRitualBehavior">
    <defName>FeastCannibal</defName>
    <durationTicks>5000</durationTicks>
    <roles Inherit="False"/>
    <spectatorsLabel>Participants</spectatorsLabel>
    <spectatorGerund>participate</spectatorGerund>
    <stages Inherit="False">
      <li>
        <defaultDuty>EatAtCannibalPlatter</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1.0</percentage>
          </li>
        </endTriggers>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>ScarificationCeremony</defName>
    <workerClass>RitualBehaviorWorker_Mutilation</workerClass>
    <cancellationTriggers>
      <li Class="RitualCancellationTrigger_CannotScarify">
        <roleId>target</roleId>
      </li>
    </cancellationTriggers>
    <roles>
      <li Class="RitualRoleScarificationTarget">
        <label>target</label>
        <id>target</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <missingDesc>the person to scarify</missingDesc>
        <ignoreBleeding>true</ignoreBleeding>
        <countsAsParticipant>False</countsAsParticipant>
      </li>
      <li Class="RitualRoleTag">
        <label>cutter</label>
        <id>doer</id>
        <precept>IdeoRole_Moralist</precept>
        <tag>Moralist</tag>
        <maxCount>1</maxCount>
        <substitutable>true</substitutable>
        <required>true</required>
        <missingDesc>the person who performs the scarification</missingDesc>
        <countsAsParticipant>False</countsAsParticipant>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
    <stages>
      <!-- Target is taken -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>doer</pawnId>
            <targetId>target</targetId>
          </li>
        </targets>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>doer</takerId>
            <takeeId>target</takeeId>
            <desc>Target is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>doer</pawnId>
          </li>
        </failTriggers>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
            <clearTag>true</clearTag>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>DeliverPawnToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell">
                <offset>(-1,0,0)</offset>
                <facing>South</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
            <clearTag>true</clearTag>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.7</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Scarification</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li Class="RitualStage_InteractWithRole">
        <targetId>target</targetId>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_MutilatedRole">
            <roleId>target</roleId>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>Scarify</dutyDef>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.3</percentage>
          </li>
        </endTriggers>
        <postAction Class="RitualStageAction_ClearTag">
          <roleId>doer</roleId>
          <tag>Arrived</tag>
        </postAction>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Scarification</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <!-- Target is brought to bed -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>doer</pawnId>
            <targetId>target</targetId>
          </li>
        </targets>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
          </li>
        </endTriggers>
        <preAction Class="RitualStageAction_StunPawns">
          <roleIds>
            <li>target</li>
          </roleIds>
          <stunDurationTicks>300</stunDurationTicks>
        </preAction>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>DeliverPawnToBedIfAliveThenIdle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>BlindingCeremony</defName>
    <workerClass>RitualBehaviorWorker_Mutilation</workerClass>
    <roles>
      <li Class="RitualRoleBlindingTarget">
        <label>target</label>
        <id>target</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <missingDesc>the person to blind</missingDesc>
        <ignoreBleeding>true</ignoreBleeding>
        <countsAsParticipant>False</countsAsParticipant>
      </li>
      <li Class="RitualRoleTag">
        <label>cutter</label>
        <id>doer</id>
        <precept>IdeoRole_Moralist</precept>
        <tag>Moralist</tag>
        <maxCount>1</maxCount>
        <substitutable>true</substitutable>
        <required>true</required>
        <missingDesc>the person who performs the blinding</missingDesc>
        <countsAsParticipant>False</countsAsParticipant>
      </li>
    </roles>
    <stages>
      <!-- Target is taken -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>doer</pawnId>
            <targetId>target</targetId>
          </li>
        </targets>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>doer</takerId>
            <takeeId>target</takeeId>
            <desc>Target is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>doer</pawnId>
          </li>
        </failTriggers>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
            <clearTag>true</clearTag>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>DeliverPawnToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell">
                <offset>(-1,0,0)</offset>
                <facing>South</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
            <clearTag>true</clearTag>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.7</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Blinding</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell">
                <offset>(-1,0,0)</offset>
                <facing>South</facing>
              </li>
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <li Class="RitualStage_InteractWithRole">
        <targetId>target</targetId>
        <defaultDuty>Spectate</defaultDuty>
        <essential>True</essential>
        <endTriggers>
          <li Class="StageEndTrigger_MutilatedRole">
            <roleId>target</roleId>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>Blind</dutyDef>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell">
                <offset>(-1,0,0)</offset>
                <facing>South</facing>
              </li>
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.3</percentage>
          </li>
        </endTriggers>
        <postAction Class="RitualStageAction_ClearTag">
          <roleId>doer</roleId>
          <tag>Arrived</tag>
        </postAction>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Blinding</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell">
                <facing>West</facing>
              </li>
            </customPositions>
          </li>
          <li>
            <roleId>target</roleId>
            <dutyDef>Idle</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell">
                <offset>(-1,0,0)</offset>
                <facing>South</facing>
              </li>
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <!-- Target is brought to bed -->
      <li Class="RitualStage_InteractWithRole">
        <targets>
          <li>
            <pawnId>doer</pawnId>
            <targetId>target</targetId>
          </li>
        </targets>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>doer</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>doer</roleId>
            <dutyDef>DeliverPawnToBedIfAliveThenIdle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>Conversion</defName>
    <workerClass>RitualBehaviorWorker_Conversion</workerClass>
    <durationTicks>5000</durationTicks>
    <preceptRequirements><li Class="PreceptRequirement_Altar"/></preceptRequirements>
    <roles Inherit="False">
      <li Class="RitualRoleTag">
        <label>speaker</label>
        <id>moralist</id>
        <tag>Moralist</tag>
        <precept>IdeoRole_Moralist</precept>
        <required>True</required>
        <maxCount>1</maxCount>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
      </li>
      <li Class="RitualRoleConvertee">
        <label>convertee</label>
        <id>convertee</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <allowOtherIdeos>True</allowOtherIdeos>
        <countsAsParticipant>False</countsAsParticipant>
      </li>
    </roles>
    <stages>
      <li Class="RitualStage_InteractWithRole">
        <defaultDuty>Spectate</defaultDuty>
        <targetId>convertee</targetId>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDeliveredOrNotValid"/>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>moralist</takerId>
            <takeeId>convertee</takeeId>
            <desc>Prisoner is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>moralist</pawnId>
          </li>
        </failTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>DeliverPawnToAltar</dutyDef>
          </li>
          <li>
            <roleId>convertee</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_InFrontThingCenter"/>
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>moralist</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Conversion</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_Lectern">
                <maxDistanceToFocus>5</maxDistanceToFocus>
              </li>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>convertee</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>TreeConnection</defName>
    <durationTicks>2000</durationTicks>
    <useVisualEffectsFromRoleIdIdeo>connector</useVisualEffectsFromRoleIdIdeo>
    <roles>
      <li Class="RitualRoleColonistConnectable">
        <id>connector</id>
        <label>connector</label>
        <maxCount>1</maxCount>
        <required>True</required>
        <substitutable>true</substitutable>
        <requiredWorkType>PlantCutting</requiredWorkType>
        <defaultForSelectedColonist>true</defaultForSelectedColonist>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <customChildDisallowMessage>Only adults can connect to the Gauranlen tree.</customChildDisallowMessage>
      </li>
    </roles>
    <spectatorsLabel>Spectators</spectatorsLabel>
    <spectatorGerund>spectate</spectatorGerund>
    <stages>
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>connector</roleId>
            <dutyDef>SpeakOnCell</dutyDef>
            <speakerInteraction>Speech_TreeConnection</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_BesideTree" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>Execution</defName>
    <durationTicks>660</durationTicks>
    <workerClass>RitualBehaviorWorker_Execution</workerClass>
    <spectatorFilter Class="RitualSpectatorFilter_WillWitnessExecution">
      <description>Spectators must be willing to watch the execution.</description>
    </spectatorFilter>
    <useVisualEffectsFromRoleIdIdeo>executioner</useVisualEffectsFromRoleIdIdeo>
    <roles>
      <li Class="RitualRoleWarden">
        <label>executioner</label>
        <missingDesc>an executioner</missingDesc>
        <id>executioner</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <allowChild>false</allowChild>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
      <li Class="RitualRolePrisoner">
        <label>prisoner</label>
        <missingDesc>a prisoner</missingDesc>
        <id>prisoner</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <ignoreBleeding>true</ignoreBleeding>
      </li>
    </roles>
    <stages>
      <li Class="RitualStage_InteractWithPrisoner">
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDeliveredOrNotValid"/>
        </endTriggers>
        <failTriggers>
          <li Class="StageFailTrigger_TargetPawnUnreachable">
            <takerId>executioner</takerId>
            <takeeId>prisoner</takeeId>
            <desc>Prisoner is not reachable.</desc>
          </li>
          <li Class="StageFailTrigger_PawnAsleep">
            <desc>escort asleep</desc>
            <pawnId>executioner</pawnId>
          </li>
        </failTriggers>
        <roleBehaviors>
          <li>
            <roleId>executioner</roleId>
            <dutyDef>DeliverPawnToAltar</dutyDef>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>Idle</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.625</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>executioner</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Execution</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
      </li>
      <li Class="RitualStage_InteractWithPrisoner">
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_PawnDead">
            <roleId>prisoner</roleId>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>executioner</roleId>
            <dutyDef>Sacrifice</dutyDef>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
          <li>
            <roleId>prisoner</roleId>
            <dutyDef>LayDownAwake</dutyDef>
          </li>
        </roleBehaviors>
        <visualEffectDef>SacrificePrisoner</visualEffectDef>
      </li>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>0.375</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>executioner</roleId>
            <dutyDef>SpeakOnCellFacingSpectators</dutyDef>
            <speakerInteraction>Speech_Execution</speakerInteraction>
            <customPositions>
              <li Class="RitualPosition_OnInteractionCell" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

  <RitualBehaviorDef>
    <defName>RoleChange</defName>
    <durationTicks>4500</durationTicks>
    <spectatorsLabel>Spectators</spectatorsLabel>
    <spectatorGerund>spectate</spectatorGerund>
    <roles>
      <li Class="RitualRoleIdeoRoleChanger">
        <label>role changer</label>
        <missingDesc>a role changer</missingDesc>
        <id>role_changer</id>
        <maxCount>1</maxCount>
        <required>True</required>
        <countsAsParticipant>False</countsAsParticipant>
        <mustBeAbleToReachTarget>True</mustBeAbleToReachTarget>
      </li>
    </roles>
    <stages>
      <li>
        <defaultDuty>Spectate</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_RolesArrived">
            <roleIds>
              <li>role_changer</li>
            </roleIds>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>role_changer</roleId>
            <dutyDef>ArriveToCell</dutyDef>
            <customPositions>
              <li Class="RitualPosition_BehindThingCenter" />
            </customPositions>
          </li>
        </roleBehaviors>
      </li>
      <li>
        <defaultDuty>SpectateCircle</defaultDuty>
        <endTriggers>
          <li Class="StageEndTrigger_DurationPercentage">
            <percentage>1</percentage>
          </li>
        </endTriggers>
        <roleBehaviors>
          <li>
            <roleId>role_changer</roleId>
            <dutyDef>AcceptRole</dutyDef>
          </li>
        </roleBehaviors>
      </li>
    </stages>
  </RitualBehaviorDef>

</Defs>