Bug - Fixed Skills cast from runskillz.php not recorded

ckb

Minion
Staff member
If I cast a summon skill from the Skillz.php page, with or without my SkillsWTF relay, they are cast via a call to runskillz.php

Mafia fails to record the casting of these summon skills when they are cast this way.
When cast via ash or CLI or breakfast command, they are recorded correctly.

Example, after casting That's Not a Knife from the skillz page, I get this (highlight mine):


> ash $skill[that's not a knife]

Returned: That's Not a Knife
level => 5
image => knife.gif
traincost => 1250
class => Disco Bandit
libram => false
passive => false
buff => false
combat => false
song => false
expression => false
summon => true
permable => true
dailylimit => 1
timescast => 1

Then, from the CLI after that:

> cast 1 that's not a knife

Summon limit exceeded.

> ash $skill[that's not a knife]

Returned: That's Not a Knife
level => 5
image => knife.gif
traincost => 1250
class => Disco Bandit
libram => false
passive => false
buff => false
combat => false
song => false
expression => false
summon => true
permable => true
dailylimit => 0
timescast => 2

There are probably more details here that I am not aware of, but I have cast all my summon skills for today. More investigation tomorrow maybe.

Update: it seems like skills cast via the KoL interface buttons are recorded ok, but those cast via my relay links are not. These do have the same URL, just in different locations.
 
Last edited:
Update: it seems like skills cast via the KoL interface buttons are recorded ok, but those cast via my relay links are not. These do have the same URL, just in different locations.
What does your session log say?

And can I see a DEBUG log of summoning via the KoL interface button and via your relay link?
 
Logged in, cast Pastamastery from my skillz link on my relay override:
Code:
http://127.0.0.1:60080/runskillz.php?action=Skillz&whichskill=3006&pwd=x&quantity=1

Cast was successful. CLI echos this:
You acquire dry noodles (5)

From the CLI:
> ash $skill[Pastamastery]

Returned: Pastamastery
level => 5
image => bowl.gif
traincost => 1250
class => Pastamancer
libram => false
passive => false
buff => false
combat => false
song => false
expression => false
summon => true
permable => true
dailylimit => 1
timescast => 1

Clicked on the Pastamastery link from Kol (in ther iconic skill layout. Pastamastery was greyed out).

Then, I get this:
> ash $skill[Pastamastery]

Returned: Pastamastery
level => 5
image => bowl.gif
traincost => 1250
class => Pastamancer
libram => false
passive => false
buff => false
combat => false
song => false
expression => false
summon => true
permable => true
dailylimit => 0
timescast => 2

Debug log attached.
Session log reports this:
Code:
cast 1 Pastamastery
You acquire dry noodles (5)

cast 1 Pastamastery
 

Attachments

When asking for logs, I should request people to not be in chat and to not be running other relay scripts; a substantial part of that log was chat and chit.

Here are the skill-related requests I extracted from your log:

Code:
1% Starting relay script: skillz.ash
Requesting: http://www.kingdomofloathing.com/skillz.php
Retrieved: http://www.kingdomofloathing.com/skillz.php
12% Finished relay script: skillz.ash

Requesting: http://www.kingdomofloathing.com/runskillz.php?action=Skillz&whichskill=3006&pwd&quantity=1
Retrieved: http://www.kingdomofloathing.com/runskillz.php?action=Skillz&whichskill=3006&pwd&quantity=1
Field: location = [skillz.php]

30% Starting relay script: skillz.ash
Requesting: http://www.kingdomofloathing.com/skillz.php
Retrieved: http://www.kingdomofloathing.com/skillz.php
Processing results...
You acquire dry noodles (5)
Processing result: dry noodles (5)
41% Finished relay script: skillz.ash

65% Starting relay script: skillz.ash
Requesting: http://www.kingdomofloathing.com/skillz.php
Retrieved: http://www.kingdomofloathing.com/skillz.php
76% Finished relay script: skillz.ash

Requesting: http://www.kingdomofloathing.com/runskillz.php?action=Skillz&whichskill=3006&targetplayer=0&pwd&quantity=1&ajax=1&_=1421010508424
Retrieved: http://www.kingdomofloathing.com/runskillz.php?action=Skillz&whichskill=3006&targetplayer=0&pwd&quantity=1&ajax=1&_=1421010508424

<script type="text/javascript">top.charpane.location.href="charpane.php";</script><script type="text/javascript">if (window.updateInv) updateInv([])</script><script type="text/javascript">if (!window.updateInv && parent.mainpane.updateInv) parent.mainpane.updateInv([])</script><center><table  width=95%  cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Results:</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td>You can't use that skill again today.</td></tr></table></center></td></tr><tr><td height=4></td></tr></table></center>
Processing results...
Processing result:  MP: 0

94% Starting relay script: skillz.ash
Requesting: http://www.kingdomofloathing.com/skillz.php?oneskillz=3006
Retrieved: http://www.kingdomofloathing.com/skillz.php?oneskillz=3006
95% Finished relay script: skillz.ash
Your Relay Script was invoked 4 times.

1) You call the skills link from the topmenu
Your script is invoked and does what it wants.

2) You click on the link to runskillz.
KoL replies with a redirect to skillz.php
Your script is invoked and makes the (redirected) request and does what it wants with the response to the casting.

3) You click on the skills menu link again, apparently.
Your script is invoked and does what it wants.

You click on the greyed out skill.
The call to runskillz (with ajax=1) is invoked.
KoL responds with no indirect.
It says "You can't use that skill again today."

4) You then clicked on something which asked for skillz.php?oneskillz=3006
Your script is invoked and does what it wants.

I am not sure where you got the idea that "These do have the same URL, just in different locations". "it seems like skills cast via the KoL interface buttons are recorded ok" - which are cast via ajax=1 - "but those cast via my relay links are not" - which are not cast using ajax.

If one request has "ajax=1" and the other does NOT have that, that is in no way "the same URL".

I'm going to have to look at our code to try and understand what's going wrong.
 
OK, that is probably exactly the issue. When KoL came out with the new skillz page, I saw that every skill you cast on it was an ajax request to runskillz.php, and experimentation showed that the response to that URL came back with no redirection, and, therefore, that was the only URL for which we needed to parse the response.

It never occurred to me that if an ASH script invoked runskillz.php WITHOUT ajax that KoL would send the response back in a redirect to skillz.php.

I expect that simply looking for a skill casting response in the reply to skillz.php will handle this case.

Try revision 15170.
 
Just tried r15174. Success!
Thank you much.

Also, combing through the debug logs a bit more, and the skills html, I do see that url += '&ajax=1'; This I did not notice the first time I looked. Also, I found out that 'ajax' is actually a thing. Also, when I hover over the Kol icons (using chrome) to get a skill casting link, it does NOT have the ajax=1, and it looks just like the link I was using.
Also, Inspect element gives me a URL that looks just like mine.

I guess my little (incomplete) knowledge is a dangerous thing.

Is it better if I add &ajax=1 to my skill links? What difference will that make? It seems to work both ways.
 
Ajax is a thing that allows KoL to insert new stuff into the existing frame rather than generating a whole new page. You've seen it when you click a "use" link (either KoLmafia generated or KoL generated on the inventory) and it puts a little Results section above the currently displayed page.

It's a heck of a lot faster, since the Results section is a heck of a lot smaller than the full inventory or skills page. And, as you have seen in this case, it happens in a single request/response, rather than a request/redirect/request/response.

Internally, KoLmafia uses ajax=1 whenever it is possible for exactly those reasons.

If your script uses it, it will submit runskillz with ajax=1 and KoL will execute it and send a response with no redirect - and your script will not be called again, since the response does not redirect to skillz.php. If that's fine with you, go for it! Try it out, see how you like it.
 
Back
Top