• 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.

[Trigger] Not Damaging

Status
Not open for further replies.
[trigger=]Projectile System
Events
Map initialization
Conditions
Actions
Custom script: set udg_PS_Hash = InitHashtable()
-------- -------------------------------------------- --------
-------- Determines how many models can be attached --------
-------- -------------------------------------------- --------
Set PS_MaxModelsIndex = 5
-------- -------------------------------------------- --------
-------- Creating dummy cutter --------
-------- -------------------------------------------- --------
Set PS_Loc = (Center of (Playable map area))
Unit - Create 1 Peasant for Neutral Passive at PS_Loc facing Default building facing degrees
Set PS_Cutter = (Last created unit)
Custom script: call UnitAddAbility(udg_PS_Cutter,'Aloc')
Unit - Hide PS_Cutter
Unit - Make PS_Cutter Invulnerable
Custom script: call RemoveLocation(udg_PS_Loc)
Custom script: call ExecuteFunc("InitProjectileSystem")
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function destroys missile --------
-------- -------------------------------------------- --------
Custom script: function DestroyMissile takes unit u , integer key returns nothing
Custom script: call FlushChildHashtable(udg_PS_Hash,key)
Custom script: call GroupRemoveUnitSimple(u,udg_PS_LoopGroup)
Custom script: call RemoveUnit(u)
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function applies coordinates then moving the unit --------
-------- -------------------------------------------- --------
Custom script: function MoveMissile takes unit u,real speed,real angle returns nothing
Custom script: local real x = GetUnitX(u) + speed * Cos(angle * bj_DEGTORAD)
Custom script: local real y = GetUnitY(u) + speed * Sin(angle * bj_DEGTORAD)
Custom script: call SetUnitPosition(u,x,y)
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function applies Z arc --------
-------- -------------------------------------------- --------
Custom script: function ApplyArcHeight takes unit u,real distance,real travelled,real speed,real heightmultiplier returns nothing
Custom script: local real arc = 4 *( heightmultiplier/2 * distance) / distance * ((travelled + speed )/ distance) * (distance - (travelled + speed))
Custom script: call SetUnitFlyHeight(u, arc, 0.00)
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function applies ground arc --------
-------- -------------------------------------------- --------
Custom script: function ApplyGroundArc takes unit u,real distance,real travelled,real arcwidth,location loc,real speed,real angle,boolean arcleft returns nothing
Custom script: local real arc
Custom script: local real x
Custom script: local real y
Custom script: set travelled = travelled + speed
Custom script: set x = GetLocationX(loc) + travelled * Cos(angle*bj_DEGTORAD)
Custom script: set y = GetLocationY(loc) + travelled * Sin(angle*bj_DEGTORAD)
Custom script: if arcleft == true then
Custom script: set angle = angle + 90
Custom script: else
Custom script: set angle = angle - 90
Custom script: endif
Custom script: set arc = 4 * (arcwidth/2 * distance) / distance * (travelled / distance) * (distance - travelled )
Custom script: set x = x + arc * Cos(angle*bj_DEGTORAD)
Custom script: set y = y + arc * Sin(angle*bj_DEGTORAD)
Custom script: call SetUnitPosition(u,x,y)
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function is run periodically after picking the main group --------
-------- -------------------------------------------- --------
Custom script: function Missile takes nothing returns nothing
Set PS_U = (Picked unit)
Custom script: set udg_PS_Key = GetHandleId(udg_PS_U)
-------- -------------------------------------------- --------
-------- Load --------
-------- -------------------------------------------- --------
Set PS_TempSpeed = ((Load 1 of PS_Key from PS_Hash) x 0.03)
Set PS_TempAngle = (Load 2 of PS_Key from PS_Hash)
Set PS_TempDistance = (Load 3 of PS_Key from PS_Hash)
Set PS_TempTravelled = (Load 4 of PS_Key from PS_Hash)
Set PS_LoadImpactSFX = (Load 5 of PS_Key from PS_Hash)
Set PS_LoadAllowDestroyTreesImpact = (Load 6 of PS_Key from PS_Hash)
Set PS_LoadDamage = (Load 10 of PS_Key from PS_Hash)
Set PS_LoadRange = (Load 11 of PS_Key from PS_Hash)
Set PS_LoadAllowGroundArc = (Load 12 of PS_Key from PS_Hash)
Set PS_LoadArcWidth = (Load 13 of PS_Key from PS_Hash)
Set PS_LoadAllowArc = (Load 14 of PS_Key from PS_Hash)
Set PS_LoadArcHeight = (Load 15 of PS_Key from PS_Hash)
Set PS_LoadAllowArcLeft = (Load 16 of PS_Key from PS_Hash)
Set PS_LoadX = (Load 17 of PS_Key from PS_Hash)
Set PS_LoadY = (Load 18 of PS_Key from PS_Hash)
Set PS_MaxModelsTemp = (Load 19 of PS_Key from PS_Hash)
-------- -------------------------------------------- --------
-------- -------------------------------------------- --------
Set PS_Owner = (Owner of PS_U)
Set PS_Loc = (Position of PS_U)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PS_TempTravelled Less than PS_TempDistance
Then - Actions
Set PS_TempLoc = (Point(PS_LoadX, PS_LoadY))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PS_LoadAllowGroundArc Equal to True
Then - Actions
Custom script: call ApplyGroundArc(udg_PS_U,udg_PS_TempDistance,udg_PS_TempTravelled,udg_PS_LoadArcWidth,udg_PS_TempLoc,udg_PS_TempSpeed,udg_PS_TempAngle,udg_PS_LoadAllowArcLeft)
Else - Actions
Custom script: call MoveMissile(udg_PS_U,udg_PS_TempSpeed,udg_PS_TempAngle)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PS_LoadAllowArc Equal to True
Then - Actions
Custom script: call ApplyArcHeight(udg_PS_U,udg_PS_TempDistance,udg_PS_TempTravelled,udg_PS_TempSpeed,udg_PS_LoadArcHeight)
Else - Actions
Animation - Change PS_U flying height to 75.00 at 0.00
Custom script: call SetUnitAnimationByIndex(udg_PS_U,360)
Hashtable - Save (PS_TempTravelled + PS_TempSpeed) as 4 of PS_Key in PS_Hash
Custom script: call RemoveLocation(udg_PS_TempLoc)
Else - Actions
-------- -------------------------------------------- --------
-------- Damage Units --------
-------- -------------------------------------------- --------
Set PS_ImpactGroup = (Units within PS_LoadRange of PS_Loc matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False)) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of PS_Owner) Eq
Unit Group - Pick every unit in PS_ImpactGroup and do (Actions)
Loop - Actions
Unit - Cause PS_U to damage (Picked unit), dealing PS_LoadDamage damage of attack type Spells and damage type Normal
Custom script: call DestroyGroup(udg_PS_ImpactGroup)
-------- -------------------------------------------- --------
-------- Destroy Trees --------
-------- -------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PS_LoadAllowDestroyTreesImpact Equal to True
Then - Actions
Destructible - Pick every destructible within PS_LoadRange of PS_Loc and do (Actions)
Loop - Actions
Set PS_Dest = (Picked destructible)
Unit - Order PS_Cutter to Harvest PS_Dest
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of PS_Cutter) Equal to (Order(harvest))
Then - Actions
Destructible - Kill PS_Dest
Else - Actions
Unit - Order PS_Cutter to Stop
Else - Actions
Special Effect - Create a special effect at PS_Loc using PS_ImpactSFX
Special Effect - Destroy (Last created special effect)
-------- -------------------------------------------- --------
-------- Clean Up --------
-------- -------------------------------------------- --------
For each (Integer I) from 1 to PS_MaxModelsTemp, do (Actions)
Loop - Actions
Set PS_TempModel = (Load (22 + I) of PS_Key in PS_Hash)
Special Effect - Destroy PS_TempModel
Custom script: call DestroyMissile(udg_PS_U,udg_PS_Key)
Custom script: call RemoveLocation(udg_PS_Loc)
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function is run periodically --------
-------- -------------------------------------------- --------
Custom script: function MissileLoop takes nothing returns nothing
Unit Group - Pick every unit in PS_LoopGroup and do (Actions)
Loop - Actions
Custom script: call ExecuteFunc("Missile")
Custom script: endfunction
-------- -------------------------------------------- --------
-------- This function will setup the missile --------
-------- -------------------------------------------- --------
Custom script: function MissileSetup takes nothing returns nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PS_MaxModels Greater than PS_MaxModelsIndex
Then - Actions
Set PS_MaxModels = PS_MaxModelsIndex
Else - Actions
Unit - Create 1 Dummy for PS_Owner at PS_Loc facing PS_Angle degrees
Set PS_Missile = (Last created unit)
Custom script: call SetUnitAnimationByIndex(udg_PS_Missile,360)
Custom script: set udg_PS_TempKey = GetHandleId(udg_PS_Missile)
For each (Integer I) from 1 to PS_MaxModels, do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the origin of PS_Missile using PS_MissileModel
Set PS_Model = (Last created special effect)
Animation - Change PS_Missile's size to (PS_MissileScale%, 100.00%, 100.00%) of its original size
Custom script: set udg_PS_X = GetLocationX(udg_PS_Loc)
Custom script: set udg_PS_Y = GetLocationY(udg_PS_Loc)
-------- -------------------------------------------- --------
-------- Save --------
-------- -------------------------------------------- --------
Hashtable - Save PS_Speed as 1 of PS_TempKey in PS_Hash
Hashtable - Save PS_Angle as 2 of PS_TempKey in PS_Hash
Hashtable - Save PS_Distance as 3 of PS_TempKey in PS_Hash
Hashtable - Save 0.00 as 4 of PS_TempKey in PS_Hash
Hashtable - Save PS_ImpactSFX as 5 of PS_TempKey in PS_Hash
Hashtable - Save PS_AllowDestroyTreeImpact as 6 of PS_TempKey in PS_Hash
Hashtable - Save PS_Damage as 10 of PS_TempKey in PS_Hash
Hashtable - Save PS_Radius as 11 of PS_TempKey in PS_Hash
Hashtable - Save PS_AllowGroundArc as 12 of PS_TempKey in PS_Hash
Hashtable - Save PS_ArcWidth as 13 of PS_TempKey in PS_Hash
Hashtable - Save PS_AllowArc as 14 of PS_TempKey in PS_Hash
Hashtable - Save PS_ArcHeight as 15 of PS_TempKey in PS_Hash
Hashtable - Save PS_AllowArcLeft as 16 of PS_TempKey in PS_Hash
Hashtable - Save PS_X as 17 of PS_TempKey in PS_Hash
Hashtable - Save PS_Y as 18 of PS_TempKey in PS_Hash
Hashtable - Save PS_MaxModels as 19 of PS_TempKey in PS_Hash
For each (Integer I) from 1 to PS_MaxModels, do (Actions)
Loop - Actions
Hashtable - Save Handle OfPS_Model as (21 + I) of PS_TempKey in PS_Hash
Unit Group - Add PS_Missile to PS_LoopGroup
Custom script: endfunction
-------- -------------------------------------------- --------
-------- Initialize --------
-------- -------------------------------------------- --------
Custom script: function InitProjectileSystem takes nothing returns nothing
Custom script: local trigger t = GetTriggeringTrigger()
Custom script: set udg_PS_Loop = CreateTrigger()
Custom script: call TriggerClearActions(t)
Custom script: call TriggerAddAction(t,function MissileSetup)
Custom script: call TriggerAddAction(udg_PS_Loop,function MissileLoop)
Custom script: call TriggerRegisterTimerEventPeriodic(udg_PS_Loop, 0.03 )
[/trigger]


Even though i dont know what's wrong here,i dont know why it isnt damaging.
 

Attachments

  • Projectile System v1.0 (1).w3x
    32 KB · Views: 64
Level 12
Joined
Oct 16, 2010
Messages
680
your example has the problem
in a unit is attacked event
triggering player is the ATTACKED units owner

Because of this, the dummy is created for the attacked units owner and not for the attacker player
It should be Set PS_Owner = Owner of (Attacking Unit)

and then the "matching unit belongs to an enemy of PS_Owner equals to true"
always fails.

(did't check it, but watch what happens if you move close to the enemy) the projectile will land at the same dinstance all time.
it should be homing I think.
 
Status
Not open for further replies.
Top