Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > King's Bounty > King`s Bounty: Warriors of the North

King`s Bounty: Warriors of the North Next game in the award-winning King’s Bounty series

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2012, 09:30 PM
Zechnophobe's Avatar
Zechnophobe Zechnophobe is offline
Approved Member
 
Join Date: Nov 2009
Posts: 991
Default

Code:
    
 iskrit = ( kritProbRnd < kritProb )
      if iskrit then
        if receiver_human and not receiver_glot then
          kritProb = kritProb - skill_power("weakness_lore", 2)
          if kritProbRnd < kritProb then
            iskrit = true
          else
            iskrit = false
            is_weakness_lore = true
          end
        end
      end
Logic was just all topsy turvy. They intend to check IF IT IS STILL A CRIT, but instead of letting it be a crit, they instead cancel it. I believe the above should fix it unless I'm misremembering lua 'else' syntax.
Reply With Quote
  #2  
Old 10-31-2012, 09:39 PM
camelotcrusade's Avatar
camelotcrusade camelotcrusade is offline
Approved Member
 
Join Date: Apr 2009
Location: San Francisco, CA
Posts: 448
Default

Nice, Zechnophobe. I'll link to it once it's confirmed and Bhruic adds it to the summary. Too bad getting crit isn't easy to test. You almost need to keep a save near a hero who casts doom.
Reply With Quote
  #3  
Old 10-31-2012, 09:57 PM
Bhruic Bhruic is offline
Approved Member
 
Join Date: Oct 2012
Posts: 233
Default

Quote:
Originally Posted by Zechnophobe View Post
Code:
    
 iskrit = ( kritProbRnd < kritProb )
      if iskrit then
        if receiver_human and not receiver_glot then
          kritProb = kritProb - skill_power("weakness_lore", 2)
          if kritProbRnd < kritProb then
            iskrit = true
          else
            iskrit = false
            is_weakness_lore = true
          end
        end
      end
Logic was just all topsy turvy. They intend to check IF IT IS STILL A CRIT, but instead of letting it be a crit, they instead cancel it. I believe the above should fix it unless I'm misremembering lua 'else' syntax.
Well, what they were trying to do is check if Sense Weakness would prevent it from being a crit. Which they did correctly. Unfortunately what they didn't do is consider the case where you didn't have Sense Weakness.

Your code does mostly fix it, but I already posted a different fix in the main post. Both do roughly the same thing but different ways. The main point is that it should be working correctly now.
Reply With Quote
  #4  
Old 10-31-2012, 10:04 PM
Zechnophobe's Avatar
Zechnophobe Zechnophobe is offline
Approved Member
 
Join Date: Nov 2009
Posts: 991
Default

Quote:
Originally Posted by Bhruic View Post
Well, what they were trying to do is check if Sense Weakness would prevent it from being a crit. Which they did correctly. Unfortunately what they didn't do is consider the case where you didn't have Sense Weakness.

Your code does mostly fix it, but I already posted a different fix in the main post. Both do roughly the same thing but different ways. The main point is that it should be working correctly now.
Heh, the 'correct' way to fix it is actually just make the operand be >= in that second check, which I realized after I just saw my silly solution again.
Reply With Quote
  #5  
Old 10-31-2012, 10:09 PM
Bhruic Bhruic is offline
Approved Member
 
Join Date: Oct 2012
Posts: 233
Default

Quote:
Originally Posted by Zechnophobe View Post
Heh, the 'correct' way to fix it is actually just make the operand be >= in that second check, which I realized after I just saw my silly solution again.
That'd involve less steps, certainly. I think mine's slightly more elegant in that it requires less steps if you don't have Sense Weakness. Of course, I might be biased.
Reply With Quote
  #6  
Old 11-01-2012, 12:02 AM
Zechnophobe's Avatar
Zechnophobe Zechnophobe is offline
Approved Member
 
Join Date: Nov 2009
Posts: 991
Default

Quote:
Originally Posted by Bhruic View Post
That'd involve less steps, certainly. I think mine's slightly more elegant in that it requires less steps if you don't have Sense Weakness. Of course, I might be biased.
Hmm, just for the sake of discussion...

I wasn't optimizing for speed, since that is no doubt a non-issue with something like this. More just for how clarity and ease of debugging. Calling in additional functions to do your logic like that makes the code slightly weightier. And then, any edit to an external source should generally be simple so as a diff is easy to understand. Seeing:

Code:
Blah blah < bleh bleh
Turn into

Code:
Blah blah >= bleh bleh
Is pretty clear what the problem was, and the solution for it.

Er, not that any of this really matters... I've just been doing code reviews at work recently and it has me thinking about Ivory Tower code production stuff.
Reply With Quote
  #7  
Old 11-01-2012, 09:12 AM
Bhruic Bhruic is offline
Approved Member
 
Join Date: Oct 2012
Posts: 233
Default

Quote:
Originally Posted by Zechnophobe View Post
Er, not that any of this really matters... I've just been doing code reviews at work recently and it has me thinking about Ivory Tower code production stuff.
lol, I know. I was being semi-facetious. Had I thought of doing it your way first, I would have stuck with that as being the simpler approach. Still, as both ways work equally well, I'm going to stick with the approach I took and call it "better"! (even if it's not)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:19 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.