| 07-20-2008, 07:54 AM | #1 |
Yeah, I've got a number of questions on the topics of unit groups and the topic of special effects (not together) and this time around I'm using Jass, I've also got a few random questions. No vJass please. Using Groups of Units
Special Effects
Random questions.
EDIT! Is my syntax checker broken? JASS:loop set u = FirstOfGroup(g) call GroupRemoveUnit(u, g) exitwhen u==null endloop //Obviously it's incomplete, but the error message is: //Line 117: Invalid argument type (group) |
| 07-20-2008, 09:29 AM | #2 | ||||||||||||
Using Groups of Units Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Special Effects Quote:
Quote:
Quote:
Random questions. Quote:
(Condition and Filter actually create child types of boolexprs, but they are what you use.) Quote:
Quote:
JASS:native GroupRemoveUnit takes group whichGroup, unit whichUnit returns nothing |
| 07-20-2008, 09:57 AM | #3 |
Oh right, haha I was trusting WC3's editor and it said the null thing was wrong... I'll work on it soon enough. Thanks for all those answers, I fear that's not the complete end of my queries though. |
| 07-20-2008, 01:04 PM | #4 |
you cant enum locust unit. |
| 07-20-2008, 01:11 PM | #5 |
You can with OfPlayer and OfType. |
| 07-21-2008, 07:55 AM | #6 |
Alrighty, I'm back with one more question: If I remove a unit from a group and then add it again, will it be put in last or first of group? |
| 07-21-2008, 10:38 AM | #7 |
last. |
| 07-21-2008, 10:46 AM | #8 |
I'm not 100% sure about that answer 'cause I put two statements up and "first" is the last statement... So it gets moved to last of group? ____ Problem! Here's how the recorded events in game go: 1. Cast Hurl Chain 2. Message: "Hurl Chain has been cast" 3. End. Main trigger: JASS:function Trig_Start_Chain_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local unit u local location l = GetSpellTargetLoc() local player p = GetOwningPlayer(GetTriggerUnit()) local group g local group tempg local integer counter = 0 local integer i = 0 local integer leader = 0 local real r = 0. local real x = GetUnitX(caster) local real y = GetUnitY(caster) call TideAE_System() call BJDebugMsg("Hurl Chain has been cast") set leader = udg_TS_LeadInteger call GroupEnumUnitsOfPlayer(g, p, null) set tempg = g call BJDebugMsg("Hurl Chain first loop has started") loop exitwhen u==null set counter = counter + 1 set u = FirstOfGroup(tempg) call GroupRemoveUnit(tempg, u) endloop call BJDebugMsg("Hurl Chain second loop has started") loop exitwhen u==null set i = i + 1 set r = r + 75 set u = FirstOfGroup(g) if GetUnitTypeId(u) != 'e000' then call GroupRemoveUnit(g, u) set i = i - 1 set counter = counter - 1 endif call SetUnitX(u, x) call SetUnitY(u, y) endloop call BJDebugMsg("Hurl Chain clean up has started") set udg_TS_Boolean[leader] = true set udg_TS_WispStyle[leader] = 1 set udg_TS_WispNumber[leader] = counter set udg_TS_Angle[leader] = TideAE_Ang_U2L(caster, l) set udg_TS_Distance[leader] = r set udg_TS_CasterUnit[leader] = caster set udg_TS_WispGroup[leader] = g set udg_TS_OriginPoint[leader] = GetUnitLoc(caster) set udg_TS_StepMax[leader] = 35. set udg_TS_StepCurrent[leader] = 0. call RemoveLocation(l) call DestroyGroup(g) call DestroyGroup(tempg) set caster = null set u = null call BJDebugMsg("Hurl Chain is ready") endfunction Assistant triggers: JASS:function TideAE_System takes nothing returns nothing local integer LIMIT = 50 local integer i = 0 local boolean b loop set i = i + 1 if udg_TS_Boolean[i]==false then set b = true set udg_TS_LeadInteger = i endif exitwhen b==true or i==LIMIT endloop if udg_TS_Boolean[i]==false then set udg_TS_Boolean[i] = true endif endfunction JASS:function TideAE_Ang_U2L takes unit start, location end returns real local real xstart = GetUnitX(start) local real ystart = GetUnitY(start) local real xend = GetLocationX(end) local real yend = GetLocationY(end) return bj_RADTODEG * Atan2(yend - ystart, xend - xstart) endfunction What's meant to happen is all the wisps are meant to be pulled in (that's all these triggers are concerned with) and then be shot out in a straight line making a chain-like body that stretches out and whacks the enemy (which is up to a separate trigger). |
| 07-21-2008, 11:47 AM | #9 |
JASS:local group g //... call GroupEnumUnitsOfPlayer(g, p, null) |
| 07-21-2008, 11:49 AM | #10 |
Blergh... how does one go about initializing group variables? I've never quite understood/learned properly how to. |
| 07-21-2008, 11:50 AM | #11 |
local group g = CreateGroup() Or preferably use a global group. set tempg = g Here you want to have tempg as a new group and add the contents of g to it. At the moment you're just making them reference the same group. JASS:loop exitwhen u==null set counter = counter + 1 set u = FirstOfGroup(tempg) call GroupRemoveUnit(tempg, u) endloop |
| 07-21-2008, 11:51 AM | #12 |
Thank you. Rep's on waiting list... Another problem, very sadly. What's going on this time... 1. I cast the spell 2. All the messages from the starter appear 3. End. 4. Unable to cast spell again What's meant to be going on: 1. I cast the spell 2. All wisps are pulled in 3. A series of messages from the starter appear 4. The chain extends out and a series of messages from the extender appear 5. The chain retracts and a series of messages from the retractor appear 6. Ready for recast The starter JASS:function Trig_Start_Chain_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local unit u local location l = GetSpellTargetLoc() local player p = GetOwningPlayer(GetTriggerUnit()) local group g = CreateGroup() local group tempg = CreateGroup() local integer counter = 0 local integer i = 0 local integer leader = 0 local real r = 0. local real x = GetUnitX(caster) local real y = GetUnitY(caster) call TideAE_System() call BJDebugMsg("Hurl Chain has been cast") set leader = udg_TS_LeadInteger call GroupEnumUnitsOfPlayer(g, p, null) set tempg = g call BJDebugMsg("Hurl Chain first loop has started") loop set u = FirstOfGroup(tempg) exitwhen u==null set counter = counter + 1 call GroupRemoveUnit(tempg, u) endloop call BJDebugMsg("Hurl Chain second loop has started") loop set u = FirstOfGroup(g) exitwhen u==null set i = i + 1 set r = r + 75 if GetUnitTypeId(u) != 'e000' then call GroupRemoveUnit(g, u) set i = i - 1 set counter = counter - 1 endif call SetUnitX(u, x) call SetUnitY(u, y) endloop call BJDebugMsg("Hurl Chain clean up has started") set udg_TS_Boolean[leader] = true set udg_TS_WispStyle[leader] = 1 set udg_TS_WispNumber[leader] = counter set udg_TS_Angle[leader] = TideAE_Ang_U2L(caster, l) set udg_TS_Distance[leader] = r set udg_TS_CasterUnit[leader] = caster set udg_TS_WispGroup[leader] = g set udg_TS_OriginPoint[leader] = GetUnitLoc(caster) set udg_TS_StepMax[leader] = 35. set udg_TS_StepCurrent[leader] = 0. call RemoveLocation(l) call DestroyGroup(g) call DestroyGroup(tempg) set caster = null set u = null call BJDebugMsg("Hurl Chain is ready") endfunction The extender JASS:function ChainExtend takes nothing returns nothing local real originx = GetLocationX(udg_TS_OriginPoint[udg_TS_LeadInteger]) local real originy = GetLocationY(udg_TS_OriginPoint[udg_TS_LeadInteger]) local real distance = 0. local real x = 0. local real y = 0. local real r = 0 local unit u local group g = udg_TS_WispGroup[udg_TS_LeadInteger] set udg_TS_StepCurrent[udg_TS_LeadInteger] = udg_TS_StepCurrent[udg_TS_LeadInteger] + 1 set distance = udg_TS_Distance[udg_TS_LeadInteger]/udg_TS_StepCurrent[udg_TS_LeadInteger] loop set r = r + 1. set u = FirstOfGroup(g) set x = originx + distance*r*Cos(udg_TS_Angle[udg_TS_LeadInteger] * bj_DEGTORAD) set y = originy + distance*r*Sin(udg_TS_Angle[udg_TS_LeadInteger] * bj_DEGTORAD) call SetUnitX(u, x) call SetUnitY(u, y) call GroupRemoveUnit(g, u) exitwhen r==I2R(udg_TS_WispNumber[udg_TS_LeadInteger]) endloop call DestroyGroup(g) set u = null if udg_TS_StepCurrent[udg_TS_LeadInteger] == udg_TS_StepMax[udg_TS_LeadInteger] then set udg_TS_WispStyle[udg_TS_LeadInteger] = 2 endif endfunction The retractor JASS:function ChainRetract takes nothing returns nothing local real originx = GetLocationX(udg_TS_OriginPoint[udg_TS_LeadInteger]) local real originy = GetLocationY(udg_TS_OriginPoint[udg_TS_LeadInteger]) local real distance = 0. local real x = 0. local real y = 0. local real r = 0 local unit u local group g = udg_TS_WispGroup[udg_TS_LeadInteger] set udg_TS_StepCurrent[udg_TS_LeadInteger] = udg_TS_StepCurrent[udg_TS_LeadInteger] - 1 set distance = udg_TS_Distance[udg_TS_LeadInteger]/udg_TS_StepCurrent[udg_TS_LeadInteger] loop set r = r + 1. set u = FirstOfGroup(g) set x = originx + distance*r*Cos(udg_TS_Angle[udg_TS_LeadInteger] * bj_DEGTORAD) set y = originy + distance*r*Sin(udg_TS_Angle[udg_TS_LeadInteger] * bj_DEGTORAD) call SetUnitX(u, x) call SetUnitY(u, y) call GroupRemoveUnit(g, u) exitwhen r==I2R(udg_TS_WispNumber[udg_TS_LeadInteger]) endloop call DestroyGroup(g) set u = null if udg_TS_StepCurrent[udg_TS_LeadInteger] == 0 then set udg_TS_Boolean[udg_TS_LeadInteger] = false set udg_TS_WispStyle[udg_TS_LeadInteger] = 0 set udg_TS_WispNumber[udg_TS_LeadInteger] = 0 set udg_TS_Angle[udg_TS_LeadInteger] = 0. set udg_TS_Distance[udg_TS_LeadInteger] = 0. call RemoveLocation(udg_TS_OriginPoint[udg_TS_LeadInteger]) set udg_TS_StepMax[udg_TS_LeadInteger] = 0. set udg_TS_StepCurrent[udg_TS_LeadInteger] = 0. endif endfunction The time "engine" JASS:function Trig_TideAE_Spell_Engine_Actions takes nothing returns nothing local integer i = 0 local integer limit = 50 loop set i = i + 1 if udg_TS_Boolean[i] == true then set udg_TS_LeadInteger = i if udg_TS_WispStyle[i] == 1 then call ChainExtend() elseif udg_TS_WispStyle[i] == 2 then call ChainRetract() elseif udg_TS_WispStyle[i] == 3 then endif endif exitwhen i==limit endloop endfunction //=========================================================================== function InitTrig_TideAE_Spell_Engine takes nothing returns nothing set gg_trg_TideAE_Spell_Engine = CreateTrigger( ) call TriggerRegisterTimerEventPeriodic( gg_trg_TideAE_Spell_Engine, 0.04 ) call TriggerAddAction( gg_trg_TideAE_Spell_Engine, function Trig_TideAE_Spell_Engine_Actions ) endfunction As been shown, coding is not my specialty. Could anyone assist me in my brain-crackingly bad coding? |
| 07-21-2008, 12:28 PM | #13 |
set tempg = g
That doesn't do what you're expecting. It simply makes tempg point to the same group g is pointing to. What you need is: JASS:set tempg = CreateGroup() call GroupAddGroup(g, tempg) Edit: JASS:set udg_TS_WispGroup[leader] = g //.... call DestroyGroup(g) You do the same thing in The extender and The retractor, while all you should be doing is set g = null. |
| 07-21-2008, 12:30 PM | #14 |
Alrighty, will do and I'll return with my awesomely long list of problems (should any remain). |
