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 253 54 55121 122 Next To the start

old Re: Scripting Questions

Apostle
User Off Offline

Quote
Sorry to double post, but I just registered.

I am also trying to make it so sheep breed. However my knowledge on scripting is limited, and I am not sure how to go about creating the script.

I would like it to on:changeday to check whether or not there is 2 or more units in range to create or spawn a unit, but I would also like it so if there is a certain number of units in range it will not spawn anymore units.
If anyone could give me an idea of how I need to set up a script for it, that would be great. Although I am not sure how complicated it would be to make such a script.

It would also be great if a random chance was set up to spawn a unit instead of having a new unit every day.

Any help would greatly be appreciated.
Thank you.

EDIT: Okay, I managed to throw together this script and it works.

1
2
3
4
5
6
7
8
9
10
11
12
on:changeday {
	local $c;
	$c+=count_inrange("unit",15,250,"self");
		if ($c>1){
			if ($c<5){
				if (random(5)==1){
					create "unit",15,getx("self"),getz("self");
				}
			}
		}
	freevar $c;
	}

However, each of the sheep seem to create a new unit. Is there a way to make it so only 1 sheep create a new one instead of all of them or is that getting too complicated? or would I have to have two separate units a male and female and do it that way?

If I have to use 2 separate units how roughly would the script look?

This might make it a bit more tricky, but is there also a way if this is possible to make it on the first sheep that is "bred" it can add a diary entry.
edited 3×, last 02.11.08 11:49:01 am

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
@J.B
Yes, you can do exactly that with the stuff I posted

@Apostel
1. Did you add a line event "iskill_cooking","global"; to the combinations of juice and wine?

2. I don't think that's a good idea, if there are a lot of sheeps it will slow the game dramatically down, and the player won't notice the diference anyway. Although it would be possible.

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
lol kinda hard. I did it with sharks were if there was 2 close together they'd lay eggs- either 1 or 3 each. you could do it with
1
2
3
4
5
6
if (count_inrange (sheep ID)) { $variable=1}
on:changeday{
	if ($variable==1){
		create "unit", sheep ID, getx "self",getz "self";
	}
}
Basicly that's it but that script probobly won't work. I use alot of variables with if's- not much else

old Re: Scripting Questions

Guest

Quote
Hi fellows.

Could you have a look at this.
Im trying to make a script so that when you use the hammock, you will rest for 1 hour.
I'm using "hour", but it seems that is does not return the hour correct. When having it display hour, it returns "hour" in letters. So in the end it resets the hour to 0.
Am I using the "hour" command correct?

Script:
script=start
     on:build_finish {
          event "hammockbuild",0,0;
     }
     on:use {
          if (getplayervalue(4)>5){
               process "Taking a nap",1,10000;
               play "sleep.wav";
               consume 5,-10,-10,25;
               local $nap;
               $nap=hour;
               msg "$nap"; //debug
               $nap+=2;
               sethour=$nap;
               freevar "$nap";
          }else{
               speech "negative";
               msg "I'm not tired enough!",3;
               skipevent;
          }
script=end

Regards,

old Re: Scripting Questions

Guest

Quote
@Bloodshot:
Could you give a bit more advice?
I tried putting in the brackets inthe line, like this: $nap=hour(); ... It doesnt seem to work.
What needs to be in the brackets?

old Re: Scripting Questions

Apostle
User Off Offline

Quote
Flying Lizard has written
@Apostel
1. Did you add a line event "iskill_cooking","global"; to the combinations of juice and wine?

2. I don't think that's a good idea, if there are a lot of sheeps it will slow the game dramatically down, and the player won't notice the diference anyway. Although it would be possible.


Yes, I did add those lines to the combinations. Is there something else I am leaving out? I've examined how the other skills work and I can't seem to identify the problem.

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
### Wine (30xGrapes + Stone)
combi=start
id=wine
req=45,30
req=23,1,stay
gen=39
script=start
	play "bubbles.wav";
	process "pressing grapes",2270;
	event "iskill_cooking","global";
script=end
combi=end

### Juice (30xBerries + Stone)
combi=start
id=juice
req=46,30
req=23,1,stay
gen=47
script=start
	play "bubbles.wav";
	process "making juice",2270;
	event "iskill_cooking","global";
script=end
combi=end


With the sheep. They only multiply if they are in a close proximity to each other and what I meant it for was if you had two sheep penned then they would multiply and you would have another source of food.

Is there a way to do a total count of a unit on the map, so if the population of a unit on the map got below a certain level they would multiply? If so this would be a much tidier idea then inside a specific range, and would reduce lag and avoid spamming the game with a specific unit.

Bloodshot has written
lol kinda hard. I did it with sharks were if there was 2 close together they'd lay eggs- either 1 or 3 each. you could do it with Code:
if (count_inrange (sheep ID)) { $variable=1}
on:changeday{
if ($variable==1){
create "unit", sheep ID, getx "self",getz "self";
}
}

Basicly that's it but that script probobly won't work. I use alot of variables with if's- not much else


You wouldn't be willing to send me that script would you? It would be a great help to my understanding of script and not to mention it is a great idea.

My lack of understanding of variables is what is letting me down, however I do understand that with the idea of "breeding" it would involve a great number of variables and many if/else statements.

Thank you.

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
Technicly no. but you can do count_ inrange and set the total area of the map doubled (doubled because it does it from the player and the player could be at any end). And yeah right here
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
on:changeday {
		local $sharkx,$sharky,$sharkz,$babychance,$eggtime,$3sharkeggs,$sharkegg,$eggsexsist;
		if((count_inrange("unit",13,250))>0){
			$sharkx=getx "self";
			$sharky=gety "self";
			$sharkz=getz "self";
			$babychance=random (1,6);
			if ($babychance<4){
				if ($babychance==2) {
					$3sharkeggs=1;
					$eggs exsist=1;
				}else{
					$sharkegg=1;
					$eggs exsist=1;
				}
			}
		if($eggsxist==1) {
			$eggtime++;
		}
		if($eggtime==3){
			if($3sharkeggs==1){
				create "unit",13,$sharkx,$sharky,$sharkz;
				create "unit",13,$sharkx,$sharky,$sharkz;
				create "unit",13,$sharkx,$sharky,$sharkz;
			}
		}elseif ($sharkegg==1){
									create "unit",13,$sharkx,$sharky,$sharkz;
		}
	}

old Re: Scripting Questions

Guest

Quote
Bloodshot has written
nothing, it should work... did u save? dunno otherwise.


Found it. You were right. I just had to change my sethour.
From sethour=$xx --> sethour($xx).

Thanks for the help.

old Re: Scripting Questions

Apostle
User Off Offline

Quote
Bloodshot has written
Technicly no. but you can do count_ inrange and set the total area of the map doubled (doubled because it does it from the player and the player could be at any end). And yeah right here


Thanks for script helped a lot. I also managed to get my script working properly and now it wont go over the limit set for the map. This should stop the game slowing down Flying Lizard

Here's the code feel free to use it.

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:start {
		[b]$mapz=mapsize();[/b]
		local $id;
		$id=create("item",48,0,0,2);
		store $id,"self";
		freevar $id;
	}
	//Add 3xWool per Night
	on:changeday {
		if (count_stored("self",48)<15){
			local $id;
			$id=create("item",48,0,0,3);
			store $id,"self";
			freevar $id;
		}
		[b]local $sheep;
		if ((count_inrange("unit",15,$mapz,"self"))<20){
			$sheep+=count_inrange("unit",15,250,"self");
				if ($sheep>1){
					if ($sheep<8){
						if (random(15)=1){
							create "unit",15,getx("self"),getz("self");
						}
					}
				}
			freevar $sheep;
		}[/b]
	}

The bold is what I added into units.inf

Still haven't resolved the problem with the juice and wine combinations not being unlocked.

Game.inf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Lock combis (see combinations_xxx.inf)

		if (skillvalue("cook")<150){
			lockcombi "juice";
		}
		if (skillvalue("cook")<250){
			lockcombi "wine";
		}

//Skill stuff

	on:skill_cook { msgbox "Skill Info","sys/skillinfos/cook.inf";}
	on:iskill_cook {
		incskill "cook",1,"Cooking";
		$tmp=skillvalue("cook");
		if ($tmp==150){ event "skillup","global"; unlockcombi "juice"; }
		if ($tmp==250){ event "skillup","global"; unlockcombi "wine"; }
		if ($tmp==300){ event "skillup","global";}
		if ($tmp==450){ event "skillup","global";}
	}

Combinations_potions.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
25
### Wine (30xGrapes + Stone)
combi=start
id=wine
req=45,30
req=23,1,stay
gen=39
script=start
	play "bubbles.wav";
	process "pressing grapes",2270;
		event "iskill_cook","global";
script=end
combi=end

### Juice (30xBerries + Stone)
combi=start
id=juice
req=46,30
req=23,1,stay
gen=47
script=start
	play "bubbles.wav";
	process "making juice",2270;
		event "iskill_cook","global";
script=end
combi=end

Does anyone know what I am leaving out?
Thank you.

old Re: Scripting Questions

Gradir
User Off Offline

Quote
I'm trying to make a script that will allow player to do something only when facing a specific object. Is it possible?

Edit:
Ah, I've found the s2 cmd inview command, but now how to get the proper ID's of the objects I want to have in my view...

Edit 2:
Ok, I've made it! Had to use a s2 cmd scantarget and s2 cmd targetid and then check if the targeted object is of the proper s2 cmd type
yarr! Frying small meat on a stick over a campfire works!
edited 2×, last 04.11.08 07:57:23 am

old Re: Scripting Questions

darksol
User Off Offline

Quote
Apostle has written
Bloodshot has written
Technicly no. but you can do count_ inrange and set the total area of the map doubled (doubled because it does it from the player and the player could be at any end). And yeah right here


Thanks for script helped a lot. I also managed to get my script working properly and now it wont go over the limit set for the map. This should stop the game slowing down Flying Lizard

Here's the code feel free to use it.

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:start {
		[b]$mapz=mapsize();[/b]
		local $id;
		$id=create("item",48,0,0,2);
		store $id,"self";
		freevar $id;
	}
	//Add 3xWool per Night
	on:changeday {
		if (count_stored("self",48)<15){
			local $id;
			$id=create("item",48,0,0,3);
			store $id,"self";
			freevar $id;
		}
		[b]local $sheep;
		if ((count_inrange("unit",15,$mapz,"self"))<20){
			$sheep+=count_inrange("unit",15,250,"self");
				if ($sheep>1){
					if ($sheep<8){
						if (random(15)=1){
							create "unit",15,getx("self"),getz("self");
						}
					}
				}
			freevar $sheep;
		}[/b]
	}

The bold is what I added into units.inf

Still haven't resolved the problem with the juice and wine combinations not being unlocked.

Game.inf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Lock combis (see combinations_xxx.inf)

		if (skillvalue("cook")<150){
			lockcombi "juice";
		}
		if (skillvalue("cook")<250){
			lockcombi "wine";
		}

//Skill stuff

	on:skill_cook { msgbox "Skill Info","sys/skillinfos/cook.inf";}
	on:iskill_cook {
		incskill "cook",1,"Cooking";
		$tmp=skillvalue("cook");
		if ($tmp==150){ event "skillup","global"; unlockcombi "juice"; }
		if ($tmp==250){ event "skillup","global"; unlockcombi "wine"; }
		if ($tmp==300){ event "skillup","global";}
		if ($tmp==450){ event "skillup","global";}
	}

Combinations_potions.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
25
### Wine (30xGrapes + Stone)
combi=start
id=wine
req=45,30
req=23,1,stay
gen=39
script=start
	play "bubbles.wav";
	process "pressing grapes",2270;
		event "iskill_cook","global";
script=end
combi=end

### Juice (30xBerries + Stone)
combi=start
id=juice
req=46,30
req=23,1,stay
gen=47
script=start
	play "bubbles.wav";
	process "making juice",2270;
		event "iskill_cook","global";
script=end
combi=end

Does anyone know what I am leaving out?
Thank you.


if you add the
          event "iskill_cook","global"
to things like making bread and baking cookies then that would be good or you can not get the cooking skill to go up in the first place to unlock the wine and juice

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
how to make scriptkeys?
i need so if you press a key (im making a giant giant walker lol!!yay!!) it will fire a weapon...
weapons are:arc turret (fires arcs) plasma turret (for plasma bullets) mass driver cannon (green snaking laser) and beam cannon (strong).
could someone tell me how to do this?
EDIT: forgot to credit:petroglyph,x-fi,sega,and nvidia for universe at war earth assault for the giant walker idea.uh oh,i animated it,and it says "entity has no animation" ?? can someone help me??
edited 1×, last 13.11.08 07:15:29 pm

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
Please point out the many probloms wrong with this 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#Iron Broadsword
id=932
name=Iron Broadsword
group=weapon
icon=gfx\broadsword.bmp
model=gfx\broadsword.b3d
scale=1.6
behaviour=blade
mat=metal
weight=1250
damage=5
info=An iron sword with a very broad blade.
healthchange=0
script=start
	on:impact {
		$tmp=impact_class();
		$tmp2=impact_id();
		//+19 Bonus Damage on Flesh
		if (compare_material("$tmp",$tmp2,"flesh")==1){
			damage "$tmp",$tmp2,19;
			if (skillvalue("Sword")>=500){
				damage "$tmp",$tmp2,20;
				addstate "$tmp",$tmp2,"bleeding";
			}elseif (skillvalue("Sword")>=420){
				damage "$tmp",$tmp2,15;
				$tmp3=random (1,2);
				if ($tmp3==1) {
					addstate "$tmp",$tmp2,"bleeding";
				}
			}elseif (skillvalue("Sword")>=360){
				damage "$tmp",$tmp2,12;
				$tmp3=random (1,4);
				if ($tmp3==1) {
					addstate "$tmp",$tmp2,"bleeding";
				}
			}elseif (skillvalue("Sword")>=250){
				damage "$tmp",$tmp2,8;
				$tmp3=random (1,5);
				if ($tmp3==1) {
					addstate "$tmp",$tmp2,"bleeding";
				}
			}elseif (skillvalue("Sword")>=200){
				damage "$tmp",$tmp2,5;
				$tmp3=random (1,8);
				if ($tmp3==1) {
					addstate "$tmp",$tmp2,"bleeding";
				}
			}
			if ($swordattack==2){
				$noattack=1;
				timer "self",750;
				heal "$tmp",$tmp2,7;
			}elseif($swordattack==3){
				$noattack=1;
				timer "self",1250;
				damage "$tmp",$tmp2,8;
				$tmp4=random (1,15);
				if($tmp4==5){
					kill $tmp2;
				}
			}
		}
		freevar $tmp;
		freevar $tmp2;
		freevar $tmp3;
		freevar $tmp4;
		if (health("$tmp",$tmp2)==0){
			event "iskill_swordmaster","global";
	}
	}
	on:timer{
		$noattack=0;
		msg "ready",4;
		freetimers "self";
	}
	on:attack1{
		if ($noattack==1){
			skipevent;
		}
	}
	on:attack2{
		event "use";
	}
	on:use{
		$swordattack++;
		if($swordsetattack==1) {
			msg "Slash",4;
		}elseif($swordsetattack==2) {
			msg "Lunge",2;
		}elseif($swordsetattack==3) {
			msg "Bash",3;
		}elseif($swordsetattack==4) {
			$swordsetattack=1
			msg "Slash",4;
		}
	}
script=end

old Re: Scripting Questions

CoreyRDean
User Off Offline

Quote
I have a question about the script
1
if (menu()==0){

The script can be found in sys\scripts\random_events

I need to know what exactly this is doing in the code?
To the start Previous 1 253 54 55121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview