Forum

> > Stranded II > Scripts > Arrows hit and stay!
Forums overviewStranded II overview Scripts overviewLog in to reply

English Arrows hit and stay!

20 replies
Page
To the start Previous 1 2 Next To the start

old Arrows hit and stay!

Assassin moder
User Off Offline

Quote
Hi! I make this script today and I need help.

This is for Objects section:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
### arrow
id=55
name=Arrowed
group=stuff
icon=gfx\arrow.png
model=gfx\arrow.b3d
fx=16
scale=0.5
col=1
health=5
mat=wood
autofade=5000
script=start
	on:create{
		timer "self",300000,1,"freearrow";
	}
	on:use {
		find 53;
		freetimers "self";
		free "self";
	}
	on:freearrow {
		free "self";
	}
script=end

And this is for items_weapons section (changing arrow script)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
### Arrow
id=53
name=Arrow
group=ammo
icon=gfx\arrow.bmp
model=gfx\arrow.b3d
fx=16
behaviour=ammo:59,ammo:60,ammo:61
scale=0.5
mat=wood
weight=5
info=Arrow with stone end
damage=16
healthchange=0
script=start
	on:impact{
		$arrowpitch=getpitch("self");
		$arrowyaw=getyaw("self");
		$arrow=create ("object",55);
		$arrowy=impact_y();
		if(impact_ground()==1){$arrowy+=5;}
		else{
		$arrowy+=2;
		}
		setpos "object",$arrow,impact_x(),$arrowy,impact_z();
		setrot "object",$arrow,$arrowpitch,$arrowyaw,0;
	}
script=end

NOTE:This is for my mod if there be some problems!

Can you help me upgrade it? If yes here is list what should be fixed/added

-Pitch and yaw must be corect
-do not cast on flesh units and glass material (drop function)

Anyone help?
edited 1×, last 28.04.12 09:24:18 pm

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
Well, the pitch and the yaw should be correct with the script you wrote. To not cast on flash and glass you can use this script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
on:impact {
			on:impact {
	  $tmp=impact_class();
	  $tmp2=impact_id();
          $arrowpitch=getpitch("self");
          $arrowyaw=getyaw("self");
          $arrow=create ("object",55);
          $arrowy=impact_y();
          if(impact_ground()==1){ $arrowy+=5; }
          else{
          $arrowy+=2;
          }
		if (compare_material($tmp,$tmp2,"flesh")==1){
			skip;
		} elseif (compare_material($tmp,$tmp2,"glass")==1){
		skip;
		} else { 
      setpos "object",$arrow,impact_x(),$arrowy,impact_z();
          setrot "object",$arrow,$arrowpitch,$arrowyaw,0;
}

Sorry if something is wrong.

old Repaired!

Assassin moder
User Off Offline

Quote
Thanks man I'll try it and I report if something is wrong but thanks again

EDIT2: YEAH! I moved some scripts to the right lines! Now it's work perfectly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
on:impact {
		if (impact_first()==1){
			$tmp=impact_class();
			$tmp2=impact_id();
			$arrowpitch=getpitch("self");
			$arrowyaw=getyaw("self");
			$arrowy=impact_y();
         		if(impact_ground()==1){$arrowy+=5;}
          		else{
          		$arrowy+=2;
          		}
			if(compare_material($tmp,$tmp2,"flesh")==1){
				$selfdrop=create ("item",53);
				setpos "item",$selfdrop,impact_x(),impact_y(),impact_z();
				setrot "item",$selfdrop,$arrowpitch,$arrowyaw,0;
			}
			elseif(compare_material($tmp,$tmp2,"glass")==1){
				$selfdrop=create ("item",53);
				setpos "item",$selfdrop,impact_x(),impact_y(),impact_z();
				setrot "item",$selfdrop,$arrowpitch,$arrowyaw,0;
			}else{
			freevar $tmp;
			freevar $tmp2;
			$arrow=create ("object",55);
			setpos "object",$arrow,impact_x(),$arrowy,impact_z();
			setrot "object",$arrow,$arrowpitch,$arrowyaw,0;
 		}
	}
edited 3×, last 30.04.12 02:49:14 pm

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
I'm glad to see you got it. Sorry, I thought you wanted the script to not work while hit flash or glass and not that you wanted to make the item drop when you hit them.

In my opinion: put the drop also to stone and metal material. You should also add this script for spear, clawnspear and other stuff like that.

And, can I use this script on my mod? I'll give you all the credits of course.

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
In addition, it might be worth taking a look at my update of the source code where all this is already implemented...

I have tested the solution above and it works horrible... (because there are some inaccuracies with the impact-command)

Unfortunately it is still in german, but yates_rates has offered to translate some stuff, and I will also take a look what I can do...

old Re: Arrows hit and stay!

Assassin moder
User Off Offline

Quote
O.o ? What is wrong for you with this script?

EDIT: @user Mc Leaf: Yours script is need yours titanium source code! I make this script for somebody who need other aource code like me

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
user Assassin moder has written
O.o ? What is wrong for you with this script?

For example arrows sometimes hanging in the air (e.g. if you just miss an object, or if you hit a tree, which is swaying...).

user Assassin moder has written
EDIT: @user Mc Leaf: Yours script is need yours titanium source code! I make this script for somebody who need other aource code like me

That's a good argument, of course.

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
Mc leaf, I used your titanium mod some time ago and I had a horrible experience in windows 7. Does your mod have already a windows 7 support?

EDITED: And Assassin moder, you should add line "editor=0" for the arrow object. That way the people won't see the arrow in the editor. (just an idea)

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
user Stranded_Guy2910 has written
Mc leaf, I used your titanium mod some time ago and I had a horrible experience in windows 7. Does your mod have already a windows 7 support?

It should be fixed with Version 1.0.1.0:

http://www.file-upload.net/download-4165226/Stranded-2---Titanium-v1.0.1.0.rar.html

But I don't have win7, so I'm not sure about it... (would be nice to know, if it works)

user Assassin moder has written
EDIT: Or this is impossible

Yes, isn't it...?

As I said there are at least some inaccuracies, which have to do with a quite big collision sphere (which is used for detecting a collision).
Also I'm quite sure that there's is no possibility to attach an item simply to an object... Even if there seems to be one, like those berries hanging at a that bush...

Try
1
2
3
swayspeed=1
swaypower=2
behaviour=tree
in the definition of the bush and you'll see what I mean (berries themself don't sway, and also the arrow stucked in a tree).

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
user Mc Leaf has written
user Assassin moder has written
EDIT: Or this is impossible

Yes, isn't it...?

As I said there are at least some inaccuracies, which have to do with a quite big collision sphere (which is used for detecting a collision).
Also I'm quite sure that there's is no possibility to attach an item simply to an object... Even if there seems to be one, like those berries hanging at a that bush...

Try
1
2
3
swayspeed=1
swaypower=2
behaviour=tree
in the definition of the bush and you'll see what I mean (berries themself don't sway, and also the arrow stucked in a tree).


What you can do is to remove the sway of the trees.

I think the only way to make the arrows sway with the trees is to make them as a unit adding animations for them and veryfing the impact for when hitting certain trees (don't set to verify the behaviour "tree" because not all the trees sway), and that would be a very big work for a very simple thing.

EDITED: And of course the arrow can not sway the same way the trees some times.

EDITED2: Thanks Mc leaf, your mod is now working fine. It's amazing but it could be better if there was a translation
edited 1×, last 01.05.12 02:19:48 am

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
user Stranded_Guy2910 has written
What you can do is to remove the sway of the trees.

I think the only way to make the arrows sway with the trees is to make them as a unit adding animations for them and veryfing the impact for when hitting certain trees (don't set to verify the behaviour "tree" because not all the trees sway), and that would be a very big work for a very simple thing.

Quite complicated...

It is much easier to do that with some changes to the source code.

user Stranded_Guy2910 has written
EDITED2: Thanks Mc leaf, your mod is now working fine. It's amazing but it could be better if there was a translation

I'm working on it...

But at the moment I'm busy with some medieval stuff...

old Re: Arrows hit and stay!

Assassin moder
User Off Offline

Quote
Or it's possible to remove wind effect in options But arrows can destroy trees I fix that it's simple

EDIT: Fix tha it's not simple

@user Stranded_Guy2910: I allready add editor=0 in object script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
######################################################### Utiles
### arrow
id=55
name=Arrowed
group=stuff
icon=gfx\arrow.png
model=gfx\arrow.b3d
fx=16
scale=0.5
editor=0
col=2
health=5
mat=wood
autofade=5000
script=start
	on:create{
		timer "self",180000,1,"freearrow";
	}
	on:use {
		find 53;
		freetimers "self";
		free "self";
	}
	on:freearrow {
		free "self";
	}
script=end

### wood arrow
id=56
name=Arrowed Wood
group=stuff
icon=gfx\arrow_wood.png
model=gfx\arrow_wood.b3d
fx=16
scale=0.5
col=2
editor=0
health=5
mat=wood
autofade=5000
script=start
	on:create{
		timer "self",180000,1,"freearrow";
	}
	on:use {
		find 54;
		freetimers "self";
		free "self";
	}
	on:freearrow {
		free "self";
	}
script=end

### spear
id=57
name=Speared
group=stuff
icon=gfx\spear.png
model=gfx\spear.b3d
fx=16
scale=1.3
col=2
editor=0
mat=wood
autofade=5000
script=start
	on:create{
		timer "self",180000,1,"freespear";
	}
	on:use {
		find 52;
		freetimers "self";
		free "self";
	}
	on:freespear {
		free "self";
	}
script=end

Changed disapear time from 5 minutes to 3 minutes

Also when arrow/spear not approve this is can be "destroyed" arrow/spear

Edit:@user Mc Leaf: I had Idea for you titanium

Add lensflares for the sun and when lensflares is not vissible (by the tree, and not in night!) add something like shadow
edited 1×, last 01.05.12 11:56:11 am

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
user Assassin moder has written
Add lensflares for the sun and when lensflares is not vissible (by the tree, and not in night!) add something like shadow

Yeah... there were already lensflares in the official version of s2...

But I temporarily deactivated them, because a had some struggle making the lensflares get dimmed when the sun is behind the clouds...

Shadows aren't supported by bb3d, afaik... But I could check that again.

old Re: Arrows hit and stay!

Assassin moder
User Off Offline

Quote
EDIT: This script is bugged when arrow is casted by Defense Tower How to repair it? please help!
edited 1×, last 04.05.12 08:28:48 pm

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
user Assassin moder has written
EDIT: This script is bugged when arrow is casted by Defense Tower How to repair it? please help!


What happen when the defense tower cast arrows?

I'm having a bug, when you cast your last arrow the script doesn't work, the console says that the $pitch can't be settled because it's related for a item that was already deleted. When I add an "if (playergotitem(53)>0)" the console says me nothing but the script doesn't work.

old Re: Arrows hit and stay!

Mc Leaf
Super User Off Offline

Quote
user Assassin moder has written
EDIT: This script is bugged when arrow is casted by Defense Tower How to repair it? please help!

It doesn't work. You have the lines
1
2
$arrowpitch=getpitch("self");
$arrowyaw=getyaw("self");
in the code. The commands getpitch/getyaw are applied to the item (arrow) which is stored in the players inventory. Shooting the last arrow will cause the same error like caused by the defense tower, because there is no arrow anymore in inventory. Try it. Take some arrows in bagpack and try out the defense tower again... (should be no error in that case) Also you could shoot at a palisade and turn around quickly. Then you'll see, that pitch/yaw of the stucked arrow are depending always on the player's angle...

old Re: Arrows hit and stay!

Stranded_Guy2910
User Off Offline

Quote
user Mc Leaf has written
user Assassin moder has written
EDIT: This script is bugged when arrow is casted by Defense Tower How to repair it? please help!

It doesn't work. You have the lines
1
2
$arrowpitch=getpitch("self");
$arrowyaw=getyaw("self");
in the code. The commands getpitch/getyaw are applied to the item (arrow) which is stored in the players inventory. Shooting the last arrow will cause the same error like caused by the defense tower, because there is no arrow anymore in inventory. Try it. Take some arrows in bagpack and try out the defense tower again... (should be no error in that case) Also you could shoot at a palisade and turn around quickly. Then you'll see, that pitch/yaw of the stucked arrow are depending always on the player's angle...


So... there's no way to fix it?
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview