Homing Missile!
By kenny
This is one of my first spells that i have made in vJass, so i am not fully sure if it is completely MUI etc. That is the reason why i have posted it, to get some constructive feedback and criticism from other people, so that i may improve my abilities in jass.
There is a description for implementation in the map, labeled "Implementation" just above the Homing Missile trigger.
Import difficulty: Moderate.
Jass?: Yes.
vJass?: Yes.
Lagless?: Yes.
Leakless?: Yes.
MUI?: Yes.
Requires:
ABC - Struct Attachment System, by Cohadar;
CSSafety by Vexorian; and
NewGen World Editor/vJass Preprocessor
Description: Basically, this is a spell that creates a missile that will follow its target for X amount of seconds. The missile will either reach its target and deal damage to it and smaller damage to nearby enemies, or it will explode before it gets to the target and deal small damage to enemy units near the explosion.
Here are the Screenshots for the skill:
Tooltip:
Launches a deadly missile at a target unit. The missile is capable of homing in on the target for up to 5 seconds.
Level 1 - Missile deals 75 damage to the target and 25 damage to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 25 damage to enemy units when it explodes.
Level 2 - Missile deals 150 damage to the target and 50 damage to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 50 damage to enemy units when it explodes.
Level 3 - Missile deals 225 damage to the target and 75 to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 75 damage to enemy units when it explodes.
Explosion has an area of effect of 225.
Here is the code for the spell:
Note: I only just realised that there was another skill almost exactly the same to this one about half way through making it and i assure everyone that i had no intention of just copying a skill from someone else, despite how similar they seem.
Thanks to Tinki3 for the cool Test map and to everyone who helped me with the skill.
Hope everyone likes the spell and is able to give me some constructive feedback.
kenny!
*CHANGE LOG*
- 9th of April 08 - Optimized code and changed few things suggested my ~GaLs~, thanks.
-10th of April 08 - Modified trigger a bit, now contains more configurables in the global section
to make configuring easier. Thanks to cr4xzZz, ~GaLs~, Tinki3 and others.
*UPDATED TEST MAP*
By kenny
This is one of my first spells that i have made in vJass, so i am not fully sure if it is completely MUI etc. That is the reason why i have posted it, to get some constructive feedback and criticism from other people, so that i may improve my abilities in jass.
There is a description for implementation in the map, labeled "Implementation" just above the Homing Missile trigger.
Import difficulty: Moderate.
Jass?: Yes.
vJass?: Yes.
Lagless?: Yes.
Leakless?: Yes.
MUI?: Yes.
Requires:
ABC - Struct Attachment System, by Cohadar;
CSSafety by Vexorian; and
NewGen World Editor/vJass Preprocessor
Description: Basically, this is a spell that creates a missile that will follow its target for X amount of seconds. The missile will either reach its target and deal damage to it and smaller damage to nearby enemies, or it will explode before it gets to the target and deal small damage to enemy units near the explosion.
Here are the Screenshots for the skill:


Tooltip:
Launches a deadly missile at a target unit. The missile is capable of homing in on the target for up to 5 seconds.
Level 1 - Missile deals 75 damage to the target and 25 damage to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 25 damage to enemy units when it explodes.
Level 2 - Missile deals 150 damage to the target and 50 damage to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 50 damage to enemy units when it explodes.
Level 3 - Missile deals 225 damage to the target and 75 to nearby enemy units if it reaches the target unit before 5 seconds, otherwise it will deal 75 damage to enemy units when it explodes.
Explosion has an area of effect of 225.
Here is the code for the spell:
JASS:
scope HomingMissile
// Homing Missile, by kenny!
globals
private constant integer Abil_id = 'A000' // Raw Code for Homing Missile Ability
private constant integer Unit_id = 'h000' // Raw Code for Homing Missile Dummy Unit
private constant real Turnrate = 0.55 // Turn Rate; determines how wide the missile will turn if it misses the target, the larger the number the wider the turn
private constant real Angle = 180.00 // Determines the angle at which the missile leaves the caster; not 100% necessary,but adds to realism and balance
private constant real Distance = 15.00 // How far the dummy unit will move each period, larger the number the faster the missile; slow = 10-15, fast = 20-25
private constant real Period = 0.03 // Used in periodic timer, best at 0.03 - 0.035
private constant real Impact_dist = 90.00 // Determines the distance from the enemy at which the missile will explode, best at 90-100
private constant real Damage_AoE = 225.00 // Area of Effect for missile explosion
private constant attacktype A_type = ATTACK_TYPE_CHAOS // Attack type of damage dealt
private constant damagetype D_type = DAMAGE_TYPE_UNIVERSAL // Damage type of damage dealt
private constant group Damage_group = CreateGroup() // Group created for Area of effect damage
private constant string Effect = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl" // Special effect created when the missile explodes
endglobals
//=======================================================================
private function HMDamage takes integer lvl returns real
return 50.*lvl // Damage dealt to target AND group (damage dealt to group is half of normal damage)
endfunction
//=======================================================================
private function FilterEnemies takes nothing returns boolean
return GetWidgetLife( GetFilterUnit( ) ) > 0.405 and IsUnitType(GetFilterUnit( ), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy( GetFilterUnit( ), GetOwningPlayer( GetTriggerUnit( ) ) ) == true and IsUnitType( GetFilterUnit( ), UNIT_TYPE_MAGIC_IMMUNE ) == false
endfunction // So far the Area of Effect damage will deal damage to alive enemy units that are not structures or magic immune
//=======================================================================//
// DO NOT TOUCH PAST THIS POINT UNLESS YOU KNOW WHAT YOUR ARE DOING!! //
//=======================================================================//
private function HMDamageArea takes unit Damager, real Area, real x, real y, real Dmg returns nothing
local unit FoG
set bj_groupEnumOwningPlayer = GetOwningPlayer(Damager)
call GroupEnumUnitsInRange(Damage_group, x, y, Area, Condition(function FilterEnemies))
// Function that loops through the CreateGroup()
loop // and deals damage to each enemy in the area. //
set FoG = FirstOfGroup(Damage_group)
exitwhen FoG == null
call GroupRemoveUnit(Damage_group,FoG)
call UnitDamageTarget(Damager,FoG,Dmg,false,false,A_type,D_type,null)
endloop
endfunction
//=======================================================================
private struct Data
timer t
unit targ
unit dummy
unit caster
integer lvl
location dumloc
location targloc // onDestroy method damages group using HMDamageArea.
location newpos // Also Clears Struct and releases timer.
real x
real y
method onDestroy takes nothing returns nothing
call HMDamageArea(.caster,Damage_AoE,.x,.y,(HMDamage(.lvl)/2))
call DestroyEffect(AddSpecialEffectLoc(Effect,.dumloc))
call ReleaseTimer(.t)
endmethod
endstruct
//=======================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId()==Abil_id
endfunction
//=======================================================================
private function Move takes nothing returns nothing
local Data d = GetTimerStructA(GetExpiredTimer())
set d.dumloc = GetUnitLoc(d.dummy)
set d.targloc = GetUnitLoc(d.targ)
set d.newpos = PolarProjectionBJ(d.dumloc,Distance,GetUnitFacing(d.dummy))
set d.x = GetLocationX(d.dumloc)
set d.y = GetLocationY(d.dumloc)
call SetUnitPositionLoc(d.dummy,d.newpos)
call SetUnitFacingTimed(d.dummy,AngleBetweenPoints(d.dumloc,d.targloc),Turnrate)
if(GetWidgetLife(d.dummy)<=.405)then // Deals damage to group if missile does not reach the target
call ClearTimerStructA(d.t)
call d.destroy()
endif
if(DistanceBetweenPoints(d.dumloc,d.targloc)<=Impact_dist)then
call UnitDamageTarget(d.dummy,d.targ,HMDamage(d.lvl),false,false,A_type,D_type,null)
call KillUnit(d.dummy) // Deals damage to group if missile does reach the target
call ClearTimerStructA(d.t)
call d.destroy()
endif
call RemoveLocation(d.dumloc)
call RemoveLocation(d.targloc)
call RemoveLocation(d.newpos)
endfunction
//=======================================================================
private function Actions takes nothing returns nothing
local Data d = Data.create()
local location casterpos
set d.caster = GetTriggerUnit()
set casterpos = GetUnitLoc(d.caster)
set d.lvl = GetUnitAbilityLevel(d.caster,Abil_id)
set d.dummy = CreateUnitAtLoc(GetOwningPlayer(d.caster),Unit_id,casterpos,(GetUnitFacing(d.caster)+GetRandomReal(-(Angle/2.00),(Angle/2.00))))
set d.targ = GetSpellTargetUnit()
set d.t = NewTimer()
call SetTimerStructA(d.t,d)
call TimerStart(d.t,Period,true,function Move) // Starts and continues the'Move' function periodically.
call RemoveLocation(casterpos)
set casterpos=null
endfunction
//=======================================================================
public function InitTrig takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trig,Condition(function Conditions))
call TriggerAddAction(trig,function Actions)
endfunction
endscope
Note: I only just realised that there was another skill almost exactly the same to this one about half way through making it and i assure everyone that i had no intention of just copying a skill from someone else, despite how similar they seem.
Thanks to Tinki3 for the cool Test map and to everyone who helped me with the skill.
Hope everyone likes the spell and is able to give me some constructive feedback.
kenny!
*CHANGE LOG*
- 9th of April 08 - Optimized code and changed few things suggested my ~GaLs~, thanks.
-10th of April 08 - Modified trigger a bit, now contains more configurables in the global section
to make configuring easier. Thanks to cr4xzZz, ~GaLs~, Tinki3 and others.
*UPDATED TEST MAP*
Attachments
-
68.1 KB Views: 586