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

[Spell] Combat Knife

Status
Not open for further replies.
Level 9
Joined
Apr 7, 2010
Messages
480
I started a thread concerning this spell before
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/basic-attack-spell-207889/

I was given a source by
Maker:
JASS:
function Attack_Filter takes nothing returns boolean
    return not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
endfunction

function Attack_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Acrs'
endfunction

function Attack_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u) * bj_DEGTORAD
    local player p = GetOwningPlayer(u)
    local unit t
    local real x2
    local real y2
    
    call GroupEnumUnitsInRange(bj_lastCreatedGroup, x ,y, 172+150, function Attack_Filter)
    loop
        set t = FirstOfGroup(bj_lastCreatedGroup)
        exitwhen t == null
        set x2 = GetUnitX(t)
        set y2 = GetUnitY(t)
        if IsUnitEnemy(t, p) and IsUnitInRangeXY(t, x, y, 150) and Cos(f-Atan2(y2-y, x2-x)) > 0 then
            call UnitDamageTarget(u, t, 50, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_CLAW_HEAVY_SLICE)
            call GroupClear(bj_lastCreatedGroup)
        else
            call GroupRemoveUnit(bj_lastCreatedGroup, t)
        endif
    endloop
    
    set u = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Attack takes nothing returns nothing
    set gg_trg_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Attack, Condition( function Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Attack, function Attack_Actions )
endfunction

and

mckill2009:
JASS:
//TESH.scrollpos=24
//TESH.alwaysfold=0
//Spell Name: Combat Knife
//Created by: Mckill2009

scope CombatKnife initializer init

globals
    private constant integer        SPELL_ID = 'A006'
    private constant attacktype          ATK = ATTACK_TYPE_PIERCE
    private constant damagetype          DMG = DAMAGE_TYPE_NORMAL
    private constant string              SFX = "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
    private constant string       ATTACHMENT = "chest"
    private constant real                AOE = 90
    private unit TEMP_UNIT
endglobals

private function GetDamageMin takes integer i returns real
    return 1 + i * 2.
endfunction

private function GetDamageMax takes integer i returns real
    return 3 + i * 9.
endfunction

private function OrganicUnit takes unit u returns boolean
    return not IsUnitType(u, UNIT_TYPE_MECHANICAL) and not IsUnitType(u, UNIT_TYPE_ANCIENT) and /*
         */not IsUnitType(u, UNIT_TYPE_TOWNHALL)
endfunction

private function FilterUnit takes nothing returns boolean
    local unit u = GetFilterUnit()
    local boolean b = GetWidgetLife(u) > 0.405 and IsUnitEnemy(TEMP_UNIT, GetOwningPlayer(u)) and not IsUnitType(u, UNIT_TYPE_FLYING)
    set u = null
    return b
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit first
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x1
    local real y1
    local real facing = GetUnitFacing(u)*bj_DEGTORAD
    local integer level = GetUnitAbilityLevel(u, SPELL_ID)
    local real damage = GetRandomReal(GetDamageMin(level), GetDamageMax(level))
    local texttag tag
    set x1 = x+90*Cos(facing)
    set y1 = y+90*Sin(facing)
    set TEMP_UNIT = u
    call GroupEnumUnitsInRange(bj_lastCreatedGroup, x1, y1, AOE, function FilterUnit)
    set first = FirstOfGroup(bj_lastCreatedGroup)
    if first !=null then
        set tag = CreateTextTag() 
        call UnitDamageTarget(u, first, damage, false, false, ATK, DMG, null)
        if OrganicUnit(first) then
            call DestroyEffect(AddSpecialEffectTarget(SFX, first, ATTACHMENT))        
        endif        
        call SetTextTagPosUnit(tag, first, 0.) 
        call SetTextTagText(tag, I2S(R2I(damage)), 0.02)
        call SetTextTagPermanent(tag, false)
        call SetTextTagVelocity(tag, 0.03, 0.03)
        call SetTextTagLifespan(tag, 3)
        call SetTextTagFadepoint(tag, 0.01) 
    endif
    call IssueImmediateOrder(u, "stop")
    set u = null
    set  first = null
    set tag = null
endfunction

private function Cond takes nothing returns boolean
    return GetSpellAbilityId()==SPELL_ID
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()          
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(t, Condition(function Cond))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope

And I dont know which is better, but I stop using jass since a lot of error occured in my map. can someone make a GUI MUI version of any of this spell? also kindly change the target type to unit target. Thanks
 
Level 6
Joined
Aug 27, 2008
Messages
210
Here are a few questions to make the ability how you want it:
Would you like to allow friendly fire?
If there are multiple units in range should the target be randomly selected or should the closest or the nearest to the front of the unit be targeted?
What is the angle of attack (what portion of the space around the unit is counted a being in front of the unit or "in range")?
 
Level 9
Joined
Apr 7, 2010
Messages
480
Here are a few questions to make the ability how you want it:
Would you like to allow friendly fire?
If there are multiple units in range should the target be randomly selected or should the closest or the nearest to the front of the unit be targeted?
What is the angle of attack (what portion of the space around the unit is counted a being in front of the unit or "in range")?

No its not friendly fire, and at the end of my request i added "also kindly change the target type to unit target." and i guess question 2 and 3 doesn't count since the target type would be unit target.
furthermore i was kinda hoping someone would add a "backstab effect" deals 2x damage when skill is used behind the targeted unit.
 
Level 9
Joined
Apr 7, 2010
Messages
480
im only asking 1 system. base on my 1st request the spell triggered by maker and mckill is suppose to attack the nearest target (Target type: Instant);

But what im requesting now is to convert the spell to GUI MUI and change the target type from instant to unit. also adding some feature to the spell like backstab, dealing more damage when the casting unit hits the target unit from behind.
 
Level 6
Joined
Aug 27, 2008
Messages
210
Have you looked at this thread?
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/using-spells-basic-attacks-151321/
As far as backstab, you could make a simple trigger for it
  • Events
    • Unit - A unit Finishes casting an ability
  • Conditions
    • (Ability being cast) Equal to Attack
    • (Facing of (Triggering unit)) Greater than or equal to ((Angle from (Position of (Casting unit)) to (Position of (Target unit of ability being cast))) - 45)
    • (Facing of (Triggering unit)) Less than or equal to ((Angle from (Position of (Casting unit)) to (Position of (Target unit of ability being cast))) + 45)
  • Actions
    • Unit - Cause (casting unit) to damage (Target unit of ability being cast) dealing X damage of Attack type Normal and damage type Normal
This might have a problem with facing around east so if it does I'll see what I can do.
 
Status
Not open for further replies.
Top