• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Elect new Pope trigger

Level 12
Joined
Apr 9, 2013
Messages
762
Hello,

I'm trying to introduce a Pope system in my map simulating papal elections. The easiest way I can see to make it in wc3 is this:

  • Bishop gets trained at Cathedral and if no Pope exists the bishop becomes Pope, once he is pope (hero instead of unit) he will expire in X minutes (dies), a new Bishop is picked to become Pope after 1 minute (Papal Election X minutes).
  • Any bishop on the map can become Pope (no matter which player owns it) if no other pope present, it should favour Bishops with highest amount of mana (so 100 over 99 mana etc..)
  • Every time a Pope is elected it should run a text to all Players "Pope (insert hero string name) has been elected from (insert player name)" also when he dies "Pope (insert hero string name) has died from (player name)"
    Note: pope can die in combat (earlier than expiration time) so trigger should account for this. Multiple players can train bishops but only one of them becomes Pope.
Purpose of Trigger is to emulate Papal Elections.

If anyone has an idea how to make this in wc3 or if you think there's a better way to introduce this mechanic do tell.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
You can start with a Boolean variable to track the state of things:
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable Pope_Is_Active = False
This trigger isn't actually necessary since Booleans will be False by default, but I figured it would help get the point across. Now whenever something happens that's related to the Pope you can check for this Condition.


So when a Bishop enters the map and there's no Pope active you can "elect" them:
  • Bishop Is Elected
    • Events
      • Unit - A unit Enters (Playable map area)
    • Conditions
      • Pope_Is_Active Equal to False
      • (Unit-type of (Triggering unit)) Equal to Bishop
    • Actions
      • Unit - Replace (Triggering unit) with a Pope using The old unit's relative life and mana
      • Set Variable Pope_Is_Active = True
      • Set Variable Pope = (Last replaced unit)
      • Unit - Add a 60.00 second Generic expiration timer to Pope
      • -------- Display your text messages... --------
Pope is a Unit variable.


Then when the Pope dies, set Pope_Is_Active to False and display your text messages. Note that if the Pope dies of natural causes, in other words from it's own Expiration Timer or from loss of life (not damage) there will be no (Killing unit). You would want to account for this when displaying your Text Messages. You can use an If Then Else to differentiate between the different circumstances:
  • Pope Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • Pope_Is_Active Equal to True
      • (Triggering unit) Equal to Pope
    • Actions
      • Set Variable Pope_Is_Active = False
      • -------- Display your text messages... --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to No unit
        • Then - Actions
          • -------- The Pope died of natural causes --------
        • Else - Actions
          • -------- The Pope was murdered, RIOT --------

Then for electing a Pope based on Mana values you could periodically check the Mana of each Bishop using a Unit Group and the technique seen below. The Bishop with the greatest mana will become the new Pope, ties will effectively pick a winner at random, and if no Bishop exists then nothing will happen:
  • Periodic Popage
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
      • Pope_Is_Active Equal to False
    • Actions
      • Set Variable Pope_Greatest_Mana = -1.00
      • Set Variable Pope_Best_Candidate = No unit
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Bishop))) and do (Actions)
        • Loop - Actions
          • Set VariableSet Pope_Mana = (Mana of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Pope_Mana Greater than Pope_Greatest_Mana
            • Then - Actions
              • Set Variable Pope_Greatest_Mana = Pope_Mana
              • Set Variable Pope_Best_Candidate = (Picked unit)
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Pope_Best_Candidate Not equal to No unit
        • Then - Actions
          • -------- We found a new Pope, hallelujah --------
          • Unit - Replace Pope_Best_Candidate with a Pope using The old unit's relative life and mana
          • Set Variable Pope_Is_Active = True
          • Set Variable Pope = (Last replaced unit)
          • Unit - Add a 60.00 second Generic expiration timer to Pope
        • Else - Actions
Note how the trigger won't run any Actions if there is an active Pope, ensuring that it won't attempt to "elect" a Pope until the current Pope is dead. Pope_Greatest_Mana and Pope_Mana are Real variables. Pope_Best_Candidate is a Unit variable.

Edit: Made some slight tweaks to the triggers but nothing necessary.
 
Last edited:
Level 12
Joined
Apr 9, 2013
Messages
762
You can start with a Boolean variable to track the state of things:
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable Pope_Is_Active = False
This trigger isn't actually necessary since Booleans will be False by default, but I figured it would help get the point across. Now whenever something happens that's related to the Pope you can check for this Condition.


So when a Bishop enters the map and there's no Pope active you can "elect" them:
  • Bishop Is Elected
    • Events
      • Unit - A unit Enters (Playable map area)
    • Conditions
      • Pope_Is_Active Equal to False
      • (Unit-type of (Triggering unit)) Equal to Bishop
    • Actions
      • Unit - Replace (Triggering unit) with a Pope using The old unit's relative life and mana
      • Set Variable Pope_Is_Active = True
      • Set Variable Pope = (Last replaced unit)
      • Unit - Add a 60.00 second Generic expiration timer to Pope
      • -------- Display your text messages... --------
Pope is a Unit variable.


Then when the Pope dies, set Pope_Is_Active to False and display your text messages. Note that if the Pope dies of natural causes, in other words from it's own Expiration Timer or from loss of life (not damage) there will be no (Killing unit). You would want to account for this when displaying your Text Messages. You can use an If Then Else to differentiate between the different circumstances:
  • Pope Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • Pope_Is_Active Equal to True
      • (Triggering unit) Equal to Pope
    • Actions
      • Set Variable Pope_Is_Active = False
      • -------- Display your text messages... --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to No unit
        • Then - Actions
          • -------- The Pope died of natural causes --------
        • Else - Actions
          • -------- The Pope was murdered, RIOT --------

Then for electing a Pope based on Mana values you could periodically check the Mana of each Bishop using a Unit Group and the technique seen below. The Bishop with the greatest mana will become the new Pope, ties will effectively pick a winner at random, and if no Bishop exists then nothing will happen:
  • Periodic Popage
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
      • Pope_Is_Active Equal to False
    • Actions
      • Set Variable Pope_Greatest_Mana = -1.00
      • Set Variable Pope_Best_Candidate = No unit
      • -------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Bishop))) and do (Actions)
        • Loop - Actions
          • Set VariableSet Pope_Mana = (Mana of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Pope_Mana Greater than Pope_Greatest_Mana
            • Then - Actions
              • Set Variable Pope_Greatest_Mana = Pope_Mana
              • Set Variable Pope_Best_Candidate = (Picked unit)
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Pope_Best_Candidate Not equal to No unit
        • Then - Actions
          • -------- We found a new Pope, hallelujah --------
          • Unit - Replace Pope_Best_Candidate with a Pope using The old unit's relative life and mana
          • Set Variable Pope_Is_Active = True
          • Set Variable Pope = (Last replaced unit)
          • Unit - Add a 60.00 second Generic expiration timer to Pope
        • Else - Actions
Note how the trigger won't run any Actions if there is an active Pope, ensuring that it won't attempt to "elect" a Pope until the current Pope is dead. Pope_Greatest_Mana and Pope_Mana are Real variables. Pope_Best_Candidate is a Unit variable.

Edit: Made some slight tweaks to the triggers but nothing necessary.
Hello, I tried this in a new map, the problem is that sometimes no Captain spawns or 2 Captains spawn at the same time.
 

Attachments

  • SNIperofDARknessMap V.3.w3x
    23.2 KB · Views: 3
Level 12
Joined
Apr 9, 2013
Messages
762
There was some slight mistakes here and there that I fixed. You have to double check your triggers, one little error can throw everything off.

Yes I see, you're right.

The trigger works better now, however it seems that there is an exploit that can appear, it prioritises the newest trained unit if the Pope is dead, and not existing units on the map with higher mana. Even if the times are changed, it can happen that a player trains their Bishop at the right time and the Pope dies, meaning they will get the Pope. How can I fix this?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Yes I see, you're right.

The trigger works better now, however it seems that there is an exploit that can appear, it prioritises the newest trained unit if the Pope is dead, and not existing units on the map with higher mana. Even if the times are changed, it can happen that a player trains their Bishop at the right time and the Pope dies, meaning they will get the Pope. How can I fix this?
If you always want the newest Pope to be the one with the most mana then you should take the "best candidate" logic and apply it to your "bishop was elected" trigger.

On Bishop enters map -> Pope Is Active Equal to False -> Trigger - Run Periodic Popage (ignoring conditions)
 
Last edited:
Level 12
Joined
Apr 9, 2013
Messages
762
If you always want the newest Pope to be the one with the most mana then you should take the "best candidate" logic and apply it to your "bishop was elected" trigger.

On Bishop enters map -> Pope Is Active Equal to False -> Trigger - Run Periodic Popage (ignoring conditions)

How do I go about that when the Pope is elected it says the name of the Hero, so Pope Gregory ascended etc..
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
How do I go about that when the Pope is elected it says the name of the Hero, so Pope Gregory ascended etc..
You use the functions for getting a unit's name in your text message:
  • Game - Display to (All players) the text: ((Name of (Owner of Captain_Unit)) + (( has elected + (Name of Captain_Unit)) + as Captain))
1723904822008.png

If it's a Hero, you may want to reference it's Hero - Hero Proper Name instead.

I attached an updated map with a new text message. Also, the last map I uploaded seemed to have some mistakes which are fixed now.
 

Attachments

  • SNIperofDARknessMap V.3 2 Fix1.w3x
    23.2 KB · Views: 4
Level 12
Joined
Apr 9, 2013
Messages
762
You use the functions for getting a unit's name in your text message:
  • Game - Display to (All players) the text: ((Name of (Owner of Captain_Unit)) + (( has elected + (Name of Captain_Unit)) + as Captain))
View attachment 483298
If it's a Hero, you may want to reference it's Hero - Hero Proper Name instead.

I attached an updated map with a new text message. Also, the last map I uploaded seemed to have some mistakes which are fixed now.
Oh thank you, you even fixed the bug where it always prioritised the first unit trained to become new Pope. Great!
 
Level 12
Joined
Apr 9, 2013
Messages
762
You use the functions for getting a unit's name in your text message:
  • Game - Display to (All players) the text: ((Name of (Owner of Captain_Unit)) + (( has elected + (Name of Captain_Unit)) + as Captain))
View attachment 483298
If it's a Hero, you may want to reference it's Hero - Hero Proper Name instead.

I attached an updated map with a new text message. Also, the last map I uploaded seemed to have some mistakes which are fixed now.

How could I add some colour to the player name and also to the Hero's name (attached)


1724079681785.png

EDIT:
Trigger in action
I suppose in the far future i'd also want to add an Anti-Pope feature, where if a Pope is present, a bishop can (with Destroyer Upgrade) become anti-pope, the anti-pope, if the real pope dies the anti pope becomes the new Pope.
Pope wars.
 
Last edited:
Level 25
Joined
Mar 29, 2020
Messages
1,466
here is a colored string. I colored the word stuff light green: |cff00ff00stuff|r

this string is made up of 4 parts:

1. the prefix,: |c
this is telling the parser that it should start coloring the string from here

2. the color I chose: ff00ff00
this is the color in ARGB format
  • ff is the alpha component (255 in decimal, fully opaque),
  • 00 is the red component (0 in decimal),
  • ff is the green component (255 in decimal, full green),
  • 00 is the blue component (0 in decimal).

3. The text that I want to be displayed in color, in this case the word: "stuff"

4. the suffix that tells the parser the string that I am coloring has ended: |r

knowing this - you can use string concatenation and put the correct prefix and suffix around any variable based, dynamically generated string.

here is an example:

  • Untitled Trigger 003
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: ((|cff00ff00 + (Name of Player 1 (Red))) + stuff|r)
to do this you select concatenate string to define the string. you can keep doing this (babushka style) to achieve a string with as many pieces as you want.
 
Top