• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Shotgun

Status
Not open for further replies.
Level 6
Joined
Jan 31, 2014
Messages
67
I'm creating a Shotgun spell , and I was thinking how to make (with triggers) nearby units to take more damage , I made this trigger , but it only damaged one unit nearby or none of them.
I based shotgun spell of Carrion Swarm
Events
Unit-A unit starts the effect of an ability.
conditions
ability being cast equal to shotgun
Action
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Targeted unit) has buff Shotgun) Equal to True
Then - Actions
Unit Group - Pick every unit in (Units within 100.00 of (Target point of ability being cast)) and do (Actions)
Loop - Actions
Unit - Cause (Triggering unit) to damage (Targeted unit), dealing 50.00 damage of attack type Spells and damage type Normal
Else - Actions
This way it only damage one unit or don't do any damage at all...
Can you help me?
 
Level 9
Joined
Feb 15, 2013
Messages
372
[trigger=Shotgun]
Shotgun
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Shotgun
Actions
Set SG_Caster = (Triggering unit)
Set SG_Target = (Target unit of ability being cast)
Set SG_Point = (Position of SG_Target)
Set SG_Group = (Units within 100.00 of SG_Point 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 SG_Caster)) Equal to True) and ((Matching unit) Not equal to S
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in SG_Group and do (Actions)
Loop - Actions
Unit - Cause SG_Caster to damage (Picked unit), dealing 50.00 damage of attack type Spells and damage type Normal
Custom script: call RemoveLocation(udg_SG_Point)
Custom script: set udg_SG_Point = null
Set SG_Caster = No unit
Set SG_Target = No unit
[/trigger]

Try this, this might help you :)
 
Level 6
Joined
Jan 31, 2014
Messages
67
[trigger=Shotgun]
Shotgun
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Shotgun
Actions
Set SG_Caster = (Triggering unit)
Set SG_Target = (Target unit of ability being cast)
Set SG_Point = (Position of SG_Target)
Set SG_Group = (Units within 100.00 of SG_Point 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 SG_Caster)) Equal to True) and ((Matching unit) Not equal to S
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in SG_Group and do (Actions)
Loop - Actions
Unit - Cause SG_Caster to damage (Picked unit), dealing 50.00 damage of attack type Spells and damage type Normal
Custom script: call RemoveLocation(udg_SG_Point)
Custom script: set udg_SG_Point = null
Set SG_Caster = No unit
Set SG_Target = No unit
[/trigger]

Try this, this might help you :)

Don't know why ,but Custom script: set bj_wantDestroyGroup = true counts to me as error.
 
Level 9
Joined
Feb 15, 2013
Messages
372
Hmmm....
[trigger=Shotgun]
Shotgun
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Shotgun
Actions
Set SG_Caster = (Triggering unit)
Set SG_Target = (Target unit of ability being cast)
Set SG_Point = (Position of SG_Target)
Set SG_Group = (Units within 100.00 of SG_Point 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 SG_Caster)) Equal to True) and ((Matching unit) Not equal to S
Unit Group - Pick every unit in SG_Group and do (Actions)
Loop - Actions
Unit - Cause SG_Caster to damage (Picked unit), dealing 50.00 damage of attack type Spells and damage type Normal
Custom script: call DestroyGroup(udg_SG_Group)
Custom script: call RemoveLocation(udg_SG_Point)
Custom script: set udg_SG_Point = null
Set SG_Caster = No unit
Set SG_Target = No unit
[/trigger]

Try this?
 
You can easily add a multiplier based on the distance to the target. There is a GUI function called "distance between points", which takes two locations and gives you the distance between them. Now, you want the damage to be inversely proportional to the distance. The formula is really simple, here is a basic sketch:

set [distance] = distance between (picked unit) and (casting unit)

if [distance] is less than 200, then (give full damage)

else damage (picked unit) with ((200/distance)*dmg) damage

In this case, (200/distance) is the factor, and dmg is the max damage of the spell. As you notice, the factor will shrink as the distance becomes longer. There are ways to modify it so that the damage will drop quicker, but test this first. To group all units in a line in front of the target, i suggest you do something like this:

set TempGroup2 = new group
for each index A from 1 to 3, do:
set TempPoint = point offset of (For loop index A)*(shotgun range/3), with angle (facing of casting unit)
set TempGroup1 = units within (For loop index A)*(max spread radius/3) of TempPoint
add TempGroup1 to TempGroup2
destroy TempGroup1

Then, when you want to apply the damage, just loop through the units in TempGroup2. Note that i have not really added any leak fixes and stuff, i trust you know that yourself. I am also a bit fuzzy on how groups work in GUI, but you get the point. Basically, what i am trying to say is:

*First, group all the units in a line in front of the caster, using three or more points.
*Second, go through all units in the group and check their range from the caster.
*Third, calculate and apply damage based on distance to caster.
 
Last edited:
When you use and destroy group variables, there is no need for 'set bj_wantDestroyGroup = true'.

It's also more readable and editable if you place an If/Then/Else in the group loop, and cache the Picked Unit to avoid repetitive function calls.

Also, no need to null temp variables as they are going to be used again.
 
Status
Not open for further replies.
Top