Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   file naming HELP (https://forums.graalonline.com/forums/showthread.php?t=134264419)

blackbeltben 08-30-2011 01:07 PM

file naming HELP
 
Trying to word this is going to be tricky, but i'll give it a go.
The issue i'm having is that I'm trying to make collision for my custom baddie.
Basically, if the baddie reconizes the player.ani is an "ATTACK" gani, it will trigger the event. The ISSUE is that i have more than one ani for attack. (for different weapons)

For example, I have servername_sword_atkblade, servername_sword_atkstaff, etc

How do i make the baddie reconize all GANIs starting with "servername_sword_"?

PHP Code:

if (player.ani "servername_sword_???")
{
 
//blablabla 

Other Note: i DO NOT want to use function onWas.Hit because i am not using default movement system so it doesn't even work.

Gunderak 08-30-2011 01:12 PM

i think this is what your looking for
PHP Code:

if(player.ani.starts("servername_")) { 

Also if your doing an if statement for an equal thing it has to be
PHP Code:

if(whatever.whatever == whatever) { 

im not sure if one equal sign would work but your meant to use two.

blackbeltben 08-30-2011 01:35 PM

PHP Code:

if (player.ani.starts == "servername_sword_")
{
 
scheduleEvent(0.05"onIs.hit"); 

This doesnt work :cry:

Crow 08-30-2011 01:58 PM

Quote:

Originally Posted by blackbeltben (Post 1666237)
PHP Code:

if (player.ani.starts == "servername_sword_")
{
 
scheduleEvent(0.05"onIs.hit"); 

This doesnt work :cry:

PHP Code:

if (player.ani.name.starts("servername_sword_")) 


blackbeltben 08-30-2011 02:21 PM

Quote:

Originally Posted by Crow (Post 1666239)
PHP Code:

if (player.ani.name.starts("servername_sword_")) 




Still doesn't work. And i even tested it with if (player.ani = "sword),
and it DOES trigger the function. The issue is with the player.ani.name.starts thing.

Crow 08-30-2011 02:25 PM

Quote:

Originally Posted by blackbeltben (Post 1666241)
Still doesn't work. And i even tested it with if (player.ani = "sword),
and it DOES trigger the function. The issue is with the player.ani.name.starts thing.

Did you make sure your gani actually starts with "servername_sword_"?

blackbeltben 08-30-2011 02:34 PM

yes. I checked over and over.

fowlplay4 08-30-2011 03:09 PM

You're going to have to include more code than you have in your first post.

Surprisingly enough gunderak gave you the solution to the problem you asked already.

Gunderak 08-30-2011 03:17 PM

are you checking for the if statement on a timeout? or on created?
if you only check for it on the wrong function it wont work.
as fowlplay said, you should post the script here and someone may be able to help you.

Gunderak 08-30-2011 03:19 PM

even if you dont want to check for if the players ani is whatever on a timeout do somthing like this i think.
PHP Code:

function onKeypressed(codekeyscan) {
   if(
key == "s") {
     if(
player.ani.starts("servername_whatever")) { 

also with your if statements, write them as follows.
PHP Code:

if(whatever == whatever) { 

make sure you have two equals signs.
i learnt this from fowlplay :D

blackbeltben 08-30-2011 04:35 PM

aaah, i got it. but HOW would you do a everything "but" if there is no =
You can't put != because it's set up like
(player.ani.name.starts("servername_sword_"))

Last question, what is the importance of adding two equal signs when one works?

Crow 08-30-2011 04:41 PM

Quote:

Originally Posted by blackbeltben (Post 1666251)
aaah, i got it. but HOW would you do a everything "but" if there is no =
You can't put != because it's set up like
(player.ani.name.starts("servername_sword_"))

Last question, what is the importance of adding two equal signs when one works?

You can put the exclamation mark in front of it all, like this:
PHP Code:

if (!player.ani.name.starts("servername_sword_")) 

Also, you need to use two equal signs because a single one doesn't work. Using only a single one you are assigning a value to a variable, or at least trying to do so. If you want to compare stuff, use double equal signs.

Entrok 08-30-2011 04:43 PM

In onCreated put:

PHP Code:

this.ganiname "servername_sword_"

then use

PHP Code:

if (player.ani == this.ganiname "whatever")
{
  
// script



Crow 08-30-2011 04:44 PM

Quote:

Originally Posted by Entrok (Post 1666253)
.

You're not being useful at all, please delete your post.

ffcmike 08-30-2011 07:37 PM

Quote:

Originally Posted by blackbeltben (Post 1666230)
Trying to word this is going to be tricky, but i'll give it a go.
The issue i'm having is that I'm trying to make collision for my custom baddie.
Basically, if the baddie reconizes the player.ani is an "ATTACK" gani, it will trigger the event. The ISSUE is that i have more than one ani for attack. (for different weapons)

For example, I have servername_sword_atkblade, servername_sword_atkstaff, etc

How do i make the baddie reconize all GANIs starting with "servername_sword_"?

PHP Code:

if (player.ani "servername_sword_???")
{
 
//blablabla 

Other Note: i DO NOT want to use function onWas.Hit because i am not using default movement system so it doesn't even work.

If this is a matter of making your baddies receive attacks from the player, it would be inefficient to have every single baddy checking for the players gani, especially should you go on to add multiple different types of attacks later on.
It would be much better to script an area NPCs trigger within the weapon script.

Basic example:

PHP Code:

//#CLIENTSIDE
function swordAttack(){
  
temp.player.0.5 + (vecx(player.dir) * 2);
  
temp.player.+ (vecy(player.dir) * 2);
  
temp.tnpcs findareanpcs(temp.xtemp.y22);
  for(
temp.temp.tnpcs){
    
temp.n.trigger("Slash"player.swordpower);
  }


I personally have a system for handling multiple types of area NPC triggers different attack weapons are communicating with rather than writing this type of code out within each weapon.

What you're attempting to do with checking ganis however is pretty much how the default hit detection works, it's a good way to check for attacks from other players.
What I do for this on Classic is create a static var containing all the different types of attacks as secondary variable names:

PHP Code:

//#CLIENTSIDE
function onCreated(){
  
//function, frames
  
this.attacks = new TStaticVar();
  
this.attacks.nameofswordgani = {"functionToGetAttackData"ArrayOfFrameNums};


Rather than looping through an array of different possible attacks, it is then essentially a matter of doing:

PHP Code:

temp.attack this.attacks.(@ temp.playerobj.ani.name);
if(
temp.attack != NULL){
  
//check the frame number is valid for attacking, NULL means any
  
if(temp.attack[1].index(temp.playerobj.anistep) > -|| temp.attack[1] == NULL){
    
temp.attackdata this.(@ this.attacks[0])(temp.playerobj);
    
//do stuff to check hitboxes based on that data
  
}




All times are GMT +2. The time now is 10:01 AM.

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