Looping through available skill that give effects issue

Stardock

Member
I'm using the following code to loop through all available skills that give effects:

Code:
int i = 0;
while(i < 10000)
{
    if(to_effect(to_skill(i)) != $effect[none])
    {
        print(to_effect(to_skill(i)));
    }
    i += 1;
}

The issue is I end up with a ton of spam to the CLI "<skill name> does not match anything in the status effect database."

How do I check if it exists without triggering the spam?
 

Theraze

Active member
Mainly, switch it around and go the other way. :)

This one line gives you all the effects that come from skills:
Code:
ashq foreach eff in $effects[] if (to_skill(eff) != $skill[none]) print(eff);
 

Theraze

Active member
Basically, $effects[] is a map of all of the effects, so it won't try to do 10000 skills that don't exist. No new map, just using the existing one.

Similarly, if you want the spam, you could do sk in $skills[] and to_effect(sk), but it'll be noisy.
 

Stardock

Member
I want to go in skill order from skill id 1 to skill id 10000.

Is there a way to sort the $effects[] map by skill id?
 

Theraze

Active member
Hmm... more complicated, but this will do that.
ashq boolean[skill]sk; foreach eff in $effects[] if (to_skill(eff) != $skill[none]) sk[to_skill(eff)] = true; foreach skl in $skills[] if (sk contains skl) print_html(skl);
We're making a boolean map, setting the skills as we see them happening, then going through the skills in order and displaying them if they have a skill.
 

Stardock

Member
This works for the most part, weird issue though with Spectral Snapper and Cold-blooded fearlessness which somehow end up in the map despite not having an effect.
 

Stardock

Member
Figured it out, spectral snapper was matching spectral and cold-blooded fearlessness was matching cold blooded.
 

Theraze

Active member
Ah... that makes sense. Unfortunately, I don't think there's any proxy records yet for effects caused by items or skills, so we're forced to hope for the best... :)
 

Bale

Minion
Add a small check for !sk.passive && !sk.combat, perhaps? Hacky, yes, but gets around the issue.

No, I thought of that already. It doesn't entirely do the job. It will still throw error messages for skills like cannelloni cocoon and advanced saucecrafting.
 

Theraze

Active member
I think hee[sup]3[/sup] means to add that to my line, like so...
ashq boolean[skill]sk; foreach eff in $effects[] if (to_skill(eff) != $skill[none]) sk[to_skill(eff)] = true; foreach skl in $skills[] if (sk contains skl && !skl.passive && !skl.combat) print(skl);
It's a hack, but it does hide the 2 bad skills that were improperly matching. :D

Unfortunately, it hides these skills:
Gothy Handwave
Cold-Blooded Fearlessness
Spectral Snapper
Hot Breath
Cold Breath
Spooky Breath
Stinky Breath
Sleazy Breath
Recite 'The Spirit of Crimbo'
Mighty Shout
And those combat skills are real effects... hmm... the passive check is fine, because that just gets rid of fearlessness, but there doesn't appear to be any 'proper' way to eliminate snapper without hardcoding it.
 
Last edited:

heeheehee

Developer
Staff member
Hmm. Mighty Shout is removed incorrectly, but that's very situational.

Gothy handwave and snapper don't give an effect... breaths are granted by effects, not the other way around. Recite spirit of crimbo... that's granted by an equip and used to defeat Crimbomination, some years back, right? No associated effect. So those seem right.
 
Top