Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-11-2009, 03:41 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Distributing weapons.

Ok, I have a weapon NPC on the server that has alot of chat commands etc, but currently I have to add it to people for them to have it, what is the easiest method to have the NPC server check and add it to anyone who doesn't have it when they log on?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #2  
Old 04-11-2009, 04:03 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Raelyn View Post
Ok, I have a weapon NPC on the server that has alot of chat commands etc, but currently I have to add it to people for them to have it, what is the easiest method to have the NPC server check and add it to anyone who doesn't have it when they log on?
-Click on your NPCs button (the button on the far left of your NPC-Control).
-Right click Control-NPC and edit the script.
-If the script is blank, add this:
PHP Code:
function onActionPlayerOnline() {
  
player.addWeapon("weapon name");

-If the script is not blank, just add player.addWeapon("weapon name"); in your actionplayeronline function.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 04-11-2009, 05:01 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Tigairius View Post
-Click on your NPCs button (the button on the far left of your NPC-Control).
-Right click Control-NPC and edit the script.
-If the script is blank, add this:
PHP Code:
function onActionPlayerOnline() {
  
player.addWeapon("weapon name");

-If the script is not blank, just add player.addWeapon("weapon name"); in your actionplayeronline function.
Thanks!

Oi, I should start another thread titled "Raelyn's Big List of Questions" since I have about a million more. Such as, what is the GS2 equivalent of the lay and lay2 commands? And why does firing arrows and placing bombs on the gmap seem to not work properly? :P

Also, I have a script for setani is GS1, how would I setani in GS2? And the GS1 version doesn't work in the gmap, only indoor levels, what would cause this?

Thank you.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #4  
Old 04-11-2009, 08:09 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
Simple ani scripts:
PHP Code:
(this.)setcharani("sch_ctfblueidle","null"); //changes the ani of the NPC
//(dont know about null(Serverside only)), this. isnt needed, but I got told to use

replaceani("walk""another_walk"); //to replace the players first gani 
//with a second(Clientside only)

setani("burninair","null"); //changes the ani of the Player
//(dont know about null(Clientside only)) 
Go make that thread, I'll try to help you(1 newb helps the other)
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #5  
Old 04-11-2009, 08:21 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Raelyn View Post
Thanks!

Oi, I should start another thread titled "Raelyn's Big List of Questions" since I have about a million more. Such as, what is the GS2 equivalent of the lay and lay2 commands? And why does firing arrows and placing bombs on the gmap seem to not work properly? :P

Also, I have a script for setani is GS1, how would I setani in GS2? And the GS1 version doesn't work in the gmap, only indoor levels, what would cause this?

Thank you.
"lay", "lay2", "shootarrow", etc. commands are all deprecated commands that were only left for compatibility and are not actually recommended to use.

An example of laying a green rupee could be replicated (depending on your 'gralats' class) with something as simple as:
PHP Code:
with (putnpc2(xy"join gralats;")) {
  
this.type 1// 0 = green, 1 = blue, 2 = red, 3 = gold

Other commands, like shootarrow() can be replicated using a shoot() command.

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
// TServerLevel.shoot(x,y,z,angle,zangle,strength,ani,aniparams)
  
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.zgetangle(vecx(player.dir), vecy(player.dir)), NULLNULL"arrow"NULL);

You would have to make a gani called 'arrow' with an arrow facing all four directions, of course. It's my recommendation that you don't use any of those older commands, and re-script most of that kind of stuff.

Simple animation changes are:
PHP Code:
setCharAni("idle"NULL); // This will set the NPC's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

setAni("idle"NULL); // This will set the player's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

replaceAni("walk""newwalk"); // Replaces 'walk' with 'newwalk'. 
The top two commands for ganis work both clientside and serverside.


If you really need to place bombs on a gmap, I recommend doing something like this:

PHP Code:
temp.mapx player.gmap.name == NULL getmapx(player.level.name) * 64;
temp.mapy player.gmap.name == NULL getmapy(player.level.name) * 64;
putbomb(1temp.mapx xtemp.mapy y); 
Quote:
Originally Posted by Schetti View Post
Simple ani scripts:
PHP Code:
(this.)setcharani("sch_ctfblueidle","null"); //changes the ani of the NPC
//(dont know about null(Serverside only)), this. isnt needed, but I got told to use

setani("burninair","null"); //changes the ani of the Player
//(dont know about null(Clientside only)) 
Go make that thread, I'll try to help you(1 newb helps the other)
Let's not teach bad habits, probably better to leave the teaching to the teachers
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”

Last edited by Tigairius; 04-24-2009 at 02:34 AM.. Reason: Clarification
Reply With Quote
  #6  
Old 04-11-2009, 08:37 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
Quote:
Originally Posted by Tigairius View Post
Let's not teach bad habits, probably better to leave the teaching to the teachers
ok
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #7  
Old 04-11-2009, 11:18 AM
fragman85 fragman85 is offline
Banned
Join Date: Mar 2009
Location: Switzerland
Posts: 261
fragman85 is on a distinguished road
Ah c'mon Schetti just wanted to help him, rofl
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:43 AM.


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