group problem

Prozix

New Member
Reaction score
7
Rewritten the trigger:
JASS:
scope HolyLight
globals
    private constant integer ABILITY_ID = 'A08F' //ability id
    private constant real DAMAGE = 25.0 //damage per level
    private constant real AOE_MAX = 400. //area of effect which will grow
    private constant real AOE_GROW = 100. //grow rate of aoe of spell
    private constant string EFFECT_ENEMY = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl" //effect in enemy when damage happen
    private constant string EFFECT_ALLY = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" //effect in ally when heal happen
    private constant string EFFECT_CIRCLE = "Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl"
    private constant string EFFECT_ATTACH = "origin" //position of effect
endglobals

private function HolyLight_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction
    
private function UnitFilter takes nothing returns boolean
    local unit u = GetFilterUnit()
    return IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and IsUnitType(u, UNIT_TYPE_DEAD) == false
endfunction

//The spell effect
globals
    private unit CASTER
    private real AMOUNT
endglobals
private function SpellEffectEnum takes nothing returns nothing
    local unit u = GetEnumUnit()
    if IsUnitEnemy(u, GetOwningPlayer(CASTER)) == true then
        call DestroyEffect(AddSpecialEffectTarget(EFFECT_ENEMY, u, EFFECT_ATTACH))
        call UnitDamageTarget(CASTER, u, AMOUNT, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    else
        call DestroyEffect(AddSpecialEffectTarget(EFFECT_ALLY, u, EFFECT_ATTACH))
        call SetWidgetLife(u, GetWidgetLife(u) + AMOUNT)
    endif
endfunction
//
//Actions
private function HolyLight_Actions takes nothing returns nothing
    local location targetLoc = GetSpellTargetLoc()
    local real range = 0.0
    local integer n = 1
    local group g
    local unit caster = GetTriggerUnit()
    local real damage = DAMAGE * GetUnitAbilityLevel(caster, ABILITY_ID)
    loop
        call CreateEffectCircle(targetLoc, range, n, EFFECT_CIRCLE, 2)
        set g = CreateGroup()
        call GroupEnumUnitsInRangeOfLoc(g, targetLoc, range, Filter(function UnitFilter)) //get the group
        set CASTER = caster
        set AMOUNT = damage
        call ForGroup(g, function SpellEffectEnum)
        call DestroyGroup(g)
        set g = null
        
        set range = range + AOE_GROW
        set n = n + 10
        exitwhen range >= AOE_MAX
        
        call TriggerSleepAction (.3)
    endloop
    call RemoveLocation(targetLoc)
    set targetLoc = null
endfunction

function InitTrig_Holy_Light takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function HolyLight_Conditions))
    call TriggerAddAction(t, function HolyLight_Actions)
endfunction

endscope


couldn't test it because I haven't got your map
 

Laiev

Hey Listen!!
Reaction score
188
@Romek

thx, fixed all :)

@Prozix

I will test if mine still don't working
 

Prozix

New Member
Reaction score
7
made minor changes of the global names. I could have replaced some things automatically that shouldn't have. But you can easily fix that. I hope my code works. I wanna learn myself so if your map is small, maybe you can post it?
 

Laiev

Hey Listen!!
Reaction score
188
made minor changes of the global names. I could have replaced some things automatically that shouldn't have. But you can easily fix that. I hope my code works. I wanna learn myself so if your map is small, maybe you can post it?

Small? I don't think so :p

5mb and is an AoS

EDIT: something to fix in your script...

exitwhen i >= AOE_MAX
must be
exitwhen range >= AOE_MAX

:p i think... correct me if i'm wrong

EDIT[2]: no, your script don't work and don't do nothing :X
 

Prozix

New Member
Reaction score
7
I could have replaced some things automatically that shouldn't have. But you can easily fix that.
hahah exactly what I said, and yes it should have been range. I fixed it in my post. Does it work?

Edit:
Oh... that's too bad. Does it give errors or doesn't it work in game?
Maybe you should add some BJDebugMsg("I'm here") thingies to see how many times or if a piece of code is executed?
 

Prozix

New Member
Reaction score
7
GroupEnumUnitsInRangeOfLoc doesn't create a group
so you would have to add
set g = CreateGroup()
before that function, i think that'll work :p
 

Laiev

Hey Listen!!
Reaction score
188
GroupEnumUnitsInRangeOfLoc doesn't create a group
so you would have to add
set g = CreateGroup()
before that function, i think that'll work :p

I think this is the problem in my version...

because when I use group, I destroy and null it, so = no group created o.o'

will test

EDIT: ya, i'm right :D

this is the problem, i set unit in group which don't exist, so just creategroup before again

thx alot guys :D i can't give more reps :( so sorry about that
 

Prozix

New Member
Reaction score
7
Hurray!! :thup: you're welcome

Look what I made while waiting on a reply xD
JASS:
scope EffectFunction initializer Init
globals
    private constant real PI =  3.14159265
    private constant integer MAX_EFFECTS = 500
endglobals

function CreateNEffectsCircle takes real x, real y, real radius, integer n, string e returns nothing
    local real a
    local integer i
    
    if n>0 then
        if n>MAX_EFFECTS then
            set n = MAX_EFFECTS
        endif
        if n==1 then
            call DestroyEffect(AddSpecialEffect(e, x, y))
        else
            set a = 2*PI/n //divide the circle into pieces
            set i=0
            loop
                exitwhen i>=n or i>=MAX_EFFECTS
                call DestroyEffect(AddSpecialEffect(e, x  +radius*Cos(a*i), y + radius*Sin(a*i)))
                set i = i+1
            endloop
        endif
    endif
endfunction

function CreateSpacedEffectCircle takes real x, real y, real radius, real distance, string e returns nothing
    local real o = 2*PI*radius //circumthing
    local integer n = R2I((o/distance)-.5) //round down for the number of effects in the circle
    if n == 0 then
        set n = 1
    endif
    if n>0 then
        call CreateNEffectsCircle(x, y, radius, n, e)
    endif
endfunction

private function Actions takes nothing returns nothing 
    local integer i = 0
    loop
        call CreateNEffectsCircle(-500, 0, 150*i+50, S2I(GetEventPlayerChatString()), "Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl")
        call CreateSpacedEffectCircle(500, 0, 150*i+50, S2R(GetEventPlayerChatString()), "Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl")
        set i = i + 1
        exitwhen i==4
    endloop
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t, Player(0), "", false)
    call TriggerAddAction(t, function Actions)
endfunction
endscope

if you add this and type "8" for example, it creates two*4 "circles", one bunch with 8 effects, and one bunch with the effects spaced 8 from each other, with a maximum of 500 effects
 

Laiev

Hey Listen!!
Reaction score
188
interstant... o.õ probably based on

[ljass]call CreateEffectCircle (point <loc>, radius <real>, num <number of effects>, effect <especial effect>, duration <real>)[/ljass]

right?
 

Prozix

New Member
Reaction score
7
Well, I saw the call in your code and I started writing the function from scratch out of boredom. So it's not based on it, it was more like.. happily inspired by it :p
 

Laiev

Hey Listen!!
Reaction score
188
:p is what i mean.. sorry

but is a function of EGUI

look the script:

JASS:
function CreateEffectCircle takes location loc, real radius, integer num, string path, real duration returns nothing
    local integer i = 1
    local real angle = 90
    local real angleincrement = 360 / I2R(num)
    local real x
    local real y
   
    loop
        exitwhen i &gt; num
        set angle = angle + angleincrement
        set x = GetLocationX(loc) + radius * Cos(angle * (3.1415 / 180))
        set y = GetLocationY(loc) + radius * Sin(angle * (3.1415 / 180))
        if p &gt; 8190 then
            set p = 0
            set e[p] = AddSpecialEffect(path, x, y)
            set z[p] = NewTimer()
            call SetTimerData(z[p], p)
            call TimerStart(z[p], duration, false, function DT)
        else
            set e[p] = AddSpecialEffect(path, x, y)
            set z[p] = NewTimer()
            call SetTimerData(z[p], p)
            call TimerStart(z[p], duration, false, function DT)
            set p = p + 1
        endif
        set i = i + 1
    endloop
endfunction
 

Prozix

New Member
Reaction score
7
It's pretty similar, except that my code removes some effects immediately. The EGUI code overwrites effects if you create more than 8090 before one gets destroyed, but that won't happen very often. I was wondering what
[LJASS]call SetTimerData(z[p], p)[/LJASS]
does
 

Prozix

New Member
Reaction score
7
Aha, thanks. I don't understand hashtables (yet), maybe I will do some research on it. How is your AoS map called and are you working on it alone? I think I'm pretty offtopic right now. There was a chatting like thingy on the forums right?
 

Laiev

Hey Listen!!
Reaction score
188
Aha, thanks. I don't understand hashtables (yet), maybe I will do some research on it. How is your AoS map called and are you working on it alone? I think I'm pretty offtopic right now. There was a chatting like thingy on the forums right?

Well, just check my profile :p and you'll see it... and ya, i'm working on it alone, just because most <probably 90%> of guys in my country <brazil> are stupid and noobs and don't know what do with editor, and all say "newgen sucks.. normal WE rules" bla bla bla bla make no sense...

I'll pm u ;P
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top