| 01-23-2009, 01:48 AM | #1 |
hi guys, i have a very big problem using Toadcops BX-TRSII Inventory System would be very nice if someone know this system and could help me please if there is someone who dont know the system but wanna set what it is and how it works here is the link to the system: http://www.wc3campaigns.net/showthread.php?t=91163 so here are the facts: I imported the Inventory system to my map and everything worked fine but there are some reasons i have to change the system 1. i need a diffrent style of the system but this was no problem and now i have the style i want (works fine) 2. i need a save/load system to save the equipped items in the TRSII (but this is not my problem at the moment i will go for the save/load a little later) 3. (and this is my problem at the moment) i need some items (like mana or heal potions, questitems, scrolls and so on)that could be picked up by the user and go into the normal 6 slot hero inventory of wc3 (for better and faster use in fight ofc) so i searched the forums and found a very nice code that check the itemsclass wich go into the TRSII via a boolean ok so i put the code into my map and i couldnt trust my eyes it worked the items go were i want them to go (so the normal equipment items go into the TRSII Inventory and the usable items go into the normal inventory i was very happy to see this and tryed to use an item in my normal inventory and kaboom "wc3 crit error" i tryed again and again ... i can equip the items in the TRSII and they work fine... so TRSII works very well but only if i use an item in the normal 6 slot inventory of warcraft it will crash so here are all the changes i made at the main code of TRSII: so i changed the gridcreate function in TRSInv to get my own style if the inventory TRSInv JASS:function CreateGridExec takes nothing returns nothing local real x=TRSGridX() local real y=TRSGridY() local integer i=eax local real xstep=TRSXstep() set InvPlayerX[i]=x+(i*xstep) set InvPlayerY[i]=y+2 call CreateGridBR(i,null,x+(i*xstep),y,6,7,0,"inv","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVINVSlotIcon(),-15.5,8.90,TRSInvSetup_IconSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Right Side call CreateGridBR(i,"right",x+(i*xstep),y,1,1,1,"helm","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVHelmSlotIcon(),-18.4,8.55,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Helm call CreateGridBR(i,"right",x+(i*xstep),y,1,1,2,"shoulder","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVShoulderLeftSlotIcon(),-18.4,5.883,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Shoulder //call CreateGridBR(i,"right",x+(i*xstep),y,1,1,3,"weapon","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVWeaponSlotIcon(),-18.4,3.216,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),Condition(function INVCustomReqWeaponSlot)) // Weapon call CreateGridBR(i,"right",x+(i*xstep),y,1,1,3,"armor","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVArmorSlotIcon(),-18.4,3.216,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Armor call CreateGridBR(i,"right",x+(i*xstep),y,1,1,4,"belt","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVBeltSlotIcon(),-18.4,0.549,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Belt call CreateGridBR(i,"right",x+(i*xstep),y,1,1,5,"pants","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVPantsSlotIcon(),-18.4,-2.118,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Pants // Ring call CreateGridBR(i,"right",x+(i*xstep),y,1,1,6,"ring","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVRingRightSlotIcon(),-18.4,-4.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Ring call CreateGridBR(i,"right",x+(i*xstep),y,1,1,7,"ring","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVRingRightSlotIcon(),-15.7,-4.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Ring // Left Side call CreateGridBR(i,"left",x+(i*xstep),y,1,1,8,"amulet","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVAmuletSlotIcon(),-4.75,8.55,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Amulet call CreateGridBR(i,"left",x+(i*xstep),y,1,1,9,"shoulder","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVShoulderRightSlotIcon(),-4.75,5.883,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Shoulder //call CreateGridBR(i,"left",x+(i*xstep),y,1,1,10,"shield","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVShieldSlotIcon(),-4.75,3.216,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),Condition(function INVCustomReqWeaponSlot)) // Shield call CreateGridBR(i,"left",x+(i*xstep),y,1,1,10,"gloves","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVGlovesSlotIcon(),-4.75,3.216,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Gloves call CreateGridBR(i,"left",x+(i*xstep),y,1,1,11,"bracers","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVBracersSlotIcon(),-4.75,0.549,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Bracers call CreateGridBR(i,"left",x+(i*xstep),y,1,1,12,"boots","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVBootsSlotIcon(),-4.75,-2.118,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Boots // Ring call CreateGridBR(i,"left",x+(i*xstep),y,1,1,13,"ring","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVRingLeftSlotIcon(),-4.75,-4.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Ring call CreateGridBR(i,"left",x+(i*xstep),y,1,1,14,"ring","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVRingLeftSlotIcon(),-7.455,-4.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Ring set InvMinChargedSlot[i]=17 set InvMaxChargedSlot[i]=18 // Charms call CreateGridBR(i,"UseSlot1",x+(i*xstep),y,1,1,17,"charged","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVCharged2SlotIcon(),-7.455,-6.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Charged call CreateGridBR(i,"UseSlot2",x+(i*xstep),y,1,1,18,"charged","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVCharged1SlotIcon(),-15.7,-6.785,TRSInvSetup_IconEquipmentSizeAspect(),0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Charged //Weapons call CreateGridBR(i,"right",x+(i*xstep),y,1,1,15,"weapon","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVWeaponSlotIcon(),-13.355,-5,TRSInvSetup_IconEquipmentSizeAspect()+0.05,0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),Condition(function INVCustomReqWeaponSlot)) // Weapon call CreateGridBR(i,"left",x+(i*xstep),y,1,1,16,"shield","TRS\\TRSINVtrkEx.mdx",TRSInvSetup_INVShieldSlotIcon(),-10.36,-5,TRSInvSetup_IconEquipmentSizeAspect()+0.05,0,0,function Track,function Hit,Condition(function TRSTrue),Condition(function TRSTrue),Condition(function INVCustomReqWeaponSlot)) // Shield // Merchant call CreateGridBR(i,null,x+(i*xstep),y,8,4,0,"merchant","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVINVSlotIcon(),0.5,0.5,TRSInvSetup_IconSizeAspect(),0,0,function TrackMerch,function HitMerch,Condition(function TRSTrue),Condition(function TRSTrue),null) // Background call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"background","TRS\\TRSINVtrkBack.mdx",0,0,0,0,0,0,function Track,function Track,Condition(function TRSTrue),Condition(function TRSTrue),null) // command buttons // call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"pagedown","TRS\\TRSINVtrk0x1.mdx",TRSInvSetup_PageListDownDis(),-5.5,-9.8,TRSInvSetup_PageListSize(),0,0,function Track,function INVPageDown,Condition(function TRSTrue),Condition(function TRSTrue),null) // Page Down // call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"pageup","TRS\\TRSINVtrk0x1.mdx",TRSInvSetup_PageListUpDis(),-5.5,10.6,TRSInvSetup_PageListSize(),0,0,function Track,function INVPageUp,Condition(function TRSTrue),Condition(function TRSTrue),null) // Page Up // call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"pagedownmerch","TRS\\TRSINVtrk0x1.mdx",TRSInvSetup_PageListDownDis(),15.73,-3.95,TRSInvSetup_PageListSize(),0,0,function Track,function INVPageDownMerch,Condition(function TRSInvIsByMerchant),Condition(function TRSInvIsByMerchant),null) // Page Down merchant // call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"pageupmerch","TRS\\TRSINVtrk0x1.mdx",TRSInvSetup_PageListUpDis(),15.73,6.95,TRSInvSetup_PageListSize(),0,0,function Track,function INVPageUpMerch,Condition(function TRSInvIsByMerchant),Condition(function TRSInvIsByMerchant),null) // Page Up merchant call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"sellitem","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVSellItem(),-1.25,-1.25,TRSInvSetup_INVSellItemButtonSize(),0,0,function Track,function MerchantSellItemBR,Condition(function TRSInvIsByMerchant),Condition(function TRSInvIsByMerchant),null) // Exit call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"buyitem","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVBuyItem(),-1.25,-3.5,TRSInvSetup_INVBuyItemButtonSize(),0,0,function Track,function MerchantBuyItemBR,Condition(function TRSInvIsByMerchant),Condition(function TRSInvIsByMerchant),null) // Exit call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"exit","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVCancelButton(),-6.5,-8.0,TRSInvSetup_INVCancelButtonSize(),0,0,function Track,function INVButtonExit,Condition(function TRSTrue),Condition(function TRSTrue),null) // Exit call CreateGridBR(i,null,x+(i*xstep),y,1,1,0,"drop","TRS\\TRSINVtrk.mdx",TRSInvSetup_INVDropButton(),-4,-8.0,TRSInvSetup_INVDropButtonSize(),0,0,function Track,function INVDropItem,Condition(function TRSTrue),Condition(function TRSTrue),null) // Drop Item call StoreInteger(TRSInv,"PlayerInv"+I2S(i),"Size",42) call StoreInteger(TRSInv,"PlayerInv"+I2S(i),"MerchantSize",32) call StoreInteger(TRSInv,"PlayerInv"+I2S(i),"ExtraSlots",16) endfunction then i added the boolean in the EquipItem code EquipItem JASS:function EquipItemCondition takes nothing returns boolean return not ebx32 endfunction function EquipItemAct takes nothing returns nothing local boolean equiped=false local boolean ex=GetUnitAbilityLevel(GetManipulatingUnit(),TRSExInvId())>0 if (GetItemType(GetManipulatedItem()) == ITEM_TYPE_CAMPAIGN) then call TRSGetInvBR(GetManipulatingUnit()) if GetItemUserData(GetManipulatedItem())==0 then call SetItemUserData(GetManipulatedItem(),GetCustomItemID()) endif call PreGenerateParBR(I2S(GetItemTypeId(GetManipulatedItem())),I2S(GetItemUserData(GetManipulatedItem()))) if GetStoredString(TRSItems,I2S(GetItemTypeId(GetManipulatedItem())),"type")=="charm" and ex then call EquipItemBR(GetManipulatingUnit(),I2S(GetItemTypeId(GetManipulatedItem())),I2S(GetItemUserData(GetManipulatedItem())),true) endif if not ex then set equiped=AddItemToCusInvBR(GetManipulatingUnit(),I2S(GetItemUserData(GetManipulatedItem()))) if equiped==false then call UnitRemoveItem(GetManipulatingUnit(),GetManipulatedItem()) else call RemoveItem(GetManipulatedItem()) endif endif endif endfunction //=========================================================================== function InitTrig_EquipItem takes nothing returns nothing set gg_trg_EquipItem = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_EquipItem,EVENT_PLAYER_UNIT_PICKUP_ITEM) call TriggerAddAction(gg_trg_EquipItem,function EquipItemAct) call TriggerAddCondition(gg_trg_EquipItem,Condition(function EquipItemCondition)) endfunction and the opposite in the UnequipItem code UnequipItem JASS:function UnequipItemAct takes nothing returns nothing if (GetItemType(GetManipulatedItem()) != ITEM_TYPE_CAMPAIGN) then return endif if GetUnitAbilityLevel(GetTriggerUnit(),TRSExInvId())>0 then call UnequipItemBR(GetTriggerUnit(),I2S(GetItemTypeId(GetManipulatedItem())),I2S(GetItemUserData(GetManipulatedItem())),true) endif endfunction //=========================================================================== function InitTrig_UnequipItem takes nothing returns nothing set gg_trg_UnequipItem = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_UnequipItem,EVENT_PLAYER_UNIT_DROP_ITEM) call TriggerAddAction(gg_trg_UnequipItem,function UnequipItemAct) endfunction i didnt changed anything else at the core or something so these are all changes so far but it must be a reason of the Equip and Unequip code that i added because i tryed to change only the Equip and Unequip code in the DemoMap of TRSII and it also crashes... so ... is there anybody out there who could help me ? ofc i will give Rep for this ! xD Thanks & regards Schyy |
| 01-23-2009, 02:47 AM | #2 | |
If you could post the part of the code which detects when an Item is used, or post the map (or a map with just the modified code) so I can go through the entire script, that would help greatly. Quote:
|
| 01-23-2009, 04:23 AM | #3 | |
first of all ... i thank you for ur reply i attached the map with the changed script and marked it with a comment i hope u will see it ^^ Quote:
oh ... i didnt know this because iam new to this forum but i thank u for this nice information and will try to help were ever i can to get some rep to +rep u ^^ regards |
| 01-23-2009, 05:22 AM | #4 |
I found where it is occurring and why it is occurring. The solution seems deeper than the function though, so I can't do anything to help you solve it, only tell you where it is (partly because I have never tried to learn BX-TRSII and don't really want to). JASS:function ShowItemStatsActions takes nothing returns nothing local string it= I2S(GetItemUserData(GetManipulatedItem())) local string id= GetStoredString(TRSItems,it,"ID") local unit u= GetManipulatingUnit() local string inv= TRSGetInvBR(u) local string ittype= GetStoredString(TRSItems,id,"type") local boolean used= UseItemBR(u,id,it) if used==false then if GetStoredInteger(TRSItems,id,"stack")>0 then call SetItemCharges(GetManipulatedItem(),GetItemCharges(GetManipulatedItem())+1) endif endif if GetUnitAbilityLevel(u,TRSExInvId())>0 then call ShowItemStatsBR(u,it,id) endif if GetItemCharges(GetManipulatedItem())<1 and ittype=="charged" and GetStoredInteger(TRSItems,id,"stack")>0 then //##################### call UnequipItemBR(u,id,it,true) call StoreInteger(TRSInv,inv,"ItemsOfType"+ittype,GetStoredInteger(TRSInv,inv,"ItemsOfType"+ittype)-1) call StoreString(TRSInv,inv,"SlotEx"+I2S(GetStoredInteger(TRSItems,it,"SourceSlot")),"") call StoreString(TRSInv,inv,"SlotEx"+I2S(GetStoredInteger(TRSItems,it,"SourceSlot")),"") call CleanItemParBR(it,true) call FreeCustomItemID(S2I(it)) call RemoveItem(GetManipulatedItem()) endif endfunction The problem is that the string it is set to 0 and then when it tries to get the string id it doesn't exist in the gamecache and then it returns null. So, it == 0 and id == (null) This is where the problem comes in. Apparently trying to use a null string as any of the keys for the gamecache natives causes a crash (who knew?). So, when you call any function that uses id, it crashes. So, the problem is the item does not have its ItemUserData set, therefore it is not producing a valid string and thus crashing the game. The solution would be to make sure the items always have a ItemUserData set which corresponds to an item, or make a fail-safe in the function above, to make sure id is not null. |
| 01-23-2009, 06:23 AM | #5 |
hmmm ... seems difficult ^^ ... so ... correct me if i am wrong if i use an item in the 6 slot inv the TRS system trys to find this item in gamecache and crashes because it cant be found. it searches the item in gamecache because it think its an item in the charged slot of the TRS Inv wich are normaly directly set to the 6 slot inv so my question to you how could i deactivate the request ? because i dont need the charged slots in the TRS and then i dont need the function wich checks the gamecache if i use an item in the 6 slot inventory EDIT: There are 2 premade items too wich can be used in the 6 slot inv (inventory control 1 and control 2) but i cant find the rawcodes in the script -.- |
| 01-23-2009, 06:38 AM | #6 |
Well the problem is the item is not registered to the system via its ItemUserData value (which appears to be how the system works). If you want, you can comment out the TriggerRegister... and the TriggerAddAction... functions from the init function at the bottom the trigger where the script is located and see if it has any other side-effects. I'm not sure if this function does anything other than show the items stats (as the name implies). Now, like I said before, I don't know or care how the entire system works, I just debugged it for you by looking at events and finding the functions that ran under such events and commented them out till I found the culprit. I personally don't like the method of using gamecache like this and I find it hard to read and follow, so sorry I can't be of any further assistance. |
| 01-23-2009, 06:48 AM | #7 |
ok thank ya very much for your help and your time... ill try everything i can to get this works fine :) |
| 01-23-2009, 12:02 PM | #8 | ||
yes gamecache cause crashes... if you read from not existing mission. and the main problem is what item doesnt intilize properly. you can do ofc do some checks to avoid this. Quote:
Quote:
well for wc3 purporses it's "too much". and in first place i made this system for me not anyone else. cause everyone else use to limited stuff anyway. and try to match stuff to war3. i do it otherwise. and i do this cause it would be too boring otherwise. this all damage detection etc. is a whole joke in real. |
| 01-23-2009, 02:25 PM | #9 | |
Quote:
I agree it is one of the few uses that gamecache can be justified, but trying to read through all the gamecache calls hurts the eyes and brain. For you, I know it's second nature to understand it all (since you wrote the bloody thing), but for me to try and understand what is going on, would take a lot longer. |
| 01-23-2009, 03:57 PM | #10 |
Ammorth ofc. i know it's written messy etc. and not easy to understand. But i never told this though ^_^ well btw the problem is solved author (Schyy) contacted me. + you was right about the source of error. it's easy fixable in the trigger. |
