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 242 43 44121 122 Next To the start

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
jockmo42 has written
HudaJan has written
Stored items doesn't have states...


Yeah, but that's not what I want.

Okay, say I kill a crab and it has one piece of small meat. If it were to have had a certain state when it died, could I change the items I find on its corpse?

Well, you mean when you kill (e.g.) crab and if the crab has state (e.g.) particles it has(e.g.) small meat, if it has state light it has big meat etc...?

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
HudaJan has written
Well, you mean when you kill (e.g.) crab and if the crab has state (e.g.) particles it has(e.g.) small meat, if it has state light it has big meat etc...?


Yes, that could be an example, but the small meat is for it having no states. Basically, if the crab had a specific state when it died, change its default loot to this.

Could there be some hacky way to do this with if variables and creating/deleting items in a corpse? If it's too complicated, I won't bother, but I could do some pretty cool things with it.
edited 1×, last 02.09.08 10:31:02 pm

old Re: Scripting Questions

GreyMario
User Off Offline

Quote
States, that reminds me.

What the heck does Electroshock do to you? I'm too lazy to do it to myself to find out :V

old Re: Scripting Questions

Raven Shadow
User Off Offline

Quote
jockmo42 has written
HudaJan has written
Well, you mean when you kill (e.g.) crab and if the crab has state (e.g.) particles it has(e.g.) small meat, if it has state light it has big meat etc...?


Yes, that could be an example, but the small meat is for it having no states. Basically, if the crab had a specific state when it died, change its default loot to this.

Could there be some hacky way to do this with if variables and creating/deleting items in a corpse? If it's too complicated, I won't bother, but I could do some pretty cool things with it.


Whether or not it's too complicated, depends on the
effort you're willing to make learning the ins and outs of
S2's scripting language.

You can trap the death event using the on:kill
event ( which in HudaJan's example, would have to be
on the crab) combined with :
s2 cmd getstatevalue "Class", ID, "State" [,Value] to
determine it's state.
s2 cmd getstored "Class", ID [, Type] too see what's it's
already carrying.
s2 cmd freestored "Class", ID, Type [,Count] to remove items
already stored on the crab.
$temp= s2 cmd create "Class", Type [, X, Z] [, Amount] as
part of storing a new item in the crab
s2 cmd store ItemID, "Class", ID to move newly created
items into the crabs storage ( in this example, the $temp
variable used above, would be used for ItemID ).

That should be sufficient info to get you started

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
Raven Shadow has written
Whether or not it's too complicated, depends on the
effort you're willing to make learning the ins and outs of
S2's scripting language.

You can trap the death event using the on:kill
event ( which in HudaJan's example, would have to be
on the crab) combined with :
s2 cmd getstatevalue "Class", ID, "State" [,Value] to
determine it's state.
s2 cmd getstored "Class", ID [, Type] too see what's it's
already carrying.
s2 cmd freestored "Class", ID, Type [,Count] to remove items
already stored on the crab.
$temp= s2 cmd create "Class", Type [, X, Z] [, Amount] as
part of storing a new item in the crab
s2 cmd store ItemID, "Class", ID to move newly created
items into the crabs storage ( in this example, the $temp
variable used above, would be used for ItemID ).

That should be sufficient info to get you started


This is a good start, thanks!

So class is the kind of game thing it is, like item or object, right? And type is... The kind of item I want? Like edible or stuff?

Also, what does the x and z refer to here, the items I want to create?

$temp= s2 cmd create "Class", Type [, X, Z] [, Amount] as
part of storing a new item in the crab
edited 6×, last 03.09.08 12:28:44 am

old Re: Scripting Questions

Guest

Quote
Can someone tell me what's wrong with this? I think the top part is right, but the bottom part is supposed to add bleeding on impact. When I hit something it doesn't add the bleeding state.

script=start
     on:impact {
          if (impact_first()==1){
               if (skillvalue("hunt")>=100){
                    if (random(1,10)<=8){
                         $tmp=create("item",135);
                         setpos "item",$tmp,impact_x(),impact_y(),impact_z();
                         setrot "item",$tmp,0,getyaw("unit",1),0;

          $tmp2=impact_class();
          $tmp3=impact_id();
          //+8 Bonus Damage + Bleeding on Flesh
          if (compare_material($tmp2,$tmp3,"flesh")==1){
               damage $tmp2,$tmp3,8;
               //Bleeding
               addstate $tmp2,$tmp3,"bleeding";
               statevalue $tmp2,$tmp3,"bleeding",9;
          }
          freevar $tmp2;
          freevar $tmp3;
                    }
               }
          }
     }
script=end

Thanks for any help.

old Re: Scripting Questions

GreyMario
User Off Offline

Quote
You can't add the state by using the name of the state - you need the ID.

I don't know what the ID of the Bleeding state is, though - check the AI of the shark or something.

EDIT: The ID of the Bleeding state is 1. So you'd use
1
addstate $tmp2,$tmp3,1

old Re: Scripting Questions

Raven Shadow
User Off Offline

Quote
jockmo42 has written
Raven Shadow has written
Whether or not it's too complicated, depends on the
effort you're willing to make learning the ins and outs of
S2's scripting language.

You can trap the death event using the on:kill
event ( which in HudaJan's example, would have to be
on the crab) combined with :
s2 cmd getstatevalue "Class", ID, "State" [,Value] to
determine it's state.
s2 cmd getstored "Class", ID [, Type] too see what's it's
already carrying.
s2 cmd freestored "Class", ID, Type [,Count] to remove items
already stored on the crab.
$temp= s2 cmd create "Class", Type [, X, Z] [, Amount] as
part of storing a new item in the crab
s2 cmd store ItemID, "Class", ID to move newly created
items into the crabs storage ( in this example, the $temp
variable used above, would be used for ItemID ).

That should be sufficient info to get you started


This is a good start, thanks!

So class is the kind of game thing it is, like item or object, right? And type is... The kind of item I want? Like edible or stuff?

Also, what does the x and z refer to here, the items I want to create?

$temp= s2 cmd create "Class", Type [, X, Z] [, Amount] as
part of storing a new item in the crab


All of the commands were copy/pasted from the german
reference pages, so the command formats may not be
translated into thier correct english counter parts,
and require patience and some common sense, when
reading it, or when using an online translator as part of
learning process.

"Class" referes to the classification of the object you are
trying to affect. Basically an object's "class" can be
determined by the following rules:
All objects in the game are defined in .inf files
located in Starnded's mods\Stranded II\sys subfolder.
If an object is defined in an .inf whose name begins with:
"items"- It's Class is item.
"objects" - It's Class is object
"units" - It's Class is unit
Objects defined in buildings.inf must first be defined
in one of the objects_XXXX.inf files, so they're class is
also object.

X & Y & z are terms you become familar with when you
learn to make your own models. And in in the more
advanced math classes (such as Algebra and higher)
in high school.
They are used to indicate where a object is positioned
in a 3D space.
When viewing a 3D modelling enviroment from a "Front"
view, the X-axis runs from left to right, the Y-axis
runs from bottom to top (or from below ground level
to high altitude), and Z-axis runs from close up to the
distant background.

Type is mistranslated, and referes to the ID of the item
to be created.
As you learn S2 scripting, the references usage of
ID will confuse you, until till you learn that every
item/object/unit in the game has 2 ID's.
One ID is assigned in the file an object is defined in,
and the 2nd is assigned by the game when an object is
created in game.
Commands that need an ID for an object that already
exists in the game, need the 2nd ID and the commands
that need an ID for items not yet created or as part of
the creation process, need the first ID.

old Re: Scripting Questions

Guest

Quote
GreyMario has written
You can't add the state by using the name of the state - you need the ID.


Strange, that's how the clawspear does it.

I tried your method anyway. Same results. I think it's something else.

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
Raven Shadow has written
"Class" referes to the classification of the object you are
trying to affect. Basically an object's "class" can be
determined by the following rules:
All objects in the game are defined in .inf files
located in Starnded's mods\Stranded II\sys subfolder.
If an object is defined in an .inf whose name begins with:
"items"- It's Class is item.
"objects" - It's Class is object
"units" - It's Class is unit
Objects defined in buildings.inf must first be defined
in one of the objects_XXXX.inf files, so they're class is
also object.


Good, that's what I thought.

Raven Shadow has written
X & Y & z are terms you become familar with when you
learn to make your own models. And in in the more
advanced math classes (such as Algebra and higher)
in high school.
They are used to indicate where a object is positioned
in a 3D space.
When viewing a 3D modelling enviroment from a "Front"
view, the X-axis runs from left to right, the Y-axis
runs from bottom to top (or from below ground level
to high altitude), and Z-axis runs from close up to the
distant background.


Oh, of course. If I'd seen a Y I would have guessed that. I thought you were just being odd.

Raven Shadow has written
Type is mistranslated, and referes to the ID of the item
to be created.
As you learn S2 scripting, the references usage of
ID will confuse you, until till you learn that every
item/object/unit in the game has 2 ID's.
One ID is assigned in the file an object is defined in,
and the 2nd is assigned by the game when an object is
created in game.
Commands that need an ID for an object that already
exists in the game, need the 2nd ID and the commands
that need an ID for items not yet created or as part of
the creation process, need the first ID.


Okay, that makes sense. I'll throw something together and come back for help when I can't find anything wrong with it, thanks.

old Re: Scripting Questions

GreyMario
User Off Offline

Quote
Hmm. I would have figured that's what was wrong.

I'll examine the rest of the code.

EDIT: Close your ifs before checking the material of the object, man.
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
script=start
	on:impact {
		if (impact_first()==1){
			if (skillvalue("hunt")>=100){
				if (random(1,10)<=8){
					$tmp=create("item",135);
					setpos "item",$tmp,impact_x(),impact_y(),impact_z();
					setrot "item",$tmp,0,getyaw("unit",1),0;
				}
			}


			$tmp2=impact_class();
			$tmp3=impact_id();
			//+8 Bonus Damage + Bleeding on Flesh
			if (compare_material($tmp2,$tmp3,"flesh")==1){
				damage $tmp2,$tmp3,8;
				//Bleeding
				addstate $tmp2,$tmp3,"bleeding";
				statevalue $tmp2,$tmp3,"bleeding",9;
			}
			freevar $tmp2;
			freevar $tmp3;
		}
	}
script=end
Try that.

another edit: formatting
edited 1×, last 03.09.08 04:54:54 am

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
GreyMario has written
Hmm. I would have figured that's what was wrong.

I'll examine the rest of the code.


Thanks, buddeh, that did it!

Guest was me, by the way. My brain wasn't working and I guested all over the place.
edited 1×, last 03.09.08 05:03:06 am

old Re: Scripting Questions

GreyMario
User Off Offline

Quote
I needed to get a little more scripting practice in anyway.

Now, I'm going to maybe proceed to do something stupid and invent... (gasp!) a writable/rewritable signpost/map marker combo! I think I've got the basic idea of how to do it...

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
I was wondering with the getstatevalue, how would I make it refer to only the crab I hit? I know about $local, just not quite how to apply it in this case. Any help?

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
GreyMario has written
I'm thinking s2 cmd currentid would do that job, but I'm not sure... currently trying to figure it out for myself.


Haha, most commands in my scripts would do the job, I just can't tell them to do it.

old Re: Scripting Questions

ESKARN
User Off Offline

Quote
can someone tell me what im doing wrong


page=p4
script=start
if (playergotitem(111)>=1){
if (playergotitem(106)>=1){
if (playergotitem(49)>=1){
if (playergotitem(120)>=1){
freestored "unit",1,106,1;
freestored "unit",1,49,1;
freestored "unit",1,120,1;
freestored "unit",1,111,1;
damage"object",93,9999999;

}else{
dialogue "no","maps/my maps/the lake diary.s2s","c";
script=end
text=start
thank you now im free we will now take you to the nearest town
text=end

page=no
text=start
you do not have the items
text=end
button=action:close, sorry ill get them now






it just crashes or dosent say the right thing

old Re: Scripting Questions

DC
Admin On Online

Quote
you have many open { but you don't close them! every { needs a fitting }! this counts for every type of bracket.

if you need many conditions and else you can either connect them with logical operators (and/&&, or/||) or you do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$x=0;
if (playergotitem(111)>=1){ $x++; }
if (playergotitem(106)>=1){ $x++; }
if (playergotitem(49)>=1){ $x++; }
if (playergotitem(120)>=1){ $x++; }
if ($x==4){
	freestored "unit",1,106,1;
	freestored "unit",1,49,1;
	freestored "unit",1,120,1;
	freestored "unit",1,111,1;
	damage"object",93,9999999;
}else{
	dialogue "no","maps/my maps/the lake diary.s2s","c"; 
}

hint: use indention (with tab) in your scripts. this will make it easier to read it and you will have less problems with complicated if-structures!
To the start Previous 1 242 43 44121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview