Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   [Broken(?)] shootarrow/nuke/ect (https://forums.graalonline.com/forums/showthread.php?t=134258038)

Deas_Voice 02-16-2010 10:03 PM

[Broken(?)] shootarrow/nuke/ect
 
i was making a weapon script with shootarrow() today, and i noticed that, it wont shoot correctly, it doesnt follow the player.
however, this seems to work on UN, i dont know why, but i guess it's because it got gs1 enabled still(?) x_x.

either stefan fixes this, we better come up with a workaround for all types of shoot*()..
:mad:

xAndrewx 02-16-2010 10:06 PM

HTML Code:

Shootarrow(dir);
Just shoots an arrow in the direction...

You're probably thinking of a custom projectile using the command shoot().

Deas_Voice 02-16-2010 11:45 PM

Quote:

Originally Posted by xAndrewx (Post 1556556)
HTML Code:

Shootarrow(dir);
Just shoots an arrow in the direction...

that's what im trying to do. i update the weapon, i shoot using onWeaponFired(), it shoots at the player's x/y, but if i move, it doesnt follow the player.
Quote:

Originally Posted by xAndrewx (Post 1556556)
You're probably thinking of a custom projectile using the command shoot().

no im not.

(i'm not an idiot or a newby scripter.)

Immolate 02-16-2010 11:49 PM

Quote:

Originally Posted by Deas_Voice (Post 1556584)
that's what im trying to do. i update the weapon, i shoot using onWeaponFired(), it shoots at the player's x/y, but if i move, it doesnt follow the player.

So, for example, you shoot an arrow at point A(30, 30) and then move to, say, point B(20, 20) the arrow still shoots from point A?

Deas_Voice 02-16-2010 11:52 PM

Quote:

Originally Posted by Immolate (Post 1556585)
So, for example, you shoot an arrow at point A(30, 30) and then move to, say, point B(20, 20) the arrow still shoots from point A?

yes, until you update the weapon, then it's shooting from point B, but if u move again, it will remain at point B.

DustyPorViva 02-16-2010 11:52 PM

Not sure what you mean by "following the player".

DustyPorViva 02-16-2010 11:55 PM

From what I remember, the old shootX()'s work off the NPC's x/y instead of the player's.

Something like:

this.x = player.x;
this.y = player.y;
shootarrow(player.dir);

might work. However, I'm pretty sure you don't need to take precautions like this(as WNPC's should by, default, be positioned at the player's x/y). Default bows are actually scripted and simply use shootarrow(player.dir).

Immolate 02-16-2010 11:56 PM

Quote:

Originally Posted by Deas_Voice (Post 1556587)
yes, until you update the weapon, then it's shooting from point B, but if u move again, it will remain at point B.

Works perfectly fine for me on Testbed? :confused:

Deas_Voice 02-16-2010 11:57 PM

Quote:

Originally Posted by DustyPorViva (Post 1556590)
From what I remember, the old shootX()'s work off the NPC's x/y instead of the player's.

Something like:

this.x = player.x;
this.y = player.y;
shootarrow(player.dir);

might work. However, I'm pretty sure you don't need to take precautions like this(as WNPC's should by, default, be positioned at the player's x/y). Default bows are actually scripted and simply use shootarrow(player.dir).

yes, i know about the bow, but i need shootnuke, shootfireball, ect too.
i don't see how setting this.x/y to player's x/y is going to change the shootarrow, but i'll try that tomorrow anyway.

xAndrewx 02-16-2010 11:57 PM

HTML Code:

//#CLIENTSIDE
function onWeaponFired() {
  shootarrow(player.dir);
}

This works fine... what's your script?

Deas_Voice 02-16-2010 11:59 PM

Quote:

Originally Posted by xAndrewx (Post 1556597)
HTML Code:

//#CLIENTSIDE
function onWeaponFired() {
  shootarrow(player.dir);
}

This works fine... what's your script?

PHP Code:

//#CLIENTSIDE
public function apply(itemid) {
  
shootarrow(player.dir);


apply is the same as onWeaponFired() but, on Aeon.

DustyPorViva 02-17-2010 12:01 AM

Quote:

Originally Posted by Deas_Voice (Post 1556596)
yes, i know about the bow, but i need shootnuke, shootfireball, ect too.
i don't see how setting this.x/y to player's x/y is going to change the shootarrow, but i'll try that tomorrow anyway.

Well back in the day, bows like the super bow(which fire 4 arrows of all types in a row) would change the position of the weapon NPC in relation to the player, to change the placement of the arrow. So doing something like:

PHP Code:

if (weaponfired) {
  
shootarrow playerdir;
  
playery 1;
  
shootnuke playerdir;
  
playery 1;
  
shootfireball playerdir;


Would make the arrow shoot normally, with a fireball above it and a nuke below it.

However, I'm not even sure that will work anymore as I'm pretty sure Stefan make this.x/y not accessible via script in WNPCs since a lot of old weapon scripts used those without intending to alter the position of the weapon's x/y.

DustyPorViva 02-17-2010 12:02 AM

Quote:

Originally Posted by Deas_Voice (Post 1556600)
PHP Code:

//#CLIENTSIDE
public function apply(itemid) {
  
shootarrow(player.dir);


apply is the same as onWeaponFired() but, on Aeon.

Try changing that to just onWeaponFired() and seeing if it fixes it. May just be a problem with the two NPC's(the one calling the function and the one with the public function) having different positions.

xAndrewx 02-17-2010 12:02 AM

Are you using a custom movement that doesn't involve player.x and player.y? [Don't know why- but that's all I can think of]

Deas_Voice 02-17-2010 12:05 AM

Quote:

Originally Posted by DustyPorViva (Post 1556603)
Try changing that to just onWeaponFired() and seeing if it fixes it. May just be a problem with the two NPC's(the one calling the function and the one with the public function) having different positions.

well, i can't do onWeaponFired(), unless i make a trigger for it, or remove all the systemscripts from my attributes (witch i dont have time for right now).

DustyPorViva 02-17-2010 12:07 AM

Quote:

Originally Posted by Deas_Voice (Post 1556607)
well, i can't do onWeaponFired(), unless i make a trigger for it, or remove all the systemscripts from my attributes (witch i dont have time for right now).

Well you'll need to show all scripts involved in firing this weapon, and their type(WNPC/class) for anyone to really know what's going on.

Immolate 02-17-2010 12:13 AM

What ever I do, I can't seem to recreate your problem. This is weird.

DustyPorViva 02-17-2010 12:16 AM

Quote:

Originally Posted by Immolate (Post 1556614)
What ever I do, I can't seem to recreate your problem. This is weird.

I think it has a lot to do with whatever set-up he is using with the public functions and such.

Immolate 02-17-2010 12:28 AM

Quote:

Originally Posted by DustyPorViva (Post 1556615)
I think it has a lot to do with whatever set-up he is using with the public functions and such.

I think so too. It just confuses me how they've managed to set up systems which would allow that to happen. Chances are that another weapon is calling that public function, so the x/y should always be the same (player.x/y) no matter what. It's also strange how it's only updating when the weapon containing the public function is updated, so it doesn't SEEM to be originating from the calling script.

xXziroXx 02-17-2010 01:48 AM

Did you use it on a GMAP? 'Cause they don't work on GMAP's.

DustyPorViva 02-17-2010 01:50 AM

Quote:

Originally Posted by xXziroXx (Post 1556628)
Did you use it on a GMAP? 'Cause they don't work on GMAP's.

The only bug with projectiles on gmaps are that they loop around the level. They still shoot correctly from the player.

fowlplay4 02-17-2010 02:01 AM

Quote:

Originally Posted by DustyPorViva (Post 1556629)
The only bug with projectiles on gmaps are that they loop around the level. They still shoot correctly from the player.

Which is fixed in v6 :3

Deas_Voice 02-17-2010 05:16 PM

i am using this on gmap and a singel level, V6 does not fix this, i haven't tested the windows version, so i only got the unupdated linux version.
yes, anoter weapon is caling the public function, but i dont see how that should be a problem, i mean, if i was to make a weapon that triggerd another weapon, would it break then?

Immolate 02-17-2010 05:18 PM

Quote:

Originally Posted by Deas_Voice (Post 1556732)
i am using this on gmap and a singel level, V6 does not fix this, i haven't tested the windows version, so i only got the unupdated linux version.
yes, anoter weapon is caling the public function, but i dont see how that should be a problem, i mean, if i was to make a weapon that triggerd another weapon, would it break then?

That's not what I was getting at, to be honest. Try it on Windows anyway and feedback.

Deas_Voice 02-17-2010 05:19 PM

Quote:

Originally Posted by Immolate (Post 1556733)
That's not what I was getting at, to be honest. Try it on Windows anyway and feedback.

FYI, it's broken in v5, no matter what OS you got.

Immolate 02-17-2010 06:35 PM

Quote:

Originally Posted by Deas_Voice (Post 1556734)
FYI, it's broken in v5, no matter what OS you got.

Are you 100% sure? As in, tested it on Windows as I said?

Deas_Voice 02-17-2010 07:20 PM

Quote:

Originally Posted by Immolate (Post 1556748)
Are you 100% sure? As in, tested it on Windows as I said?

i don't see how this would be linux's fault, because it's not.
(currently booted in windows, tried in v5 and v6, both broken.)

Immolate 02-17-2010 07:36 PM

Quote:

Originally Posted by Deas_Voice (Post 1556758)
i don't see how this would be linux's fault, because it's not.
(currently booted in windows, tried in v5 and v6, both broken.)

I was covering all bases. I wasn't saying it was a fault with Linux, just asking you to check if it was a problem with the Linux graal client.

xAndrewx 02-17-2010 08:52 PM

Quote:

Originally Posted by xAndrewx (Post 1556597)
HTML Code:

//#CLIENTSIDE
function onWeaponFired() {
  shootarrow(player.dir);
}

This works fine... what's your script?

Can you do this again but remove all the Aeon stuff so that you're using default Graal systems. If there is an error it's your playerworld / client, if not it's Aeon. :)

DustyPorViva 02-17-2010 08:54 PM

You still haven't shown us the scripts doing this. I mean if you don't want to, fine, but it just makes it nearly impossible for anyone to see what's going on.

Deas_Voice 02-18-2010 09:16 AM

Quote:

Originally Posted by DustyPorViva (Post 1556777)
You still haven't shown us the scripts doing this. I mean if you don't want to, fine, but it just makes it nearly impossible for anyone to see what's going on.

that's because i can't show the script that triggers the public function; it's in another weapon, and i dont have access to it.

sorry.
i'll try to replicate it on testbed.

**EDIT**
it was quite easy to replicate, i only had to try once.

Public/Deas_Voice/Weapon:
(When you update this script, it goes to player's x/y, but if u move, it stays at that x/y)
PHP Code:

//#CLIENTSIDE
public function use() {
  
shootarrow(player.dir);


Public/Deas_Voice/WeaponTrigger:
(this is the wnpc you use to trigger the Weapon)
PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  (
"Public/Deas_Voice/Weapon").use();


PS. these two exists on Testbed.

*Edit2: I've added "shootfireball(player.dir);" to the WeaponTrigger (on Testbed) because i want to show how it should look like.

Immolate 02-18-2010 11:26 AM

Quote:

Originally Posted by Deas_Voice (Post 1556949)
that's because i can't show the script that triggers the public function; it's in another weapon, and i dont have access to it.

sorry.
i'll try to replicate it on testbed.

**EDIT**
it was quite easy to replicate, i only had to try once.

Public/Deas_Voice/Weapon:
(When you update this script, it goes to player's x/y, but if u move, it stays at that x/y)
PHP Code:

//#CLIENTSIDE
public function use() {
  
shootarrow(player.dir);


Public/Deas_Voice/WeaponTrigger:
(this is the wnpc you use to trigger the Weapon)
PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  (
"Public/Deas_Voice/Weapon").use();


PS. these two exists on Testbed.

*Edit2: I've added "shootfireball(player.dir);" to the WeaponTrigger (on Testbed) because i want to show how it should look like.

The problem is fixed if you some how get the code you can't access changed to use triggers instead of calling a public function.

Deas_Voice 02-18-2010 04:32 PM

Quote:

Originally Posted by Immolate (Post 1556958)
The problem is fixed if you some how get the code you can't access changed to use triggers instead of calling a public function.

but that will change the function to "onApply()" which is madness to do now, because you have to change all other scripts to that, just for the shootarrow/nuke/ect to work..

Immolate 02-18-2010 04:33 PM

Quote:

Originally Posted by Deas_Voice (Post 1557020)
but that will change the function to "onApply()" which is madness to do now, because you have to change all other scripts to that, just for the shootarrow/nuke/ect to work..

Not hard to do by script.

DrakilorP2P 02-19-2010 02:51 AM

Quote:

Originally Posted by Deas_Voice (Post 1557020)
but that will change the function to "onApply()" which is madness to do now, because you have to change all other scripts to that, just for the shootarrow/nuke/ect to work..

If it means less changes, try triggering something like onWakeUp.

Deas_Voice 02-19-2010 10:38 AM

Quote:

Originally Posted by DrakilorP2P (Post 1557154)
If it means less changes, try triggering something like onWakeUp.

how do you mean?
where do you want to to make a trigger?

DrakilorP2P 02-19-2010 11:29 AM

Quote:

Originally Posted by Deas_Voice (Post 1557202)
how do you mean?
where do you want to to make a trigger?

Same place that calls apply().

Admins 02-19-2010 12:54 PM

shootarrow() takes the position of the npc/weapon that shoots the arrow. Weapons are automatically moved to the player position. You cannot change the weapon position if you are on a gmap.
About triggering another weapon: If you call the function of the other weapon directly it is not syncing the position, only if the weapon receives an event (onWeaponFired, trigger etc.). I suggest using a simple approach and calling shootarrow in the original weapon script (or pass the weapon object to the other function and then call callerweapon.shootarrow()).

Deas_Voice 02-19-2010 03:59 PM

uhh, okey.

well it got solved by doing trigger in the public function, then do shootarrow() in that function.
thanks maui.
~and the rest of you.


All times are GMT +2. The time now is 10:48 PM.

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