| 07-16-2008, 10:37 PM | #1 |
Well, I thought I would not need help for this, but apparantly I do. I can use the recipes or fusion or whatever you want to call it, but, the main problem is this- When a recipe has 2 or more items of the same type it will only use one item. I will use 2 examples- Recipe- Boomstick- Requires 2 shotguns and a Boomstick recipe. However you only need 1 shotgun and a recipe. I also want to make a trigger where for certian items, if you buy another so you have 2 the items will fuse into a different one (E.g. you have a mark of intelligence, and you buy another, they fuse and you get a mark of genius). My basic trigger is like this |
| 07-16-2008, 11:43 PM | #2 |
um im not exactly sure what you need help with but i think if you can just create the same item but different name like name: shotgun alpha shotgun beta and so forth to make the item and then the game might not mistake the trigger for taking 1 item instead of two or just add a "wait" action between the two removals |
| 07-17-2008, 04:57 AM | #3 |
I had this problem before. I had a hope that I fixed it, and I did, except it caused an infinite loop that crashed my game. So instead, I use different items completely. What I would do however is if you're REALLY desperate, make it so the recipe will only combine (or trigger) whenever the recipe is picked up. Then, you can remove one shotgun, check if he has another, remove it if so and then give the output. If not, then give it back (which creates the infinite loop, however with just the recipe item it's okay). |
| 07-17-2008, 06:30 AM | #4 |
I am very sorry but I'm multitasking so I can't get a 100% whole answer. http://www.wc3campaigns.net/showthread.php?t=98324 I made a tutorial on this topic, especially made for GUI. |
| 07-17-2008, 07:17 AM | #5 |
Here's the item system I made for my map (a simplified version, it used to have support for engineering upgrade abilities and class items, plus functions for AI). Its in jass, just create a script, convert it to custom text and paste this text. If you don't use vJass you will need to remove the globals..endglobals block and insert every variable into Variables dialog, then replace variable names in the script to udg_<variablename>. Then remove the library/endlibrary lines and rename InitItems function to InitTrig_<triggername>. JASS:library libItems initializer InitItems globals private integer array combo_id private integer array comp_1 private integer array comp_2 private integer array comp_3 private integer array comp_4 private integer array comp_5 private integer array comp_6 private integer num_recipes = 0 endglobals function AddRecipe takes integer combo, integer c1, integer c2, integer c3, integer c4, integer c5, integer c6 returns nothing set combo_id[num_recipes] = combo set comp_1[num_recipes] = c1 set comp_2[num_recipes] = c2 set comp_3[num_recipes] = c3 set comp_4[num_recipes] = c4 set comp_5[num_recipes] = c5 set comp_6[num_recipes] = c6 set num_recipes = num_recipes + 1 endfunction function OnGetItem takes nothing returns nothing local unit u = GetManipulatingUnit () local item it = GetManipulatedItem () local integer iid = GetItemTypeId (it) local integer i = 0 local integer j local integer k local integer array req local boolean array rem loop exitwhen i >= num_recipes set req[0] = comp_1[i] set req[1] = comp_2[i] set req[2] = comp_3[i] set req[3] = comp_4[i] set req[4] = comp_5[i] set req[5] = comp_6[i] set j = 0 loop exitwhen j > 5 set it = UnitItemInSlot (u, j) set rem[j] = false if it != null then set iid = GetItemTypeId (it) set k = 0 loop exitwhen k > 5 if iid == req[k] then set req[k] = 0 set rem[j] = true set k = 6 endif set k = k + 1 endloop endif set j = j + 1 endloop if (req[0] == 0) and (req[1] == 0) and (req[2] == 0) and (req[3] == 0) and (req[4] == 0) and (req[5] == 0) then set j = 0 loop exitwhen j > 5 if rem[j] then set it = UnitRemoveItemFromSlot (u, j) call RemoveItem (it) endif set j = j + 1 endloop call UnitAddItemById (u, combo_id[i]) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl", u, "origin")) set i = num_recipes endif set i = i + 1 endloop set u = null set it = null endfunction private function InitItems takes nothing returns nothing local trigger trg = CreateTrigger () call TriggerRegisterAnyUnitEventBJ (trg, EVENT_PLAYER_UNIT_PICKUP_ITEM) call TriggerAddAction (trg, function OnGetItem) set trg = null // Add your recipes here. First ID is the result, then up to 6 components. call AddRecipe ('I009', 'I00B', 'I007', 'I008', 0, 0, 0) // etc etc etc endfunction endlibrary |
| 07-17-2008, 07:54 AM | #6 |
I don't think he uses Jass at the moment :P Trigger: All Counter does is count the number of Shotguns and it just has to be 2 or greater. To my knowledge, this trigger should work just fine - though it will only fire when the recipe item is acquired. |
| 07-17-2008, 01:39 PM | #7 | |
Quote:
By the way, you forgot to set your counter to 0 at the start of your trigger. |
| 07-17-2008, 02:14 PM | #8 |
umm what counter? the global variable? its initialized when it is declared. the local variables in the combining functions? only i is initialized because all others are initialized inside loops. |
| 07-24-2008, 06:39 AM | #9 |
Thanks for the triggers guys. And for the record, I can read about 40% of JAss, but i cant really code it. I can usually manipulate it though. Im using the jass one. It works great. |
