• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Undead "Sacrifice" ability

Status
Not open for further replies.
Level 8
Joined
Mar 24, 2011
Messages
353
you know how does a "Shade" in the Undeads?
which has an "Acolyte" and you sacrifice him at home, waiting a few seconds and get a "Shade"?
so I wanted something similar for example to my map
I needed this "system" example:
My "Villager" went to the "Arcane Sancturn" used the "safricique" and a few seconds became a "Priest"
how do I an effect this? why the ability to "sacrifice" of the undead only works with "Acolyte" :/

Thanks :ogre_haosis::ogre_haosis:
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
Phew, it took me longer than I expected. If anyone sees anything wrong with this or has any idea how to improve it, please let me know.

READ ME
JASS:
==================================
== THIS SYSTEM DOES NOT SUPPORT ==

a) More than 1 type of Sacrifice-type spell on the same unit-type
Both the original (undead) Sacrifice and the custom Sacrifice share same spell ID.
If unit/building has both these spells, they will conflict with each other.

b) Queue units to be trained.
This means that if you are already training any unit in the building and you want to sacrifice
another unit in it, nothing will happen (error message should pop up).


==========================
== THIS SYSTEM REQUIRES ==

a) The new unit (e.g. Shade) must not be trained in any other building!
The new unit is either disabled (= cannot be seen) for that player or enabled (= can be seen and trained),
it is not possible for that unit to be disabled for specific building only!

This can be bypassed by:
    1) Having a copy of the same unit-type as the new unit
         - one unit-type is enabled and regular for training, the other is disabled and used
           as Sacrifice_NewUnit. Then when one or the other has been created, that unit is replaced
           by the other unit-type.
    2) Training/Byuing that unit from neutral passive player


  • Sacrifice Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- THIS SHOULD BE SET UP BY THE USER --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- 1 --------
      • Set Sacrifice_Index = (Sacrifice_Index + 1)
      • -------- ---------- --------
      • Set Sacrifice_Building[Sacrifice_Index] = Arcane Sanctum
      • Set Sacrifice_BuildingName[Sacrifice_Index] = Arcane Sanctum
      • Set Sacrifice_Victim[Sacrifice_Index] = Faithful Villager
      • Set Sacrifice_VictimName[Sacrifice_Index] = Faithful Villager
      • Set Sacrifice_NewUnit[Sacrifice_Index] = Priest
      • Set Sacrifice_Gold[Sacrifice_Index] = 135
      • Set Sacrifice_Lumber[Sacrifice_Index] = 10
      • Set Sacrifice_Food[Sacrifice_Index] = 1
      • Set Sacrifice_Ability_Building[Sacrifice_Index] = Initiation (Building)
      • Set Sacrifice_Ability_Unit[Sacrifice_Index] = Initiation (Unit)
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- 2 --------
      • Set Sacrifice_Index = (Sacrifice_Index + 1)
      • -------- ---------- --------
      • Set Sacrifice_Building[Sacrifice_Index] = Barracks
      • Set Sacrifice_BuildingName[Sacrifice_Index] = Barracks
      • Set Sacrifice_Victim[Sacrifice_Index] = Stout Villager
      • Set Sacrifice_VictimName[Sacrifice_Index] = Stout Villager
      • Set Sacrifice_NewUnit[Sacrifice_Index] = Footman
      • Set Sacrifice_Gold[Sacrifice_Index] = 135
      • Set Sacrifice_Lumber[Sacrifice_Index] = 0
      • Set Sacrifice_Food[Sacrifice_Index] = 1
      • Set Sacrifice_Ability_Building[Sacrifice_Index] = Enlistment (Building)
      • Set Sacrifice_Ability_Unit[Sacrifice_Index] = Enlistment (Unit)
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- ACTIONS BELOW SHOULD NOT BE TOUCHED --------
      • -------- Note: The action below disables every Sacrifice_NewUnit for all players! --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
            • Loop - Actions
              • Player - Make Sacrifice_NewUnit[LoopInteger] Unavailable for training/construction by (Picked player)
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • Hashtable - Create a hashtable
      • Set SacrificeHash = (Last created hashtable)
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • Set ErrorRace[1] = Human
      • Set ErrorNoFood[1] = Build more Farms to continue unit production.
      • -------- --------- --------
      • Set ErrorRace[2] = Orc
      • Set ErrorNoFood[2] = Build more Burrows to continue unit production.
      • -------- --------- --------
      • Set ErrorRace[3] = Undead
      • Set ErrorNoFood[3] = Summon more Ziggurats to continue unit production.
      • -------- --------- --------
      • Set ErrorRace[4] = Night Elf
      • Set ErrorNoFood[4] = Create more Moon Wells to continue unit production.
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
  • Sacrifice Order Check
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(sacrifice))
          • (Issued order) Equal to (Order(requestsacrifice))
    • Actions
      • Set u1 = (Triggering unit)
      • Set u2 = (Target unit of issued order)
      • Set order = (Issued order)
      • Set player = (Owner of u1)
      • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Level of Sacrifice_Ability_Building[LoopInteger] for u1) Equal to 1
                  • (Level of Sacrifice_Ability_Unit[LoopInteger] for u1) Equal to 1
            • Then - Actions
              • Set int = LoopInteger
            • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- CHECKS WHICH ORDER HAS BEEN ISSUED AND CHECKS CONDITIONS --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • order Equal to (Order(requestsacrifice))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u2) Not equal to Sacrifice_Victim[int]
            • Then - Actions
              • -------- SANCTUM DOES NOT TARGET VILLAGER --------
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorFound = True
              • Set ErrorMessage = (Must target + (Sacrifice_VictimName[int] + .))
              • Set ErrorPlayer = (Triggering player)
              • -------- ------------------------------------------------------------------------ --------
            • Else - Actions
              • Unit - Order u2 to Undead Sacrificial Pit - Sacrifice u1
        • Else - Actions
          • -------- THE ITEs BELOW CHECK ALL CONDITIONS --------
          • -------- a) If correct unit is selected --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u1) Equal to Sacrifice_Victim[int]
              • (Unit-type of u2) Not equal to Sacrifice_Building[int]
            • Then - Actions
              • -------- VILLAGER DOES NOT TARGET SANCTUM --------
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorFound = True
              • Set ErrorMessage = (Must target + (Sacrifice_BuildingName[int] + .))
              • Set ErrorPlayer = (Triggering player)
              • -------- ------------------------------------------------------------------------ --------
            • Else - Actions
          • -------- ------------------------------------------------------------------------ --------
          • -------- b) If player has enough resources --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (player Current gold) Less than Sacrifice_Gold[int]
            • Then - Actions
              • -------- NOT ENOUGH GOLD --------
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorFound = True
              • Set ErrorMessage = Not enough gold.
              • Set ErrorPlayer = (Triggering player)
              • -------- ------------------------------------------------------------------------ --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (player Current lumber) Less than Sacrifice_Lumber[int]
                • Then - Actions
                  • -------- NOT ENOUGH LUMBER --------
                  • Custom script: if udg_ErrorSound == null then
                  • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
                  • Custom script: endif
                  • Set ErrorFound = True
                  • Set ErrorMessage = Not enough lumber.
                  • Set ErrorPlayer = (Triggering player)
                  • -------- ------------------------------------------------------------------------ --------
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((player Food max) - (player Food used)) Less than Sacrifice_Food[int]
                    • Then - Actions
                      • -------- NOT ENOUGH FOOD --------
                      • Custom script: if udg_ErrorSound == null then
                      • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
                      • Custom script: endif
                      • Set ErrorFound = True
                      • For each (Integer LoopInteger) from 1 to 4, do (Actions)
                        • Loop - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Race of player) Equal to ErrorRace[LoopInteger]
                            • Then - Actions
                              • Set ErrorMessage = ErrorNoFood[LoopInteger]
                            • Else - Actions
                      • Set ErrorPlayer = (Triggering player)
                      • -------- ------------------------------------------------------------------------ --------
                    • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- CHECKS IF BUILDING IS ALREADY CREATING A UNIT --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of u1) Equal to Sacrifice_Building[int]
          • (Load 1 of (Key (Triggering unit)) from SacrificeHash) Equal to True
        • Then - Actions
          • -------- SACRIFICE-BUILDING IS TRAINING A UNIT ALREADY! --------
          • Custom script: if udg_ErrorSound == null then
          • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
          • Custom script: endif
          • Set ErrorFound = True
          • Set ErrorMessage = This building is currently occupied.
          • Set ErrorPlayer = (Triggering player)
          • -------- ------------------------------------------------------------------------ --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u2) Equal to Sacrifice_Building[int]
              • (Load 1 of (Key (Target unit of issued order)) from SacrificeHash) Equal to True
            • Then - Actions
              • -------- SACRIFICE-BUILDING IS TRAINING A UNIT ALREADY! --------
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorFound = True
              • Set ErrorMessage = This building is currently occupied.
              • Set ErrorPlayer = (Triggering player)
              • -------- ------------------------------------------------------------------------ --------
            • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- IF ERROR AND TRIG.UNIT IS VILLAGER, STOPS THAT UNIT --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ErrorFound Equal to True
          • (Unit-type of u1) Equal to Sacrifice_Victim[int]
        • Then - Actions
          • Unit - Pause u1
          • Unit - Order u1 to Stop
          • Unit - Unpause u1
        • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- SHOWS ERROR, IF ANY HAS BEEN FOUND --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ErrorFound Equal to True
        • Then - Actions
          • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
          • Custom script: call ClearTextMessages()
          • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
          • Custom script: call StartSound(udg_ErrorSound)
          • Custom script: endif
          • Set ErrorFound = False
        • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • Set u1 = No unit
      • Set u2 = No unit
      • Set order = (Order(<Empty String>))
      • Custom script: set udg_player = null
  • Sacrifice Training Check
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Current order of (Triggering unit)) Equal to (Order(sacrifice))
      • (Load 1 of (Key (Target unit of ability being cast)) from SacrificeHash) Equal to False
    • Actions
      • Set u1 = (Triggering unit)
      • Set u2 = (Target unit of ability being cast)
      • Set player = (Owner of u1)
      • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sacrifice_Ability_Unit[LoopInteger] for u1) Equal to 1
            • Then - Actions
              • Set int = LoopInteger
            • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- CHECKS CONDITIONS --------
      • -------- a) If player has enough resources --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (player Current gold) Less than Sacrifice_Gold[int]
        • Then - Actions
          • -------- NOT ENOUGH GOLD --------
          • Custom script: if udg_ErrorSound == null then
          • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
          • Custom script: endif
          • Set ErrorFound = True
          • Set ErrorMessage = Not enough gold.
          • Set ErrorPlayer = (Triggering player)
          • -------- ------------------------------------------------------------------------ --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (player Current lumber) Less than Sacrifice_Lumber[int]
            • Then - Actions
              • -------- NOT ENOUGH LUMBER --------
              • Custom script: if udg_ErrorSound == null then
              • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
              • Custom script: endif
              • Set ErrorFound = True
              • Set ErrorMessage = Not enough lumber.
              • Set ErrorPlayer = (Triggering player)
              • -------- ------------------------------------------------------------------------ --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((player Food max) - (player Food used)) Less than Sacrifice_Food[int]
                • Then - Actions
                  • -------- NOT ENOUGH FOOD --------
                  • Custom script: if udg_ErrorSound == null then
                  • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
                  • Custom script: endif
                  • Set ErrorFound = True
                  • For each (Integer LoopInteger) from 1 to 4, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Race of player) Equal to ErrorRace[LoopInteger]
                        • Then - Actions
                          • Set ErrorMessage = ErrorNoFood[LoopInteger]
                        • Else - Actions
                  • Set ErrorPlayer = (Triggering player)
                  • -------- ------------------------------------------------------------------------ --------
                • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- b) if Building is already creating a unit --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load 1 of (Key (Target unit of issued order)) from SacrificeHash) Equal to True
        • Then - Actions
          • -------- SACRIFICE-BUILDING IS TRAINING A UNIT ALREADY! --------
          • Custom script: if udg_ErrorSound == null then
          • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
          • Custom script: endif
          • Set ErrorFound = True
          • Set ErrorMessage = This building is currently occupied.
          • Set ErrorPlayer = (Triggering player)
          • -------- ------------------------------------------------------------------------ --------
        • Else - Actions
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- SHOWS ERROR, IF ANY HAS BEEN FOUND, ELSE GOES ON --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ErrorFound Equal to True
        • Then - Actions
          • Set ErrorFound = False
          • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
          • Custom script: call ClearTextMessages()
          • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
          • Custom script: call StartSound(udg_ErrorSound)
          • Custom script: endif
        • Else - Actions
          • Hashtable - Save Handle Ofu1 as 2 of (Key (Target unit of ability being cast)) in SacrificeHash
          • Unit - Make u1 Invulnerable
          • Unit - Pause u1
          • Unit - Change ownership of u1 to Neutral Passive and Retain color
          • Unit - Hide u1
          • -------- ------------------------------------------------------------------------ --------
          • Player - Make Sacrifice_NewUnit[int] Available for training/construction by player
          • Unit - Order u2 to train/upgrade to a Sacrifice_NewUnit[int]
          • Player - Make Sacrifice_NewUnit[int] Unavailable for training/construction by player
          • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • -------- ------------------------------------------------------------------------ --------
      • Set u1 = No unit
      • Set u2 = No unit
      • Custom script: set udg_player = null
  • Sacrifice Production Start
    • Events
      • Unit - A unit Begins an upgrade
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • Set u1 = (Triggering unit)
      • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u1) Equal to Sacrifice_Building[LoopInteger]
            • Then - Actions
              • Hashtable - Save True as 1 of (Key (Triggering unit)) in SacrificeHash
            • Else - Actions
      • Set u1 = No unit
  • Sacrifice Production Cancel
    • Events
      • Unit - A unit Cancels an upgrade
      • Unit - A unit Cancels training a unit
      • Unit - A unit Finishes an upgrade
    • Conditions
    • Actions
      • Set u1 = (Triggering unit)
      • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u1) Equal to Sacrifice_Building[LoopInteger]
            • Then - Actions
              • Hashtable - Save False as 1 of (Key (Triggering unit)) in SacrificeHash
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Trained unit-type) Equal to Sacrifice_NewUnit[LoopInteger]
                • Then - Actions
                  • Set player = (Owner of u1)
                  • Set u2 = (Load 2 of (Key (Triggering unit)) in SacrificeHash)
                  • Unit - Make u2 Vulnerable
                  • Unit - Unpause u2
                  • Unit - Change ownership of u2 to player and Retain color
                  • Unit - Unhide u2
                  • Hashtable - Save 0 as 2 of (Key (Triggering unit)) in SacrificeHash
                  • Set u2 = No unit
                  • Custom script: set udg_player = null
                • Else - Actions
            • Else - Actions
      • Set u1 = No unit
  • Sacrifice Production Finish
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set u1 = (Triggering unit)
      • For each (Integer LoopInteger) from 1 to Sacrifice_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u1) Equal to Sacrifice_Building[LoopInteger]
            • Then - Actions
              • Hashtable - Save False as 1 of (Key (Triggering unit)) in SacrificeHash
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Trained unit-type) Equal to Sacrifice_NewUnit[LoopInteger]
                • Then - Actions
                  • Set u2 = (Load 2 of (Key (Triggering unit)) in SacrificeHash)
                  • Unit - Remove u2 from the game
                  • Hashtable - Save 0 as 2 of (Key (Triggering unit)) in SacrificeHash
                  • Set u2 = No unit
                • Else - Actions
            • Else - Actions
      • Set u1 = No unit

Map attached
How to import this is explained in the map and all variables are listed and explained there as well.
 

Attachments

  • Custom Sacrifice version 1.02.w3x
    34.2 KB · Views: 109
Last edited:
Status
Not open for further replies.
Top