first struct spell not working.

shiFt

Member
Reaction score
8
I got this spell framework from a spell that KingKing helped me make a while ago, so i chopped the struct stuff and tried to make another spell but it doesn't work, and I don't know why. Caster goes invisible, and is able to run through units, damages all units in a small radius around the hero.

JASS:
 scope WW initializer Init

    globals 
        private constant integer SPELL_ID = 'A01X'
        private hashtable ht = InitHashtable()
    endglobals
    
    private struct Data
        unit cs
        real x
        real y
        player p
        real dur
        integer ticks
        integer timeScaleTicks
        timer t
        group g
        real dmg
    endstruct
    
    globals
        private unit U
        private Data D
        private real X
        private real Y
        private integer array TimerData
        private conditionfunc cf
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Effect2 takes nothing returns boolean
        set U = GetFilterUnit()
        if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", U, "chest"))
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", U, "chest"))
            call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
        endif
        return false
    endfunction
    
    private function Effects takes nothing returns nothing
        local Data d = LoadInteger(ht,GetHandleId(GetExpiredTimer()),0)
        if d.ticks > 0 then
            set d.ticks = d.ticks - 1
            if d.timeScaleTicks > 0 then
                set d.timeScaleTicks = d.timeScaleTicks - 1
            else
                set d.timeScaleTicks = 10000
            endif
            set d.x = GetUnitX(d.cs)
            set d.y = GetUnitY(d.cs)
            set D = d
            call GroupEnumUnitsInRange(d.g,d.x,d.y,175.,cf)
            return
        endif
        call PauseTimer(d.t)
        call d.destroy()
    endfunction
    
    private function Actions takes nothing returns nothing
        local Data d = Data.create()
        set d.cs = GetTriggerUnit()
        set d.p = GetOwningPlayer(d.cs)
        set d.dur = 4.
        set d.ticks = R2I(d.dur / .05)
        set d.timeScaleTicks = R2I(1. / .05)
        set d.dmg = 60 + ( 10* GetUnitAbilityLevel(d.cs,SPELL_ID))
        if d.t == null then
            set d.t = CreateTimer()
            call SaveInteger(ht,GetHandleId(d.t),0,d)
        endif
        if d.g == null then
            set d.g = CreateGroup()
        endif
        call TimerStart(d.t,.05,true,function Effects)
    endfunction

//---------------------------------------------------------------------------------------------------------
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
		local integer i = 0
		
		loop
			exitwhen i > 11
			call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
			set i = i + 1
		endloop

		call TriggerAddCondition( t, Condition( function Conditions ) )
		call TriggerAddAction( t, function Actions )
		 set cf = Condition(function Effect2)
		set t = null
	endfunction
    
endscope
 

shiFt

Member
Reaction score
8
edited the first post, got it to work now :),thnx kingking. had to refresh the cs x/y.

How do I make it so that that damage is only dealt once to the picked units?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
->
JASS:
    private function Effect2 takes nothing returns boolean
        set U = GetFilterUnit()
        if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and not IsUnitInGroup(U,D.g) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", U, "chest"))
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", U, "chest"))
            call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            call GroupAddUnit(D.g,U)
        endif
        return false
    endfunction
 

shiFt

Member
Reaction score
8
I think kings method is not working because it already made the group before this action is called thus to add it to the same group would change nothing.
 

shiFt

Member
Reaction score
8
Still doesnt work, if that clears the group before its made and the if selects units that are not in the group every timer interval it still wouldnt do anything, so confusing
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Use a global group for the enumerations, while adding damaged units to the instance group. This way you never enumerate any units into the group in the struct, you only add them via the GroupAddUnit() call, making it possible to use a IsUnitInGroup() check in the boolexpr.
 

shiFt

Member
Reaction score
8
So im making 2 groups, one global one attached to struct? where do I make the global group, so far ive got, this, its not working but I dont knw where in the code to set the global group.
JASS:
scope WW initializer Init

    globals 
        private constant integer SPELL_ID = 'A01X'
        private hashtable ht = InitHashtable()
    endglobals
    
    private struct Data
        unit cs
        real x
        real y
        player p
        real dur
        integer ticks
        integer timeScaleTicks
        timer t
        group g
        real dmg
    endstruct
    
    globals
        private unit U
        private Data D
        private real X
        private real Y
        private integer array TimerData
        private conditionfunc cf
        private group gg
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

  private function Effect2 takes nothing returns boolean
        set U = GetFilterUnit()
        if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and not IsUnitInGroup(U,gg) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", U, "chest"))
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", U, "chest"))
            call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            call GroupAddUnit(gg,U)
        endif
        return false
    endfunction
    
    private function Effects takes nothing returns nothing
        local Data d = LoadInteger(ht,GetHandleId(GetExpiredTimer()),0)
        if d.ticks > 0 then
            set d.ticks = d.ticks - 1
            if d.timeScaleTicks > 0 then
                set d.timeScaleTicks = d.timeScaleTicks - 1
            else
                set d.timeScaleTicks = 10000
            endif
            set d.x = GetUnitX(d.cs)
            set d.y = GetUnitY(d.cs)
            set D = d
            call GroupEnumUnitsInRange(d.g,d.x,d.y,175.,cf)
            call GroupEnumUnitsInRange(gg,d.x,d.y,175.,cf)
            return
        endif
       call PauseTimer(d.t)
        call GroupClear(d.g)
        call d.destroy()
    endfunction
    
    private function Actions takes nothing returns nothing
        local Data d = Data.create()
        set d.cs = GetTriggerUnit()
        set d.p = GetOwningPlayer(d.cs)
        set d.dur = 4.
        set d.ticks = R2I(d.dur / .05)
        set d.timeScaleTicks = R2I(1. / .05)
        set d.dmg = (( 60 + ( 10* GetUnitAbilityLevel(d.cs,SPELL_ID)))* 0.05)
        if d.t == null then
            set d.t = CreateTimer()
            call SaveInteger(ht,GetHandleId(d.t),0,d)
        endif
        if d.g == null then
            set d.g = CreateGroup()
            set gg = CreateGroup()
        endif
        call TimerStart(d.t,.05,true,function Effects)
    endfunction

//---------------------------------------------------------------------------------------------------------
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
		local integer i = 0
		
		loop
			exitwhen i > 11
			call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
			set i = i + 1
		endloop

		call TriggerAddCondition( t, Condition( function Conditions ) )
		call TriggerAddAction( t, function Actions )
		 set cf = Condition(function Effect2)
		set t = null
	endfunction
    
endscope
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
You can just create it the following way:

JASS:
globals
    private group gg = CreateGroup()
endglobals


The thing you're doing wrong now is that you're using the struct group for enumaration, don't do this. Only use the global one for this purpose (note that you clear the group when you call GroupEnumUnits..., so there is no need for any clearing of the global group).

The only calls you should use the struct group for are the following:
- Creating it
- Checking if a unit is in the group already, if they are do not damage them.
- Adding damaged units to the group
- Destroying it at the end of the instance

It also goes without saying that the global group never should be destroyed (and as previously stated, clearing it is not needed).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top