• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Buying Item

Status
Not open for further replies.
Level 9
Joined
Nov 19, 2011
Messages
516
Hi all,

Got a little problem. Ive made trigger which replace fake items with real ones, but its not starts.

attachment.php


I had a condition here to (item-class of item being manipulated = campain) but I've removed it naive thinking that it may be problem with classes.

Item-type that I am buing is of course FakeItem[1] (to avoid going out of 'for' range).
 

Attachments

  • trigger.jpg
    trigger.jpg
    62.3 KB · Views: 197
Last edited:
Level 6
Joined
Oct 7, 2008
Messages
113
Let me translate it for you (polish is one of my two native languages)

Unit- A unit buys/sells an item (from shop) { i do not know if he has chosen the right event here, as i never used the polish editor}

actions:
for each (integer A) from 1 to 27, do
if all conditions are true
if- itemtype of (item being manipulated) equals TitemFake[(Integer A)]
then:
item-remove (item being manipulated)
hero- create Titem True[(Integer A)] and give it to (Buying Unit)
Skip remaining actions



Some possible problems:
maybe he has picked the wrong event( don't know)
maybe he did not make a table with all the items listed
 
Level 9
Joined
Nov 19, 2011
Messages
516
A unit gains item is the same as unit takes item? If so it still not work, and I can't find other unit (sth) item event... :/ I've made some check poits so I alredy know that problem is with condition. Look at map. If you want to test it do it as WorldEdit user. Type '-points x' at begin, and then '!test'. 1st recipe from 1st shop should be TItemFake[1].

Looks like no more ideas..
 

Attachments

  • CtF v1.12.w3x
    723.2 KB · Views: 62
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
A unit gains item is the same as unit takes item? If so it still not work, and I can't find other unit (sth) item event... :/ I've made some check poits so I alredy know that problem is with condition. Look at map. If you want to test it do it as WorldEdit user. Type '-points x' at begin, and then '!test'. 1st recipe from 1st shop should be TItemFake[1].

Looks like no more ideas..

Look at this trigger:

  • VAR Items
    • Events
    • Conditions
    • Actions
      • Set TItemFake[1] = Recipe: Amored Boots
      • Set TItemTrue[1] = Amored Boots - recipe
      • Set TItemFake[2] = Recipe: BloodStone
      • Set TItemTrue[2] = BloodStone - recipe
      • Set TItemFake[3] = Recipe: Bone Crusher
      • Set TItemTrue[3] = Bone Crusher - recipe
      • Set TItemFake[4] = Recipe: Bracer
      • Set TItemTrue[4] = Bracer - recipe
      • Set TItemFake[5] = Recipe: Brain Cage
      • Set TItemTrue[5] = Brain Cage - recipe
      • Set TItemFake[6] = Recipe: Charged Arrows
      • Set TItemTrue[6] = Charged Arrows - recipe
      • Set TItemFake[7] = Recipe: Claws of Terror
      • Set TItemTrue[7] = Claws of Terror - recipe
      • Set TItemFake[8] = Recipe: Cold Arrows
      • Set TItemTrue[8] = Cold Arrows - recipe
      • Set TItemFake[9] = Recipe: Dark Arrows
      • Set TItemTrue[9] = Dark Arrows - recipe
      • Set TItemFake[10] = Recipe: Demon Blade
      • Set TItemTrue[10] = Demon Blade - recipe
      • Set TItemFake[11] = Recipe: Demon Boots
      • Set TItemTrue[11] = Demon Boots - recipe
      • Set TItemFake[12] = Recipe: Gladius
      • Set TItemTrue[12] = Gladius - recipe
      • Set TItemFake[13] = Recipe: Hellfire Claws
      • Set TItemTrue[13] = Hellfire Claws - recipe
      • Set TItemFake[14] = Recipe: Holy Shield
      • Set TItemTrue[14] = Holy Shield - recipe
      • Set TItemFake[15] = Recipe: Iron Hammer
      • Set TItemTrue[15] = Iron Hammer - recipe
      • Set TItemFake[16] = Recipe: Iron Shield
      • Set TItemTrue[16] = Iron Shield - recipe
      • Set TItemFake[17] = Recipe: Perseverence
      • Set TItemTrue[17] = Perseverence - recipe
      • Set TItemFake[18] = Recipe: Plate Boots
      • Set TItemTrue[18] = Plate Boots - recipe
      • Set TItemFake[19] = Recipe: Powered Amulet
      • Set TItemTrue[19] = Powered Amulet - recipe
      • Set TItemFake[20] = Recipe: Quiet Runners
      • Set TItemTrue[20] = Quiet Runners - recipe
      • Set TItemFake[21] = Recipe: Royal Helmet
      • Set TItemTrue[21] = Royal Helmet - recipe
      • Set TItemFake[22] = Recipe: Soul Booster
      • Set TItemTrue[22] = Soul Booster - recipe
      • Set TItemFake[23] = Recipe: Storm Hammer
      • Set TItemTrue[23] = Storm Hammer - recipe
      • Set TItemFake[24] = Recipe: Unholy Shield
      • Set TItemTrue[24] = Unholy Shield - recipe
      • Set TItemFake[25] = Recipe: Vanguard
      • Set TItemTrue[25] = Vanguard - recipe
      • Set TItemFake[26] = Recipe: War Drums
      • Set TItemTrue[26] = War Drums - recipe
      • Set TItemFake[27] = Recipe: Winter Staff
      • Set TItemTrue[27] = Winter Staff - recipe
There's no event, thus the fake and true items are never defined, I suggest adding map initialization, or even beter...
Put it in your initialization trigger that you already have.
That should solve it...

EDIT: funny to see a CtF map again, I created 7 different game modes like these a few years ago :D

Capture The Flag
Oddball
Juggernaut
King of the hill
Deathmatch
Team deathmatch
Headquarters

All in one map :p
Also had a multikill system and of course it included a save/load code to save your rank and stuff xD
Was quite a usefull save/load code since you didn't have to type -save, the code would be displayed locally to each player when the game ends.
So they need to finish the game in order to gain exp :p
You did need to type -load yourcode
Would be so awesome if there was a way of skipping that too though 0.o!
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
My mistake, I'll look further...

EDIT:

JASS:
globals
    // User-defined
    real                    udg_FadingTime             = 0
    real                    udg_LifespanTime           = 0
    integer                 udg_DropChance             = 0
    integer                 udg_C                      = 0
    integer                 udg_D                      = 0
    integer array           udg_TPoints
    integer                 udg_Win                    = 0
    string                  udg_tmp
    string                  udg_BotName
    real array              udg_TExperience
    integer array           udg_TKills
    player                  udg_Host                   = null
    string array            udg_TColoredName
    item                    udg_Rune                   = null
    timer                   udg_Timer                  = null
    integer array           udg_TDeaths
    player                  udg_Winer                  = null
    player                  udg_BestKills              = null
    player                  udg_BestDeaths             = null
    player                  udg_BestPoints             = null
    unit array              udg_THero
    integer array           udg_THeroes
    boolean array           udg_THeroes_Check
    integer                 udg_R                      = 0
    integer array           udg_TItemFake
    integer array           udg_TItemTrue

    // Generated
    rect                    gg_rct_JumpRedOut          = null
    rect                    gg_rct_JumpRedWater        = null
    rect                    gg_rct_House               = null
    rect                    gg_rct_Blue                = null
    rect                    gg_rct_Purple              = null
    rect                    gg_rct_JumpGreenOut        = null
    rect                    gg_rct_JumpGreenWater      = null
    rect                    gg_rct_RedBase             = null
    rect                    gg_rct_GreenBase           = null
    rect                    gg_rct_Rev                 = null
    rect                    gg_rct_Rune_1              = null
    rect                    gg_rct_Rune_2              = null
    rect                    gg_rct_SpawnUnits          = null
    rect                    gg_rct_CheckPointRed       = null
    rect                    gg_rct_CheckPointGreen     = null
    rect                    gg_rct_RedSpawn            = null
    rect                    gg_rct_GreenSpawn          = null
    rect                    gg_rct_SoulSpawn           = null
    trigger                 gg_trg_Initialization      = null
    trigger                 gg_trg_SetPoints           = null
    trigger                 gg_trg_Balance             = null
    trigger                 gg_trg_SC                  = null
    trigger                 gg_trg_MVP                 = null
    trigger                 gg_trg_VAR_Heros           = null
    trigger                 gg_trg_VAR_Items           = null
    trigger                 gg_trg_OldTable            = null
    trigger                 gg_trg_Random_hero         = null
    trigger                 gg_trg_Add_event_to_random_hero = null
    trigger                 gg_trg_PickedHeroRemove    = null
    trigger                 gg_trg_GoldTextModification = null
    trigger                 gg_trg_PurpleTextModification = null
    trigger                 gg_trg_ExperienceModification = null
    trigger                 gg_trg_MultiboardUpdate    = null
    trigger                 gg_trg_SetColoredNames     = null
    trigger                 gg_trg_Effect              = null
    trigger                 gg_trg_DoomLord            = null
    trigger                 gg_trg_SludgeMonster       = null
    trigger                 gg_trg_SludgeLord          = null
    trigger                 gg_trg_FirstBlood          = null
    trigger                 gg_trg_FAKE                = null
    trigger                 gg_trg_Amored_Boots        = null
    trigger                 gg_trg_BloodStone          = null
    trigger                 gg_trg_BoneCrusher         = null
    trigger                 gg_trg_Bracer              = null
    trigger                 gg_trg_BrainCage           = null
    trigger                 gg_trg_ChargedArrows       = null
    trigger                 gg_trg_ClawsOfTerror       = null
    trigger                 gg_trg_ColdArrows          = null
    trigger                 gg_trg_DarkArrows          = null
    trigger                 gg_trg_DemonBlade          = null
    trigger                 gg_trg_DemonBoots          = null
    trigger                 gg_trg_FrostStaff          = null
    trigger                 gg_trg_Gladius             = null
    trigger                 gg_trg_HellfireClaws       = null
    trigger                 gg_trg_HolyShield          = null
    trigger                 gg_trg_IronHammer          = null
    trigger                 gg_trg_IronShield          = null
    trigger                 gg_trg_Perseverence        = null
    trigger                 gg_trg_PlateBoots          = null
    trigger                 gg_trg_PoweredAmulet       = null
    trigger                 gg_trg_QuietRunners        = null
    trigger                 gg_trg_RoyalHelmet         = null
    trigger                 gg_trg_SoulBooster         = null
    trigger                 gg_trg_StormHammer         = null
    trigger                 gg_trg_UnholyShiled        = null
    trigger                 gg_trg_Vanguard            = null
    trigger                 gg_trg_FlagDrop            = null
    trigger                 gg_trg_ItemStack           = null
    trigger                 gg_trg_Drop                = null
    trigger                 gg_trg_MagicSoup           = null
    trigger                 gg_trg_MagicSoupRefresh    = null
    trigger                 gg_trg_Trees               = null
    trigger                 gg_trg_Income              = null
    trigger                 gg_trg_Choose              = null
    trigger                 gg_trg_HeroKill            = null
    trigger                 gg_trg_UnitKill            = null
    trigger                 gg_trg_PointRed            = null
    trigger                 gg_trg_PointGreen          = null
    trigger                 gg_trg_Hit                 = null
    trigger                 gg_trg_Runes               = null
    trigger                 gg_trg_Spawn               = null
    trigger                 gg_trg_CheckPointRed       = null
    trigger                 gg_trg_CheckPointGreen     = null
    trigger                 gg_trg_Add                 = null
    trigger                 gg_trg_Win                 = null
    trigger                 gg_trg_test                = null
    trigger                 gg_trg_unstuck             = null
    trigger                 gg_trg_ms                  = null
    trigger                 gg_trg_Acid                = null
    trigger                 gg_trg_AutoCannonAddon     = null
    trigger                 gg_trg_CourseOfTheSilent   = null
    trigger                 gg_trg_DemonBladeArmor     = null
    trigger                 gg_trg_DemonicResistance   = null
    trigger                 gg_trg_FartCloud           = null
    trigger                 gg_trg_FireballUP          = null
    trigger                 gg_trg_FrostCut            = null
    trigger                 gg_trg_HeavyBullets        = null
    trigger                 gg_trg_HolyHand            = null
    trigger                 gg_trg_Mines               = null
    trigger                 gg_trg_Purification        = null
    trigger                 gg_trg_SlowingWeb          = null
    trigger                 gg_trg_SniperShot          = null
    unit                    gg_unit_ntav_0019          = null
    unit                    gg_unit_n004_0071          = null
    unit                    gg_unit_nslf_0046          = null
    item                    gg_item_rman_0070          = null
    unit                    gg_unit_nfov_0062          = null
    unit                    gg_unit_nsln_0057          = null


//JASSHelper struct globals:

endglobals


//===========================================================================
// 
// Capture The Flag v1.12T
// 
//   Warcraft III map script
//   Generated by the Warcraft III World Editor
//   Date: Wed Jan 11 02:02:55 2012
//   Map Author: MajorKaza
// 
//===========================================================================

//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************


function InitGlobals takes nothing returns nothing
    local integer i= 0
    set udg_FadingTime = 1.00
    set udg_LifespanTime = 2.00
    set udg_DropChance = 500
    set udg_C = 0
    set udg_D = 0
    set i = 0
    loop
        exitwhen ( i > 12 )
        set udg_TPoints[i]=0
        set i = i + 1
    endloop

    set udg_Win = 0
    set udg_tmp = ""
    set udg_BotName = "[|ca000ff00BOT|r]"
    set i = 0
    loop
        exitwhen ( i > 12 )
        set udg_TExperience[i]=80.00
        set i = i + 1
    endloop

    set i = 0
    loop
        exitwhen ( i > 12 )
        set udg_TKills[i]=0
        set i = i + 1
    endloop

    set i = 0
    loop
        exitwhen ( i > 12 )
        set udg_TColoredName[i]=""
        set i = i + 1
    endloop

    set udg_Rune = null
    set udg_Timer = CreateTimer()
    set i = 0
    loop
        exitwhen ( i > 12 )
        set udg_TDeaths[i]=0
        set i = i + 1
    endloop

    set i = 0
    loop
        exitwhen ( i > 20 )
        set udg_THeroes_Check[i]=true
        set i = i + 1
    endloop

    set udg_R = 0
endfunction

Your TItemFake and TItemTrue variables are not recognized in any trigger because the editor did not initialize these global variables.
A solution would be: removing TItemFake and TItemTrue from your variable editor and recreate them with a different name such as ItemTrue and ItemFake, then redefine the variable and see if that works.

I'm gonna test it myself right now :)
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Lol I didn't even notice that, I should've checked all triggers...
Even though, after removing all the wait actions this problem still occurs.

And when I converted the FAKE trigger into custom text and used a syntax checker it told me that the trigger variable and the TItemTrue and TItemFalse variables are undeclared.

Still haven't found a solution but I'm gonna give my eyes some rest, I'll try to find out tomorrow... Way to tired.

EDIT: I think it got something to do with war3map.j but I'm not sure, check the script that I posted above.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Just advice, do all variable declaration in a single map init not with eventless triggers, since easier read ur system, than check 10-20 trigger where no event just run trigger this and that.
its just confuse thepeoples the so much trigger without sense

FIRST:
event is
  • Unit - A unit Sells an item (from shop)
and not unit aquired item, coz that included the pick etc, (buying unit also not declared if event is aquired item not selling item)

somebody can tell me what is the problem? coz i dont see problem

  • FAKE Copy
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Quest - Display to (All players) the Quest Update message: [|cffffcc00TRIGGER|...
      • For each (Integer A) from 1 to 27, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Sold Item)) Equal to TItemFake[(Integer A)]
            • Then - Actions
              • Quest - Display to (All players) the Quest Update message: [|cffffcc00TRIGGER|...
              • Item - Remove (Sold Item)
              • Hero - Create TItemTrue[(Integer A)] and give it to (Buying unit)
              • Skip remaining actions
            • Else - Actions
 

Attachments

  • 1.jpg
    1.jpg
    144.3 KB · Views: 84
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
It seems as if the global variable TItemTrue and TItemFake do not get recognized by the triggers.

I tryed creating them locally inside the FAKE trigger and then use the local variables as comparisons.

It seemed to have worked.

But in order to add extra recipe's you do need to add the raw code to the local integer array.

To see the raw code of a item, ability, unit etc press ctrl+D inside your object editor.

Then once you know the raw code of the item that you want to add and replace, simply go into FAKE trigger and add it to the set ItemTrue[number] and set ItemFalse[number].

Don't forget to increase the exitwhen i > number inside the loop.

http://www.hiveworkshop.com/forums/pastebin.php?id=9ywr1h

This is the trigger:
JASS:
function Trig_FAKE_Actions takes nothing returns nothing
    local integer i
    local integer array ItemFake
    local integer array ItemTrue
    set ItemFake[1] = 'I029'
    set ItemTrue[1] = 'I01O'
    set ItemFake[2] = 'I02A'
    set ItemTrue[2] = 'I01V'
    set ItemFake[3] = 'I02B'
    set ItemTrue[3] = 'I00T'
    set ItemFake[4] = 'I02C'
    set ItemTrue[4] = 'I01Q'
    set ItemFake[5] = 'I02D'
    set ItemTrue[5] = 'I01C'
    set ItemFake[6] = 'I02E'
    set ItemTrue[6] = 'I017'
    set ItemFake[7] = 'I02F'
    set ItemTrue[7] = 'I01X'
    set ItemFake[8] = 'I02G'
    set ItemTrue[8] = 'I00A'
    set ItemFake[9] = 'I02H'
    set ItemTrue[9] = 'I00H'
    set ItemFake[10] = 'I02I'
    set ItemTrue[10] = 'I01H'
    set ItemFake[11] = 'I02J'
    set ItemTrue[11] = 'I010'
    set ItemFake[12] = 'I02K'
    set ItemTrue[12] = 'I00W'
    set ItemFake[13] = 'I02L'
    set ItemTrue[13] = 'I028'
    set ItemFake[14] = 'I02M'
    set ItemTrue[14] = 'I026'
    set ItemFake[15] = 'I02N'
    set ItemTrue[15] = 'I007'
    set ItemFake[16] = 'I02O'
    set ItemTrue[16] = 'I024'
    set ItemFake[17] = 'I02P'
    set ItemTrue[17] = 'I00O'
    set ItemFake[18] = 'I02Q'
    set ItemTrue[18] = 'I019'
    set ItemFake[19] = 'I02R'
    set ItemTrue[19] = 'I015'
    set ItemFake[20] = 'I02S'
    set ItemTrue[20] = 'I012'
    set ItemFake[21] = 'I02T'
    set ItemTrue[21] = 'I01E'
    set ItemFake[22] = 'I02U'
    set ItemTrue[22] = 'I01L'
    set ItemFake[23] = 'I02V'
    set ItemTrue[23] = 'I00F'
    set ItemFake[24] = 'I02W'
    set ItemTrue[24] = 'I020'
    set ItemFake[25] = 'I02X'
    set ItemTrue[25] = 'I022'
    set ItemFake[26] = 'I02Y'
    set ItemTrue[26] = 'I01M'
    set ItemFake[27] = 'I02Z'
    set ItemTrue[27] = 'I00R'
    set i = 1
    call DisplayTextToPlayer(Player(1), 0, 0, "Acquired Item ID: " + I2S(GetItemTypeId(GetManipulatedItem())))
    loop
        exitwhen i > 27
        if ( GetItemTypeId(GetManipulatedItem()) == ItemFake[i] ) then
            call DisplayTextToPlayer(Player(1), 0, 0, "Confirmed Item ID: " + I2S(ItemFake[i]))
            call RemoveItem( GetManipulatedItem() )
            call DisplayTextToPlayer(Player(1), 0, 0, "Newly Created Item ID: " + I2S(ItemTrue[i]))
            call UnitAddItemById( GetTriggerUnit(), ItemTrue[i] )
            call DisplayTextToPlayer(Player(1), 0, 0, "Item succesfully switched!")
        endif
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_FAKE takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent( t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null )
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction( t, function Trig_FAKE_Actions )
    set t = null
endfunction

I know it's not an ideal solution, but it's something for now..

b.t.w. remove the VAR items trigger and the global variables called ItemTrue and ItemFalse in your variable editor. You don't need it anymore.
You can also remove the DisplayTextToForce if you want to remove the anoying messages in-game ;)

Check the map out first, you might like it -,^
Pick your hero, grab the item, see what happens...
If you buy any items that are not in the arrays they will not be switched ofcourse...
However the aqcuired item ID always gets displayed at this moment :p

EDIT: 444 posts ^.^

EDIT 2: if you want to do this in GUI for yourself, you can also keep the event on acquires an item and then change add item to triggering unit instead of buying unit, you can then use both shop and pick up...
Don't forget to put the condition back to manipulating item instead of sold item ;)
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
It seems as if the global variable TItemTrue and TItemFake do not get recognized by the triggers.

I tryed creating them locally inside the FAKE trigger and then use the local variables as comparisons.

It seemed to have worked.

But in order to add extra recipe's you do need to add the raw code to the local integer array.

To see the raw code of a item, ability, unit etc press ctrl+D inside your object editor.

Then once you know the raw code of the item that you want to add and replace, simply go into FAKE trigger and add it to the set ItemTrue[number] and set ItemFalse[number].

Don't forget to increase the exitwhen i > number inside the loop.

http://www.hiveworkshop.com/forums/pastebin.php?id=9ywr1h

This is the trigger:
JASS:
function Trig_FAKE_Actions takes nothing returns nothing
    local integer i
    local integer array ItemFake
    local integer array ItemTrue
    set ItemFake[1] = 'I029'
    set ItemTrue[1] = 'I01O'
    set ItemFake[2] = 'I02A'
    set ItemTrue[2] = 'I01V'
    set ItemFake[3] = 'I02B'
    set ItemTrue[3] = 'I00T'
    set ItemFake[4] = 'I02C'
    set ItemTrue[4] = 'I01Q'
    set ItemFake[5] = 'I02D'
    set ItemTrue[5] = 'I01C'
    set ItemFake[6] = 'I02E'
    set ItemTrue[6] = 'I017'
    set ItemFake[7] = 'I02F'
    set ItemTrue[7] = 'I01X'
    set ItemFake[8] = 'I02G'
    set ItemTrue[8] = 'I00A'
    set ItemFake[9] = 'I02H'
    set ItemTrue[9] = 'I00H'
    set ItemFake[10] = 'I02I'
    set ItemTrue[10] = 'I01H'
    set ItemFake[11] = 'I02J'
    set ItemTrue[11] = 'I010'
    set ItemFake[12] = 'I02K'
    set ItemTrue[12] = 'I00W'
    set ItemFake[13] = 'I02L'
    set ItemTrue[13] = 'I028'
    set ItemFake[14] = 'I02M'
    set ItemTrue[14] = 'I026'
    set ItemFake[15] = 'I02N'
    set ItemTrue[15] = 'I007'
    set ItemFake[16] = 'I02O'
    set ItemTrue[16] = 'I024'
    set ItemFake[17] = 'I02P'
    set ItemTrue[17] = 'I00O'
    set ItemFake[18] = 'I02Q'
    set ItemTrue[18] = 'I019'
    set ItemFake[19] = 'I02R'
    set ItemTrue[19] = 'I015'
    set ItemFake[20] = 'I02S'
    set ItemTrue[20] = 'I012'
    set ItemFake[21] = 'I02T'
    set ItemTrue[21] = 'I01E'
    set ItemFake[22] = 'I02U'
    set ItemTrue[22] = 'I01L'
    set ItemFake[23] = 'I02V'
    set ItemTrue[23] = 'I00F'
    set ItemFake[24] = 'I02W'
    set ItemTrue[24] = 'I020'
    set ItemFake[25] = 'I02X'
    set ItemTrue[25] = 'I022'
    set ItemFake[26] = 'I02Y'
    set ItemTrue[26] = 'I01M'
    set ItemFake[27] = 'I02Z'
    set ItemTrue[27] = 'I00R'
    set i = 1
    call DisplayTextToPlayer(Player(1), 0, 0, "Acquired Item ID: " + I2S(GetItemTypeId(GetManipulatedItem())))
    loop
        exitwhen i > 27
        if ( GetItemTypeId(GetManipulatedItem()) == ItemFake[i] ) then
            call DisplayTextToPlayer(Player(1), 0, 0, "Confirmed Item ID: " + I2S(ItemFake[i]))
            call RemoveItem( GetManipulatedItem() )
            call DisplayTextToPlayer(Player(1), 0, 0, "Newly Created Item ID: " + I2S(ItemTrue[i]))
            call UnitAddItemById( GetTriggerUnit(), ItemTrue[i] )
            call DisplayTextToPlayer(Player(1), 0, 0, "Item succesfully switched!")
        endif
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_FAKE takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent( t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null )
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction( t, function Trig_FAKE_Actions )
    set t = null
endfunction

I know it's not an ideal solution, but it's something for now..

b.t.w. remove the VAR items trigger and the global variables called ItemTrue and ItemFalse in your variable editor. You don't need it anymore.
You can also remove the DisplayTextToForce if you want to remove the anoying messages in-game ;)

Check the map out first, you might like it -,^
Pick your hero, grab the item, see what happens...
If you buy any items that are not in the arrays they will not be switched ofcourse...
However the aqcuired item ID always gets displayed at this moment :p

EDIT: 444 posts ^.^

but why? simple just add event to item setting trigger, like map init and work flawless
also with change event and item type u can see the result in screenshot what i posted before :D
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
but why? simple just add event to item setting trigger, like map init and work flawless
also with change event and item type u can see the result in screenshot what i posted before :D

Nevermind I realised afterwards it was really simple because it had to do with the event, item being manipulated and triggering unit instead of buying unit >.>

At first I thought the TItemTrue and TItemFalse returned incorrect values since when syntax checking them they where undeclared,
I thought it had something to do with the globals not being initialized in war3map.j. That's why I used the displaytexttoforce to return the values.

It seemed to all have worked, so udg_TItemTrue and udg_TItemFalse can also be used instead of local variable inside my trigger trigger...

Then the local variables can be removed from the trigger and the global ones can be declared and used again. So can the text messages be removed.

Thanks a lot.

@shadow
I've chacked. But here it still not worked. :/ Hmmm... I have some problems with editor...

Have you tested my map yet?

Link: http://www.hiveworkshop.com/forums/pastebin.php?id=9ywr1h
Click it and download the map...
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
i tell the reason why dont work :D

i dont saved the map before uploaded :D
(anyway add event map init to varitem trigger)

(even that if u make trigger like i made + add map init event to trigger then work it without downloading the map too but i hope now it was saved well :D)
 

Attachments

  • CtF v1.12 (1).w3x
    718.2 KB · Views: 41
Level 14
Joined
Apr 20, 2009
Messages
1,543
I'll just post this here for shadowvzs if he's interested:
JASS:
function Trig_FAKE_Actions takes nothing returns nothing
    local integer i
    set i = 1
    //Remove the // before call DisplayTextToPlayer for testing purposes...
    //call DisplayTextToPlayer(Player(1), 0, 0, "Acquired Item ID: " + I2S(GetItemTypeId(GetManipulatedItem())))
    loop
    
        exitwhen i > udg_MaxArraySize
        if ( GetItemTypeId(GetManipulatedItem()) == udg_TItemFake[i-1] ) then
            //call DisplayTextToPlayer(Player(1), 0, 0, "Confirmed Item ID: " + I2S(udg_TItemFake[i-1]))
            call RemoveItem( GetManipulatedItem() )
            //call DisplayTextToPlayer(Player(1), 0, 0, "Newly Created Item ID: " + I2S(udg_TItemTrue[i-1]))
            call UnitAddItemById( GetTriggerUnit(), udg_TItemTrue[i-1] )
            //call DisplayTextToPlayer(Player(1), 0, 0, "Item succesfully switched!")
        endif
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_FAKE takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent( t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null )
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction( t, function Trig_FAKE_Actions )
    set t = null
endfunction

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Quest - Create a Required quest titled Commands with the description List of avaible com..., using icon path ReplaceableTextures\CommandButtons\BTNBansheeMaster.blp
      • Quest - Create a Required quest titled Support with the description If you have any ide..., using icon path ReplaceableTextures\CommandButtons\BTNScroll.blp
      • Quest - Create a Optional quest titled Credits with the description Graphic and models:..., using icon path ReplaceableTextures\CommandButtons\BTNSelectHeroOn.blp
      • -------- Variables --------
      • Set TItemFake[1] = Recipe: Amored Boots
      • Set TItemTrue[1] = Amored Boots - recipe
      • Set TItemFake[2] = Recipe: BloodStone
      • Set TItemTrue[2] = BloodStone - recipe
      • Set TItemFake[3] = Recipe: Bone Crusher
      • Set TItemTrue[3] = Bone Crusher - recipe
      • Set TItemFake[4] = Recipe: Bracer
      • Set TItemTrue[4] = Bracer - recipe
      • Set TItemFake[5] = Recipe: Brain Cage
      • Set TItemTrue[5] = Brain Cage - recipe
      • Set TItemFake[6] = Recipe: Charged Arrows
      • Set TItemTrue[6] = Charged Arrows - recipe
      • Set TItemFake[7] = Recipe: Claws of Terror
      • Set TItemTrue[7] = Claws of Terror - recipe
      • Set TItemFake[8] = Recipe: Cold Arrows
      • Set TItemTrue[8] = Cold Arrows - recipe
      • Set TItemFake[9] = Recipe: Dark Arrows
      • Set TItemTrue[9] = Dark Arrows - recipe
      • Set TItemFake[10] = Recipe: Demon Blade
      • Set TItemTrue[10] = Demon Blade - recipe
      • Set TItemFake[11] = Recipe: Demon Boots
      • Set TItemTrue[11] = Demon Boots - recipe
      • Set TItemFake[12] = Recipe: Gladius
      • Set TItemTrue[12] = Gladius - recipe
      • Set TItemFake[13] = Recipe: Hellfire Claws
      • Set TItemTrue[13] = Hellfire Claws - recipe
      • Set TItemFake[14] = Recipe: Holy Shield
      • Set TItemTrue[14] = Holy Shield - recipe
      • Set TItemFake[15] = Recipe: Iron Hammer
      • Set TItemTrue[15] = Iron Hammer - recipe
      • Set TItemFake[16] = Recipe: Iron Shield
      • Set TItemTrue[16] = Iron Shield - recipe
      • Set TItemFake[17] = Recipe: Perseverence
      • Set TItemTrue[17] = Perseverence - recipe
      • Set TItemFake[18] = Recipe: Plate Boots
      • Set TItemTrue[18] = Plate Boots - recipe
      • Set TItemFake[19] = Recipe: Powered Amulet
      • Set TItemTrue[19] = Powered Amulet - recipe
      • Set TItemFake[20] = Recipe: Quiet Runners
      • Set TItemTrue[20] = Quiet Runners - recipe
      • Set TItemFake[21] = Recipe: Royal Helmet
      • Set TItemTrue[21] = Royal Helmet - recipe
      • Set TItemFake[22] = Recipe: Soul Booster
      • Set TItemTrue[22] = Soul Booster - recipe
      • Set TItemFake[23] = Recipe: Storm Hammer
      • Set TItemTrue[23] = Storm Hammer - recipe
      • Set TItemFake[24] = Recipe: Unholy Shield
      • Set TItemTrue[24] = Unholy Shield - recipe
      • Set TItemFake[25] = Recipe: Vanguard
      • Set TItemTrue[25] = Vanguard - recipe
      • Set TItemFake[26] = Recipe: War Drums
      • Set TItemTrue[26] = War Drums - recipe
      • Set TItemFake[27] = Recipe: Winter Staff
      • Set TItemTrue[27] = Winter Staff - recipe
      • Set MaxArraySize = 27
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
            • Then - Actions
              • Set Host = (Player((Integer A)))
              • Skip remaining actions
            • Else - Actions
      • Set Rune = Rune of Mana 0070 <gen>


Now it is fully GUI compatible. In your Initialization trigger you can add new Items to the array. All you have to do is set MaxArraySize to the maximum index of your array...

Also: this is more optimized then using your GUI trigger to swap the items.

And PLEASE remove the wait 0.01 actions I don't get it :S Why call so many functions just to wait for 0.01 seconds (it takes up speed for something so fast the human eye won't even notice)

Download:
 

Attachments

  • CtF v1.12.w3x
    721 KB · Views: 86
Last edited:
Status
Not open for further replies.
Top