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 12-03-2008, 04:38 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Custom Projectile

PHP Code:
function onPlayerChats() {
  if (
player.chat == ":destroy")
    
this.destroy();
}
//#CLIENTSIDE
function onCreated() {
  
setimg("era_pl9-bullet.png");
  
setshape(1,32,32);
  
setTimer(0.05);
  
this.owneraccount player.account;
  
this.dird player.dir;
  
this.spread random(-client.spread,client.spread);
  
scheduleevent(5,"Destroy","");
}
function 
onTimeOut() {
  
this.+= vecx(this.dird) + (player.dir in {02} ? this.spread/16 0);
  
this.+= vecy(this.dird) + (player.dir in {13} ? this.spread/16 0);
  
setTimer(0.05);

I am trying to make a custom projectile.
Well, it works fine unill now, the only part that is missing, is the damage part.

Well, I am stuck, how can I make it damage on Hit, without using shoot()?
Reply With Quote
  #2  
Old 12-03-2008, 05:26 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
You'll have to detect in a timeout if the projectile is on a player/npc, and thus... BOOM.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 12-03-2008, 05:26 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
I'd probably do something like this in the timeout loop:

PHP Code:
for (plplayers) {
  if (
this.x in |pl.xpl.3| && this.y in |pl.ypl.y3|) {
    
//hit stuff
  
}

I think you'd do something similar for NPCs.

Last edited by Codein; 12-03-2008 at 07:51 PM..
Reply With Quote
  #4  
Old 12-04-2008, 02:12 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Might be easier or more efficient to use findnearestplayer()
__________________
Reply With Quote
  #5  
Old 12-04-2008, 11:53 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Codein View Post
I'd probably do something like this in the timeout loop:

PHP Code:
for (plplayers) {
  if (
this.x in |pl.xpl.3| && this.y in |pl.ypl.y3|) {
    
//hit stuff
  
}

I think you'd do something similar for NPCs.
You're a genius dude.

Thanks.
Reply With Quote
  #6  
Old 12-04-2008, 12:04 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
PHP Code:
for (temp.0temp.2temp.i++) {
  for (
temp.objnpcs players) {
    if (
this.x in |obj.xobj.3| && this.y in |obj.yobj.y3|) {
      
//hit stuff
    
}
  }

There, now you have a loop for both players and NPC's.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #7  
Old 12-04-2008, 12:13 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by xXziroXx View Post
PHP Code:
for (temp.0temp.2temp.i++) {
  for (
temp.objnpcs players) {
    if (
this.x in |obj.xobj.3| && this.y in |obj.yobj.y3|) {
      
//hit stuff
    
}
  }

There, now you have a loop for both players and NPC's.
Why would I need a loop for the player and for the Projectile?
o_O
Reply With Quote
  #8  
Old 12-04-2008, 12:15 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Pelikano View Post
Why would I need a loop for the player and for the Projectile?
o_O
So you're saying your projectiles will only be able to damage players, and not NPC's? If that's the case, by all means, use Codein's loop, but otherwise you'd need mine.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #9  
Old 12-04-2008, 12:18 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Well, I don't have any NPCs
Reply With Quote
  #10  
Old 12-04-2008, 06:39 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
you will if you're making an era type server, trust me.
Reply With Quote
  #11  
Old 12-04-2008, 06:53 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
I'd also use a gani for the bullet, rather than it being a static image.

Last edited by Codein; 12-04-2008 at 11:31 PM..
Reply With Quote
  #12  
Old 12-13-2008, 08:30 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Well.
Thanks again, I got another question tho:

I am trying to make the projectile destroy after 3 seconds, so I'm using:

scheduleevent(3,"StarDestroy","");

function onStarDestroy() {
triggeraction(this.x + 6/16, this.y + 6/16, "StarDestroy", nil);
}

function onActionStar() {
this.destroy();
}

And it doesnt work x_X, am I triggering it wrong, or what? :o
Reply With Quote
  #13  
Old 12-13-2008, 08:49 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Why are you triggering an action to destroy it? Just destroy it in the function.
Reply With Quote
  #14  
Old 12-14-2008, 12:40 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Uhm..
Well, because when I use this.destroy(); clientside, it doesn't really destroy it o_O
Reply With Quote
  #15  
Old 12-14-2008, 12:51 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Pelikano View Post
Uhm..
Well, because when I use this.destroy(); clientside, it doesn't really destroy it o_O
Then just do something like this:

PHP Code:

function onCreated() {
  
setTimer(3);
}

function 
onTimeout() {
  
destroy();
}
//#CLIENTSIDE

// All your clientside code here 
__________________
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 03:57 PM.


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