Int Spawn Undead

Events


Map initialization

Conditions

Actions


-------- For a starting example we'll use the Ghoul --------


-------- Most of the comments will be devoted to this unit --------


-------- The others will mostly lack them --------


-------- Ghoul --------


Set AbilityCast[0] = Summon Ghoul


Set UndeadSummonUnitType[0] = Ghoul


-------- Sets the number of undead spawned by this spell --------


Set NumberofUndeadSpawned[0] = 1


-------- Resources needed --------


Set CorpsesNeeded[0] = 3


Set FoodNeeded[0] = 2


Set GoldNeeded[0] = 120


Set LumberNeeded[0] = 0


-------- Use this to ensure the summon is from a corpse --------


Set SpawnFromCaster[0] = False


-------- This selects the area which corpses are used to summon. It is a Real. --------


Set CorpseArea[0] = 650.00


-------- This action sets up whether the player pays resources in the Trigger or the spell. --------


-------- If this variable is set to true, you will pay using this trigger --------


-------- If it is set to false, you will be refunded resources if the spell fails to work --------


-------- If you wish to use the spell, Charge Gold and lumber as your base, set to false --------


Set PayResourcesInTrigger[0] = True


-------- Count index --------


-------- Make sure this integer is equal to the highest index used in this trigger --------


Set IndexCount = 0
Spawn undead

Events


Unit - A unit Starts the effect of an ability

Conditions


Or - Any (Conditions) are true



Conditions




(Ability being cast) Equal to AbilityCast[0]

Actions


Actions

-------- This selecs the ability based on the integer it is used --------

For each (Integer A) from 0 to IndexCount, do (Actions)


Loop - Actions



If (All Conditions are True) then do (Then Actions) else do (Else Actions)




If - Conditions





(Ability being cast) Equal to AbilityCast[(Integer A)]




Then - Actions





Set AbilitIndex = (Integer A)




Else - Actions

Set CasterUnit = (Triggering unit)

Set CastingPlayer = (Triggering player)

Player Group - Add CastingPlayer to TriggeringPlayergroup

-------- Now to check if the Resources Needed are available to the player --------

If (All Conditions are True) then do (Then Actions) else do (Else Actions)


If - Conditions



((CastingPlayer Food used) + FoodNeeded[AbilitIndex]) Less than or equal to (CastingPlayer Food max)


Then - Actions



If (All Conditions are True) then do (Then Actions) else do (Else Actions)




If - Conditions





Or - Any (Conditions) are true






Conditions







PayResourcesInTrigger[AbilitIndex] Equal to False







(CastingPlayer Current gold) Greater than or equal to GoldNeeded[AbilitIndex]




Then - Actions





If (All Conditions are True) then do (Then Actions) else do (Else Actions)






If - Conditions







Or - Any (Conditions) are true








Conditions









PayResourcesInTrigger[AbilitIndex] Equal to False









(CastingPlayer Current lumber) Greater than or equal to LumberNeeded[AbilitIndex]






Then - Actions







-------- Ok... Here is where the real Meat starts. --------







-------- First we set the location of where we gather our corpses from --------







Set CasterLoc = (Position of CasterUnit)







-------- Then we set up which ones we gather from --------







-------- THe comparison here selects Dead units --------







-------- And makes sure those Dead units are neither heroes nor structures --------







Set Sapwnundeadgroup = (Units within CorpseArea[AbilitIndex] of CasterLoc matching ((((Matching unit) is dead) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A Hero) Equal to False))))







-------- After that we check how many corpses we consume --------







-------- If there are not enough, we cancel the spell --------







If (All Conditions are True) then do (Then Actions) else do (Else Actions)








If - Conditions









(Number of units in Sapwnundeadgroup) Greater than or equal to CorpsesNeeded[AbilitIndex]








Then - Actions









-------- Remove Resources --------









If (All Conditions are True) then do (Then Actions) else do (Else Actions)










If - Conditions











PayResourcesInTrigger[AbilitIndex] Equal to True










Then - Actions











Player - Set CastingPlayer Current gold to ((CastingPlayer Current gold) - GoldNeeded[AbilitIndex])











Player - Set CastingPlayer Current lumber to ((CastingPlayer Current lumber) - LumberNeeded[AbilitIndex])










Else - Actions









-------- And now we create a new unit group based on how many units we wish to consume --------









Set SpawnUndeadGroupTiny = (Random CorpsesNeeded[AbilitIndex] units from Sapwnundeadgroup)









Set SpwanUndeadCorpseTarget = (Random unit from SpawnUndeadGroupTiny)









Set SpawnUndeadTargetPoint = (Position of SpwanUndeadCorpseTarget)









Set SpwanUndeadCorpseTarget = No unit









If (All Conditions are True) then do (Then Actions) else do (Else Actions)










If - Conditions











SpawnFromCaster[AbilitIndex] Equal to True










Then - Actions











Unit - Create NumberofUndeadSpawned[AbilitIndex] UndeadSummonUnitType[AbilitIndex] for CastingPlayer at CasterLoc facing Default building facing degrees










Else - Actions











Unit - Create NumberofUndeadSpawned[AbilitIndex] UndeadSummonUnitType[AbilitIndex] for CastingPlayer at SpawnUndeadTargetPoint facing Default building facing degrees









Custom script: call RemoveLocation(udg_SpawnUndeadTargetPoint)









-------- This stets the rally point up as a location so that the unit may be ordered to go there --------









Set SummonRallyPoint = (Rally-Point of CasterUnit as a point)









Unit - Order (Last created unit) to Move To SummonRallyPoint









Custom script: call RemoveLocation(udg_SummonRallyPoint)









Set CasterUnit = (Triggering unit)









Unit Group - Pick every unit in SpawnUndeadGroupTiny and do (Actions)










Loop - Actions











Set SpawnundeadspecialEffectPoint = (Position of (Picked unit))











-------- Create special effect then instantly destroy it. --------











Special Effect - Create a special effect at SpawnundeadspecialEffectPoint using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl











Special Effect - Destroy (Last created special effect)











-------- Remove Point --------











Custom script: call RemoveLocation(udg_SpawnundeadspecialEffectPoint)











Unit - Remove (Picked unit) from the game









Custom script: call DestroyGroup(udg_SpawnUndeadGroupTiny)








Else - Actions









If (All Conditions are True) then do (Then Actions) else do (Else Actions)










If - Conditions











PayResourcesInTrigger[AbilitIndex] Equal to False










Then - Actions











Player - Set CastingPlayer Current gold to ((CastingPlayer Current gold) + GoldNeeded[AbilitIndex])











Player - Set CastingPlayer Current lumber to ((CastingPlayer Current lumber) + LumberNeeded[AbilitIndex])










Else - Actions









Unit - Remove AbilityCast[AbilitIndex] from CasterUnit









Unit - Add AbilityCast[AbilitIndex] to CasterUnit









Game - Display to TriggeringPlayergroup the text: There are not enoug...







-------- And now since we don't need this location or group anymore, we remove it to patch up leaks --------







Custom script: call DestroyGroup(udg_Sapwnundeadgroup)







Custom script: call RemoveLocation(udg_CasterLoc)






Else - Actions







Unit - Remove AbilityCast[AbilitIndex] from CasterUnit







Unit - Add AbilityCast[AbilitIndex] to CasterUnit







Game - Display to TriggeringPlayergroup the text: Not Enough Lumber




Else - Actions





Unit - Remove AbilityCast[AbilitIndex] from CasterUnit





Unit - Add AbilityCast[AbilitIndex] to CasterUnit





Game - Display to TriggeringPlayergroup the text: Not Enough Gold


Else - Actions



If (All Conditions are True) then do (Then Actions) else do (Else Actions)




If - Conditions





PayResourcesInTrigger[AbilitIndex] Equal to False




Then - Actions





Player - Set CastingPlayer Current gold to ((CastingPlayer Current gold) + GoldNeeded[AbilitIndex])





Player - Set CastingPlayer Current lumber to ((CastingPlayer Current lumber) + LumberNeeded[AbilitIndex])




Else - Actions



Unit - Remove AbilityCast[AbilitIndex] from CasterUnit



Unit - Add AbilityCast[AbilitIndex] to CasterUnit



Game - Display to TriggeringPlayergroup the text: Not Enough Food

Set CasterUnit = No unit

Player Group - Remove CastingPlayer from TriggeringPlayergroup