HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Another Corpse Bomber in Need

10-26-2007, 10:43 PM#1
Hydrolisk
Right now, I'm trying to make an exploding corpse ability.

The one below is supposed to "detect" corpses by creating a dummy and making it cast Raise Dead. (An extra bit I need help on: Order the dummy to target a unit, or just cast randomly?)
Trigger:
Corpse Bomb Detection
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Corpse Bomb
Collapse Actions
Set corbomp2 = (Target point of ability being cast)
Set corbomug3 = (Units within 200.00 of corbomp2 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is dead) Equal to True)))
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at corbomp2 facing Default building facing degrees
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Unit - Add Corpse Bomb (Detection) to (Last created unit)
Unit - Order (Last created unit) to Undead Necromancer - Raise Dead (Random unit from corbomug3)
Unit - Order (Last created unit) to Undead Necromancer - Raise Dead
Custom script: call RemoveLocation( udg_corbomp2 )
Custom script: call DestroyGroup( udg_corbomug3 )

-

The trigger below is supposed to deal the damage and make special effects. The +1 is for the corpse the dummy used. I'll add corpse removal later. (Tips here are helpful.)
Trigger:
Corpse Bomb
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Corpse Bomb (Detection)
Collapse Actions
Set corbomp1 = (Position of (Triggering unit))
Set corbomug1 = (Units within 200.00 of corbomp1 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is dead) Equal to True)))
Set corbomug2 = (Units within 200.00 of corbomp1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))))
Set corbomi1 = ((Number of units in corbomug1) + 1)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for (Triggering unit)) Equal to 3
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Chosen Knight 0013 <gen> to damage (Picked unit), dealing (40.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for (Triggering unit)) Equal to 2
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Chosen Knight 0013 <gen> to damage (Picked unit), dealing (80.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for (Triggering unit)) Equal to 1
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Chosen Knight 0013 <gen> to damage (Picked unit), dealing (120.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Custom script: call RemoveLocation( udg_corbomp1 )
Custom script: call RemoveLocation( udg_corbomp3 )
Custom script: call DestroyGroup( udg_corbomug1 )
Custom script: call DestroyGroup( udg_corbomug2 )

-

The problem is, only the detection part seems to work, but the actual effect does not.

I need to find the answer to why this doesn't work.
10-27-2007, 09:05 AM#2
Silvenon
The dummy is firing the second code and you were checking if Corpse Bomb for the dummy is 1/2/3. You needed to check if Corpse Bomb for the caster is 1/2/3. So change these:

Trigger:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for (Triggering unit)) Equal to 3
Then - Actions

Into something like this:

Trigger:
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for Caster) Equal to 3
Then - Actions

But you need to store the caster in a variable (named Caster, in this case).
10-28-2007, 05:08 PM#3
Hydrolisk
Oh my, that slipped from me too easily. Thanks.

+Rep (because it's polite).
10-29-2007, 12:38 AM#4
Hydrolisk
Argh, it's not working again! It always seems to be random; one game it WILL work, next game it WON'T. It's really frustrating!

Detection half:
Trigger:
Corpse Bomb Detection
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Corpse Bomb
Collapse Actions
Set corbomp2 = (Target point of ability being cast)
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at corbomp2 facing Default building facing degrees
Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
Unit - Add Corpse Bomb (Detection) to (Last created unit)
Unit - Order (Last created unit) to Undead Necromancer - Raise Dead
Custom script: call RemoveLocation( udg_corbomp2 )

Effect half:
Trigger:
Corpse Bomb
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Corpse Bomb (Detection)
Collapse Actions
Set corbomp1 = (Position of (Triggering unit))
Set corbomug1 = (Units within 210.00 of corbomp1 matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is dead) Equal to True)))
Set corbomug2 = (Units within 210.00 of corbomp1 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))))
Set corbomi1 = ((Number of units in corbomug1) + 1)
Special Effect - Create a special effect at corbomp1 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for Hero) Equal to 3
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Hero to damage (Picked unit), dealing (40.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for Hero) Equal to 2
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Hero to damage (Picked unit), dealing (80.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of Corpse Bomb for Hero) Equal to 1
Collapse Then - Actions
Collapse For each (Integer A) from 0 to corbomi1, do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in corbomug2 and do (Actions)
Collapse Loop - Actions
Set corbomp3 = (Position of (Picked unit))
Special Effect - Create a special effect at corbomp3 using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Unit - Cause Hero to damage (Picked unit), dealing (120.00 x (Real(corbomi1))) damage of attack type Spells and damage type Normal
Else - Actions
Collapse Unit Group - Pick every unit in corbomug1 and do (Actions)
Collapse Loop - Actions
Unit - Remove (Picked unit) from the game
Custom script: call RemoveLocation( udg_corbomp1 )
Custom script: call RemoveLocation( udg_corbomp3 )
Custom script: call DestroyGroup( udg_corbomug1 )
Custom script: call DestroyGroup( udg_corbomug2 )
10-29-2007, 01:27 AM#5
Malf
Collapse JASS:
function YourCondition takes nothing returns boolean
 return GetSpellAbilityId() == 'YourCorpseBombId'
endfunction

function CorpseBomb takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit() //The corpse
local real r = GetUnitState(t,UNIT_STATE_MAX_LIFE)
 call DestroyEffect(AddSpecialEffect("YourEffectPathHere",GetUnitX(t),GetUnitY(t)))
 ..damage units nearby using 'r' because it is the max life of the unit..
 ..when you're done clean leaks..
 set u = null
 set t = null
endfunction

function CorpseBomb_Cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local unit dummy = CreateUnit(GetOwningPlayer(u),'YourId',GetLocationX(l),GetLocationY(l)
 if not IssueImmediateOrder(dummy,"raisedead") then
  call IssueImmediateOrder(u,"stop")
  call CS_Error(GetOwningPlayer(u),"Must cast on area with corpses!")
 endif
 call RemoveLocation(l)
 call RemoveUnit(dummy)
 set u = null
 set dummy = null
 set l = null
endfunction

function InitTrig_CorpseBomb takes nothing returns nothing
local trigger t = CreateTrigger()
 set gg_trg_CorpseBomb = CreateTrigger()
 //Use unit casts an ability for an event and add the function CorpseBomb_Cast to that trigger's triggeraction
 call TriggerAddAction(gg_trg_CorpseBomb,function CorpseBomb_Cast)
 call TriggerAddCondition(gg_trg_CorpseBomb,Condition(function YourConditions))

 //Second trigger
 call TriggerAddAction(t,function CorpseBomb)
 call TriggerAddCondition(t,Condition(function YourConditions))
endfunction

Basically CorpseBomb_Cast uses a dummy, creates it at the target point, orders it to raise dead and if isn't cast(if there are no corpses) then it will stop the caster and simulate and error to avoid wasting his mana and cooldown. Else just proceed with the ability to be started of its effects.

When it starts the effect, another trigger fires off. It stores the caster and the target(the corpse) into variables and then does whatever you want just type in the code.

That's all that you'll need.