Declaring Groups / Integers In One "Trigger", Using Them In Another

WolfieeifloW

WEHZ Helper
Reaction score
372
Up to this point, I've just been using "private constant <type> <name>".
But now I need to know how to declare a variable in one trigger object (scope I guess they're called) and carry it over to another.
Here's my code (at least, the parts that you guys need to see):
JASS:
globals
    private constant group crushedGroup
    private constant integer ability_ACid = &#039;A001&#039;
    private constant integer ability_ACBid = &#039;A002&#039;
    private constant integer buff_ACid = &#039;B001&#039;
    private constant integer buff_ACdid = &#039;B000&#039;
    private constant integer ability_ACdid = &#039;A000&#039;
    private constant integer dummyCaster = &#039;n000&#039;
    private constant integer dummyBuffer = &#039;n001&#039;
endglobals

How do I change those to be usable in other scopes?

EDIT: Also, how do I initialize that group?
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
change 'private' to 'public', and then, in other scopes, prefix it with whatever the scope is those things are declared in.

JASS:
set DeclarationScope_crushedGroup = CreateGroup()
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Where do I set that group?
Or do I change the line I have to that?

JASS:
// +----------------------------------------------------------+
// |                                                          |
// |       -=-=- Armor Crush by Wolfie[NoCT] v1.0 -=-=-       |
// |                                                          |
// +----------------------------------------------------------+
// |   -=-=- Version History -=-=-                            |
// |                                                          |
// |      Version 1.0                                         |
// |         - Initial version                                |
// |                                                          |
// +----------------------------------------------------------+

scope ArmorCrush initializer ACInit

// +-------------------------------------+
// |       -=-=- MODIFY HERE -=-=-       |
// |       -=-=- MODIFY HERE -=-=-       |
// |       -=-=- MODIFY HERE -=-=-       |
// +-------------------------------------+

globals
    public constant group crushedGroup
    public constant integer ability_ACid = &#039;A001&#039;
    public constant integer ability_ACBid = &#039;A002&#039;
    public constant integer buff_ACid = &#039;B001&#039;
    public constant integer buff_ACdid = &#039;B000&#039;
    public constant integer ability_ACdid = &#039;A000&#039;
    public constant integer dummyCaster = &#039;n000&#039;
    public constant integer dummyBuffer = &#039;n001&#039;
    private constant integer crushMin = 1
    private constant integer crushMax = 100
    private constant integer crushChance = 15
    private constant integer crushStack = 3
    private constant sound crushSound = gg_snd_Feedback
    private constant integer crushSoundVolume = 100
    private constant string crushSFX = &quot;Abilities\\Spells\\Items\\ResourceItems\\ResourceEffectTarget.mdl&quot;
    private constant string crushAttach = &quot;overhead&quot;
    private constant attacktype attackType = ATTACK_TYPE_NORMAL
    private constant damagetype damageType = DAMAGE_TYPE_NORMAL
    private constant real crushReturn = 0.02
    private constant real tOffset = 0
    private constant real tSize = 10
    private constant real tRed = 0
    private constant real tGreen = 0
    private constant real tBlue = 100
    private constant real tTrans = 0
    private constant real tLife = 3
    private constant real tAge = 2
    private constant real tVelocity = 75
    private constant real tDegrees = 90
    private constant string buffCommand = &quot;innerfire&quot;
endglobals

// +---------------------------------------+
// |       -=-=- END OF MODIFY -=-=-       |
// |       -=-=- END OF MODIFY -=-=-       |
// |       -=-=- END OF MODIFY -=-=-       |
// +---------------------------------------+

private function Conditions takes nothing returns boolean
    if (GetRandomInt(crushMin, crushMax) &lt;= crushChance) then
        return true
    else
        return false
    endif
    if GetUnitAbilityLevel(GetTriggerUnit(), buff_ACid) &gt; 0 then
        return true
    else
        return false
    endif
endfunction

private function CGConditions takes nothing returns boolean
    if IsUnitInGroup(GetAttacker(), crushedGroup) then
        return true
    else
        return false
    endif
endfunction

private function CVConditions takes nothing returns boolean
    if (GetUnitUserData(GetAttacker()) &lt; crushStack) then
        return true
    else
        return false
    endif
endfunction

private function Actions takes nothing returns nothing
    local location tempPoint = GetUnitLoc(GetAttacker())
    local integer array damageAttacker

    call AddSpecialEffectTargetUnitBJ(crushAttach, GetAttacker(), crushSFX)
    call DestroyEffect(GetLastCreatedEffectBJ())
    call PlaySoundOnUnitBJ(crushSound, crushSoundVolume, GetAttacker())
    set damageAttacker[0] = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetAttacker()))
    call UnitDamageTargetBJ(GetAttackedUnitBJ(), GetAttacker(), (GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ()) * (crushReturn * I2R(GetUnitAbilityLevelSwapped(ability_ACid, GetAttackedUnitBJ())))), attackType, damageType)
    call CreateNUnitsAtLoc(1, dummyCaster, GetOwningPlayer(GetAttackedUnitBJ()), tempPoint, bj_UNIT_FACING)
    call UnitApplyTimedLifeBJ(2.00, &#039;BTLF&#039;, GetLastCreatedUnit())
    set damageAttacker[1] = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetAttacker()))
    set damageAttacker[2] = (damageAttacker[0] - damageAttacker[1])
    call CreateTextTagUnitBJ((I2S(damageAttacker[2]) + &quot;!&quot; ), GetAttacker(), tOffset, tSize, tRed, tGreen, tBlue, tTrans)
    call SetTextTagPermanentBJ(GetLastCreatedTextTag(), false)
    call SetTextTagLifespanBJ(GetLastCreatedTextTag(), tLife)
    call SetTextTagFadepointBJ(GetLastCreatedTextTag(), tAge)
    call SetTextTagVelocityBJ(GetLastCreatedTextTag(), tVelocity, tDegrees)
    if (CVConditions()) then
        call SetUnitUserData(GetAttacker(), (GetUnitUserData(GetAttacker()) + 1))
        call SetUnitAbilityLevelSwapped(ability_ACdid, GetLastCreatedUnit(), (GetUnitUserData(GetAttacker()) * GetUnitAbilityLevelSwapped(ability_ACid, GetAttackedUnitBJ())))
        call IssueTargetOrder(GetLastCreatedUnit(), buffCommand, GetAttacker())
        if (CGConditions()) then
            call GroupAddUnitSimple(GetAttacker(), crushedGroup)
        else
        endif
    else
    endif
    call RemoveLocation(tempPoint)
endfunction

//===========================================================================
private function ACInit takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(trig, Condition(function Conditions))
    call TriggerAddAction(trig, function Actions)
endfunction

endscope

JASS:
// +----------------------------------------------------------+
// |                                                          |
// |       -=-=- Armor Crush by Wolfie[NoCT] v1.0 -=-=-       |
// |                                                          |
// +----------------------------------------------------------+
// |   -=-=- Version History -=-=-                            |
// |                                                          |
// |      Version 1.0                                         |
// |         - Initial version                                |
// |                                                          |
// +----------------------------------------------------------+

scope CGRemoval initializer CGRInit

private function Conditions takes nothing returns boolean
    if IsUnitGroupEmptyBJ(crushedGroup) then
        return false
    else
        return true
    endif
endfunction

private function BuffConditions takes nothing returns boolean
    if GetUnitAbilityLevel(GetTriggerUnit(), buff_ACdid) &gt; 0 then
        return true
    else
        return false
    endif
endfunction

private function GroupRemoveActions takes nothing returns nothing
    if (BuffConditions()) then
        call GroupRemoveUnitSimple(GetEnumUnit(),crushedGroup)
        call SetUnitUserData(GetEnumUnit(), 0)
    else
    endif
endfunction

private function Actions takes nothing returns nothing
    call ForGroupBJ(crushedGroup, function GroupRemoveActions)
endfunction

//===========================================================================
private function CGRInit takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterTimerEventPeriodic(trig, 1.50)
    call TriggerAddCondition(trig, Condition(function Conditions))
    call TriggerAddAction(trig, function Actions)
endfunction

endscope
 

quraji

zap
Reaction score
144
To use public globals declared inside the ArmorCrush scope in another scope, add 'ArmorCrush_' to the variable name.

For example, you'd change this:

JASS:
private function Conditions takes nothing returns boolean
    if IsUnitGroupEmptyBJ(crushedGroup) then
        return false
    else
        return true
    endif
endfunction

to this:
JASS:
private function Conditions takes nothing returns boolean
    if IsUnitGroupEmptyBJ(ArmorCrush_crushedGroup) then
        return false
    else
        return true
    endif
endfunction
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yeah, I fixed that but forgot to edit the post.
I still need to know how to declare that unit group though.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
If those constants aren't used outside of your system by the end user, instead of making the variables public, just add all the triggers into the scope (well it's now a library if you choose to use my optimizations to your code :D). This will avoid naming conflicts etc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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