Graal Forums

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

Unkownsoldier 02-02-2009 07:47 PM

Little help.
 
Alright so what I need added onto this is a script that allows me to take .5 out of a players health in a given range of 1,1..

Heres what I have so far.


//#CLIENTSIDE

//up
if (playerdir=0){
this.x=playerx-10;
this.y=playery-20;
}
//left
if (playerdir=1){
this.x=playerx-10;
this.y=playery-10;
}
//down
if (playerdir=2){
this.x=playerx+0.4;
this.y=playery+10;
}
//right
if (playerdir=3){
this.x=playerx-10;
this.y=playery-10;
}
function onKeyPressed(c, k) {
if (k == "a") {
replaceani("idle", "idle");
replaceani("walk", "walk");
setani("idle", NULL);
}
}

if (weaponfired) {
setani pancho_katana-attack,;
replaceani idle,pancho_katana-idle;
replaceani walk,pancho_katana-walk;
hurtplayer(.5);


}

Soala 02-02-2009 07:51 PM

so you want your script to actually take out .5 health from a player when you use the katana ? Because actually all it would do would be to hurt the player using the katana =P

Unkownsoldier 02-02-2009 07:59 PM

I would like it to take out damage on another player.

Schetti 02-02-2009 08:35 PM

just an idea, but what would be with something like:

if (weaponfired) {this.account=player.account;
setani pancho_katana-attack,;
replaceani idle,pancho_katana-idle;
replaceani walk,pancho_katana-walk;

}
function onPlayerTouchsme() {
if (player.account ==! this.account)
hurtplayer(.5);
}



just an idea, and makes this roll on, I hope ^^

Unkownsoldier 02-02-2009 09:07 PM

Nah soz man that doesnt work, if you can't make it hurt the other person I understand but can you tell me how to make the other person do a gani when they are hit.

cbk1994 02-02-2009 09:32 PM

This is the katana script:
PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  
temp.dx player.vecx(player.dir) * 1.5;
  
temp.dy player.vecy(player.dir) * 2;
  
triggeraction(dxdy"AttackPlayer"player.account.5);


Put this in a script that all players have:

PHP Code:

//#CLIENTSIDE
function onActionAttackPlayer(accdamage) {
  if (
acc == player.account) {
    return; 
// this ends the function
  
}
  if (
damage <= 0) {
     return;
  }
  
  
hurt(damage);
  
setAni("HURTGANI"null);


Let me know if you need anything explained.

Soala 02-02-2009 09:32 PM

Quote:

Originally Posted by Unkownsoldier (Post 1462264)
Nah soz man that doesnt work, if you can't make it hurt the other person I understand but can you tell me how to make the other person do a gani when they are hit.

Go in your offline editor, put a simple NPC (a character actually) and give him everything (attack, etc...) then double click it, and study !

Unkownsoldier 02-02-2009 10:20 PM

Still doesnt work but I will try experimenting

//#CLIENTSIDE

//up
if (playerdir=0){
this.x=playerx-10;
this.y=playery-20;
}
//left
if (playerdir=1){
this.x=playerx-10;
this.y=playery-10;
}
//down
if (playerdir=2){
this.x=playerx+0.4;
this.y=playery+10;
}
//right
if (playerdir=3){
this.x=playerx-10;
this.y=playery-10;
}
function onKeyPressed(c, k) {
if (k == "a") {
replaceani("idle", "idle");
replaceani("walk", "walk");
setani("idle", NULL);
}
}

if (weaponfired) {
setani pancho_katana-attack,;
replaceani idle,pancho_katana-idle;
replaceani walk,pancho_katana-walk;

}





function onWeaponFired() {
temp.dx = player.x + vecx(player.dir) * 1.5;
temp.dy = player.y + vecy(player.dir) * 2;
triggeraction(dx, dy, "AttackPlayer", player.account, .5);
}

function onActionAttackPlayer(acc, damage) {
if (acc == player.account) {
return; // this ends the function
}
if (damage <= 0) {
return;
}

hurt(damage);
setAni("HURTGANI", null);
}

cbk1994 02-03-2009 12:42 AM

Look closely at what I posted. There are two scripts there.

Programmer 02-03-2009 01:05 AM

Quote:

Originally Posted by Unkownsoldier (Post 1462296)
Still doesnt work but I will try experimenting

PHP Code:

//#CLIENTSIDE

//up
if (playerdir=0){
this.x=playerx-10;
this.y=playery-20;
}
//left
if (playerdir=1){
this.x=playerx-10;
this.y=playery-10;
}
//down
if (playerdir=2){
this.x=playerx+0.4;
this.y=playery+10;
}
//right
if (playerdir=3){
this.x=playerx-10;
this.y=playery-10;
}
function 
onKeyPressed(ck) {
if (
== "a") {
replaceani("idle""idle");
replaceani("walk""walk");
setani("idle"NULL);
}
}

if (
weaponfired) {
setani pancho_katana-attack,;
replaceani idle,pancho_katana-idle;
replaceani walk,pancho_katana-walk;

}





function 
onWeaponFired() {
  
temp.dx player.vecx(player.dir) * 1.5;
  
temp.dy player.vecy(player.dir) * 2;
  
triggeraction(dxdy"AttackPlayer"player.account.5);
}  

function 
onActionAttackPlayer(accdamage) {
  if (
acc == player.account) {
    return; 
// this ends the function
  
}
  if (
damage <= 0) {
     return;
  }
  
  
hurt(damage);
  
setAni("HURTGANI"null);



Can you please encapsulate your code in [php] tags? This makes it easier to read and to understand. Thanks.

osrs 02-03-2009 03:32 AM

Use '==' when comparing two values for equality.
Use '=' when assigning a value to a variable.

Also, read: http://forums.graalonline.com/forums...ad.php?t=53858

Ronnie 02-03-2009 06:35 PM

Also unknownsoldier , it would be good if you had a specific weapon that all players had that you can add all the clientside effects which weapons do and such on the server your working for if they have one or not. Helps keep everything organized. And chris's script should work fine I just tested it.


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

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