Nested coupled foreach loops
I have searched the forums, though not exhaustively, for help on this topic but this was the only thread close to what I want to accomplish:
http://www.eqemulator.org/forums/showthread.php?t=31777 I am trying to create nested foreach loops where the inner loop simultaneously reads two @lists containing 8 items each. Here's what I have so far, and can't figure out how to reference the $item (@itemlist). Any help would be appreciated. Thanks. Code:
sub EVENT_SPAWN { Code:
#checks to see if player has item equipped |
Update: perhaps?
Code:
sub EVENT_SPAWN { |
Try this for the NPC:
Code:
sub EVENT_SPAWN { Code:
sub check_hasitemequipped { |
I see you've avoided the nested loops by shifting one iteration to the plugin; good idea. Now to tweak allowing bracers in either left or right slots (9 or 10).
I would want to limit the checked slots to visible slots (2,7,9,10,12,17,18,19), so the 1->22 $i++ iteration would need changing. Thanks Kingly_Krab p.s. This can also be utilized to accomplish the "remove weapon or armor" emotes and checks during MPG trials. |
Okay, I'd like to see how you're going to use this. Unless you're just using it for the MPG trials.
|
No, the MPG trials were an afterthought use. I plan on utilizing this check to implement a way to force usage of "resist gear" beyond the simple type resist checks. I.e., if you equip (not just own) 3 of 8 pieces of this gear, you only get hit with 5 of the 8 iterations of a DD, for example; whereas if you have the entire set on (lore to be added) the DD does not harm you.
I'll post the event when completed. Thanks again. |
Results of testing:
Trying your suggested code for npc and plugin, the code merely checks for the proper item on the client's head (the lowest value slot in which an item can appear from the @itemlist). If that passes, returns a 1 and check ends. If that fails, returns a 0 and check ends. I.e., the for loop 1-22 is not executing past a true Code:
if ($client->GetItemIDAt($i) == $item) { My quest continues... |
I'm probably missing something...
Code:
my @itemlist = (0000,0000,0000,0000,0000,0000,0000,0000); Wouldn't any item found in any checked slot return 0? Quote:
|
Yes, the actual numbers for the items are not 0000, those were just placeholders when I began thinking of this script at work today. I have decided to axe the plugin and do it manually and it works perfectly, only I still have the explicit right versus left wrists to tackle. Finally, I need to get it working as a loop to have the ill effects count the number of correct/missing items of the 8.
This works as intended for checking all 8 visible armor items: Code:
sub EVENT_SPAWN { |
If you HAVE you do your if statement that way, try this. (Spacing should not look like this, this is just for looks.)
Code:
if ($ent->GetItemIDAt(2) == 2298 |
Next question: is there a function or call that accomplishes the following, or can one of you experts create one to look into an item's file and find the assigned weapon type by value? I imagine it would mirror the function of
quest::isdisctome(item_id) # Checks if 'item_id' is a discipline tome. Code:
#usage quest::isweapon_type($itemid, type) where you choose the value for slash, blunt, et cetera |
All times are GMT -4. The time now is 12:54 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.