Fitzwilliam Beginner
Joined: 24 Aug 2006 Posts: 11
|
Posted: Mon Sep 04, 2006 5:02 pm
Working Damaged Equipment Code (Need Help) |
This is code someone wrote to keep track of damage to equipment on Realms of Despair. When equipment is damaged, this code will keep track and if it gets too damaged it will remove the item before it gets destroyed.
QUESTIONS:
1. The problem is that from the way I am reading it, if you have two items that are named the same it will not work for them. For example, say you have a traveling cloak in both neck slots, because the variable damcon_eq only uses the last word for the item, I do not think it would keep track of both separately.
2. Can this be made more comprehensible? The trigger code uses variables like aaa eee ccc and such and it is hard to follow.
3. Can this be made better, performance wise or efficiency wise by reducing code?
Thank you
VARIABLES
damcon_eq ;items you want to keep an eye on using the LAST WORD of its name, case matters.
Value Example: Lifebane|Wrath|kilt|Shieldbreaker|Whispers|Chaos
damcon_max ;list of the maximum number of hits the items can take before you want them removed,
Value Example: 10|12|14|10|15|13
damcon_rem ;fill the list of keywords for each item. The triggers will remove the items by these keywords.
Value Example: lifebane|veil|kilt|shieldb|whispers|chaos-belt
ALIAS
rep ;this alias is used when you get your equipment repaired by an NPC
remove all
repair all
wear all
#VAR damcon_dam ""
#FORALL @damcon_eq {#VAR damcon_dam %additem("0",@damcon_dam)}
dam ;this alias displays the number of times damaged of all of your equipment
#SHOW *** hit counters: ***
#LOOP 1,%numitems(@damcon_eq) {#SHOW %item(@damcon_dam,%i) %item(@damcon_rem,%i)}
TRIGGER
Pattern: ^~((*) gets damaged~)$
#VAR eee {%1}
#VAR eee %word({@eee},%numwords(@eee))
#VAR aaa %ismember(@eee,@damcon_eq)
#IF (@aaa > 0) {#VAR bbb %item(@damcon_max,@aaa)
#VAR ccc %eval(%item(@damcon_dam,@aaa))
#ADD ccc 1
#VAR ddd %item(@damcon_rem,@aaa)
#DELNITEM damcon_eq @aaa
#VAR damcon_eq %additem(@eee,@damcon_eq)
#DELNITEM damcon_rem @aaa
#VAR damcon_rem %additem(@ddd,@damcon_rem)
#DELNITEM damcon_max @aaa
#VAR damcon_max %additem(@bbb,@damcon_max)
#DELNITEM damcon_dam @aaa
#VAR damcon_dam %additem(@ccc,@damcon_dam)
#IF (@ccc >= @bbb) {#BEEP
#COLOR red
rem @ddd}} |
|