• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Little bug. Alot of text.

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hello.

First of all I need to say I'm not a good jass user, I just started learning it so please don't flame me of doing something at a very weird way.

This is the problem:

I'm making an Equipment System which allows you to equip items in a spellbook. For this I gave every unit some abilities (agi16, agi8, agi4..etc) to improve their stat points when they equip an item.
I made my first few moves in Jass, and thoud I was done with the first part of the system now.. but now I tested it.

When my hero clicks the item to equip it (it has a spell based on Fan of Knives) the trigger doesn't run. I made a test trigger with the right event and a game message when it goes off, and this worked. So I'm not using the wrong event.

Can someone look through it (alot of work I think) and tell me what I'm doing wrong?

This is the Initialization Trigger to set the item data (how much strength an item gives per example)
JASS:
function Trig_ItemInit_Actions takes nothing returns nothing
///////////////////ItemBonusses/////////////////////////////
local integer i = 1
local integer t = 0
set i = 1
loop
    exitwhen i > 4 ////EDIT the 4 to the maxitems////
        set t = t + 1
        set udg_ItemType[t] = 'I000'
        set udg_ItemIntelligence[t] = 4
        set udg_ItemStrength[t] = 1
        set udg_ItemAgility[t] = 2
        set udg_ItemArmor[t] = 3
        set i = i + 1
    endloop

set udg_agi[1] = 'A01Z'
set udg_agi[16] = 'A020'
set udg_agi[2] = 'A021'
set udg_agi[4] = 'A022'
set udg_agi[8] = 'A023'
set udg_int[1] = 'A024'
set udg_int[16] = 'A025'
set udg_int[2] = 'A026'
set udg_int[4] = 'A027'
set udg_int[8] = 'A028'
set udg_str[1] = 'A029'
set udg_str[16] = 'A02A'
set udg_str[2] = 'A02B'
set udg_str[4] = 'A02C'
set udg_str[8] = 'A02D'
set udg_arm[1] = 'A02E'
set udg_arm[2] = 'A02F'
set udg_arm[4] = 'A02G'
set udg_arm[8] = 'A02H'
set udg_dam[1] = 'A02I'
set udg_dam[128] = 'A02J'
set udg_dam[16] = 'A02K'
set udg_dam[2] = 'A02L'
set udg_dam[32] = 'A02M'
set udg_dam[4] = 'A02N'
set udg_dam[64] = 'A02O'
set udg_dam[8] = 'A02P'
endfunction

//===========================================================================
function InitTrig_ItemInit takes nothing returns nothing
    set gg_trg_ItemInit = CreateTrigger(  )
    call TriggerAddAction( gg_trg_ItemInit, function Trig_ItemInit_Actions )
endfunction

This is the EquipItem Trigger. This should start running when a unit Uses an item, but it aint running atm.
JASS:
function Trig_ItemEquip_Conditions takes nothing returns boolean
    if (not (GetItemType(GetManipulatedItem()) == ITEM_TYPE_PERMANENT)) then
        return false
    endif
    return true
endfunction

function Trig_ItemEquip_Actions takes nothing returns nothing
local integer i = 0
local integer in = 0
local unit u = GetTriggerUnit()
local integer t = 0
local integer x = 0
set i = 1
loop
    exitwhen i > 4 ////EDIT the 4 to the maxitems////
        if udg_ItemType[i] == GetItemTypeId(GetManipulatedItem()) then
        set i = in
        else
        set i = i+1
    endif
    endloop

///////This is where it adds stats.. Not an important part to read, and I think I'm doing it pretty weird, but whatever.. I think it works.../////
set x = udg_ItemAgility[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_agi[16], u, GetUnitAbilityLevelSwapped(udg_agi[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_agi[8], u, GetUnitAbilityLevelSwapped(udg_agi[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_agi[4], u, GetUnitAbilityLevelSwapped(udg_agi[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_agi[2], u, GetUnitAbilityLevelSwapped(udg_agi[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_agi[1], u, GetUnitAbilityLevelSwapped(udg_agi[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))

set x = udg_ItemIntelligence[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_int[16], u, GetUnitAbilityLevelSwapped(udg_int[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_int[8], u, GetUnitAbilityLevelSwapped(udg_int[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_int[4], u, GetUnitAbilityLevelSwapped(udg_int[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_int[2], u, GetUnitAbilityLevelSwapped(udg_int[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_int[1], u, GetUnitAbilityLevelSwapped(udg_int[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))

set x = udg_ItemStrength[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_str[16], u, GetUnitAbilityLevelSwapped(udg_str[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_str[8], u, GetUnitAbilityLevelSwapped(udg_str[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_str[4], u, GetUnitAbilityLevelSwapped(udg_str[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_str[2], u, GetUnitAbilityLevelSwapped(udg_str[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_str[1], u, GetUnitAbilityLevelSwapped(udg_str[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))

set x = udg_ItemArmor[in]
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_arm[8], u, GetUnitAbilityLevelSwapped(udg_arm[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_arm[4], u, GetUnitAbilityLevelSwapped(udg_arm[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_arm[2], u, GetUnitAbilityLevelSwapped(udg_arm[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_arm[1], u, GetUnitAbilityLevelSwapped(udg_arm[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))
endfunction

//===========================================================================
function InitTrig_ItemEquip takes nothing returns nothing
    set gg_trg_ItemEquip = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ItemEquip, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( gg_trg_ItemEquip, Condition( function Trig_ItemEquip_Conditions ) )
    call TriggerAddAction( gg_trg_ItemEquip, function Trig_ItemEquip_Actions )
endfunction
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Nothing makes Trig_ItemInit_Actions to run, as your trigger doesn't have any event(s).

Well, this was copied from a Map Initialization event into the trigger.
But I tried to replace this with a Elapsed game time = 1.00 seconds, but that doesn't work either.

Also, you should stop using all this useless BJs (SetUnitAbilityLevelSwapped) and why the hell are you adding a billion of abilities just for one item?

The swapped thing is because of I changed it from GUI to Jass. That shouldn't really matter I think.
And I have a billion of abilities because of this:
If an item has 31 strength per example. It is divided like this:
+16 str
+8 str
+4 str
+2 str
+1 str
total +31 str.

So I made a spell with each level of the spell to have +16 str.. and a spell with +8.. you know what I mean.

Because later in the game you can have tons of attributes, so I couldnt make a spell have 100000 levels and each level add +1 to the stat point.



..so I still have no solution so far:(
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
It seems like init really doesn't have any event, which is weird since a trigger with no events doesn't have any either... another messed up thing made by Blizzard?

Anyways, what's wrong with
JASS:
function SetHeroStat takes unit whichHero, integer whichStat, integer value returns nothing
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Anyways, what's wrong with
JASS:
function SetHeroStat takes unit whichHero, integer whichStat, integer value returns nothing

What do you mean?
I'm pretty much of a jass noob. Could you explain a bit where I should put this?
 
For the first 1, have you checked the box "Run on Map Initialization"? As for the second one, I don't think its that it doesn't run, it just that the loop never ends. Because, think about it, say
JASS:
udg_ItemType[0] == GetManipulatedItem()
matches. It then sets the loop index (i) back to 0 so it runs that comparison again... and again and again and again until it hits the op limit...
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
It means that you can call SetHeroStat to change your hero's states. In GUI it would be
  • Hero - Modify Some_State of Some_Unit: Add/Subtract/Set to Some_Number
For example:
JASS:
call SetHeroStat(u,bj_HEROSTAT_STR,GetHeroStr(u,false)+udg_str[your item's index])

The states are named like the following:

constant integer bj_HEROSTAT_STR = 0
constant integer bj_HEROSTAT_AGI = 1
constant integer bj_HEROSTAT_INT = 2

And the boolean in GetHeroStr is wether to include item/ability bonuses or not.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
It means that you can call SetHeroStat to change your hero's states. In GUI it would be
  • Hero - Modify Some_State of Some_Unit: Add/Subtract/Set to Some_Number
For example:
JASS:
call SetHeroStat(u,bj_HEROSTAT_STR,GetHeroStr(u,false)+udg_str[your item's index])

The states are named like the following:

constant integer bj_HEROSTAT_STR = 0
constant integer bj_HEROSTAT_AGI = 1
constant integer bj_HEROSTAT_INT = 2

And the boolean in GetHeroStr is wether to include item/ability bonuses or not.

Yes true, but then you wont see the green text that added the stats.
If a hero has 40 strength, and equips an item with 10 strength it shouldnt be he has 50 strength.. But 40 + 10 strength.. Kinda confusing, but I want the green +XXX text behind the stats.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Oh I see... I don't think there is any way to do that, thanks to Blizzard not giving us access to many many functions.

I found the way already.
Just cant get my trigger to work.
I had this system in GUI once, but took alooooot of functions etc..
Now I want it in Jass to make it easier..

Think I created it, just cant get my trigger to start. So that was the problem actually.:D
 
For the first 1, have you checked the box "Run on Map Initialization"? As for the second one, I don't think its that it doesn't run, it just that the loop never ends. Because, think about it, say
JASS:
udg_ItemType[0] == GetManipulatedItem()
matches. It then sets the loop index (i) back to 0 so it runs that comparison again... and again and again and again until it hits the op limit...
might help...
 
Status
Not open for further replies.
Top