Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Grabbing of floor? (https://forums.graalonline.com/forums/showthread.php?t=78114)

Knightmare1 12-29-2007 05:24 AM

Grabbing of floor?
 
is there a way to do add items (guns, items, etc.) that are lying on the ground? would i have to make it like this? and so it dissapears.
PHP Code:

//#CLIENTSIDE
function onActionGrab() {
  
clientr.weapon.? = 1;
  
destroy;



Codein 12-29-2007 05:35 AM

Quote:

Originally Posted by Knightmare1 (Post 1366508)
is there a way to do add items (guns, items, etc.) that are lying on the ground? would i have to make it like this? and so it dissapears.
PHP Code:

//#CLIENTSIDE
function onActionGrab() {
  
clientr.weapon.? = 1;
  
destroy;



You'd need to make your own Grab trigger. Also, clientr. flags can't be set clientside.

Angel_Light 12-29-2007 06:41 AM

PHP Code:

function onKeyPressedcodekey)
{

  switch ( 
temp.code)
  {
  
    case 
"65"//a
      
Grab();
    break;
    
  }
}

function 
Grab()
{

  
frontPosition = { player.1.5 vecx(player.dir) * 2player.1.5 vecy(player.dir) * 2};
  
  
canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

  if ( 
canGrab)
    
triggerAction(frontPosition[0], frontPosition[1], "Grabbed"player.accountplayer.guild);



Here what I use, forgot where I got it though. :/

coreys 12-29-2007 06:59 AM

Quote:

Originally Posted by Codein (Post 1366511)
You'd need to make your own Grab trigger. Also, clientr. flags can't be set clientside.

Not...ENTIRELY true...

Angel_Light 12-29-2007 07:09 AM

Quote:

Originally Posted by coreys (Post 1366528)
Not...ENTIRELY true...

please do explain, I know client.vars can be set both and I thought clientr.vars could only be set serverside, for security. :/

coreys 12-29-2007 07:28 AM

You can...sort of set clientr vars clientside
but I think it it acts more like a public variable (a.k.a. without a heading like this. or temp.) that happens to start with "clientr," therefore effectively replacing a real one that may exist.

Anyways, it really is best to use triggeractions for this...

Codein 12-29-2007 04:15 PM

Quote:

Originally Posted by coreys (Post 1366530)
You can...sort of set clientr vars clientside
but I think it it acts more like a public variable (a.k.a. without a heading like this. or temp.) that happens to start with "clientr," therefore effectively replacing a real one that may exist.

Anyways, it really is best to use triggeractions for this...

In the way that he's using clientr. variables, I think he'd want to set them serverside. Either way, even if you can or can't, it'd just be best for him to set them serverside.

cbk1994 12-29-2007 04:36 PM

destroy() not destroy;

Knightmare1 12-29-2007 06:31 PM

Quote:

Originally Posted by Angel_Light (Post 1366526)
PHP Code:

function onKeyPressedcodekey)
{

  switch ( 
temp.code)
  {
  
    case 
"65"//a
      
Grab();
    break;
    
  }
}

function 
Grab()
{

  
frontPosition = { player.1.5 vecx(player.dir) * 2player.1.5 vecy(player.dir) * 2};
  
  
canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

  if ( 
canGrab)
    
triggerAction(frontPosition[0], frontPosition[1], "Grabbed"player.accountplayer.guild);



Here what I use, forgot where I got it though. :/

would that be for the system script? or the item script?

xXziroXx 12-29-2007 06:56 PM

If that's what you're gonna use, it should be clientsided in a system NPC.

coreys 12-29-2007 07:00 PM

Quote:

Originally Posted by Codein (Post 1366585)
In the way that he's using clientr. variables, I think he'd want to set them serverside. Either way, even if you can or can't, it'd just be best for him to set them serverside.

Oh, well yeah, I know.

cbk1994 12-29-2007 08:04 PM

I thought clientr. variables had to be set serverside? Or am I totally wrong?

Either way, I would set something like that serverside.

Knightmare1 12-29-2007 10:05 PM

and in that script that angel made, what would i edit to make it show an icon?

Angel_Light 12-29-2007 10:25 PM

well thats part of a system weapon. For Instance you add this to a weapon.

PHP Code:

//#CLIENTSIDE
function onKeyPressedcodekey)
{

  switch ( 
temp.code)
  {
  
    case 
"65"//a
      
Grab();
    break;
    
  }
}

function 
Grab()
{

  
frontPosition = { player.1.5 vecx(player.dir) * 2player.1.5 vecy(player.dir) * 2};
  
  
canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

  if ( 
canGrab)
    
triggerAction(frontPosition[0], frontPosition[1], "Grabbed"player.accountplayer.guild);



then in a level NPC on the ground you would add this.

PHP Code:


function onCreated()
{

  
setImgimage);
  
setShape116*216*2);

}

function 
onActionGrabbed()
{

  
findPlayerparams0]).addWeaponweapon);

  
destroy();




Knightmare1 12-30-2007 02:18 AM

PHP Code:

function onCreated()
{

  
setImg(this.image);
  
setShape116*216*2);

}

function 
onActionGrabbed()
{

  
findPlayerparams0]).addWeaponweapon);

  
destroy();



could i make the image this.image = "image" in the NPC? im using classes.

cbk1994 12-30-2007 02:49 AM

That script needs some work (I would add logging, etc, and checks to make sure it hasn't already been picked up but not destroyed for some reason.

However, I would do something like

setImg( this.img );

and then

PHP Code:

temp.putnpc2temp.dxtemp.dy"" );
with temp.)
{
  
join"object_dropitem" );
  
this.img "block.png";
  
this.weapon "Staff/Abuse/Major/Bloo/Tool"// shout-out to Bloo



Knightmare1 12-30-2007 04:48 AM

Quote:

Originally Posted by cbkbud (Post 1366737)
That script needs some work (I would add logging, etc, and checks to make sure it hasn't already been picked up but not destroyed for some reason.

However, I would do something like

setImg( this.img );

and then

PHP Code:

temp.putnpc2temp.dxtemp.dy"" );
with temp.)
{
  
join"object_dropitem" );
  
this.img "block.png";
  
this.weapon "Staff/Abuse/Major/Bloo/Tool"// shout-out to Bloo



PHP Code:

temp.putnpc2temp.dxtemp.dy"" );
with temp.)
{
  
join"object_flooritem" );
  
this.img "final_ak47-icon.gif";
  
this.weapon "Guns/AK47";


would that work?

cbk1994 12-30-2007 05:35 AM

Quote:

Originally Posted by Knightmare1 (Post 1366754)
PHP Code:

temp.putnpc2temp.dxtemp.dy"" );
with temp.)
{
  
join"object_flooritem" );
  
this.img "final_ak47-icon.gif";
  
this.weapon "Guns/AK47";


would that work?

Yes, the code you posted earlier had addweapon( weapon ); just change that to addweapon( this.weapon );

Knightmare1 12-30-2007 07:30 AM

Quote:

Originally Posted by cbkbud (Post 1366775)
Yes, the code you posted earlier had addweapon( weapon ); just change that to addweapon( this.weapon );

dam chris, you've done it again. ^^
and is there a way to randomize spawn points once picked up? like
PHP Code:

setlevel2"final_gmap.gmap"randomize(1,200), randomize(1,200) ); 

would this work?

cbk1994 12-30-2007 05:21 PM

I would get rid of the destroy() and add a hide, then sleep, then warp it, and show it.

As for warping it, this.x = random( 0, 200 ) and the same for y. I'll give an example when I get home, hard to script on a phone.

DustyPorViva 12-30-2007 05:46 PM

Quote:

Originally Posted by Knightmare1 (Post 1366790)
dam chris, you've done it again. ^^
and is there a way to randomize spawn points once picked up? like
PHP Code:

setlevel2"final_gmap.gmap"randomize(1,200), randomize(1,200) ); 

would this work?

PHP Code:

temp.spawnpoints={{1,5},{8,2},{9,1},{12,62},{12,6},{15,73},{51,52}};
temp.random=int(random(0,temp.spawnpoints.size());
setlevel2("final_gmap.gmap",temp.spawnpoints[temp.random][0],temp.spawnpoints[temp.random][1]); 


coreys 12-30-2007 06:05 PM

Actually, Dusty, temp.random should just be int(random(0,temp.spawnpoints.size()));
shouldn't it? o.0

Knightmare1 12-30-2007 06:12 PM

PHP Code:

function onCreated()
{

  
setImgthis.img );
  
setShape116*216*);
  
temp.spawnpoints={{ 1,},{ 8,},{ 9,},{ 12,62 },{ 12,},{ 15,73 },{ 51,52 }}; 
  
temp.random=int(random(0,temp.spawnpoints.size()+1);

}

function 
onActionGrabbed()
{

  
findPlayerparams0] ).addWeaponthis.weapon );
  
hide;
  
sleep(540);
  
setlevel2("final_gmap.gmap",temp.spawnpoints[temp.random][0],temp.spawnpoints[temp.random][1]);
  
show;


would this work?

DustyPorViva 12-30-2007 06:14 PM

That it should be... I think... my mind isn't processing so I'm having a hard time double checking if it's right or wrong. I'll go ahead and say you're right.

And no, that won't work. temp. is only accessible in the function it's called in. You're gonna have to change that temp. to a this.

Knightmare1 12-30-2007 06:17 PM

PHP Code:

function onCreated()
{

  
setImgthis.img );
  
setShape116*216*);
  
this.spawnpoints={{ 1,},{ 8,},{ 9,},{ 12,62 },{ 12,},{ 15,73 },{ 51,52 }}; 
  
this.random=int(random(0,this.spawnpoints.size()+1));

}

function 
onActionGrabbed()
{

  
findPlayerparams0] ).addWeaponthis.weapon );
  
hide;
  
sleep(540);
  
setlevel2("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
  
show;
}

/*The script for NPC.

temp.n = putnpc2( temp.dx, temp.dy, "" ); 
with ( temp.n ) 


  join( "flooritem" ); 
  this.img = "icon.type"; 
  this.weapon = "Weapon/Name"; 

}

*/ 

this works?

cbk1994 12-30-2007 08:26 PM

no. setlevel2 is for warping players. Use this.x and this.y

Knightmare1 12-30-2007 08:28 PM

Quote:

Originally Posted by cbkbud (Post 1366888)
no. setlevel2 is for warping players. Use this.x and this.y

what about setting the level?

coreys 12-30-2007 09:04 PM

Hmm, I...think you can do that with setting this.level. I'm not entirely sure, though. I've never really tried it.

cbk1994 12-30-2007 11:42 PM

Quote:

Originally Posted by coreys (Post 1366895)
Hmm, I...think you can do that with setting this.level. I'm not entirely sure, though. I've never really tried it.

Nope. setlevel( name ); for npcs. Still need to set x and y.

Inverness 12-31-2007 03:54 AM

To warp an npc you would use warpto(levelname, x, y);

Knightmare1 01-05-2008 06:58 PM

PHP Code:

function onCreated()
{

  
setImgthis.img );
  
setShape116*216*);
  
this.spawnpoints={{ 1,},{ 8,},{ 9,},{ 12,62 },{ 12,},{ 15,73 },{ 51,52 }}; 
  
this.random=int(random(0,this.spawnpoints.size()+1));

}

function 
onActionGrabbed()
{

  
findPlayerparams0] ).addWeaponthis.weapon );
  
hide;
  
sleep(540);
  
warpto("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
  
show;


so this?

Chompy 01-05-2008 08:46 PM

have you tried it? :p

Knightmare1 01-05-2008 08:53 PM

Quote:

Originally Posted by Chompy (Post 1368263)
have you tried it? :p

nope, because i have no graphics yet.

Chompy 01-05-2008 09:28 PM

Quote:

Originally Posted by Knightmare1 (Post 1368267)
nope, because i have no graphics yet.

use "block.png" ;)

Knightmare1 01-07-2008 02:01 AM

Quote:

Originally Posted by Chompy (Post 1368277)
use "block.png" ;)

i did, it wont work.

Chompy 01-07-2008 10:54 PM

Quote:

Originally Posted by Knightmare1 (Post 1368579)
i did, it wont work.

what didn't work? adding the weapon? we-appearing some where on a gmap?

Knightmare1 01-07-2008 11:03 PM

Quote:

Originally Posted by Chompy (Post 1368702)
what didn't work? adding the weapon? we-appearing some where on a gmap?

LOL i tried to use it on my OSL.

Chompy 01-07-2008 11:15 PM

Quote:

Originally Posted by Knightmare1 (Post 1368708)
LOL i tried to use it on my OSL.

What the ..? You didn't state that anywhere did you? Because of what you said, it seems that you aren't using the script that you posted some posts earlier..

And you don't give info at all, do you? Sorry, can't help you.

projectigi 01-07-2008 11:48 PM

Quote:

Originally Posted by Knightmare1 (Post 1368240)
PHP Code:

function onCreated()
{

  
setImgthis.img );
  
setShape116*216*);
  
this.spawnpoints={{ 1,},{ 8,},{ 9,},{ 12,62 },{ 12,},{ 15,73 },{ 51,52 }}; 
  
this.random=int(random(0,this.spawnpoints.size()+1));

}

function 
onActionGrabbed()
{

  
findPlayerparams0] ).addWeaponthis.weapon );
  
hide;
  
sleep(540);
  
warpto("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
  
show;


so this?

uh well, either its an npc(warpto()) or its a weapon( addWeapon( this.weapon ) ); or what you set @ this.weapon? xD

cbk1994 01-08-2008 12:57 AM

Night, I'll help you with this whenever we're both on if you like.

Post your code.


All times are GMT +2. The time now is 02:07 AM.

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