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 2117 118 119121 122 Next To the start

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
Some states have existed in the game, but they are not labeled. "Speed" state is one of them.
But to make states, you gots to modify the game via source code.

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Oh ok. Guess I wont be doing that then! How to you add the "speed" state to the game then? I mean, what's its ID?

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
you can use the command s2 cmd addstate to add the state 54 (speedmod) and then use the command s2 cmd statevalue to set statevalue (0) to a new value which then is the new speed of the unit.
if you need to know a current speed of a unit which has state 54 added you can use the command s2 cmd getstatevalue.

old Re: Scripting Questions

lucas is stranded
User Off Offline

Quote
I have a question about making new combinations.


I want to use the buildings you see in the editor (big fence, house, plane...) in random games but I don't know how to add a new combination into the game.


I'm looking for something similar to phyre's mod, only with a regular hammer.


Or if such thing alredy exists, I apreciate a link to download the file.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
I think what you mean are the definitions of what you need to build something...?

then you have to go to the buildings.inf file, define your object as a new building and set the needed materials by a line like this (you just have to input the values):
1
req=Item-Type, Amount
you can repeat this line if you want to use more than 1 type of item for the building.

old Re: Scripting Questions

lucas is stranded
User Off Offline

Quote
I got another question (it helps if you play/played kidnap mod).


I want to remove the recoil of the machine gun, it's more annoying than anything, can someone re-do the script for me?

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
### Sub-machine gun
id=123
name=Sub-machine gun
group=weapon
icon=gfx\submachine.bmp
model=gfx\submachine.b3d
scale=0.335
behaviour=gun
range=1000
rate=55
mat=metal
weight=2500
info=Ready to crack down on them?
damage=0.3
healthchange=0
script=start
	on:attack1 {
	if ($fingers<=3){
			msg "Shot with $fingers",3;
			msg "fingers?",3;
			skipevent;
			speech "negative";}
	if (playergotitem(29)>0) {
		local $sht;
		$sht++;
		if (gety("unit",1)<-15){
			skipevent;
			speech "negative";
			msg "Shoot underwater?",3;
			msg "are you crazzy?",3;
		}elseif ($sht==31){
	process "reloading";
	play "crack2.wav",15;
	play "crack1.wav",15;
	freevar "$sht";
	skipevent;
	}else{
	if (playergotitem(29)>0) { 	play "thomp.wav",10;
					$pitch=(getpitch("unit",1)-5);
					$yaw=getyaw("unit",1);
					setrot "unit",1,$pitch,$yaw,0;}
		}
	}
}
	on:impact {
		$tmp=impact_class();
		$tmp2=impact_id();
		//+100 Bonus Damage on Fruit
		if (compare_material($tmp,$tmp2,"fruit")==1){
			damage $tmp,$tmp2,100;
		//+200 Bonus Damage on Glass
		} elseif (compare_material($tmp,$tmp2,"glass")==1){
			damage $tmp,$tmp2,200;
		}
		freevar $tmp;
		freevar $tmp2;
	}
	on:inhand {
		play "crack1.wav";
	}
	on:noammo {
		speech "negative";
		msg "No ammo!",3;
	}
script=end

I honestly don't know what causes the recoil in this script.


I tried replacing some features with the pistol script (since it's a stable gun when shooting) but it just mess with the game.


If you played kidnap mod you probably know how much recoil the machine gun have...


Btw, this is for personal use, I can't add new items in the game so let alone make a mod full of stolen stuff.


And if such thing exists, I'd like a script that makes friendly NPCs attack hostile creatures (kinda like the mobster or the bamboo villagers, except that they shoot at creatures and not at me).


Sorry for all the questions, I just can't understand all these codes and scripts

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
the recoil is effected by these lines:
1
2
3
$pitch=(getpitch("unit",1)-5);
$yaw=getyaw("unit",1);
setrot "unit",1,$pitch,$yaw,0;

the second line is rather unimportant here but the first and the third line are of importance.
if you want to have less recoil just write a smaller number where the 5 is writen at the end of the first line.
if you want to have to recoil at all you can simply write a 0 there.

More >

old Re: Scripting Questions

lucas is stranded
User Off Offline

Quote
Thank you.

Everyone says scripting and modding in stranded 2 isn't hard, I'll look for a tutorial or something so I can stop asking questions here

------


Now I need to know how I can use the script from the machine gun to make pistols and shotguns reload.


Machine Gun script:

Spoiler >


I know the reloading part is probably somewhere near the place where the author wrote "reloading" ( ) but I don't see the magazine size or the reloading time (30 bullets before reloading and 3~6 seconds to reload the machine gun).


I'm looking for a similar script for the shotgun and the pistol that I can modify the magazine size and reloading time myself, if that's possible.


-------------

Scripting question number two:

So I tried messing with this script:

Spoiler >


It's the original raptor script but without the "ouch! he dropped me!" feature.

For some reason, when i test this in the editor the debug mode shows some kind of error for every action (hit player, ride, die and loot corpse).


I honestly don't know what I done wrong in the raptor script...
edited 4×, last 22.01.11 02:18:07 am

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
@lucas is stranded:
Try using Vectar666's gun reload script.
And, also try looking closely at the raptor script. You may have deleted too many parentheses.

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
there is a "}" in the raptor script right below the "ride;" command. you have to delete it because it must not be there.
there always has to be the same number of "{" as "}".


in the reload script there is a variable that is called "$sht".
in the beginning its value is 0 but whenever you shoot enlarged by 1.
and once this value reaches 31 it says "No ammo!". so this means that you can shoot 30 times with one clip.
after this you have to reload which is done by this:
1
process "reloading";
in this script line there is no parameter which sets the time that is needed for the process so therefore the tandard value "3000" is used which means that the process takes 3 seconds.
edited 1×, last 22.01.11 07:56:46 pm

old Re: Scripting Questions

lucas is stranded
User Off Offline

Quote
@hurri04:

My stranded 2 hero, you make scripting sounds easy.

How do I change the reloading time tough?

@pupp3t:

I prefer kidnap's reloading, v666 has a good weapon system tough.


So now I'm trying to make the bad natives with bows shoot arrows at you (their behavior is animal, for some reason they only shoot arrows at you in adventure mode before you find the forest village).


I tried replacing the behavior to predator and put the defense tower script into it:

Spoiler >


Debug mode showed no problems with the script, the unit hunts me and attacks me with no problem... Doesn't shoot arrows tough.


I tried giving it a attackrange but it's just makes his melee attack range wider.



I also tried to give the pistol the reload feature, but for some reason I get a memory acess violation when reloading the machine gun:

Spoiler >


Did I done something wrong?
edited 1×, last 22.01.11 06:40:27 pm

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
for a different reloading time just wirte another paramter at the end of the command:
1
process "reloading", 1000;
with this the process time is 1 second.

for the bowmen problem:
if you want that they shoot the player you have to write a 4 instead of a 6 in the s2 cmd projectile command at the parameter for the mode so they shoot the player instead of the next aggressive unit in range:
1
projectile 53,$x,$y,$z,4,350,15,59;

for the other problem:
I think it is a problem with the amount of the "{" and "}" again or at least with their order.

if you wrote the script yourself I strongly recommend to you to use the tab key to make different levels of script in order to make it much more readable and to be able to see problems more easily.
an example:
1
2
3
4
5
6
7
8
9
10
11
on:start {
	if($var1==1) {
		if($var2==2) {
			if($var3==3) {
				msg "Hello!";
			}
		}
	}elseif($var1==2) {
		msg "Test";
	}
}

old Re: Scripting Questions

lucas is stranded
User Off Offline

Quote
Well I tried again and again but none of the scripts I tried seem to work... >.<

I think I'll just stick with mapping and adding new objects/units, thank you for your patience hurri04 and anyone else who answered my questions

old Wait, WHAT?!

UncagedDragon0
User Off Offline

Quote
What is the name of the script this runs in? I keep reading that it runs in Blitz3D, which ironically enough I own this freaking 500 Page book that came With a Blitz3D deal I bought not too long ago. Does it run in the script that book "teaches" (it shows you basic stuff yeah but it seems to be made around the program it comes with) you which would be: BASIC. If so, holy sh** im going to have an easy scripting reference

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
nope, it's jsut the game itself which was programmed in Blitz3d.
the scripting language in the game, however, is completely different. in fact, it is more like php style.

in case that you are looking for a scripting tutorial or references of commands you might want to check this site:
http://www.stranded.unrealsoftware.de/s2_mods.php

old Re: Scripting Questions

pupp3tStudios
User Off Offline

Quote
Can you script it so that when an enemy spots you, a sound and message plays?
Example: You're walking in the dark corridors. An enemy spots you. As well as hearing a sound that comes from YOU, there is also a message that says: "You're under watch..".

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
how about this:
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
on:start {
	timer 0, 1000, 0, "enemyinsight";
}

on:enemyinsight {
	//the player sees the raptor
	$playerx=getx("unit", 1);
	$playery=gety("unit", 1);
	$playerz=getz("unit", 1);
	if(count_behaviourinrange("unit", "raptor", 300)>0) {
		loop("units") {
			$raptorx=getx("unit", loop_id());
			$raptory=gety("unit", loop_id());
			$raptorz=getz("unit", loop_id());
			if(viewline($playerx, $playery, $playerz, $raptorx, $raptory, $raptorz)==1) {
				$raptorsinrange++;
			}
		}
		if($raptorclosemode==0) {
			if($raptorsinrange>0) {
				msg "I see a raptor!";
				$raptorclosemode=1;
				$raptorsinrange=0;
			}
		}elseif($raptorclosemode==1) {
			if($raptorsinrange==0) {
				$raptorclosemode=0;
				$raptorsinrange=0;
			}
		}

		//the raptor has spotted the player
		if(playerspotted()==1) {
			if($spottedmode==0) {
				msg "The raptor has seen me!";
				$spottedmode=1;
			}
		}elseif(playerspotted()==0) {
			if($spottedmode==1) {
				msg "I think it has let me alone.";
				$spottedmode=0;
			}
		}
	}
}

old Re: Scripting Questions

Lion_Hearted
User Off Offline

Quote
Hello,

For Alienation I'm making a solar panel building that will catch energy from the sun to recharge batteries... However, I can't figure out how to make a script which will charge 2 batteries on change day...

The idea is, you have a building, that you can put an unlimited amount of batteries in, and every morning 2 of those batteries will be charged...


It should be a fairly simple script... and I would be very grateful for your assistance.

old Re: Scripting Questions

Vectarrio
User Off Offline

Quote
loop("items",battery_id){
     if(really don't know, smth about stored items){
          alteritem(loop_id(),chargedbattery_id)
     }
}
change chargedbattery_id and battery_id to actual numbers
To the start Previous 1 2117 118 119121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview