Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   NPC warping (https://forums.graalonline.com/forums/showthread.php?t=56559)

falco10291029 12-22-2004 04:28 AM

NPC warping
 
I am working on a new battle system for ELemental Kingdoms but I cannot find a way to warp npcs to a level, which is a huge part of it (I have tried a few other ways, to no avail). anyb suggestions (please dont say get a good NAT)?

ZeroTrack 12-22-2004 04:41 AM

Quote:

Originally Posted by falco10291029
I am working on a new battle system for ELemental Kingdoms but I cannot find a way to warp npcs to a level, which is a huge part of it (I have tried a few other ways, to no avail). anyb suggestions (please dont say get a good NAT)?

to my knowledge there are a few ways to do it, canwarp and canwarp2 depending if the npcs are attached to you or are moving. and doing with(getnpc(npcname)) setlevel2 level,x,y; this only works with dbnpc's though

falco10291029 12-22-2004 04:50 AM

I am not using a db npc, its a class npc, that's what makes it hard :(

Slash-P2P 12-22-2004 05:11 AM

use canwarp/canwarp2 and warpto x,y,level;

falco10291029 12-22-2004 05:39 AM

warpto doesnt work except on database npcs :/

ZeroTrack 12-22-2004 05:54 AM

Quote:

Originally Posted by falco10291029
warpto doesnt work except on database npcs :/

this is true , you cant warp local npc's if this is what your trying to do, you have to use canwarp/canwarp2 and either attach it to the player or use move

falco10291029 12-22-2004 06:41 AM

hmm i know the command to attatch to a player i just didnt think it warped with them plus I wqas told that it wasnt a good thing to do. I will try that soon and let you guys know.

Python523 12-22-2004 06:55 AM

NPCs that were layed with putnpc2 can warpto and stuff.

ZeroTrack 12-22-2004 08:08 AM

Quote:

Originally Posted by Python523
NPCs that were layed with putnpc2 can warpto and stuff.

cause they are considered held on the server correct? not local npcs?

Python523 12-22-2004 08:48 AM

Quote:

Originally Posted by ZeroTrack
cause they are considered held on the server correct? not local npcs?

They are considered DB NPCs, so technically, yea.

falco10291029 12-22-2004 09:30 AM

well mine just join the class directly, so that wouldnt work, ill try the attatching. But i'll remeber that putnpc2 thing, maybe make a summoning spell :)

falco10291029 12-23-2004 03:34 AM

hmm, how do i find the npcs id that i want the player to be attached to? i tried a couple ways, like a for loop, but it didnt seem to work.

Loriel 12-23-2004 03:36 AM

The current NPC's ID is stored, unsurprisingly, in the variable
NPC Code:
id

. By extension, you should be able to use
NPC Code:
players[index].id

.

falco10291029 12-23-2004 04:34 AM

ok, i wasnt sure if that worked, because it didnt seem to, i'l lretry it.

falco10291029 12-23-2004 04:40 AM

It attaches, but doesn't warp, here's the script, I can't see what's wrong:
PHP Code:

 else if (players[i].x in |x-3,x+3|&&players[i].y in |y-3,y+3|) {
this.w=int(random(0,1000));
copylevel neutral-battle.nw,neutral-battle#v(this.w).nw;
canwarp;
      
with(players[i]) {
attachplayertoobj 0,id;
setlevel2 neutral-battle#v(this.w).nw,30,20;
detatchplayer;
   }

timeout=1;




Slash-P2P 12-23-2004 06:39 AM

Quote:

Originally Posted by falco10291029
It attaches, but doesn't warp, here's the script, I can't see what's wrong:
PHP Code:

 else if (players[i].x in |x-3,x+3|&&players[i].y in |y-3,y+3|) {
this.w=int(random(0,1000));
copylevel neutral-battle.nw,neutral-battle#v(this.w).nw;
canwarp;
      
with(players[i]) {
attachplayertoobj 0,id;
setlevel2 neutral-battle#v(this.w).nw,30,20;
detatchplayer;
   }

timeout=1;




The first thing thats wrong is not using KSI-GS.

PHP Code:

} else {
if (
players[i].x in |x-3,x+3| && players[i].y in |y-3,y+3|) {
  
this.w=int(random(0,1000));
  
copylevel neutral-battle.nw,neutral-battle#v(this.w).nw;
  
canwarp;
  
with (players[i]) { // don't you mean getplayer(#a(i)) or allplayers[i]
    
attachplayertoobj 0,id;
    
setlevel2 neutral-battle#v(this.w).nw,30,20;
    
detatchplayer;
  }
  
timeout 1;



falco10291029 12-23-2004 07:06 AM

Quote:

// don't you mean getplayer(#a(i)) or allplayers[i]
No. it's meant to look for people on the current level first, then (i dont know why it works this ay but it does) it looks on the rest of the gmap.

Kaimetsu 12-23-2004 07:50 AM

Quote:

Originally Posted by Slash-P2P
The first thing thats wrong is not using KSI-GS

I think you have a strange idea of what KSI-GS is.

Slash-P2P 12-23-2004 08:09 AM

Quote:

Originally Posted by Kaimetsu
I think you have a strange idea of what KSI-GS is.

I think I meant styling.

Kaimetsu 12-23-2004 09:57 AM

Quote:

Originally Posted by Slash-P2P
I think I meant styling.

Styling is a matter of personal preference, there's no right or wrong.

falco10291029 12-23-2004 09:27 PM

Right, now about the script? Help? please? (as for the mods of thsio forum that enjoy closing these type threads: I have tried several ways to get it working, i understand what I'm doing, ect ect, I just can't find the bug in my script)

Loriel 12-23-2004 09:30 PM

Quote:

Originally Posted by falco10291029
I understand what I'm doing, ect ect, I just can't find the bug in my script

That means you do not understand what you are doing.

ZeroTrack 12-23-2004 09:58 PM

Quote:

Originally Posted by Loriel
That means you do not understand what you are doing.

haha this is very true

falco10291029 12-23-2004 11:12 PM

Quote:

That means you do not understand what you are doing.
No, that means I know what i'm doing, but I made a mistake that I didn't realize. Beside,s I mean I made the script, by understand, so I know how it works, i just don't know why it doesnt work (get it?)

CaTigus 12-31-2004 02:26 AM

Quote:

Originally Posted by falco10291029
No, that means I know what i'm doing, but I made a mistake that I didn't realize. Beside,s I mean I made the script, by understand, so I know how it works, i just don't know why it doesnt work (get it?)

NPC Code:

else if (players[i].x in |x-3,x+3|&&players[i].y in |y-3,y+3|) {
this.w=int(random(0,1000));
copylevel neutral-battle.nw,neutral-battle#v(this.w).nw;<-Copylevel requires the folder names example:
copylevel levels/battlelevels/neutral-battle.nw,levels/battlelevels/neutral-battle#v(this.w).nw; and I really recommend making your own folder for these levels.
canwarp;
with(players[i]) {
detatchplayer;
setlevel2 neutral-battle#v(this.w).nw,30,20;
attachplayertoobj 0,id;
}
timeout=1;
}


Tolnaftate2004 12-31-2004 04:54 AM

You misspelled detachplayer.
This probably doesn't fix your problem, but I thought I'd let you know.

falco10291029 12-31-2004 05:02 AM

Quote:

;<-Copylevel requires the folder names example:
Quote:

You misspelled detachplayer.
I will try fixing both of those, and see if it helps.



EDIT:
PHP Code:

else if (players[i].x in |x-3,x+3|&&players[i].y in |y-3,y+3|) { 
this.w=int(random(0,1000)); 
copylevel levels/neutral-battle.nw,levels/neutral-battle#v(this.w).nw//I plan to delete the extra battle levels or have a script do it every now and then; 
canwarp
      
with(players[i]) { 
attachplayertoobj 0,id
setlevel2 neutral-battle#v(this.w).nw,30,20; 
detachplayer
   } 

timeout=1




Doesn't work still, that's the current script, it attaches you to the mold, but doesnt create or warpto the new level, nor make you warp there.

Slash-P2P 12-31-2004 05:50 AM

I suggest instead of creating a random level, you make a database npc to hold the indexes of the levels created. Then when the player ends the battle, erase the level.

You could also have a timeout NPC running in the level. Read the index of the level with #e(#,#,#L) or something and make the script run deletelevel if the playerscount is 0. If the player enters, start the timeout.

falco10291029 12-31-2004 05:53 AM

yes i was considering the second thing in the leve, but figured there isn't a point until I both;

A) Get the script to work.
B) have enough people on that it would matter

CaTigus 12-31-2004 06:17 AM

You could do:
NPC Code:

else if (players[i].x in |x-3,x+3|&&players[i].y in |y-3,y+3|) {
this.w++;
copylevel levels/neutral-battle.nw,levels/neutral-battle#v(this.w).nw;
canwarp;
with(players[i]) {
attachplayertoobj 0,id;
setlevel2 neutral-battle#v(this.w).nw,30,20;
detachplayer;
}
timeout=1;
}


and in levels/neutral-battle.nw put this script exactly:
NPC Code:

if (playerleaves && playercount<0) {
deletelevel #L;
}


But make sure you have a backup of the original neutral battle.
We're deleting the level to make less lag. Now if that doesn't work i'll get online and play with it.

falco10291029 12-31-2004 06:23 AM

The only change you made to the original script was making this.w progressively increase instea dof being random. I tried it just in case and it didn't help, so i went back to the original desing. Again iw on't be deleting the levels with a script until the average playercount is higher (crrently it's 2 :( )

CaTigus 12-31-2004 06:26 AM

It would kind of help if I knew the whole script so I knew what you were trying to do exactly.

falco10291029 12-31-2004 06:42 AM

That is the part of the script that is broken, the fighting system level warp, the overall script is the monster, mold. Posting it would only give noobs a script to copy.

Tolnaftate2004 12-31-2004 07:10 AM

Quote:

Originally Posted by CaTigus
NPC Code:

if (playerleaves && playercount<0) {
deletelevel #L;
}


Can it have a negative playerscount?

falco10291029 12-31-2004 07:15 AM

no i think they meant "==0", and if not, well.....

CaTigus 12-31-2004 07:35 AM

Quote:

Originally Posted by falco10291029
no i think they meant "==0", and if not, well.....

Yeah, Both those would work, == just looks ugly to me.

Slash-P2P 12-31-2004 08:49 AM

Quote:

Originally Posted by CaTigus
Yeah, Both those would work

No.
NPC Code:
if (created || initialized) {
sendtorc Playerscount: #v(playerscount);
}


Returns 0. (DB NPC)
Quote:

Originally Posted by CaTigus
== just looks ugly to me.

Looks perfectly fine to me.

CaTigus 12-31-2004 04:53 PM

Quote:

Originally Posted by Slash-P2P
No.
Looks perfectly fine to me.

Haha, I think it just looks ugly. I'm not going to argue over 2 equal signs with you :p

falco10291029 12-31-2004 07:27 PM

Yes, less arguing more helping my problem :D, this should be working.......

CaTigus 12-31-2004 07:38 PM

If you want to get all the players you're going to need
NPC Code:

for(i=0;i<playerscount;i++) {
with(players[i]) {
script;
}
}


To get serverside NPCs use:
NPC Code:

for(i=0;i<npcscount;i++) {
with(npcs[i]) {
script;
}
}


This works for classes aswell. You can control text's of a class and such with this, possibly warpto in the script, Which I have never tried.
I'm starting to lose understanding of your question.


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

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