Simple rerolling script for RPG game
|
|
I was wondering how hard this would be, and if someone could possibly get me started in the right direction. ******** MORE INFORMATION IN 3rd POST ***************** There is a website I play on called http://www.sryth.com And part of the user creation process is unlimited rolling for your stats, which are random from 6-20, I was wondering how hard it would be to disable the reroll button if you get perfect stats. The html can be viewed by logging in and going to create a new character.
Your stats have been rolled.
Skill Potential (Based on your stats) Lore: 25% Exp. Bonus
****% MORE INFORMATION IN MY SECOND POST %**** Thank you very much! |
|
|
You can't paste html like that here (didn't you notice?), the easy way to get around that is to add a space like < input name="aname">.
|
|
|
I apologize descriptor, I was pulling an all nighter and pretty out of it. I looked over the page again and there is no onsubmit or onclick, looks like it's all plain html w/ some css stuff at the top. The easiest way I can see to know that I want the button removed is to search for the text strings:
Here's the reroll button I want to remove when the stats are all 20:
< form method="POST" action="/game/ci.php" > < input type="hidden" name="f_c" value="member_createpc.inc" > < input type="hidden" name="f_task" value="roll" > < td align=middle valign=middle > < input type="submit" value="REROLL STATS" class="submitbutton2" > < /td > < /form > In order to look and see if the stats are all 20 I think it's more involved, so it would probably be easier to see if the experience modifiers are all 30%, below I've listed what the html for that would look like:
< table cellpadding=0 cellspacing=0 border=0 class="table_basic" width=100% > < tr > < td align=right valign=top width=50% >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_arcana" target="_blank" style="color:#004f00;" >Arcana< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_diplomacy" target="_blank" style="color:#004f00;" >Diplomacy< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_woodsmanship" target="_blank" style="color:#004f00;" >Woodsmanship< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_weaponry" target="_blank" style="color:#004f00;" >Weaponry< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_unarmedcombat" target="_blank" style="color:#004f00;" >Unarmed Combat< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_seamanship" target="_blank" style="color:#004f00;" >Seamanship< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_horsemanship" target="_blank" style="color:#004f00;" >Horsemanship< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_lore" target="_blank" style="color:#004f00;" >Lore< /a>< /font >: < /td > < td align=left valign=top width=50% >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_archery" target="_blank" style="color:#004f00;" >Archery< /a>< /font >: < /td > < td align=left valign=top width=50% >< font style="font-size:11px;" >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < tr > < td align=right valign=top width=50% >< font style="font-size:11px;" >< font color=#004f00 >< a href="/ci.php?f_c=docs.inc&f_nh=1#skills_thievery" target="_blank" style="color:#004f00;" >Thievery< /a>< /font >: < /td > < td align=left valign=top width=50% >< font style="font-size:11px;" >< font color="#000090" >30% Exp. Bonus< /font >< /td > < /tr> < /table > Thank you very much for any help/responses. |
|
|
OK, so there's no JavaScript, it's totally generated by the server. I see some unclosed font tags, I hope that doesn't effect this script.
// set global for our re-roll checks, true to disable button
var S_Stop = true;
// to disable button or reroll
function S_ReRoll(stop){
var button = document.evaluate("//input[@value='REROLL STATS']", document, null, 9, null).singleNodeValue;
if(stop){ button.disabled = true }
// else stop = false, click button - or remove line to do nothing
else{ button.click() }
}
If you don't want the script to re-roll, then just remove the Well, that's the easy part, checking the stats is a bit more complex.
// list of stats we don't want
var badsStats = [ "No Exp. Adj.", "Exp. Penalty", "25% Exp. Bonus", "20% Exp. Bonus", "15% Exp. Bonus", "10% Exp. Bonus", "5% Exp. Bonus" ];
for(var i=0; badsStats.length > i; i++){
if(document.evaluate("//td//*[contains(text(), '" + badsStats[i] + "')]", document, null, 3, null).booleanValue){
S_Stop = false;
// done checking
break;
}
}
// check if we want to reroll
if(!S_Stop){
S_ReRoll(S_Stop);
return true;
}
// or just use S_ReRoll(S_Stop) if you dont use next function
In order to look and see if the stats are all 20, I think we can just count to 10.
// good stat value and the amount to match
var goodStats = [ "30% Exp. Bonus", 10 ];
var statsMatch = document.evaluate("//td//*[contains(text(), '" + goodStats[0] + "')]", document, null, 6, null);
if(statsMatch == null || statsMatch.snapshotLength < goodStats[1]){ S_Stop = false }
// check if we want to reroll
S_ReRoll(S_Stop);
Edit: whoops, there are 10 stats not 20 - fixed |
|
|
Thank you very much, I haven't been able to try this out because I've been working 14 hour days, but when I get some freetime I will, and I'll post back with how it worked out and my final script hopefully. |
|
|
I'm trying to modify your script, Descriptor, and I'm having issues. If you'd be so kind to help... I am attempting to read the rolled stat value for each stat.. for just the Might stat so far I have...
However, that returns an object of type HTMLSpanElement which I dont know how to work with.. I tried statMatch.innerText but that comes back as undefined.. Any thoughts on what I am doing wrong.. or better yet, any thoughts on how this should be done right? Thanks. |
|
|
Try to use textContent. innerText is a Internet Explorer only property (not standard) |
|
|
Mindeye,
|
