Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Lost at an Unexpected Action (https://forums.graalonline.com/forums/showthread.php?t=134261208)

MrOmega 11-29-2010 10:54 PM

Lost at an Unexpected Action
 
Here's the script

PHP Code:

//#CLIENTSIDE

function onCreated()
{

  
client.targetCoor NULL;
  
client.targetMode 7;
  
  new 
GuiWindowCtrl"Varia_Targetting")
  {
  
    
clearControls();
    
    
extent = { 256128};
    
position = { screenwidth this.width0};
    
    
text "Targetting Control";
    
profile "GuiWindowProfile";
    
profile.bitmap "guivaria_window.png";
    
    
visible =
    
canMove =
    
canClose =
    
canResize =
    
canMinimize =
    
canMaximise false;
    
    for ( 
temp.0temp.8temp.++)
    {
 
      new 
GuiRadioCtrl"Varia_Targetting_" temp.i
      { 
       
        
extent = { 12822};
        
position = { 10 + ( temp.3this.width0), 25 this.height * ( temp.4)};
        
profile "GuiRadioProfile";
        
profile.bitmap "guivaria_radio.png";
        
profile.fontcolor = { 4717732255};
        
profile.fillcolor = { 477732255};
        
profile.fontcolorhl = { 02000255};
        
profile.fillcolorhl = { 0900255};
        
groupnum 1;
        
text 
          
temp.== 0"Move To Here"
          
temp.== 1"Look/Study":  
          
temp.== 2"Open":  
          
temp.== 3"Read"
          
temp.== 4"Speak to"
          
temp.== 5"Attack"
          
temp.== 6"Close"
          
"Do Nothing";
         
        
checked temp.== 7truefalse;
          
        
thiso.catcheventname"onAction""onChangeAction");
      
      }
    }
  }
}

function 
GraalControl.onMouseDown()
{

  
client.targetCoor = { intmousex), intmousey)};
  
Varia_Targetting.visible true;

  
showimg0"varia_targetting.gif",  client.targetCoor0] - 2client.targetCoor1] - 2).layer 3;

  
TargetAction();

}

function 
GraalControl.onRightMouseDown()
{

  if ( 
client.targetCoor != NULL)
  {
  
    
Varia_Targetting.visible false;
    
hideimg0);
    
client.targetCoor NULL;

  }
}

function 
onChangeAction()
{

  
client.targetMode params0].substring171);
  
TargetAction();
  
}

function 
TargetAction()
{

  switch ( 
client.targetMode)
  {

    case 
0:

      
temp.dist getDistplayer.xplayer.yclient.targetCoor0], client.targetCoor1]);

    break;
    
    case 
1:
    break;
    
    case 
2:
    break;
    
    case 
3:
    break;
    
    case 
4:
    break;
    
    case 
5:
    break;
    
    case 
6:
    break;
    
    case 
7:
    break;

  }
}


function 
getDisttemp.x1temp.y1temp.x2tempy2)
{

  
temp.dist int(((( temp.x2 temp.x1) ^ 2) + (( temp.y2 temp.y1) ^ 2)) ^ 0.5);
  echo( 
temp.dist SPC params);
  return 
temp.dist;



Here's the issue. on the getDist function it's not getting the correct params that I am sending it's getting the params of whatever last function was used.

So when I click the first radio button it echoes " 33 Varia_Targetting_0, "
If I just click around after that I get the params of onMouseDown(). and the dist always seems to be 33. What the hell am I doing wrong?

ffcmike 11-29-2010 10:58 PM

Quote:

Originally Posted by MrOmega (Post 1614155)
Here's the script

PHP Code:

//#CLIENTSIDE

function onCreated()
{

  
client.targetCoor NULL;
  
client.targetMode 7;
  
  new 
GuiWindowCtrl"Varia_Targetting")
  {
  
    
clearControls();
    
    
extent = { 256128};
    
position = { screenwidth this.width0};
    
    
text "Targetting Control";
    
profile "GuiWindowProfile";
    
profile.bitmap "guivaria_window.png";
    
    
visible =
    
canMove =
    
canClose =
    
canResize =
    
canMinimize =
    
canMaximise false;
    
    for ( 
temp.0temp.8temp.++)
    {
 
      new 
GuiRadioCtrl"Varia_Targetting_" temp.i
      { 
       
        
extent = { 12822};
        
position = { 10 + ( temp.3this.width0), 25 this.height * ( temp.4)};
        
profile "GuiRadioProfile";
        
profile.bitmap "guivaria_radio.png";
        
profile.fontcolor = { 4717732255};
        
profile.fillcolor = { 477732255};
        
profile.fontcolorhl = { 02000255};
        
profile.fillcolorhl = { 0900255};
        
groupnum 1;
        
text 
          
temp.== 0"Move To Here"
          
temp.== 1"Look/Study":  
          
temp.== 2"Open":  
          
temp.== 3"Read"
          
temp.== 4"Speak to"
          
temp.== 5"Attack"
          
temp.== 6"Close"
          
"Do Nothing";
         
        
checked temp.== 7truefalse;
          
        
thiso.catcheventname"onAction""onChangeAction");
      
      }
    }
  }
}

function 
GraalControl.onMouseDown()
{

  
client.targetCoor = { intmousex), intmousey)};
  
Varia_Targetting.visible true;

  
with findImg0))
  {
  
    
client.targetCoor0] - 2;
    
client.targetCoor1] - 2;
    
    
image "varia_targetting.gif";
    
    
TargetAction();
  
  }
}

function 
GraalControl.onRightMouseDown()
{

  if ( 
client.targetCoor != NULL)
  {
  
    
Varia_Targetting.visible false;
    
hideimg0);
    
client.targetCoor NULL;

  }
}

function 
onChangeAction()
{

  
client.targetMode params0].substring171);
  
TargetAction();
  
}

function 
TargetAction()
{

  switch ( 
client.targetMode)
  {

    case 
0:

      
temp.dist getDistplayer.xplayer.yclient.targetCoor0], client.targetCoor1]);

    break;
    
    case 
1:
    break;
    
    case 
2:
    break;
    
    case 
3:
    break;
    
    case 
4:
    break;
    
    case 
5:
    break;
    
    case 
6:
    break;
    
    case 
7:
    break;

  }
}


function 
getDisttemp.x1temp.y1temp.x2tempy2)
{

  
temp.dist int(((( temp.x2 temp.x1) ^ 2) + (( temp.y2 temp.y1) ^ 2)) ^ 0.5);
  echo( 
temp.dist SPC params);
  return 
temp.dist;



Here's the issue. on the getDist function it's not getting the correct params that I am sending it's getting the params of whatever last function was used.

So when I click the first radio button it echoes " 33 Varia_Targetting_0, "
If I just click around after that I get the params of onMouseDown(). and the dist always seems to be 33. What the hell am I doing wrong?

I believe this would be caused as a result of calling "TargetAction" inside with(findImg( 0)){}, it should probably be "thiso.TargetAction" or just called outside of that bracket.

fowlplay4 11-29-2010 10:58 PM

Quick look over..

function getDist( temp.x1, temp.y1, temp.x2, tempy2)

should be

function getDist( temp.x1, temp.y1, temp.x2, temp.y2)

MrOmega 11-29-2010 11:01 PM

Quote:

Originally Posted by ffcmike (Post 1614156)
I believe this would be caused as a result of calling "TargetAction" inside with(findImg( 0)){}, it should probably be "thiso.TargetAction" or just called outside of that bracket.

I did that but still get the issue.

Quote:

Originally Posted by fowlplay4 (Post 1614157)
Quick look over..

function getDist( temp.x1, temp.y1, temp.x2, tempy2)

should be

function getDist( temp.x1, temp.y1, temp.x2, temp.y2)

Wow one those moments where I feel stupid, it has somewhat fixed it... It returns the proper dist now, but it still doesn't echo the proper params... oh well.

fowlplay4 11-29-2010 11:12 PM

Had you used your own specified params instead of taking the quick route you would have noticed. :P


All times are GMT +2. The time now is 05:11 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.