Forum

> > Stranded II > Scripts > Scripting Questions
Forums overviewStranded II overview Scripts overviewLog in to reply

English Scripting Questions

2,429 replies
Page
To the start Previous 1 295 96 97121 122 Next To the start

old Re: Scripting Questions

slow
User Off Offline

Quote
Now that I have been using your tool, it has helped me spot problems very regularly when I try to go scripting when tired or distracted and make stupid errors

I am adding more uses for bones and Psytechnic was kind enough to make a couple models for me and whatnot. However, I want sheep and lions both to be able to produce bones when killed. To keep it a bit balanced, my lions are quite powered up so I won't go hunting them too lightly

However, to keep the bones from becoming too plentiful I would like to make it a random chance that they may appear as loot. I know how to set look, but I can't figure out how to make there be perhaps a 25% chance that a bone will be included in the loot. Is it possible to adjust the chances of a particular loot item being available or is all or nothing? (And if it is possible, how so, please)

One more question which I know is quite silly and likely impossible: Is it possible to set some animal behaviours to change upon attack. For instance, you attack a monkey and as a result its behavior changes to raptor so that it may defend itself.

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
@slow:

However, to keep the bones from becoming too plentiful I would like to make it a random chance that they may appear as loot. I know how to set look, but I can't figure out how to make there be perhaps a 25% chance that a bone will be included in the loot. Is it possible to adjust the chances of a particular loot item being available or is all or nothing? (And if it is possible, how so, please)

If you set it as loot, it will always be there. No way to change the probability I think, but you could do a probability on:die of the creature to drop a certain number just in front of the corpse, but for that, you'd need to get the X,Y,Z of the creature and add something to one of the values to move it from underneath it.

One more question which I know is quite silly and likely impossible: Is it possible to set some animal behaviours to change upon attack. For instance, you attack a monkey and as a result its behavior changes to raptor so that it may defend itself.

I know that behaviours are quite hard coded. I don't know if you can switch behaviours during run-time, but I highly doubt it.

old Re: Scripting Questions

slow
User Off Offline

Quote
I rather thought those would be the answers I was hoping perhaps there was some way that I couldn't figure out for the bones since I am yet uncertain of the limitations of the range of uses for the "random" statements/attributes/whatever but as for the behavior I quite doubted it be done, but some of you are so good at finding seemingly obscure ways to achieve so many wonders I figured it was worth a shot. Thanks

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
isn't it simply possible to just use a script like
1
2
3
4
5
6
7
on:kill {
	$own_id=currentid();
	$randomloopnumber=random([MAX NUMBER OF BONES]);
	loop("count", $randomloopnumber) {
		store [BONE-ID], "unit", $own_id;
	}
}
?
if you put that script into the definitionscript of the lion there should be a random number of bones stored in the lion when it's killed.

old Re: Scripting Questions

slow
User Off Offline

Quote
Bloodshot has written
Actually, both are possible, with the s2 cmd def_extend, s2 cmd defparam, and s2 cmd def_override commands.


I am entirely ignorant of those commands but when I have time I will have to search them and if I find little to nothing to explain it well enough to me I will experiement with backups in place. (I am still quite the noob with modding the game myself)

Hurri04 has written
isn't it simply possible to just use a script like
1
2
3
4
5
6
7
on:kill {
	$own_id=currentid();
	$randomloopnumber=random([MAX NUMBER OF BONES]);
	loop("count", $randomloopnumber) {
		store [BONE-ID], "unit", $own_id;
	}
}
?
if you put that script into the definitionscript of the lion there should be a random number of bones stored in the lion when it's killed.


That appears quite promising. I will definitely give it a try and some experiments when I have time It makes sense as I see it but I can probably botch it as I have a couple of kinds of bones so far and eventually would like to find a add a couple more. I would prefer that only one can be found on the lions at a time, but it be random which appears as the bones have some different uses dependent upon type I am okay with simple things (adding new basic item/materials, combos, but I still have tons to learn I still haven't even gotten my cooking/glassblowing/mining skills working as I wish yet

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
They replace the definitions, such as health, scale, gfx, or extend the definitions, by the source file (Like notepad) you choose.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
slow has written
That appears quite promising. I will definitely give it a try and some experiments when I have time It makes sense as I see it but I can probably botch it as I have a couple of kinds of bones so far and eventually would like to find a add a couple more. I would prefer that only one can be found on the lions at a time, but it be random which appears as the bones have some different uses dependent upon type I am okay with simple things (adding new basic item/materials, combos, but I still have tons to learn I still haven't even gotten my cooking/glassblowing/mining skills working as I wish yet

let's see if I got this right:
you have a couple of different types of bones but you just want one of them to appear as loot (and then maybe with a various number of them)?

this could be solved by simply extending the script I already posted:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
on:kill {
	$own_id=currentid();

	$randombonetype=random([TOTAL NUMBER OF DIFFERENT BONES MINUS 1]);
	if($randombonetype==0) {
		$bone_type=[TYPE-ID OF THE _FIRST_ KIND OF BONE];
	}elseif($randombonetype==1) {
		$bone_type=[TYPE-ID OF THE _SECOND_ KIND OF BONE];
	}elseif($randombonetype==2) {
		$bone_type=[TYPE-ID OF THE _THIRD_ KIND OF BONE];
	}elseif($randombonetype==3) {
		$bone_type=[TYPE-ID OF THE _FOURTH_ KIND OF BONE];
	}

	$randomloopnumber=random([MAX NUMBER OF BONES]);
	loop("count", $randomloopnumber) {
		store $bone_type, "unit", $own_id;
	}
}
so now the part in the middle is new, in this example there are 4 different kinds of bones, maybe you'll have to adapt it a little bit concerning this number but as you can see it's always the same principle.
More >


so all you need to do now is put the numbers in there (the Type-IDs are those you defined in the definitionscript of the bones) and then this whole script goes into the definitionscript of the lion.

old Re: Scripting Questions

slow
User Off Offline

Quote
I finally tinkered with it this morning and though it seems very straightforward and logical that it should work, it doesn't. It doesn't throw any game ending errors or anything. It simply doesn't insert any of the bones. I've messed with it several times and still nothing

Thank you anyhow. It is much appreciated.
edited 1×, last 17.04.10 08:52:30 pm

old Re: Scripting Questions

grouch
User Off Offline

Quote
@Hurri04:
Quote
but as I have tried to find a way to set individual building-offsets for each building on my own I can tell you that it doesn't work with the current version of Stranded II, and believe me, I tried a lot of tricks but either you get a crossparsing errror, the mode where you set the buildingplace doesn't even open or the script is just ignored so the camera switches too an offset of 100 again so it all doesn't work...

I told Mc Leaf about this problem because he is currently working on the source code and he said that it shouldn't be a big problem for him to create a new command or parameter which shall be able to do the job easily

I may have found the reason in the source code, but first, the disclaimer: I am NOT a programmer, just an interested amateur, so for what it is worth:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
source file: parser_functions.bb

;### Find and Jump to Comma
Function parse_comma(error=1)
	Local s,i
	
	If p_internal=0 Then
	
		For i=p_p To p_len
			s=Asc(Mid(p_l$,i,1))
			If s<>32 Then
				;Comma (Return 1)
				If s=44 Then p_p=i+1:Return 1
				;Other
				If error=1 Then Exit
			EndIf
		Next
		;Nothing
		If error=1 Then parse_error("expect","parameter resp. ','")
		Return 0
		
	Else
I interpret that as a function that returns a "1", if a comma is found in parsing a script command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
source file: parser_commands.bb

;SelectPlace
Case "selectplace"
	pc_sp_txt$=params()
	pc_sp_height#=100
	If parse_comma(0) Then
		pc_sp_height#=param()
	EndIf
	pc_sp_x#=0
	pc_sp_y#=0
	pc_sp_z#=0
	pc_sp_class=p_env_class
	pc_sp_id=p_env_id
	If m_section<>Csection_menu Then
		m_menu=Cmenu_if_selplace
	EndIf
	;Closeblock
	in_blockclose=ms
I think the relevant line should have read:
1
2
If parse_comma(1) Then
		pc_sp_height#=param()
In effect, if it does find a comma, it falls though to the 'endif', instead of replacing the default height, else it replaces the default height with the default height.

It may have been an inadvertent mistake on DC's part, or he altered it during debugging for his own reasons, and neglected to update the command reference. More likely the former.

In any event, unless the code is re-compiled, or the .exe function is located, and hacked, I suppose we need a wizard to find an alternative method.

'Course, I could be totally wrong (as I am with so many, many things).

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
hmm... I'm not too familiar with the source code itself because I rather work with the scripting system of S2...

but yeah, as I already wrote in that part you quoted from my post I told Mc Leaf about this and he said that he'll find a way to implement this.
the only problem is that it can take some time until he releases an update of his source code mod.
(the first release was a great advancement but there still were some problems ...
for instance with the camera which moves up and down (and kind of in a way that reminds of an 8 that has been turned by 90°) when the player moves. this new feature is pretty nice but the problem with it is that this movement is kind of imbalaced so the camera moves as if you were seasick )

the reason why it could take some time for an update is that Mc Leaf is studying some stuff at the college so he doesn't have a lot of time.

In the last PM that I wrote to him I asked when we could anticipate that update, I'm just waiting for his answer, I think he'll reply this weekend...

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
How can i make different damage depending on the place you hit? (e.g. hit a turtle's shell and it wont do any damage,hit a lion's head and it kills him instantly)
or it ain't possible? hope it is.

old Re: Scripting Questions

grouch
User Off Offline

Quote
@DontKnow:

You might try adapting the script for flints fom 'item_tools.inf'.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
on:impact {
	$tmp=impact_class();
	$tmp2=impact_id();
	if (compare_behaviour($tmp,$tmp2,"torch")+compare_behaviour($tmp,$tmp2,"fireplace")>0){
		if (playergotitem(22)>1){
			if (gotstate($tmp,$tmp2,"fire")+gotstate($tmp,$tmp2,"eternalfire")>0){
				msg "Already burning";
			}else{
				if (addstate($tmp,$tmp2,"fire")==1){
					statevalue $tmp,$tmp2,"fire",0;
					msg "Fire started",4;
				}else{
					msg "It's too wet!",3;
				}
			}
		}else{
			msg "I need at least 2",3;
			msg "flints to start a fire!",3;
			speech "negative";
		}
	}
	freevar $tmp;
	freevar $tmp2;
}

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
     You must create separate objects/units for each thing, then attach them using shared local variables. For example, create an object of the lion's head, get its ID, store it in a local variable, and do get the lion's body's ID, and store that in a local variable. When the head, with less health, dies, send a kill command to the ID of the body, and vice-versa.

old Re: Scripting Questions

Vectarrio
User Off Offline

Quote
I wanted to make practically the same for my CS mod. Just use Y of unit. If Y>some variable then don't kill (if turtle) or KILL (if human). If for lion, then you must use s2 cmd sin and s2 cmd cos commands.

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
Bloodshot has written
     You must create separate objects/units for each thing, then attach them using shared local variables. For example, create an object of the lion's head, get its ID, store it in a local variable, and do get the lion's body's ID, and store that in a local variable. When the head, with less health, dies, send a kill command to the ID of the body, and vice-versa.

great idea. just how to make it follow the lion? dont want a lion head floating somewhere.

old Re: Scripting Questions

Vibhor
User Off Offline

Quote
isnt it already so with the turtle
hit him on the shell with no damage and hit him on skin for damage

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
Vibhor has written
isnt it already so with the turtle
hit him on the shell with no damage and hit him on skin for damage

No,it isnt.

@Bloodshot and Vectar666
Bloodshot: now i think about it,it will take precious Ram memory,making the game slow. im so dissapointed DC didnt make kind of those first person shooter systems that say "Headshot!" and stuff.

Vectar:your idea is more reasonable. not much ram memory taken,not much scripting,looks great. il try it out.
To the start Previous 1 295 96 97121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview