1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] {idea} [vJass] (System) CustomAttack

Discussion in 'Triggers & Scripts' started by Anachron, Apr 19, 2010.

  1. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    This is really nice. You can do it right now.

    You can do that with one line.

    You can do that with one line as well.

    Thanks for the feedback, they are all good, any more ideas?
     
  2. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    :eekani:What about.... A command that doesn't let my head go boom right now?:eekani:
     
  3. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    To difficult, I am not god ):
     
  4. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    I maybe know something cool.

    What about the possibility to change number of attacks.
    Let's say a unit's number of attacks is 3. His long atk cooldown is 2.00 and his short atk cooldown is 0.3. That means he attacks 3 times in 0.9 seconds, then waits 2 seconds and attacks 3 times in 0.9 seconds again. This makes it possible for, per example, RPG makers that have duel wielding units to have their hero have 2 different attacks.

    EDIT: and maybe something that allows you to use a damage system so DAMAGE_TYPE_MAGIC can be replaced by a custom damage type made by a system.
     
  5. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Already(/Nearly) possible.

    That would be possile too, yes. (With some changings)
     
  6. Viikuna

    Viikuna

    Joined:
    Aug 6, 2008
    Messages:
    430
    Resources:
    0
    Resources:
    0
    In old good Starcraft you could actually build attacks someway like that. ( If I remember correctly )


    You should be able to build your attack of many little attacks. To create something like Valkyrie in SC, shoots many rockets and stuff. Also ultralisk had 2 attacks in one, if I remember correctly.

    Also your attack system could support some over time damage beam, like those new protoss weapons in sc2.
     
  7. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    You can create a link (register) every attackevent, from attackstart, attackdamage up to attackfinish.

    A small update.
    Here is a little preview, so you can see that a passive projectile slow aura is already working (full MUI).
     

    Attached Files:

    • CA.jpg
      CA.jpg
      File size:
      348.4 KB
      Views:
      88
  8. YourNameHere

    YourNameHere

    Joined:
    Apr 29, 2007
    Messages:
    745
    Resources:
    4
    Maps:
    1
    Spells:
    2
    JASS:
    1
    Resources:
    4
    Only 41fps? :p
     
  9. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    My graphic card is shit, I have a maximum of 45fps when I open an empty map with wc3.
    I have 1600x1200 solution and an GForce 7600 which is crap.
     
  10. supertoinkz

    supertoinkz

    Joined:
    Dec 29, 2008
    Messages:
    2,813
    Resources:
    25
    Models:
    15
    Icons:
    7
    Maps:
    1
    Tutorials:
    2
    Resources:
    25
    How did you do that fps command ? o_O
     
  11. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,270
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
    Type /fps
     
  12. supertoinkz

    supertoinkz

    Joined:
    Dec 29, 2008
    Messages:
    2,813
    Resources:
    25
    Models:
    15
    Icons:
    7
    Maps:
    1
    Tutorials:
    2
    Resources:
    25
    lol, didn't know that
     
  13. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    looks cool can't wait for it :D
    (btw i have normaly 60 fps :p)
     
  14. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Thanks for the feedback guys, the next thing I am doing is "virtualizing" the attack so you actually attack without attacking at all, this will be amazing because it gives me the possibility to recreate the wc3 attack in every way.

    The next spell I am doing is a spell that changes the attacks of units in an AOE.
    Everytime an enemy unit is attacking around (with the buff) it'll heal damage instead of dealing it.
     
  15. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    #Update.

    You can now emulate orders (with animations) and this engine (CustomOrder) will be connected with CustomAttack.

    This allows you to be able to cast a spell at the same time you're attacking an unit. (And also I can now fully trigger the attack stuff, from the attack target detection, with the animation playing and missile throwing until the damaging and attack finishing).

    The first beta will include an missile slow aura and a passive ability that sometimes triggers 2 attacks.
     
  16. The Reborn Devil

    The Reborn Devil

    Joined:
    Dec 31, 2006
    Messages:
    1,325
    Resources:
    0
    Resources:
    0
    Could you add a the possibility of letting other units "charge" another unit's attack like the Prism Towers in Red Alert 2 or Spectrum Tower in Red Alert 3?

    Here's an image:
    [​IMG]

    In both RA2 and RA3 several towers can assist.

    O o
    /¯¯_¯¯_¯_¯__¯__¯¯__¯¯__¯__¯¯_¯__¯__¯_¯_ ¯ _¯ SHOOP DA WHOOP!
    \___¯¯_¯_¯¯__¯¯¯¯_¯¯¯__¯¯¯¯_¯¯¯¯_¯¯¯¯_¯ ¯_ ¯
     
  17. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Yes, you can already do that.

    I will make an example spell to make target units attack temporary ranged if you wish. :D
     
  18. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    nice :D
    now test it with new fps rate ^^

    offtopic:
    O o
    /¯_____________________
    | SHOOP DA WHOOP!!!
    \_¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    is the right one ;)
     
  19. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Stop offtopic talk please.
     
  20. Furby

    Furby

    Joined:
    Feb 18, 2008
    Messages:
    69
    Resources:
    1
    Icons:
    1
    Resources:
    1
    Well, this system seems ultrainteresting, I will totally use it in my map, since current projectile system sucks.

    Although, I will have to redo some spells and my whole attack system since my one works differently, I block damage when any unit is damaged and then do my stuff (ranged units have no model for missiles and missile speed 99999).. my system looks like this..

    It's not anything for public so it looks messy and maybe confusing:

    My attack system
    Code (vJASS):
    library Attack initializer OnInit requires Damage, Projectile, Event, AttackData, UnitData
       
        globals
            private trigger    OnDAMAGE = CreateTrigger()
            private Event      OnAttackEvent = 0
            private Event      OnProjEndEvent = 0
            private AttackData AttackDataX   = 0
            private unit       SourceUnit    = null
            private unit       TargetUnit    = null
            private Projectile ProjectileData = 0
            private damagetype DamageType    = DAMAGE_TYPE_NORMAL
            private attacktype AttackType    = ATTACK_TYPE_NORMAL
            private real       DamageDealt   = 0.00
        endglobals
       
        public function RegisterEvent takes trigger whichTrig returns EventReg
            return OnAttackEvent.register(whichTrig)
        endfunction
       
        public function RegisterProjEndEvent takes trigger whichTrig returns EventReg
            return OnProjEndEvent.register(whichTrig)
        endfunction
       
        public function GetSource takes nothing returns unit
            return SourceUnit
        endfunction
       
        public function GetTarget takes nothing returns unit
            return TargetUnit
        endfunction
       
        public function GetDamage takes nothing returns real
            return DamageDealt
        endfunction
       
        public function GetDamageType takes nothing returns damagetype
            return DamageType
        endfunction
       
        public function GetAttackType takes nothing returns attacktype
            return AttackType
        endfunction
       
        public function GetAttackData takes nothing returns AttackData
            return AttackDataX
        endfunction
       
        public function GetProjectileData takes nothing returns Projectile
            return ProjectileData
        endfunction
       
        function AttackDamageTarget takes unit theKiller, unit theVictim, real theDamage, boolean isRanged, attacktype attackType, damagetype damageType returns nothing
            local UnitData ud = UnitData[theVictim]
            local real origDmg = theDamage
            local real dmg = theDamage
            if not IsUnitType(theVictim, UNIT_TYPE_DEAD) then
                set DamageType = damageType
                if GetRandomReal(0., 100.) >= ud.evadeChnc then
                    if GetRandomReal(0., 100.) < ud.blockChnc then
                        if dmg - ud.blockMlt >= 5. then
                            set dmg = dmg - ud.blockMlt
                        else
                            set dmg = 5.
                        endif
                        call BlockTextTag(theVictim, origDmg - dmg)
                    endif
                    call TriggeredAttack(theKiller, theVictim, dmg, isRanged, attackType, damageType)
                    if (ud.returndamage > .0 or ud.returndamageItem > .0) and IsUnitType(theKiller, UNIT_TYPE_STRUCTURE) == false then
                        call Damage_Physical(theVictim, theKiller, dmg * (ud.returndamage * .01 + ud.returndamageItem * .01), attackType, false, false)
                    endif
                else
                    call DodgeTextTag(theVictim)
                endif
            endif
        endfunction
       
        public function OnUnitImpact takes Projectile p, unit whichUnit returns nothing
            local AttackData attad  = AttackData_GetUnit(GetUnitTypeId(whichUnit))
            if whichUnit == p.target then
                if p.unitDamage > 0. then
                    set DamageType = p.damageType
                    set AttackType = p.attackType
                    set SourceUnit  = p.caster
                    set TargetUnit  = p.target
                    set DamageDealt = p.unitDamage
                    set AttackDataX = attad
                    set ProjectileData = p
                    call OnProjEndEvent.fire()
                    call AttackDamageTarget(p.caster, whichUnit, p.unitDamage, true, p.attackType, p.damageType)
                endif
                call p.terminate()
            endif
        endfunction
       
        public function OnProjectileLoop takes Projectile p returns nothing
            if IsUnitType(p.target, UNIT_TYPE_DEAD) and p.enableHoming then
                set p.totalDist = DBPXY(GetUnitX(p.caster), GetUnitY(p.caster), GetUnitX(p.target), GetUnitY(p.target))
                set p.toDist = true
                set p.enableHoming = false
            endif
        endfunction
       
        public function GetAttackDamage takes unit u returns real
            if u != null then
                if IsUnitType(u, UNIT_TYPE_HERO) then
                    return (UnitData[u].baseDmg + Status[u].getDamageBonus() + GetHeroMainAttValue(u, UnitData[u].mainAtt, true)) + UnitData[u].numberDmg * GetRandomInt(1, UnitData[u].sidesDmg)
                else
                    return (UnitData[u].baseDmg + UnitData[u].upgradeDmg + Status[u].getDamageBonus()) + UnitData[u].numberDmg * GetRandomInt(1, UnitData[u].sidesDmg)
                endif
            endif
            return 0.0
        endfunction

        private function onDamage takes nothing returns boolean
            local unit att = GetEventDamageSource()
            local unit trg = GetTriggerUnit()
            local real ax  = GetUnitX(att)
            local real ay  = GetUnitY(att)
            local real tx  = GetUnitX(trg)
            local real ty  = GetUnitY(trg)
            local real ang = Atan2((ty - ay),(tx - ax))
            local real dmg = 0.
            local AttackData attad  = AttackData_GetUnit(GetUnitTypeId(att))
            local AttackData trgad  = AttackData_GetUnit(GetUnitTypeId(trg))
            local UnitData attud = UnitData[att]
            local UnitData trgud = UnitData[trg]
            local Projectile p   = 0
            if AttackData_IsRegistered(GetUnitTypeId(att)) and AttackData_IsRegistered(GetUnitTypeId(trg)) and GetEventDamage() > 0 then
                if Damage_IsAttack() then
                    // Blocking all damage done
                    call Damage_BlockAll()
                    if GetRandomReal(0., 100.) >= attud.missChnc then
                        set dmg = GetAttackDamage(att)
                        if GetRandomReal(0., 100.) < attud.critChnc then
                            set dmg = dmg * (1. + attud.critMlt)
                            call CriticalTextTag(att, dmg)
                        endif
                        if GetRandomReal(0., 100.) < attud.stunChance then
                            call BuffStun.create(trg).destroyTimed(attud.stunTime)
                        endif
                        if (attud.lifesteal > 0 or attud.lifestealItem > 0) and IsUnitType(trg, UNIT_TYPE_STRUCTURE) == false then
                            call SetWidgetLife(att, GetWidgetLife(att) + dmg * (attud.lifesteal * .01 + attud.lifestealItem * .01))
                            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl", att, "origin"))
                        endif
                    else
                        call MissTextTag(att)
                    endif
                   
                    if attud.isRanged then
                        set p = Projectile.create(ax, ay, attud.missileHgt, ang)
                        set p.caster        = att
                        set p.target        = trg
                        set p.owner         = GetOwningPlayer(att)
                        set p.effectPath    = attud.missileFx
                        set p.scaleSize     = attud.missileScl
                        set p.unitDamage    = dmg
                        set p.attackType    = attud.attackTyp
                        set p.damageType    = DAMAGE_TYPE_NORMAL
                        set p.unitCollision = attud.missileCol
                        set p.enableHoming  = true
                        set p.throughGround = true
                        set p.onUnit        = OnUnitImpact
                        set p.onLoop        = OnProjectileLoop
                        if attud.missileNrm then
                            call p.projectNormal(tx, ty, GetUnitFlyHeight(trg) + attud.missileHgt, attud.missileSpd)
                        else
                            call p.projectArcing(tx, ty, GetUnitFlyHeight(trg) + attud.missileHgt, attud.missileSpd, attud.missileArc)
                        endif
                    else
                        call AttackDamageTarget(att, trg, dmg, false, attud.attackTyp, DAMAGE_TYPE_NORMAL)
                    endif
                    set DamageType = DAMAGE_TYPE_NORMAL
                    set AttackType = attud.attackTyp
                    set SourceUnit  = att
                    set TargetUnit  = trg
                    set DamageDealt = dmg
                    set AttackDataX = attad
                    set ProjectileData = p
                    call OnAttackEvent.fire()
                elseif Damage_IsSpell() then
                    set dmg = GetEventDamage()
                    if attud.spellDamage != 0 then
                        set dmg = dmg * (1.0 + (attud.spellDamage * .01))
                    endif
                    if trgud.blockMagic != 0. then
                        set dmg = dmg * (1.0 - (trgud.blockMagic * .01))
                    endif
                    if dmg > GetEventDamage() then
                        call DisableTrigger(OnDAMAGE)
                        call Damage_Spell(att, trg, dmg)
                        call EnableTrigger(OnDAMAGE)
                    else
                        call Damage_Block(GetEventDamage() - dmg)
                    endif
                endif
            endif
            set att = null
            set trg = null
            return false
        endfunction

        private function OnInit takes nothing returns nothing
            set OnAttackEvent = Event.create()
            set OnProjEndEvent = Event.create()
            call Damage_RegisterEvent(OnDAMAGE)
            call TriggerAddCondition(OnDAMAGE, Condition(function onDamage))
        endfunction

    endlibrary


    Anyway, good luck on this! Finish it no matter what.