1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. 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. Catch_ya

    Catch_ya

    Joined:
    May 21, 2009
    Messages:
    982
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Might be true. :p
     
  2. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Stop offtopic dewd and tell me something about what you want to have =)
     
  3. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Attack recovery?
     
  4. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Which means?
    If you mean that you can undo attacks, would be possile, however, I'd have to create a link with every attack at an unit and would need one hashtable just for that.
     
  5. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    I'm not talking about evasion, I'm talking about a time that is required after being successfully attacked before you can do anything. If someone slashes at you with a sword while you're in the middle of swinging it's not like you're just going to take a little damage and shrug it off. It's going to hurt.
     
  6. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Ah that. Oh well, since you can hook attacks there is no problem in pausing units for x.xx seconds.

    Also what I was talking about isn't evasion, but that you can "undo" attacks later. Like a spell that does:
    "Removes the last 4 attacks from the unit and will cause the unit to do the same attacks to its attacker".
     
  7. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    I wouldn't recommend using Pause because then the unit cannot issue any orders (or queue them) while it is recovering. I suggest using something like Rising_Dusk's "UnitStatus" library.

    Eh, that's not particularly difficult. You don't need to use a
    hashtable
    either, in fact it would probably be better/easier if you used AutoIndex to index the units. This would make referencing the last X instances of damage a breeze.
     
  8. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    And where should I store all the values then? o_O
    I mean I need to store X last attacks for Y units.
     
  9. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    ------
     
  10. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    But how does that work? I don't get it. Can you make an example?
     
  11. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Code (vJASS):
    struct UnitDamage

        real array prevDamage [DAMAGE_INSTANCES]
        integer prevDamageN = 0

        method addDamage takes real damageAmount returns nothing
            local integer i = 0
            if prevDamageN < DAMAGE_INSTANCES then
                set prevDamage[prevDamageN] = damageAmount
                set prevDamageN = prevDamageN + 1
            else
                loop
                    exitwhen(i == DAMAGE_INSTANCES-1)
                    set prevDamage[i] = prevDamage[i+1]
                    set i = i + 1
                endloop
            endif
        endmethod

        implement AutoCreate
        implement AutoDestroy
    endstruct
     
  12. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    lol, but how does this save the unit that is damaged?
     
  13. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Well you'd use some method of damage detection and from there just do:

    Code (vJASS):
    call UnitDamage[ GetTriggerUnit() ].addDamage(GetEventDamage())
     
  14. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Wow, looks nice. One question though: How does this work (the core, how is the data saved)?
     
  15. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    It uses AutoIndex, which uses
    SetUnitUserData
    I believe. I think there is a configuration boolean that switches to using a
    hashtable
    if using the user-data isn't acceptable, but if you're using an indexing system then there's no point in not using it since custom data can just be saved per struct.
     
  16. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,167
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Well, looks like. I am already using AutoIndex since BonusMod requires it.
     
  17. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    No it doesn't. Only some of the features require it.
     
  18. Inferior

    Inferior

    Joined:
    Nov 3, 2008
    Messages:
    110
    Resources:
    3
    Icons:
    1
    Spells:
    2
    Resources:
    3
    Ok correct me if i'm mistaken, but the code snipet berb posted there will malfunction when you will have lots of units on the map. I dont know the value of DAMAGE_INSTANCES but array members reduce the structs instance limit, drastically. So lets say DAMAGE_INSTANCES is 5, so you have a max of 8190/5=1638 instances. Now you use this for a unit with an index higher than 1638 and nothing happens.
    If you want this to work for all units, the only possibility means "hashtable" o_O
     
  19. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    Obviously. It goes without saying that having 2000 units is not a good idea. If you've got 1638 units that you aren't recycling constantly then your map is going to leak balls anyways. That isn't a "malfunction", it's a limitation of JASS since we are only allowed 8191 array instances. If you tried to store 2000 damage instances previous it would probably "malfunction" too very quickly, the idea is that you're not stressing Warcraft with ridiculous values.
     
  20. Inferior

    Inferior

    Joined:
    Nov 3, 2008
    Messages:
    110
    Resources:
    3
    Icons:
    1
    Spells:
    2
    Resources:
    3
    well Auto Index is recycling the Units. And as i said this will just malfunction if you have more then e.g. 1638 instances. Since this is a system that can be used everywhere, there will be people who reach this limit in there map. with a hashtable you have unlimited instances. But this is up to Anachron if he makes it faster or more safe.