| 10-28-2004, 11:39 PM | #1 |
In my item system, i want the items to be locked to certain spots depending on thier classes, but my triggers lags my game up like crazy and i just found out. i have it running every .2 seconds, and there isnt anything in it that looks like it should leak anything.. i guess i may just be using slow functions.. Code:
Position lock Weapons Events Time - Every 0.02 seconds of game time Conditions Actions Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Item-class of (Item carried by (Picked unit) in slot 3)) Not equal to Permanent (Item-class of (Item carried by (Picked unit) in slot 3)) Not equal to Charged (Item-class of (Item carried by (Picked unit) in slot 3)) Not equal to Powerup (Item-class of (Item carried by (Picked unit) in slot 3)) Not equal to Artifact (Item-class of (Item carried by (Picked unit) in slot 3)) Not equal to Purchasable Then - Actions For each (Integer A) from 1 to 6, do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions Or - Any (Conditions) are true Conditions (Item-class of (Item carried by (Picked unit) in slot (Integer A))) Equal to Permanent (Item-class of (Item carried by (Picked unit) in slot (Integer A))) Equal to Charged (Item-class of (Item carried by (Picked unit) in slot (Integer A))) Equal to Powerup (Item-class of (Item carried by (Picked unit) in slot (Integer A))) Equal to Artifact (Item-class of (Item carried by (Picked unit) in slot (Integer A))) Equal to Purchasable Then - Actions Unit - Order (Picked unit) to drop (Item carried by (Picked unit) in slot (Integer A)) in 3 Else - Actions Else - Actions edit: ok, i made it a lot better, theres really only at max 10 units i need to check through, so i just added them to a unit group. so now i dont have to call any function to make sure its a hero, or check unnecesary heroes.. etc. less lag. YAY!! :) |
| 10-28-2004, 11:57 PM | #2 |
Guest | I think one reason it's so harsh is it's every 0.02 seconds! Just think about it, computers are fast, but every second this goes off 50 times! And for how many players? If it were 10 players, thats 500 times each second! Why does it need to be so fast? Maybe you can get by with a 0.5 or something, I don't see why you have to drop the item THE INSTANT they put it in the wrong spot or whatever you are doing there. |
| 10-28-2004, 11:59 PM | #3 |
well i mean, i could make it a little slower if i wanted to.. but i mean right now its perfect looking. you cant even get the item into another slot. i guess ill experiment to see how slow i can get it. |
| 10-29-2004, 12:14 AM | #4 |
Guest | Yeah, I mean, it's like "why use 0.01 when you can use 0.02" it's not like anyones gonna notice. ^_^ |
| 10-29-2004, 07:55 AM | #5 |
The problem with your original trigger was that every second, you leaked 300 unit-groups. 50 times per second, you used "pick every unit in unit group" six times. Now that you set all heroes to a preexisting variable, you always use the same unit group, so you don't have a leak. |
| 10-29-2004, 09:04 AM | #6 |
Why couldn't you just use a trigger that fires everytime a hero adds an item to an inventory or when they try to move one. that way you would only have to check the positions when the players actually are handling the items. This would be much more efficient. You wouldn't be calling the trigger 500 times a second then. only when it was needed. |
| 10-29-2004, 12:59 PM | #7 |
I guess i could... but im too lazy to figure out the move item order id numbers. but your right anitarf.. i fogot that unit groups also leak. wow.. that was really bad.. but i guess this comes to show that memory leaks are like the only cause of lag. |
| 10-30-2004, 08:03 PM | #8 |
I have such a trigger running for my backpack's inventory page its really easy. |
| 10-30-2004, 10:24 PM | #9 |
lol, i've actualy been trying to figure out your system just for my knowledge, and i got to the part that uses the order id's. and im stumped. i guess, ill just figure them out myself. but is GetIssuedOrderItem() like the item that the other item is supposed be swapped with? edit: ok i got it, move to slot: 1 - 852002 2 - 852003 3 - 852004 4 - 852005 5 - 852006 6 - 852007 edit2: oh, GetIssuedOrderItem is your own function.. |
| 10-31-2004, 01:38 AM | #10 |
O.K. I got it to work like a billion times more efficiently, but the problem is you see the item move. I have to put in a short wait so that the unit has time to actually has time to carry out the order. but it is waiting, im guessing, .25 seconds.. the minimum wait time. i guess its not that bad.. but heres the trigger: Code:
function Trig_Position_lock_Weapons_Copy_Conditions takes nothing returns boolean return GetIssuedOrderId() == 852002 or GetIssuedOrderId() == 852003 or GetIssuedOrderId() == 852005 or GetIssuedOrderId() == 852006 or GetIssuedOrderId() == 852007 endfunction function Trig_Position_lock_Weapons_Copy_Func002C takes nothing returns boolean return GetItemType(GetIssuedOrderItem()) == ITEM_TYPE_PERMANENT or GetItemType(GetIssuedOrderItem()) == ITEM_TYPE_CHARGED or GetItemType(GetIssuedOrderItem()) == ITEM_TYPE_POWERUP or GetItemType(GetIssuedOrderItem()) == ITEM_TYPE_ARTIFACT or GetItemType(GetIssuedOrderItem()) == ITEM_TYPE_PURCHASABLE endfunction function Trig_Position_lock_Weapons_Copy_Actions takes nothing returns nothing call PolledWait(.01) if ( Trig_Position_lock_Weapons_Copy_Func002C() ) then call DisplayTextToPlayer(GetOwningPlayer(GetOrderedUnit()), .5, 0, "|c00ff0000You can't move any items!") call UnitDropItemSlotBJ( GetOrderedUnit(), GetIssuedOrderItem(), 3 ) endif endfunction //=========================================================================== function InitTrig_Position_lock_Weapons_Copy takes nothing returns nothing set gg_trg_Position_lock_Weapons_Copy = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Position_lock_Weapons_Copy, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerAddCondition( gg_trg_Position_lock_Weapons_Copy, Condition( function Trig_Position_lock_Weapons_Copy_Conditions ) ) call TriggerAddAction( gg_trg_Position_lock_Weapons_Copy, function Trig_Position_lock_Weapons_Copy_Actions ) endfunction Code:
function GetIssuedOrderItem takes nothing returns item return UnitItemInSlot(GetOrderedUnit(), GetIssuedOrderId() - 852002) endfunction |
