Aller au contenu

Photo

TMI Issue -- What's the Limit?


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

I've been wrestling with an idea.  The core problem I'm trying to solve is the fact that if you have an item with charges, if as the charges drop down to the point where you can't use the item and then you boost the charges back up the item remains unusable.  If the item is 1 charge per use and has 3 charges, setting it to 4 charges makes it adjust to 4 uses.  But if it's 1 charge per use and has 0 charges, setting it to 1 charge keeps it as 0 uses.

 

The two main solutions I've seen suggested to fix this problem are the following:

 

1, remove and re-add the use property.  However, this would presumably clear the quickbar slot where the item was stored, which isn't acceptable.

 

EDIT: IT TURNS OUT THE ABOVE ACTUALLY WORKS.

 

2, have the player rest.  The catch is that this needs to work in-combat, which means ForceRest needs to be used AND the player has to be restored to the previous feats/spells/HP at a minimum.

 

As a result, I've written some code that loops through feats starting at value 0 and going up to 1115 (the last feat by default, player tool 10).  It checks the number of uses a feat has, stores this information as a local int, force rests, then decrements feat uses as appropriate.

 

The problem is that this produces a TMI loop.  However, the code is perfectly fine looping from 0 to 100.  And from 0 to 1000.  And from 1000 to 1150.  And from 900 to 1150.  But 0 to 1115 apparently breaks the instruction limit and gives me a TMI message.

 

This obviously has bad implications since I also need to do the same sorts of things for spells.

 

Presumably I could do something like separate this out into multiple scripts -- have one script check 0-600, another check for 600-1115 and rest, another decrement 0-600 if needed, and a fourth to decrement 600-1115 if needed.  But that obviously seems rather clunky and also has greater processor cost.  And I'd need the same sort of thing for spells.

 

Any suggestions regarding this?  Insight to offer on the TMI limit?



#2
Shadooow

Shadooow
  • Members
  • 4 470 messages

Few possibilities:

1) increase script efficiency via various scripting methods - this thread might help you

2) find another way to do that (for example try avoid loops in loops thats a biggest killer)

3) divide your script into multiple ones and execute them delayed (or multiple functions in one script etc.)

4) use NWNX plugin to increase the limit



#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Try making the Item use 2 charges per use and giving it an odd number of charges.



#4
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

Try making the Item use 2 charges per use and giving it an odd number of charges.

 

Didn't work when I tried it before looking at this solution.  As soon as the item registers that it has insufficient charges to use a property, you apparently need to rest or re-add that property to fix it.



#5
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

2) find another way to do that (for example try avoid loops in loops thats a biggest killer)

3) divide your script into multiple ones and execute them delayed (or multiple functions in one script etc.)

4) use NWNX plugin to increase the limit

 

2. I don't really see a way to avoid doing it.  Need to loop through every feat, need to then loop more in the first loop to increment/decrement, but the inner loop is skipped if the owner doesn't possess the feat.

 

3. Yeah, I mentioned that at the end of my post.  Are you saying multiple functions in one script will avoid the issue?  I thought it was for the script as a whole?  Could just put some of the loops in a new function in that case and problem solved.

 

4. Single player module, impossible.



#6
Shadooow

Shadooow
  • Members
  • 4 470 messages

2. I don't really see a way to avoid doing it.  Need to loop through every feat, need to then loop more in the first loop to increment/decrement, but the inner loop is skipped if the owner doesn't possess the feat.

 

3. Yeah, I mentioned that at the end of my post.  Are you saying multiple functions in one script will avoid the issue?  I thought it was for the script as a whole?  Could just put some of the loops in a new function in that case and problem solved.

 

4. Single player module, impossible.

2. yea no other way around it.

3. yes, just make void loop1() and void loop2(); and in main() call loop1 and delaycommand(0.1,loop2());

4. I see, but even when working on a multiplayer module I personally prefer choice 3 so I can test it without need to run server anyway



#7
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

3, ah, so the second loop would HAVE to be delayed?  calling loop1 and loop2 consecutively would still violate the TMI with no DelayCOmmand?  I know the DelayCommand effectively changes it into something else so maybe that's the reason.



#8
Shadooow

Shadooow
  • Members
  • 4 470 messages

3, ah, so the second loop would HAVE to be delayed?  calling loop1 and loop2 consecutively would still violate the TMI with no DelayCOmmand?  I know the DelayCommand effectively changes it into something else so maybe that's the reason.

yes



#9
Proleric

Proleric
  • Members
  • 2 354 messages
You can use AssignCommand instead of DelayCommand to by-pass the TMI check, with the advantage that it happens when the script finishes, rather than with some arbitrary delay.

#10
WhiZard

WhiZard
  • Members
  • 1 204 messages

Didn't work when I tried it before looking at this solution.  As soon as the item registers that it has insufficient charges to use a property, you apparently need to rest or re-add that property to fix it.

 

Correct.  Conventions that use 1 + m * n number of charges on items don't prevent either the need to refresh the item property when the uses run to zero, nor do they prevent item destruction, which is caused under the same circumstances when the item is not plot and there are not any later (in the sequential order listed on the item, which is newest to oldest) item properties with uses.



#11
meaglyn

meaglyn
  • Members
  • 811 messages

Is this for a custom item or all items with charges? If custom then you can give it unlimited uses per day and use your own code to track the charges. Changing the description to display the number of charges available is nice and easy enough to do as well. (Just be careful if you ever copy the item since the description changes won't be preserved.)



#12
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

Giving the item unlimited uses per day means the user doesn't see the current available uses on the quickbar, so that's not an acceptable solution.

 

Amusingly enough this would be incredibly easy to do with a feat but it requires a hak (I've done a solution like that before for another project).



#13
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

You can use AssignCommand instead of DelayCommand to by-pass the TMI check, with the advantage that it happens when the script finishes, rather than with some arbitrary delay.

 

Definitely like this more than DelayCommand in this case.

 

New problem!  I forgot ForceRest clears the action queue which is rather annoying in combat since you lose 6 seconds and disrupts your planned activities.

 

I might just have to do something like give it 5 charges at 1 charge a use and only allow it to do something when used at 3+ charges -- if used at 2 charges then it simply bumps itself back up to 2 from 1.  This would ensure the item never thinks it has 0 uses left -- but then it also misleads the player because they think they do, which is why I was trying to avoid this in the first place.

 

But the player having to remember the item only works at 3-5 uses would be better than disrupting their action queue in combat for no apparent reason, I think.



#14
Shadooow

Shadooow
  • Members
  • 4 470 messages

Wait, how you are increasing the charges? Usually this is done by some NPC or placeable, what is it that is doing it in middle of combat?



#15
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

A script.  Effectively you have an item that starts at 3 charges.  Once you use a charge, every 18 seconds a charge is restored until it registers it is at 3 charges again and then the script stops and waits until it gets used again.

 

The net result is that you can use the item every 3 rounds in general plus you can save up to 3 charges to release more rapidly if you're in a bad situation.  May bump it up to restoring a charge every 24 seconds depending on how testing goes, but that's just fiddling with tuning at that point.



#16
Shadooow

Shadooow
  • Members
  • 4 470 messages

okay then try this:

 

when item is at 0 charges

 

1. increase charge

2. add a new cast spell itemproperty

3. remove the original cast spell itemproperty

 

just and idea but might preserver the quickslot



#17
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

I'll be damned.  In fact, apparently you can add the new one and THEN remove the old one OR remove the old one and THEN add the new one.  Either way preserves the quickslot for some reason.

 

I'll be damned.  Thanks, Shadow.



#18
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages

A script.  Effectively you have an item that starts at 3 charges.  Once you use a charge, every 18 seconds a charge is restored until it registers it is at 3 charges again and then the script stops and waits until it gets used again.

 

The net result is that you can use the item every 3 rounds in general plus you can save up to 3 charges to release more rapidly if you're in a bad situation.  May bump it up to restoring a charge every 24 seconds depending on how testing goes, but that's just fiddling with tuning at that point.

Take a look at the include for auras in the mod I gave you. It does pretty much precisely what you want, along with another include for item charge alteration that properly displays on the quickbar.

 

As for TMI looping, take a look at the old, rather than the new, code for HGLL feat-table building. It shows how to do stacked loops with variables to avoid TMIs.

 

Funky



#19
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages

Thanks, Funky, I'll look into those.