Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Showing blood effects only once (https://forums.graalonline.com/forums/showthread.php?t=79985)

Stryke 06-08-2008 03:22 AM

Showing blood effects only once
 
To check if a player has been hit:

PHP Code:

//#CLIENTSIDE
function onActionProjectile()
{
  
triggerserver("weapon"this.name"BloodFX"player.1.25 random(0,0.5), player.random(0,1.5));


To make blood effects

PHP Code:

function onActionserverside()
{
  if (
params[0] == "BloodFX")
  {
    
temp.putnpc2(params[1], params[2], "");
    
temp.i.join("bloodfx");
  }


If I do this, the blood effects appear as much times as the amount of players there are on the level. How do I get around this to only show once? The blood effect is a GANI.

xXziroXx 06-08-2008 03:43 AM

You'll have to show us the script of the class "bloodfx" as well. :)

zokemon 06-08-2008 03:50 AM

I'm pretty sure onActionProjectile is triggered (when clientside) when ever a projectile hits something, not just the client player. Check up info on projectiles on the wiki as well as check out the tokens in the params variable (while in the onActionProjectile block).

Stryke 06-08-2008 03:51 AM

Sure. :)

PHP Code:

function onCreated()
{
  
drawoverplayer();
  
layer=2;
  
setshape(1,1,1);
  
this.show();
  
sleep(2);
  
this.destroy();
}

//#CLIENTSIDE
function onCreated()
{
  
drawoverplayer();
  
layer=2;
  
this.int int(random(0,3)+1);
  
setcharani("bulletfx",NULL,NULL,NULL,9,5,4,NULL);
  
setshape(1,1,1);


The 3 first parameters are the bullet effects when it hits a wall.
The next 3 are the blood effects.. The 7th param is the sound effect.

All the params = index of sprite/sound.

cbk1994 06-08-2008 03:53 AM

Quote:

Originally Posted by zokemon (Post 1395358)
I'm pretty sure onActionProjectile is triggered (when clientside) when ever a projectile hits something, not just the client player. Check up info on projectiles on the wiki as well as check out the tokens in the params variable (while in the onActionProjectile block).

That's onActionProjectile2() I believe.

DustyPorViva 06-08-2008 03:54 AM

Use showimgs, why putnpcs for blood effects?

cbk1994 06-08-2008 03:55 AM

Quote:

Originally Posted by DustyPorViva (Post 1395361)
Use showimgs, why putnpcs for blood effects?

It's a GANI.

Why not set it as a player attr?

Stryke 06-08-2008 04:05 AM

if(actionprojectile2) is the one that triggers when it hits anything. Not just the player. That's why I am using a testplayer() to see if it the player or not.

@cbk1994: How would that work?

PHP Code:

new GuiShowImgCtrl("BloodFX") {
  
player.x;
  
player.y;
  
width 8;
  
height 8;
  
ani "bloodfx";
  
this.attr[5] = 9;
  
this.attr[6] = 5;
  
this.attr[7] = 4;


You mean something like this will work ?

DustyPorViva 06-08-2008 04:08 AM

Quote:

Originally Posted by cbk1994 (Post 1395362)
It's a GANI.

Why not set it as a player attr?

I guess, after going over it I can tell he's doing something very similar to Era's... I guess that would work. At first I was assuming he was going to be leaving blood on the level.

zokemon 06-08-2008 04:12 AM

Quote:

Originally Posted by Stryke (Post 1395364)
if(actionprojectile2) is the one that triggers when it hits anything. Not just the player. That's why I am using a testplayer() to see if it the player or not.

@cbk1994: How would that work?

PHP Code:

new GuiShowImgCtrl("BloodFX") {
  
player.x;
  
player.y;
  
width 8;
  
height 8;
  
ani "bloodfx";
  
this.attr[5] = 9;
  
this.attr[6] = 5;
  
this.attr[7] = 4;


You mean something like this will work ?

No, you would need an actual TShowImg on the level board.

cbk1994 06-08-2008 04:26 AM

Quote:

Originally Posted by Stryke (Post 1395364)
How would that work?

player.attr[ 13 ] = "mybloodgani.gani";

would probably work.

If not, showani( 1, "mybloodgani", player.x, player.y ); may.

Stryke 06-08-2008 04:46 AM

Woah, didn't know there a showani() command. Thanks i'll try it.
It automatically deletes itself after being played, right?

cbk1994 06-08-2008 04:49 AM

Quote:

Originally Posted by Stryke (Post 1395374)
Woah, didn't know there a showani() command. Thanks i'll try it.
It automatically deletes itself after being played, right?

I don't think so.

Might want to do this:

PHP Code:

function showBlood()
{
  
showani( [...] );
  
scheduleventlength"GaniEnded""" );
}
function 
onGaniEnded()
{
  
hideimg);


EDIT:

Here are the showani params.

showani( index, x, y, direction, animation, params );

So something like

PHP Code:

showani1player.xplayer.y2"mybloodani""" ); 


Stryke 06-08-2008 05:00 AM

The scheduleevent doesn seem to work it keeps playing over and over again...

PHP Code:

if(actionprojectile2)
{
  
temp.pl GetPlayerIndex(#p(0), #p(1)); 
  
if(temp.pl 0)
  {
    
this.int int(random(0,3)+1);
    
showani(1,#p(0),#p(1),2,"bulletfx",1,2,3,NULL,NULL,NULL,"ricochet" @ this.int @ ".wav");
    
scheduleventlength "GaniEnded""" );
  } else {
  }
}
function 
onGaniEnded()
{
  
hideimgs);


NVM IT WAS SPELT WRONG LOL
THANKS MAN +rep osht cant..

cbk1994 06-08-2008 05:07 AM

Why do you use a combination of GS1 and GS2?

function onActionProjectile()

Also, replace 'length' with the time ...

Stryke 06-08-2008 05:19 AM

onActionProjectile only detects when hit on player.
if(actionprojectile2) detects when it hits anything.

cbk1994 06-08-2008 05:29 AM

Quote:

Originally Posted by Stryke (Post 1395379)
onActionProjectile only detects when hit on player.
if(actionprojectile2) detects when it hits anything.

I'm talking about your combination of GS1 and GS2.

function onActionProjectile() = if (actionprojectile)

function onActionProjectile2() = if(actionprojectile2)

params[0] = #p(0)

Stryke 06-08-2008 06:47 AM

For params part, #p(0) is shorter than params[0].
About the projectile2 part, it didn't work for me, but now it does. Thanks.

cbk1994 06-08-2008 06:52 AM

Quote:

Originally Posted by Stryke (Post 1395402)
For params part, #p(0) is shorter than params[0]

Who cares if it's shorter? X_X

It's ugly and makes little sense.

xXziroXx 06-08-2008 12:39 PM

Not to mention that if GS1 ever gets removed, your scripts will go BOOM.

Crow 06-08-2008 12:43 PM

Quote:

Originally Posted by xXziroXx (Post 1395424)
Not to mention that if GS1 ever gets removed, your scripts will go BOOM.

GS1 won't be removed, Stefan stated that. GS1 support itself kinda is removed already, but the syntax is still working. Though you should still not mix GS1 with GS2.

xXziroXx 06-08-2008 12:44 PM

Quote:

Originally Posted by Crow (Post 1395425)
GS1 won't be removed, Stefan stated that. GS1 support itself kinda is removed already, but the syntax is still working. Though you should still not mix GS1 with GS2.

I said if..

cbk1994 06-08-2008 05:55 PM

I've also read on the Wiki, though I can't find it now, that you should avoid mixing GS1 and GS2.

TheStan 06-08-2008 07:57 PM

Quote:

Originally Posted by Stryke (Post 1395402)
For params part, #p(0) is shorter than params[0].
About the projectile2 part, it didn't work for me, but now it does. Thanks.

That doesn't mean anything, we're talking about functionality and proper coding. You should never mix GS1 with GS2 in the case of many things such as with what ziro said in the case GS1 is removed.

Besides that it's just weird and improper coding!

zokemon 06-08-2008 08:05 PM

Message codes for the win!


All times are GMT +2. The time now is 11:05 PM.

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