| 12-22-2005, 06:30 AM | #1 |
Alright, so here's what my code looks like: JASS:function FloatingTextTimer takes unit SummonedUnit returns nothing local integer i set i = 30 loop exitwhen i == 0 call CreateTextTagUnitBJ( I2S(i), SummonedUnit, 0, 16.00, 50.00, 0.00, 0.00, 25.00 ) call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 1.00 ) call PolledWait(1) set i = i - 1 endloop endfunction function Trig_FurionJASS_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A00P' ) ) then return false endif return true endfunction function Trig_FurionJASS_Actions takes nothing returns nothing call DisplayTextToForce(GetPlayersAll(), "Furion Summon is working") set udg_LocalUnitGroup = GetUnitsInRectAll(RectFromLoc(GetSpellTargetLoc(), GetSpellTargetLoc())) set udg_LocalUnit = GroupPickRandomUnit(udg_LocalUnitGroup) call DestroyGroup(udg_LocalUnitGroup) set udg_LocalUnitGroup = null call SetUnitUserData( udg_LocalUnit, 1 ) call UnitApplyTimedLifeBJ( 30.00, 'BTLF', udg_LocalUnit ) call FloatingTextTimer(udg_LocalUnit) endfunction //=========================================================================== function InitTrig_FurionJASS takes nothing returns nothing set gg_trg_FurionJASS = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_FurionJASS, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_FurionJASS, Condition( function Trig_FurionJASS_Conditions ) ) call TriggerAddAction( gg_trg_FurionJASS, function Trig_FurionJASS_Actions ) endfunction What it's supposed to do is set the summoned unit's custom value to 1, give it a 30 second expiration timer, and then create floating text above the unit, displaying the time until it dies. So everything works except for the floating text timer. It won't appear, whatsoever. EDIT: Changed the expiration timer line, it said triggeringunit, not udg_LocalUnit. |
| 12-22-2005, 06:34 AM | #2 | |
Quote:
Firstly, your floating text is being set to a very dark color at 16 pt (a little on the big side) and 0 points from the ground (might want to try 100). Secondly, whenever debugging code, narrow it down as far as possible and then expand until the bug appears--then you'll know where it is. In this case, I'd ignore the trigger stuff for the meantime and just try calling the FloatingTextTimer function so you can make sure if that works. If it does--or once you get it working--you can then use the trigger stuff to make sure that also works. |
| 12-22-2005, 06:58 AM | #3 |
I set it to 16 so I would be sure to not miss it. In the final game it will probably be 10 or 8. Anyway, thanks for the suggestion. I'll go do that and report back. EDIT/Update: So the problem is with the SummonedUnit variable that the fuction takes... So, anyone know what's wrong with it? It's probably a silly error, but I'm somewhat new to writing JASS. |
| 12-22-2005, 07:23 AM | #4 | |
Quote:
GetUnitsInRectAll(RectFromLoc(GetSpellTargetLoc(), GetSpellTargetLoc())) Are you sure this is working? After assigning LocalUnit, try displaying the name of the unit to the screen in order to make sure that's working. If I understand correctly, you're making a region between two points--the same two points. Hence, the region would infinitely small and no unit would be found within it. Why are you using the target points and not the target unit? |
| 12-22-2005, 07:36 AM | #5 |
The ability I'm using is based off of "Item Build Tiny Great Hall." I've looked at all, or almost all, combinations of events and conditions, and event responses, but I couldn't find a single one that refers to the structure built by the ability. So I came up with that work-around. Anyone have another solution to it? |
| 12-22-2005, 08:36 AM | #6 | |
Quote:
Hrmm.. I've never worked with those before. If GetSummonedUnit() doesn't refer to it, then I'm not sure. Though on second though.... what about just detecting when said unit enters the map? When you build a structure, the structure enters the map.. so using the "MySoonToBeDeadStructure enters the map" event would work. |
| 12-22-2005, 08:42 AM | #7 |
Apart from the leaking, the rect you creating has no size, so there won't be any units in the unit group. If you want to use that workaround, you'll need to project the points a little to have an actual rect. I would suggest something like this: (you appear to be using globals, I'm not sure why, but I'll just give the example with locals) JASS:function Trig_FurionJASS_Actions takes nothing returns nothing local location l = GetSpellTargetLoc() local real x = GetLocationX(l) local real y = GetLocationY(l) local real offset = 50 call DisplayTextToForce(GetPlayersAll(), "Furion Summon is working") set udg_LocalUnitGroup = GetUnitsInRectAll(Rect(x-offset,y-offset,x+offset,y+offset)) set udg_LocalUnit = FirstOfGroup(udg_LocalUnitGroup) call DestroyGroup(udg_LocalUnitGroup) set udg_LocalUnitGroup = null call SetUnitUserData( udg_LocalUnit, 1 ) call UnitApplyTimedLifeBJ( 30.00, 'BTLF', udg_LocalUnit ) call FloatingTextTimer(udg_LocalUnit) endfunction Note: I'm not sure exactly how big thevariable 'offset' should be. Play around with it until you find something that works. And I haven't fixed all the leaks either. |
| 12-22-2005, 10:24 AM | #8 |
After 1.18 floating text that fades out is much easier it even gets destroyed automatically for example after creating a floating text t : JASS:
call SetTextTagFadepoint(t,2)
call SetTextTagLifespan(t,3)
call SetTextTagPermanent(t,false)
that is enough to make it fade away and be autodestroyed |
| 12-22-2005, 05:21 PM | #9 | |
Quote:
This is the way I originally did it, but that requires me to have two different towers, one that is spawned by the ability, and the other that is built by the builder. So this way, if/when I can get it to work, will be more simple. I'll try increasing the size of the rectangle. Seems to me like that would work. The reason I'm using globals is because the map I'm making is a joint effort between me and someone who doesn't understand JASS. So I originally made the trigger in GUI, converted a second copy of it into jass, and did the JASS-only things for the trigger. So they're completely unnessicary. I'll try out that trigger and see what happens. I was going to do the testing before posting again, but WE's trigger editor is acting up. It keeps giving me "Expected End Of Line" at totally random places. On code that I haven't modified (the polled wait, for example). And when I delete the PolledWait line, it gives me a different error right next to that line. Update: Ok, no idea what the problem was, but I copy/pasted into my most recent save right before this editing, and that part worked. Going to test right now. And however this turns out, everyone, thank you so very much for all of your help. |
| 12-22-2005, 05:39 PM | #10 |
Alright, really weird. Even WITH the offset, it still won't set udg_LocalUnit to the building. I had the game display the building's name, but nothing appeared. |
