mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2004
Posts: 16
G
GSi Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2004
Posts: 16
This command :

//echo -s $inroundrect(129,110,100,100,30,30,30,30)

in mIRC 6.2 returns $true

but in the new mIRC 6.21 returns $false

I haven't seen any reference to changes or fixed bugs in the versions.txt.

I have a pool game in my script and it doesn't works (there aren't balls collisions) for this reason.

The bug is in 6.21 and in the next version will be fixed, or the bug was in the 6.2 and now its fixed ?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
well help file says this
$inroundrect(x,y,x,y,w,h,w,h)
Returns $true if the point x y is inside the specified rounded rectangle, and $false if it isn't.

Which doesnt help you overly much as I cant even understand what the second w,h are for,

However i assume x,y number one is the point, and x,y number two is the center of the rounded rectangle, with w,h following that being the size of the rectangle.

Possably the second w,h is the size of the point? maybe the w,h are the other way around? omg who knows!

Joined: Apr 2004
Posts: 16
G
GSi Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2004
Posts: 16
The fist x,y are the point, and the second x,y,w,h are the rectangle. The second w,h defines the rounded corners.

But the cuestion is that the previous version of mIRC works in a different way, as the example shows.

I made a pool game for my script (IRcap) wich uses $inroundrect to detect collisions between balls, and with the new mIRC don't works, balls are "transparent" ones to others.

I can fix this, but since is a multiplayer game and the result in both users must be exactly the same after each shot, if I modify the way of balls collisions the game will be incompatible with previous versions using mIRC 6.2.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$inroundrect is buggy in 6.21 indeed. $inellipse is also buggy, which might be the cause of the problem in $inroundrect. Until it's fixed, you can use these scripted versions of the identifiers (you should probably do a version check and use the built-in counterparts when appropriate, as they're faster):
Code:
alias inellipseq {
  if ($calc((1-(2*($1 -$3 -$5 /2) /$5)^2)^0.5*$6 /2) && $&
    $abs($calc($2 -$4 -$6 /2)) isnum 0- $+ $v1) return $true
  return $false
}
alias inroundrectq {
  if $inrect($1,$2,$3,$4,$5,$6) { 
    var %a = $7 / 2, %b = $8 / 2, %x = $1 - $3, %y = $2 - $4
    if %x < %a {
      if (%y < %b) return $inellipseq($1,$2,$3,$4,$7,$8)
      if (%y > $calc($6 -%b)) return $inellipseq($1,$2,$3,$calc($4 +$6 -$8),$7,$8) 
    }
    elseif %x > $calc($5 -%a) {
      if (%y < %b) return $inellipseq($1,$2,$calc($3 +$5 -$7),$4,$7,$8)
      if (%y > $calc($6 -%b)) return $inellipseq($1,$2,$calc($3 +$5 -$7),$calc($4 +$6 -$8),$7,$8)
    }
    return $true
  }
  return $false
}
Note that there is no error checking at all here (to save execution time), so you should be careful not to pass invalid parameters (or an invalid number of parameters).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2004
Posts: 16
G
GSi Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2004
Posts: 16
Tank you qwerty. I use $inroundrect to check collitions between balls in the game. There are a maximun of 16 balls, so there are a maximun of 16 x 16 cheks, 50 times in a second...

I need the speed of $inrounrect, replacing it with an alias will be too slow. I will wait for next release of mIRC, better.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Use fuzzy logic to conclude if u need to check for colides

Assuming the balls are diameter 10
Then compare each balls X & Y to being with in +/- 10 of any other balls X & Y if it is not it is to far way from any other ball to colide with, only if they are closer resort to a more exactive test, this should reduce overall script time even if the $identifier was working.

Joined: Apr 2004
Posts: 16
G
GSi Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2004
Posts: 16
That is just how I did... first the collisions are cheked using $inrect, and after using $inroundrect to precise the collision angle. But too often a lot of balls are next ones to others and $inroundrect is neccesary a lot of times by second.

And I have the same problem, if I replace $inroundrect with aliases and the result is not exactly the same, then the game will be incompatible with the previous script versions. So I can't modify the $inroundrect or replace it with aliases, the only solution is that $inroundrect works like in mIRC 6.2.

Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks this has been fixed for the next version.

Joined: Apr 2004
Posts: 16
G
GSi Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Apr 2004
Posts: 16
Don't works like mIRC 6.2.

My pool game works in different way using mIRC 6.2, and using mIRC 6.21, and now with mIRC 6.3.

Perhaps there are changes in the way of decimal numbers are managed ?
Changes in $abs ?

Some thing in this code works different in mIRC 6.2 / 6.21 /6.3:

Quote:

if ($abs($calc(%x - %bx)) < 16) { if ($abs($calc(%y - %by)) < 16) {

if ($inroundrect(%x,%y,$calc(%bx - 16),$calc(%by - 16),32,32,32,32)) {

var %bw = $gettok(%b,3,22) , %bh = $gettok(%b,4,22) , %bF = $gettok(%b,5,22) , %bn = $gettok(%b,6,22) , %bxx = %bx , %byy = %by

if (!%billar.t.pri) { %billar.t.pri = %bn }
if (!%nocho) { if %sloc == on splay " $+ $mircdirmod\billar\taco.wav" | %nocho = %ii %i }

var %dx = $calc(%bx - %x) , %dy = $calc(%by - %y) , %m = $abs(%dx)
if ($abs(%dy) > %m) { %m = $abs(%dy) } | var %dx = $calc(%dx / %m) , %dy = $calc(%dy / %m)

var %z = $abs(%dx) | if ($abs(%dy) > %z) { %z = $abs(%dy) } | %dx = $calc(%dx / %z) | %dy = $calc(%dy / %z)
hadd billar %ii %bx $+  $+ %by $+  $+ %dx $+  $+ %dy $+  $+ $calc(%f / 1.15) $+  $+ %bn

%f = $calc(%f / 1.2)
%x = %xx | %y = %yy

%w = $calc(%w - (%dx / 1.15))
%h = $calc(%h - (%dy / 1.15))

var %z = $abs(%w) | if ($abs(%h) > %z) { %z = $abs(%h) } | %z = $calc(1 / %z)
var %ff = $calc(%f / %z) | if (%ff < %f) { %f = %ff }
}



(Control codes between $+ $+ are not displayed in the forum)

Last edited by GSi; 17/08/07 02:31 PM.

Link Copied to Clipboard