Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2011, 02:07 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
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_"?

Graal Script 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.
Reply With Quote
  #2  
Old 08-30-2011, 02:12 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
i think this is what your looking for
Graal Script Code:
if(player.ani.starts("servername_")) { 
Also if your doing an if statement for an equal thing it has to be
Graal Script Code:
if(whatever.whatever == whatever) { 
im not sure if one equal sign would work but your meant to use two.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #3  
Old 08-30-2011, 02:35 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Graal Script Code:
if (player.ani.starts == "servername_sword_")
{
 
scheduleEvent(0.05"onIs.hit"); 
This doesnt work
Reply With Quote
  #4  
Old 08-30-2011, 02:58 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by blackbeltben View Post
Graal Script Code:
if (player.ani.starts == "servername_sword_")
{
 
scheduleEvent(0.05"onIs.hit"); 
This doesnt work
Graal Script Code:
if (player.ani.name.starts("servername_sword_")) 
__________________
Reply With Quote
  #5  
Old 08-30-2011, 03:21 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Quote:
Originally Posted by Crow View Post
Graal Script 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.
Reply With Quote
  #6  
Old 08-30-2011, 03:25 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by blackbeltben View Post
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_"?
__________________
Reply With Quote
  #7  
Old 08-30-2011, 03:34 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
yes. I checked over and over.
Reply With Quote
  #8  
Old 08-30-2011, 04:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #9  
Old 08-30-2011, 04:17 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
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.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 08-30-2011 at 04:30 PM..
Reply With Quote
  #10  
Old 08-30-2011, 04:19 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
even if you dont want to check for if the players ani is whatever on a timeout do somthing like this i think.
Graal Script Code:
function onKeypressed(codekeyscan) {
   if(
key == "s") {
     if(
player.ani.starts("servername_whatever")) { 
also with your if statements, write them as follows.
Graal Script Code:
if(whatever == whatever) { 
make sure you have two equals signs.
i learnt this from fowlplay
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #11  
Old 08-30-2011, 05:35 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
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?
Reply With Quote
  #12  
Old 08-30-2011, 05:41 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by blackbeltben View Post
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:
Graal Script 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.
__________________
Reply With Quote
  #13  
Old 08-30-2011, 05:43 PM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
In onCreated put:

Graal Script Code:
this.ganiname "servername_sword_"
then use

Graal Script Code:
if (player.ani == this.ganiname "whatever")
{
  
// script

Reply With Quote
  #14  
Old 08-30-2011, 05:44 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Entrok View Post
.
You're not being useful at all, please delete your post.
__________________
Reply With Quote
  #15  
Old 08-30-2011, 08:37 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike Send a message via Skype™ to ffcmike
Quote:
Originally Posted by blackbeltben View Post
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_"?

Graal Script 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:

Graal Script 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:

Graal Script 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:

Graal Script 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
  
}

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:57 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.