Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Npc level changing (https://forums.graalonline.com/forums/showthread.php?t=83707)

[email protected] 01-16-2009 12:44 AM

Npc level changing
 
Is there any way to change the level of a npc to the player level?

Tigairius 01-16-2009 12:47 AM

Could you elaborate a little bit more?

[email protected] 01-16-2009 12:52 AM

Oh yea sure well i have this class script as an npc inside a level. I when the player touchs him i want him to follow him outside the level to the gmap. Is that possible? also when i have a class npc following somebody on gmap after about 2 to 3 levels it just freeze know why?

Tigairius 01-16-2009 12:56 AM

You should use a putnpc2, level NPCs can't follow you outside of the level. You could do something like:
PHP Code:

function onCreated() {
  
putnpc2(xy"join CLASS;");


Then it should follow you just fine. Make sure inside of the class you have:
PHP Code:

function onCreated() {
  
canwarp();
  
canwarp2();



[email protected] 01-16-2009 01:04 AM

Hmmm..... Its still only following me for about 2 to 3 levels then it stops.

Tigairius 01-16-2009 01:14 AM

Quote:

Originally Posted by [email protected] (Post 1457354)
Hmmm..... Its still only following me for about 2 to 3 levels then it stops.

Could you show the script?

[email protected] 01-16-2009 01:16 AM

PHP Code:

function onTimeOut()
{
 
canwarp();
 
canwarp2();
 
this.attacker "Graal713758";
  
 if ( 
client.task[3] == "halfway" )
 {  
 
hideimg(200);
  if (
thiso.smovement == "walk")
  {
  
chat this.attacker;
  
this.timer 11;
   if (
this.to_check.x in |this.x-3,this.x+3| && this.to_check.y in |this.y-3,this.y+3|)
    {
      
thiso.smovement "idle";
      
setcharani("idle",NULL);
    } 
       
thiso.smovement "walk";
  
chat thiso.smovement;
        
  if ( 
this.timer 10 )
  { 
   
with findplayer this.attacker ) )
  {
   
this.newDir getdirplayer.this.x,  player.this.);
  }
 } 
 
this.to_check findnearestplayer(this.x,this.y);
   
this.dir this.newDir;
    
this.new_x this.vecx(this.dir) * this.mov_speed;
    
this.new_y this.vecy(this.dir) * this.mov_speed;
    
this.count--;
   if (
this.count 0)
    {
      
this.to_add_x this.new_x 1.5 vecx(this.dir);
      
this.to_add_y this.new_y vecy(this.dir);
     if (
onwall(this.to_add_x,this.to_add_y)) 
      {
        
this.dir = (this.dir+2)%4;
        
this.timer 0;
      } else 
     if (
onwater(this.to_add_x,this.to_add_y)) 
      {
        
setcharani("swim",NULL);
      }else
       {
         
setcharani("spawn_weapon9mm-walk","");
         
this.new_x;
         
this.new_y;
       }
    } else
     {
       
this.count int(random(10,40));
     }
  }
 
 }
    
setTimer(0.05);  



Tigairius 01-16-2009 01:50 AM

Well you shouldn't use 0.05 timeout serverside like that, it wears on the server especially with everything you're trying to do. Use move() instead.

DustyPorViva 01-16-2009 01:54 AM

Quote:

Originally Posted by Tigairius (Post 1457370)
Well you shouldn't use 0.05 timeout serverside like that, it wears on the server especially with everything you're trying to do. Use move() instead.

It defaults to .1, I believe.

Pelikano 01-16-2009 05:16 PM

Yes, I think .05 doesn't work at all serverside.

Also, first you're using:


this.attacker = "Graal713758";

And then:

with ( findplayer ( this.attacker ) )

I think you need to use "findplayerbycommunityname()"

Crow 01-16-2009 06:27 PM

Quote:

Originally Posted by Pelikano (Post 1457459)
Also, first you're using:


this.attacker = "Graal713758";

And then:

with ( findplayer ( this.attacker ) )

I think you need to use "findplayerbycommunityname()"

No. "GraalXXXXXX" are account names, not community names.

[email protected] 01-16-2009 06:27 PM

no @ pelikano

you are using the script as an object right? [putnpc2 script, not level]

Chompy 01-16-2009 07:37 PM

Quote:

Originally Posted by Crow (Post 1457469)
No. "GraalXXXXXX" are account names, not community names.

fiundplayerbycommunityname() can find account names aswell :) It's a function that first looks for account names, then community names.

xXziroXx 01-16-2009 08:12 PM

Quote:

Originally Posted by Chompy (Post 1457487)
fiundplayerbycommunityname() can find account names aswell :) It's a function that first looks for account names, then community names.

Which makes me wonder why the findPlayer() function didn't get replaced with the code from findPlayerByCommunityName().

salesman 01-16-2009 09:39 PM

Quote:

Originally Posted by xXziroXx (Post 1457499)
Which makes me wonder why the findPlayer() function didn't get replaced with the code from findPlayerByCommunityName().

because that would have been logical


All times are GMT +2. The time now is 07:32 PM.

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