Forum

> > Stranded II > Scripts > Carving rocks into water rocks?
Forums overviewStranded II overview Scripts overviewLog in to reply

English Carving rocks into water rocks?

13 replies
To the start Previous 1 Next To the start

old Carving rocks into water rocks?

Ayrk
User Off Offline

Quote
I tried and tried... but have no clue on how to make this work; the last thing I did was this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### Rock
id=63
name=Rock
group=stone
icon=gfx\rock01.bmp
model=gfx\rock01.b3d
scale=4
detailtex=1
mat=stone
health=200
find=22,5,1
find=21,90,7
find=23,300,1,1,88
script=start
	on:kill {
		alterobject "self",74,getx("self"),getz("self"),3;
		corona getx("self"),getz("self");
	}
script=end

So... where's my error?

old Re: Carving rocks into water rocks?

DC
Admin Off Offline

Quote
He's trying to tell you that you are calling the command alterobject with the wrong parameters. Alterobject exepects just 2 parameters: The instance ID of they object you want to alter (or "self" for the current object) and the object type ID you want to alter it to. You could change a rock to a tree for instance. You just have to specify which object (the rock) you want to alter and to what (a tree).

You however are calling it with 5 parameters which doesn't make any sense:
• 1: "self"
• 2: 74
• 3: getx("self")
• 4: getz("self")
• 5: 3

Also I'm not sure if alterobject makes much sense / works properly when you call it on kill.
So what exactly are you trying to do? Please give us more information.

old Re: Carving rocks into water rocks?

Ayrk
User Off Offline

Quote
Ok.
The idea is that the player hits a specific rock (ID 63) with a hammer or a pickaxe, so that after a certain number of hits, the rock gets "carved" into the empty water rock (ID 74).
I've deactivated the fountains for the "hard" game mode and have decreased the numbers of water rocks spawned naturally to the minimal, just to make it... you know, harder.
That's the reason why it would be a great idea to have the option of "create" more water rocks in-game.

old Re: Carving rocks into water rocks?

Hurri04
Super User Off Offline

Quote
you should write the script in a way that it checks on:hit if the current hp of the rock are below like 90% of the maximum hp (adjust the value depending on how long you think the player can hit the stone before getting bored ) and then already swap the object out with another type.

as DC said, there might be problems when you do it only on:kill because then the stone falls through the ground to show that it's been destroyed and I'm not sure whether the new object wouldnt directly do the same.

here's the correct line for swapping the objects:
1
alterobject currentid(), 74;

you might also want to use s2 cmd getyaw and s2 cmd setrot to rotate the new object to the angle of the old object if this isnt done automatically.

old Re: Carving rocks into water rocks?

JasJack67
Super User Off Offline

Quote
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
### Rock
id=63
name=Rock
group=stone
icon=gfx\rock01.bmp
model=gfx\rock01.b3d
scale=4
detailtex=1
mat=stone
health=200
find=22,5,1
find=21,90,7
find=23,300,1,1,88
var=hit,Hits,50,0
script=start

on:hit {
		if (getplayerweapon()==30){
			$hit--;
			if ($hit==0){
				alterobject "self",74;
			}
		}
}

script=end

if you put a var in the ID as above, (var=hit,Hits,50,0),you can use on:hit to change the object after 50 hits. Instead of on:kill.

above on:hit checks to see if the player has a hammer ID30, then it subtracts hits from the var 50 until it reaches 0 then alters the object to object ID74.

you can check to see any other type weapon being held by the player and change the if ($hit==0) to coincide with that weapons damage, like if he has a pickaxe then maybe the rock would change in 30 hits instead of 50, so you would make it if ($hit==20) for that additional statement.

1
2
3
4
5
6
7
8
9
10
11
12
13
on:hit {
	      if (getplayerweapon()==30){
			$hit--;
			if ($hit==0){
				alterobject "self",74;
			}
           }elseif (getplayerweapon()==99){
			$hit--;
			if ($hit==20){
				alterobject "self",74;
			}
           }
}
edited 5×, last 01.06.14 08:15:47 pm

old Re: Carving rocks into water rocks?

Jawohl
User Off Offline

Quote
user Ayrk has written
Ok.
The idea is that the player hits a specific rock (ID 63) with a hammer or a pickaxe, so that after a certain number of hits, the rock gets "carved" into the empty water rock (ID 74).
I've deactivated the fountains for the "hard" game mode and have decreased the numbers of water rocks spawned naturally to the minimal, just to make it... you know, harder.
That's the reason why it would be a great idea to have the option of "create" more water rocks in-game.



I'd like to add this feature to my hardcore mod, if your willi ng to give me all of the code, of course you will be credited.

old Re: Carving rocks into water rocks?

Ayrk
User Off Offline

Quote
user JasJack67 has written
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
### Rock
id=63
name=Rock
group=stone
icon=gfx\rock01.bmp
model=gfx\rock01.b3d
scale=4
detailtex=1
mat=stone
health=200
find=22,5,1
find=21,90,7
find=23,300,1,1,88
var=hit,Hits,50,0
script=start

on:hit {
		if (getplayerweapon()==30){
			$hit--;
			if ($hit==0){
				alterobject "self",74;
			}
		}
}

script=end

if you put a var in the ID as above, (var=hit,Hits,50,0),you can use on:hit to change the object after 50 hits. Instead of on:kill.

above on:hit checks to see if the player has a hammer ID30, then it subtracts hits from the var 50 until it reaches 0 then alters the object to object ID74.

you can check to see any other type weapon being held by the player and change the if ($hit==0) to coincide with that weapons damage, like if he has a pickaxe then maybe the rock would change in 30 hits instead of 50, so you would make it if ($hit==20) for that additional statement.

1
2
3
4
5
6
7
8
9
10
11
12
13
on:hit {
	      if (getplayerweapon()==30){
			$hit--;
			if ($hit==0){
				alterobject "self",74;
			}
           }elseif (getplayerweapon()==99){
			$hit--;
			if ($hit==20){
				alterobject "self",74;
			}
           }
}


I've tried and tried to make it work, adjusting the rock's health value, assigning new hit values, changing the tool's damage, etc... but nothing seems to work. (By the way, the pickaxe's ID is 88, not 99).

If you or anyone have another code idea for this purpose, or can clean up this one a little bit, would be great. I've struggled with this thing way too much time.

old Re: Carving rocks into water rocks?

JasJack67
Super User Off Offline

Quote
there is nothing to clean up. that script is straight out of my mod...we hit the rock 50 times and it changes to a water rock.

make sure you have the right rock and the right rock's ID.

the pick axe ID is not 88 in my mod. because I changed it.

just because an object ID is a number in your mod, does not mean it is that number in every mod.

1)check the rock and the ID of the rock your hitting, make sure it is the correct rock your hitting ingame. And then make sure it has the on:hit script above, inside it's SCRIPT=START/SCRIPT=END

2)then check the hammer and it's ID, make sure it is the hammer your using ingame.

or copy and paste the script above into your mod, and just change the ID's to match your mods, you might have a typo preventing the script from working. Did you try the script while playing in Debug Mode? It should throw you and error telling you why its not working.

old Re: Carving rocks into water rocks?

Hurri04
Super User Off Offline

Quote
@user JasJack67: something I'd like to point out is that it's not very good to check for exact values here, as you do in lines 4 and 9.

instead, use
1
if ($hit<=0){
and
1
if ($hit<=20){

otherwise it would be possible to hit the rock with the item of type 30 until the $hit counter is 20 or lower, but when then changing to the item of type 99 nothing would happen if you hit the rock again.

old Re: Carving rocks into water rocks?

Klirkz
User Off Offline

Quote
I really liked the idea of Hurri04 to check the health of the rock, instead of the numbers of hits. So you don't have to implement every single possible tool (I mean, what if the player tries to create a water rock with a sword...).

Spoiler >

old Re: Carving rocks into water rocks?

Hurri04
Super User Off Offline

Quote
that would of course also work but the effect would be a little different: instead of the rock turning into a water rock when hit with certain tools only, it would do so by receiving damage from any tool or weapon.

however, it might not be necessarily a good idea to allow this, simply because it uses the damage of the item while you might want use your own damage effectiveness system; otherwise a sword could damage the stone but actually it wouldnt be the best tool for carving but it could rather destroy some of the carving progress instead.

old Re: Carving rocks into water rocks?

Klirkz
User Off Offline

Quote
Yeah, you've got a point
• Counting damage is close to Ayrks first attempt and allows the player to use any tool (no problem with wrong/additional IDs [like a pick axe of a different material] and the player is not obligated to look up wich tools are possible/more effective)
• Counting hits of certain tools is way more realistic and allows an own effectiveness system (e.g. so the player can't create a water rock with a rocket )

> So, it's up to you, Ayrk
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview