modifying attribute points

jig7c

Stop reading me...-statement
Reaction score
123
bump!

it is still not working.. what am i missing?
neither is the attribute point being added, nor is the text coming up

JASS:
scope AttributeModifier initializer Init
function Attribute_Conditions takes nothing returns boolean
    return IsUnitEnemy(GetKillingUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO)
endfunction

function Attribute_Actions takes nothing returns nothing
    local unit u = GetKillingUnit()
    local integer i = GetRandomInt(1,4)//creating integer for random attribute
    local texttag t = CreateTextTag () //floating text
    //showing a floating text over killing unit, based on the bonus given!!
    
    //Strenght
    if (i == 1) then
        call UnitModifyStr(u, 2) //adding the bonus
        call SetTextTagPosUnit( t, u, 10 )
        call SetTextTagText( t, "+2 Strength", 0.023 )
        call SetTextTagColor( t, 10, 255, 255, 0 )
        call SetTextTagPermanent (t, false)
        call SetTextTagLifespan (t, 2.00)
        call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
        call SetTextTagFadepoint (t, 2.00 )
    elseif (i == 2) then//Agility
        call UnitModifyAgi(u, 2) //adding the bonus
        call SetTextTagPosUnit( t, u, 10 )
        call SetTextTagText( t, "+2 Agility", 0.023 )
        call SetTextTagColor( t, 255, 10, 255, 0 )
        call SetTextTagPermanent (t, false)
        call SetTextTagLifespan (t, 2.00)
        call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
        call SetTextTagFadepoint (t, 2.00 )
    elseif (i == 3) then  // Intelligence
        call UnitModifyInt(u, 2) //adding the bonus
        call SetTextTagPosUnit( t, u, 10 )
        call SetTextTagText( t, "+2 Intelligence", 0.023 )
        call SetTextTagColor( t, 255, 255, 10, 0 )
        call SetTextTagPermanent (t, false)
        call SetTextTagLifespan (t, 2.00)
        call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
        call SetTextTagFadepoint (t, 2.00 )
    elseif (i == 4) then //All Stats
        call UnitModifyStr (u, 1)
        call UnitModifyAgi (u, 1)
        call UnitModifyInt (u, 1)
        call SetTextTagPosUnit( t, u, 10 )
        call SetTextTagText( t, "+1 All Stats", 0.023 )
        call SetTextTagColor( t, 200, 10, 50, 0 )
        call SetTextTagPermanent (t, false)
        call SetTextTagLifespan (t, 2.00)
        call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
        call SetTextTagFadepoint (t, 2.00 )
    endif
    
    set u = null //removing unit from var
    set t = null
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerUnitEvent( t, Player( 12 ), EVENT_PLAYER_UNIT_DEATH, null )
    call TriggerAddCondition( t, Condition( function Attribute_Conditions) )
    call TriggerAddAction( t, function Attribute_Actions )
endfunction
endscope
 

Executor

I see you
Reaction score
57
Ah, foolishness mistake.

Check with debug msg if and which code is executed or not executed.
 

Laiev

Hey Listen!!
Reaction score
188

jig7c

Stop reading me...-statement
Reaction score
123
what i need is every time a HERO kills a Neutral Hostile Unit, it either gains a random stat of +2 or +1 to all stat...
thats it, so what changes do I need to make?
 

Laiev

Hey Listen!!
Reaction score
188
if the spell don't work, the problem is with condition

if the start at least start, the text show up

EDIT: also if still don't working, put this after the text

JASS:
call SetTextTagVisibility(<text>, true)


EDIT EDIT: use this example:

JASS:
.
        call UnitModifyStr(u, 2) //adding the bonus
        call SetTextTagText( t, "+2 Strength", 0.023 )
        call SetTextTagPosUnit( t, u, 10 )
        call SetTextTagColor( t, 10, 255, 255, 0 )
        call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
        call SetTextTagVisibility(t, true)
        call SetTextTagFadepoint (t, 2.00 )
        call SetTextTagLifespan (t, 2.00)
        call SetTextTagPermanent (t, false)
 

jig7c

Stop reading me...-statement
Reaction score
123
still don't work..
maybe i have to declare UnitProperties trigger somehwhere so it can use UnitModifyStr, UnitModifyAgi and UnitModifyInt in my trigger???

but im not even getting any text...
 

tooltiperror

Super Moderator
Reaction score
231
Init should be private.

Edit: At least use the private key words.

JASS:
scope AttributeModifier initializer Init     
     private function condition takes nothing returns boolean
         return IsUnitEnemy(GetKillingUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE)) and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO)
     endfunction

     private function action takes nothing returns nothing
         local unit u = GetKillingUnit()
         local integer i = GetRandomInt(1,4)//creating integer for random attribute
         local texttag t = CreateTextTag () //floating text
         //showing a floating text over killing unit, based on the bonus given!!
    
         //Strenghth
         if (i == 1) then
             call UnitModifyStr(u, 2) //adding the bonus
             call SetTextTagPosUnit( t, u, 10 )
             call SetTextTagText( t, "+2 Strength", 0.023 )
             call SetTextTagColor( t, 10, 255, 255, 0 )
             call SetTextTagPermanent (t, false)
             call SetTextTagLifespan (t, 2.00)
             call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
             call SetTextTagFadepoint (t, 2.00 )
         elseif (i == 2) then//Agility
             call UnitModifyAgi(u, 2) //adding the bonus
             call SetTextTagPosUnit( t, u, 10 )
             call SetTextTagText( t, "+2 Agility", 0.023 )
             call SetTextTagColor( t, 255, 10, 255, 0 )
             call SetTextTagPermanent (t, false)
             call SetTextTagLifespan (t, 2.00)
             call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
             call SetTextTagFadepoint (t, 2.00 )
         elseif (i == 3) then  // Intelligence
             call UnitModifyInt(u, 2) //adding the bonus
             call SetTextTagPosUnit( t, u, 10 )
             call SetTextTagText( t, "+2 Intelligence", 0.023 )
             call SetTextTagColor( t, 255, 255, 10, 0 )
             call SetTextTagPermanent (t, false)
             call SetTextTagLifespan (t, 2.00)
             call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
             call SetTextTagFadepoint (t, 2.00 )
         elseif (i == 4) then //All Stats
             call UnitModifyStr (u, 1)
             call UnitModifyAgi (u, 1)
             call UnitModifyInt (u, 1)
             call SetTextTagPosUnit( t, u, 10 )
             call SetTextTagText( t, "+1 All Stats", 0.023 )
             call SetTextTagColor( t, 200, 10, 50, 0 )
             call SetTextTagPermanent (t, false)
             call SetTextTagLifespan (t, 2.00)
             call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
             call SetTextTagFadepoint (t, 2.00 )
         endif
         set u = null
         set t = null
     endfunction

     private function Init takes nothing returns nothing
         local trigger t=CreateTrigger()
         call TriggerRegisterPlayerUnitEvent(t,Player(12),EVENT_PLAYER_UNIT_DEATH,null)
         call TriggerAddCondition(t,Condition(function condition))
         call TriggerAddAction(t,function action)
     endfunction
endscope
 

jig7c

Stop reading me...-statement
Reaction score
123
can you post the upgraded jass?


maybe i have to declare UnitProperties trigger somewhere so it can use UnitModifyStr, UnitModifyAgi and UnitModifyInt functions in my script???

JASS:
scope AttributeModifier initializer Init
    function Attribute_Conditions takes nothing returns boolean
        return IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO)
    endfunction

    function Attribute_Actions takes nothing returns nothing
        local unit u = GetKillingUnit()
        local integer i = GetRandomInt(1,4)//creating integer for random attribute
        local texttag t = CreateTextTag () //floating text
    //showing a floating text over killing unit, based on the bonus given!!
   
        if (i == 1) then //Strenght
            call UnitModifyStr(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Strength", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 0 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 2) then//Agility
           call UnitModifyAgi(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Agility", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 0 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 3) then  // Intelligence
            call UnitModifyInt(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Intelligence", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 0 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 4) then //All Stats
            call UnitModifyStr (u, 1)
            call UnitModifyAgi (u, 1)
            call UnitModifyInt (u, 1)
            call SetTextTagText( t, "+1 All Stats", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 0 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        endif   

        set u = null //removing unit from var
        set t = null
    endfunction

//===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerUnitEvent( t, Player(12), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerAddCondition( t, Condition( function Attribute_Conditions) )
        call TriggerAddAction( t, function Attribute_Actions )
    endfunction
endscope
 

Laiev

Hey Listen!!
Reaction score
188
I just want f*ck this code LOL

So i get it and fix it :)

the problem? you set alpha to zero LOL

JASS:
scope AttributeModifier initializer Init
   private function Attribute_Conditions takes nothing returns boolean
        return IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO)
    endfunction

   private function Attribute_Actions takes nothing returns nothing
        local unit u = GetKillingUnit()
        local integer i = GetRandomInt(1,4)//creating integer for random attribute
        local texttag t = CreateTextTag () //floating text
    //showing a floating text over killing unit, based on the bonus given!!
    
        if (i == 1) then //Strenght
            call UnitModifyStr(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Strength", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 255 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 2) then//Agility
            call UnitModifyAgi(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Agility", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 255 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 3) then  // Intelligence
            call UnitModifyInt(u, 2) //adding the bonus
            call SetTextTagText( t, "+2 Intelligence", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 255 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        elseif (i == 4) then //All Stats
            call UnitModifyStr (u, 1)
            call UnitModifyAgi (u, 1)
            call UnitModifyInt (u, 1)
            call SetTextTagText( t, "+1 All Stats", 0.023 )
            call SetTextTagPosUnit( t, u, 10 )
            call SetTextTagColor( t, 10, 255, 255, 255 )
            call SetTextTagVelocity( t, 0.0355 * Cos( 90. * bj_DEGTORAD ), 0.0355 * Sin( 90. * bj_DEGTORAD ) )
            call SetTextTagVisibility(t, true)
            call SetTextTagFadepoint (t, 2.00 )
            call SetTextTagLifespan (t, 2.00)
            call SetTextTagPermanent (t, false)
        endif   
        set u = null //removing unit from var
        set t = null
    endfunction

//===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerUnitEvent( t, Player(12), EVENT_PLAYER_UNIT_DEATH, null )
        call TriggerAddCondition( t, Condition( function Attribute_Conditions) )
        call TriggerAddAction( t, function Attribute_Actions )
    endfunction
endscope


tested and working
 

jig7c

Stop reading me...-statement
Reaction score
123
the text shows up, but the stats don't get added!
+rep added to laiev for that...
 

Laiev

Hey Listen!!
Reaction score
188
well i read in egui forum part... that system is broken what add attribute to hero :p or something like that
 

jig7c

Stop reading me...-statement
Reaction score
123
i fixed it
decided not to use unitproperties...

did it using bjs.. atleast its working now..
 
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