• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Weird Bug?

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
I encountered a problem and i'm a bit confused why that's the case.


This will always work, it will always show the Floating Text of the item on the screen
JASS:
set Item = CreateItem(ItemType[GetRandomInt(1, 4)], 0, 0)
call FloatingText("|cffFF7000" + GetItemName(Item), p)
call UnitAddItem(u, Item)
set Item = null

This however, will only work if i get the item the first time. the second time i get the same item, and it will stack up, it won't show the text anymore.
JASS:
set Item = CreateItem(ItemType[GetRandomInt(1, 4)], 0, 0)
call UnitAddItem(u, Item)
call FloatingText("|cffFF7000" + GetItemName(Item), p)
set Item = null


JASS:
function FloatingText takes string s, player p returns nothing
        local texttag t = CreateTextTag()
        local real r = GetRandomReal(1.00, 360.0)
        local real x = GetCameraTargetPositionX()
        local real y = GetCameraTargetPositionY()
        call SetTextTagText(t, s, 0.0345)
        call SetTextTagPos(t, x, y, 100)
        if (GetLocalPlayer() != p) then
            call SetTextTagVisibility(t, false)
        endif
        call SetTextTagVelocity(t, 0.044375*Cos(r*bj_DEGTORAD), 0.044375*Sin(r*bj_DEGTORAD))
        call SetTextTagPermanent(t, false)
        call SetTextTagLifespan(t, 3.00)
        call SetTextTagFadepoint(t, 2.00)
        set t = null
    endfunction
 
Level 12
Joined
May 22, 2015
Messages
1,051
I know there are definitely strange things when a hero is holding an item. You could try seeing if you can even retrieve the item name for an item being carried.

I know the x and y value are not known until the item is actually on the ground. I'm more skeptical in this case since the x and y value don't exactly exist when an item is being carried, but maybe it is something like this that is causing the problem. TBH, I don't think I've ever used the "get item name" function.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
and it will stack up
I think the stacking trigger is interrupting the thread in response to the following call...
JASS:
call UnitAddItem(u, Item)
During stacking, you probably remove the item after transferring its charges to the existing item. The result is that by the time you call this...
JASS:
call FloatingText("|cffFF7000" + GetItemName(Item), p)
The variable "Item" evaluates to null. It still holds the handle value, but that has been invalidated by removal of the item. The name of a null item is quite probably null. As such the floating text might even be created, but it will have no visible characters.

Floating text does not need colour tags? There is a native to set the colour.
JASS:
native SetTextTagColor takes texttag t,integer red,integer green,integer blue,integer alpha returns nothing
 
Status
Not open for further replies.
Top