Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Bombs and Bows (https://forums.graalonline.com/forums/showthread.php?t=134263223)

mrnothersan 05-14-2011 08:49 PM

Bombs and Bows
 
Can anybody tell me how to add bombs and arrows weapons to my playerworld please? Like the default weapons on Classic iPhone

mrnothersan 05-14-2011 09:38 PM

.....?

fowlplay4 05-14-2011 11:59 PM

You script them.

As *Bow and/or *Bomb, and add them using addweapon to player.

Important Functions:
shootarrow(dir);
putbomb(power, x, y);

Search the forums they're probably out there already.

Tricxta 05-15-2011 12:00 AM

arent there problems with the gmap and default bows and arrows though?

fowlplay4 05-15-2011 12:02 AM

Quote:

Originally Posted by Tricxta (Post 1649747)
arent there problems with the gmap and default bows and arrows though?

On V5, V6 is fine though.

I posted them before here:
http://forums.graalonline.com/forums...36&postcount=3

MattKan 05-15-2011 01:01 AM

I think you can just add yourself Bombs and Bow...

Soala 05-15-2011 01:45 AM

Quote:

Originally Posted by MattKan (Post 1649757)
I think you can just add yourself Bombs and Bow...

You can edit your attributes, but you still need to script the weapon to use them.

cbk1994 05-15-2011 01:50 AM

Quote:

Originally Posted by Soala (Post 1649763)
You can edit your attributes, but you still need to script the weapon to use them.

I could be wrong but I think if you add yourself Bow and Bomb the default ones will work. I would rescript them anyway.

Soala 05-15-2011 02:01 AM

Quote:

Originally Posted by cbk1994 (Post 1649766)
I could be wrong but I think if you add yourself Bow and Bomb the default ones will work. I would rescript them anyway.

How do they work if the wNPC is not on the server? Are default bombs and bow used from a seperate file, like in the level editor?

cbk1994 05-15-2011 02:07 AM

Quote:

Originally Posted by Soala (Post 1649767)
How do they work if the wNPC is not on the server? Are default bombs and bow used from a seperate file, like in the level editor?

Pretty sure it's just something special in the client that makes those work. I could, of course, be wrong.

Admins 05-15-2011 02:42 AM

The default weapons are implemented with built-in scripts, if you want to write a custom one then you need to use a different weapon name.
I'm not sure if we have already posted the default scripts, but they are quite simple, here the bomb and bow:
PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  if (
player.bombs<=0)
    return;
  if (
player.dir==0putbomb(1,player.x+0.5,player.y-1);
  if (
player.dir==1putbomb(1,player.x-1.5,player.y+1);
  if (
player.dir==2putbomb(1,player.x+0.5,player.y+2.5);
  if (
player.dir==3putbomb(1,player.x+2.5,player.y+1);
  
player.bombs--;


PHP Code:

///#CLIENTSIDE
function onWeaponFired() {
  if (
player.darts<=0)
    return;
  
freezeplayer(0.3);
  
setani("shoot","wbow1.png");
  
setTimer(0.25);
}
function 
onTimeout() {
  
shootarrow(player.dir);
  
player.darts--;



mrnothersan 05-19-2011 05:53 PM

what would be the NPC code to add bombs to a player... as in if somebody said "10 bombs" it would add 10 bombs to the player?

mrnothersan 05-19-2011 06:34 PM

does nobody know or does it not exist x_x

Tigairius 05-19-2011 06:35 PM

PHP Code:

function onPlayerChats() {
  if (
player.chat == "10 bombs") {
    
player.bombs += 10;
  }


Would only work in a level. You need to try to look around yourself and figure things out before asking the forums though. :)

mrnothersan 05-19-2011 06:43 PM

Quote:

Originally Posted by Tigairius (Post 1650591)
You need to try to look around yourself and figure things out before asking the forums though. :)

i know i know :p

where would i put the PHP code...

iBeatz 05-19-2011 06:49 PM

PHP Code:

function onCreated(){
  
setshape(1,32,32);   //Set the shape of the NPC serverside so the triggeractions work.
}

function 
onActionGiveBombs(bombrequest){   // Executing the GiveBombs action.
  
if((99 player.bombs) > bombrequest){
    
player.bombs += bombrequest;
    
player.chat "You received "@bombrequest SPC "bombs!";
  }
  else {
    
player.bombs += 99 player.bombs;
  }
}

function 
onActionGiveArrows(arrowrequest){   // Executing the GiveArrows action.
  
if((99-player.darts) > arrowrequest){
    
player.darts += arrowrequest;
    
player.chat "You received "@arrowrequest SPC "arrows!";
  }
  else {
    
player.darts += 99-player.darts;
  }
}

//#CLIENTSIDE

function onCreated(){
  
setshape(1,32,32);
}

function 
onPlayerChats(){
  
temp.tokens player.chat.tokenize();   // Tokenizing each word in the player's chat.
  
if(temp.tokens[0] > && temp.tokens[0] <= 99){   // Checking if the requested amount is more than 0 and less than or equal to 99.
    
if(temp.tokens[1] == "bombs"){   // Checking if the player asked for bombs or arrows.
      
triggeraction(this.x+.5,this.y+.5,"GiveBombs",temp.tokens[0]);   // Triggering the GiveBombs function on the serverside.
    
}
    else if(
temp.tokens[1] == "arrows"){
      
triggeraction(this.x+.5,this.y+.5,"GiveArrows",temp.tokens[0]);   // Triggering the GiveArrows function on the serverside.
    
}
  }


This script adds both bombs and arrows, depending on what the second word is in you chat. It works in a level NPC.
Bombs and arrows can only be added serverside, which is why the triggeractions are placed in the script.
Your welcome.

Tigairius 05-19-2011 06:50 PM

Quote:

Originally Posted by mrnothersan (Post 1650597)
i know i know :p

where would i put the PHP code...

Well, it's not PHP code, it's GScript2. I used PHP tags because we don't have GScript2 tags on the forums unfortunately.

However, to answer your question, you'd place it in a level. Then when you go to the level, you would say "10 bombs".

Tigairius 05-19-2011 06:52 PM

Quote:

Originally Posted by iBeatz (Post 1650599)
This script adds both bombs and arrows, depending on what the second word is in you chat. It works in a level NPC.
Bombs and arrows can only be added serverside, which is why the triggeractions are placed in the script.
Your welcome.

This script is good if bombs/arrows are not a big deal to your server (like, not a major part of the economy or anything), but the script is bad if you don't want players to get 99 free arrows/bombs. I say this, because the triggers in your script on the clientside are insecure, you shouldn't pass the value of bombs/arrows from the clientside because they can be edited with memory editors by players.

iBeatz 05-19-2011 07:06 PM

I did it that way because he did not specify that he wanted gralats to be deducted.
And what in God's name is a memory editor? o_o

Soala 05-19-2011 07:08 PM

Quote:

Originally Posted by iBeatz (Post 1650608)
I did it that way because he did not specify that he wanted gralats to be deducted.
And what in God's name is a memory editor? o_o

A memory editor allows you to edit the game, so it's basically a hack.

iBeatz 05-19-2011 07:14 PM

Quote:

Originally Posted by Soala (Post 1650609)
A memory editor allows you to edit the game, so it's basically a hack.

Gotta love the players... :rolleyes:

mrnothersan 05-19-2011 07:29 PM

Quote:

Originally Posted by Tigairius (Post 1650591)
PHP Code:

function onPlayerChats() {
  if (
player.chat == "10 bombs") {
    
player.bombs += 10;
  }




I didn't say what i meant very clearly... i mean if the the player says "#amount bombs" they get that many... and charge 1 gralat per bomb

mrnothersan 05-19-2011 07:30 PM

Quote:

Originally Posted by iBeatz (Post 1650612)
Gotta love the players... :rolleyes:

Yep >_<

mrnothersan 05-20-2011 02:29 PM

Quote:

Originally Posted by mrnothersan (Post 1650616)
I didn't say what i meant very clearly... i mean if the the player says "#amount bombs" they get that many... and charge 1 gralat per bomb

D: i still dont know >.<...

mrnothersan 05-21-2011 02:39 PM

And I still don't know...

WhiteDragon 05-21-2011 07:35 PM

Quote:

Originally Posted by mrnothersan (Post 1650865)
And I still don't know...

I think you should take a glance at the NPC Scripting forum rules:
"Be clear on your ability level. In other words, do not post asking for scripts, or asking people to fix scripts that are above your ability level. If you are writing a script to aid learning, then try writing a simpler script. If you are looking for a script for a server, then the best solution is probably to hire a scripter."

Tig's script provides a decent base for a solution to your problem. If you want to change gralats, take a look at the variable player.gralats

If you want to split player.chat into two parts, look at the tokenize function.


All times are GMT +2. The time now is 09:39 AM.

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