English Scripting Questions

2,429 replies
Goto Page
To the start Previous 1 2 ... 59 60 61 ... 121 122 Next To the start
20.02.09 03:26:42 pm
Up
Gradir
User
Offline Off
you can make it s2 cmd stopmusic on timer, or you could make it like:
Code:
1
process "listening",2000,"stopmusic_event";

and add a global event (in the game.inf) -
Code:
1
2
3
4
on:stopmusic_event
     {
     stopmusic;
     }
Early to rise, early to bed makes a man healthy, wealthy and dead.
20.02.09 03:57:26 pm
Up
DontKnowToScript
User
Offline Off
or
on:stopmusic_event {
stopmusic;
}
if you dont use gradir's technique adding the bracket a line after.
IMG:http://i3.photobucket.com/albums/y61/anarchyluvsme/userbar/2513.jpg
IMG:http://needasig.com/3sDx.png
IMG:http://needasig.com/VM5T0.png
IMG:http://needasig.com/H14W3.png
20.02.09 04:02:10 pm
Up
Gradir
User
Offline Off
: P
Early to rise, early to bed makes a man healthy, wealthy and dead.
21.02.09 12:15:58 am
Up
Shadowacher
User
Offline Off
Hey could anyone give me an example of adding a diary? I tried adding my own, but when I start the map, the diary menu pops up but it is empty.
FFX FAN!!!
21.02.09 05:00:40 am
Up
Firecat
User
Offline Off
A diary can be made it from two ways:

In the code
Put in your code this thing:
Code:
1
2
3
4
5
6
7
8
on:start {
clear;
     add "Hello";
     add "This is the text";
     add "thats all";
     diary "yay";
     free "self";
}

s2 cmd clear clears previous texts.
s2 cmd add puts the mensage.
s2 cmd diary is the diary laucher and the title.
s2 cmd free does not allow a repeat (i think).
Outside the code
Put in your code this thing:
Code:
1
2
3
4
on:start {
     diary "yay","diary.txt:*:","diary01";
     free "self";
}

Create a text file in Stranded folder/mods/Stranded II called diary(Or the name that you put in the ∗) and put in the text this:
Code:
1
2
3
4
5
//~diary01
Hello.
This is the text.

!4Green mensage


twice ways works so use the best.

aaand also thanks Gradir and DontKnowToScript for the help, but actually i start a new idea .
21.02.09 05:57:25 am
Up
Shadowacher
User
Offline Off
Thank you Firecat it worked great.

I have a few more questions though. How do I make a unit say something else after an event happens. I need a pirate to say something after I kill a group of snails. And could somebody put an example of adding the fire state? I tried but it says script error.

Also, is there a way to make an item explode or do damage to the player when used?
edited 2×, last 22.02.09 03:39:13 am
FFX FAN!!!
23.02.09 02:51:37 am
Up
Bloodshot
User
Offline Off
Why, as usual, isn't the following working: Timer wont work-it wont stop u from attacking, and the modes wont change.
Code:
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
#Iron Sword
id=933
name=Iron Sword
group=weapon
icon=gfx\sword.bmp
model=gfx\sword.b3d
scale=1.6
behaviour=blade
mat=metal
weight=1000
damage=3
info=A simple Iron sword
healthchange=0
script=start
     on:impact {
          $tmp=impact_class();
          $tmp2=impact_id();
          //+14 Bonus Damage on Flesh
          if (compare_material("$tmp",$tmp2,"flesh")==1){
               damage "$tmp",$tmp2,14;
               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 "unit",1,750,0,"swordtimer";
                    damage "$tmp",$tmp2,6;
                    $swordtimer=1;
               }elseif($swordattack==3){
                    $noattack=1;
                    timer "unit",1,1250;
                    $swordtimer=1;
                    heal "$tmp",$tmp2,5;
                    $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:swordtime{
          $noattack=0;
          msg "ready",4;
          freetimers "unit",1;
     }
     on:attack1{
          if ($noattack==1){
               skipevent;
          }
     }
     on:use{
          event "attack2";
     }
     on:attack2{
          $swordattack+=1;
          if($swordsetattack==1) {
               msg "Slash",4;
          }elseif($swordsetattack==2) {
               msg "Lunge",2;
          }elseif($swordsetattack==3) {
               msg "Bash",3;
          }
     }
script=end

also, this is in unit 1 (player)
Code:
1
2
3
4
5
on:timer{
          if ($swordtimer==1){
               event "swordtime","global";
          }
     }
It is better to fail and then succeed than to succeed in the first place IMG:http://i420.photobucket.com/albums/pp281/L31ch3/Userbars/Strandedgamerub.png
23.02.09 01:00:05 pm
Up
Gradir
User
Offline Off
I don't get it, I don't know what are these vars like $swordattack and $swordsetattack
but I guess you should name the event on Unit 1 (player) on:swordtimer not on:timer ?

Anyway...
while testing my mod I've came upon a problem with cooking things while dropping near fire:
I didn't know that throwing things works also like dropping (event on:drop is executed while you throw things)
Now I need a way to prevent the script from going on while player THROWED an item, not DROPPED it, or I'd have to change the item's behaviour to "killthrow"

In fact the question is: how to block the ability to throw?

EDIT
never mind I used:
Code:
1
2
on:attack1
     { skipevent; }

and it works fine
edited 2×, last 23.02.09 02:11:43 pm
Early to rise, early to bed makes a man healthy, wealthy and dead.
24.02.09 02:06:29 am
Up
Bloodshot
User
Offline Off
ty. the vars are different... ill fix that...And it still dosn't work. Timers are non-existant
Code:
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
#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;
                    $swordtime=1
               }elseif($swordattack==3){
                    $noattack=1;
                    timer "self",1250;
                    damage "$tmp",$tmp2,8;
                    $tmp4=random (1,10);
                    $swordtime=1
                    if($tmp4==5){
                         kill $tmp2;
                    }
               }
          }
          freevar $tmp;
          freevar $tmp2;
          freevar $tmp3;
          freevar $tmp4;
          if(lives("$tmp",$tmp2)==1){
               event "iskill_swordmaster","global";
          }
     }
     on:attack1{
          if ($noattack==1){
               skipevent;
          }
     }
     on:use{
          event "attack2";
     }
     on:attack2{
          $swordsetattack++;
          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

plus this in player (unit 1)
Code:
1
2
3
4
5
6
7
on:swordtimer{
          if ($swordtimer==1){
               $noattack=0;
               msg "ready",4;
               freetimers "unit",1;
          }
     }
edited 1×, last 24.02.09 10:25:57 pm
It is better to fail and then succeed than to succeed in the first place IMG:http://i420.photobucket.com/albums/pp281/L31ch3/Userbars/Strandedgamerub.png
26.02.09 10:19:55 pm
Up
Gradir
User
Offline Off
I'm trying to assign an object to the player so it will move when the player moves. Anyone thinks it's possible?
Early to rise, early to bed makes a man healthy, wealthy and dead.
26.02.09 10:44:46 pm
Up
Tau
User
Offline Off
very difficult... I assume the best workaround is a timer set to 0.05 seconds or something, asking for the players position and subtracting the previous positions, then changing the object's position depending on the values gained before. I have no idea how it could be done more elegant without touching the source. Maybe theres a way with game.inf but I don't know x_X.
26.02.09 10:55:42 pm
Up
DC
Admin
Offline Off
yes. for this you need an event which is executed very frequently. create a 1 ms timer. it will be executed each frame.

then use s2 cmd setat "object",id,"unit",1; to set the item to the player position.
afterwards use s2 cmd setrot "object",id,0,getyaw("unit",1),0; to set the yaw rotation of the object to the rotation of the player.
finally use s2 cmd rpos "object",id,0,0,10; to move the object to the front of the player (if you want to have it in his front). you have to test around here. 10 might be okay but maybe you have to use a higher or lower value there to even see the object.

I didn't test it but that's the way it *SHOULD* work. maybe you also have to change the height of the object (setat will set it to the feet of the player).

please note that this takes a lot of speed and can slow down the whole game on pcs with a slow cpu because it has to parse your script each frame!
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
27.02.09 02:22:29 am
Up
Gradir
User
Offline Off
Thanks!
After experiments with making a unit that would follow the player I've read your posts and this works great. I just have to work a bit on rotation cause it doesn't want to work fine (if you look at one direction, the object is on the left side of screen, and if you look in the opposite direction, it's on the right side of the screen, while I want it to stay on one side, hmm)
Early to rise, early to bed makes a man healthy, wealthy and dead.
27.02.09 03:59:11 pm
Up
DC
Admin
Offline Off
try setrot "object",id,0,(getyaw("unit",1)+45),0; or something like that and try different values for +45 before moving it with rpos. you can also replace the two zeros in rpos to move the object on other axis.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
27.02.09 06:10:31 pm
Up
Gradir
User
Offline Off
Ok! It's working great with this basic code:
Code:
1
2
3
4
$id=currentid();
          setat "object",$id,"unit",1;
          setrot "object",$id,0,getyaw("unit",1),0;
          timer "self",30,1,"checkpos";

here is the result:
http://www.goplany.net/~gradir/screen0105.jpg

now I'm wondering how to make one texture on the object shiny and another not shiny, like on pistol model...
Early to rise, early to bed makes a man healthy, wealthy and dead.
27.02.09 09:51:33 pm
Up
Bloodshot
User
Offline Off
Im still having trouble with the sword. the timers arnt working and the bash/lunge wont do extra damage...
It is better to fail and then succeed than to succeed in the first place IMG:http://i420.photobucket.com/albums/pp281/L31ch3/Userbars/Strandedgamerub.png
27.02.09 10:28:44 pm
Up
Gradir
User
Offline Off
make sure the skill "Sword" is indeed "Sword" not "sword"

I don't know what are the vars "swordattack", "swordtime" and "swordtimer" - maybe they're supposed to be both "$swordtime"?
I'm pretty sure that phrase " timer "self",1250; " won't work until you make an on:timer event on that item, I'd suggest adding new events, and changing it to, for example
timer "self",1250,1,"newevent";

I also don't get this part:
Code:
1
2
3
4
5
6
freevar $tmp;
          freevar $tmp2;
          freevar $tmp3;
          freevar $tmp4;
          if(lives("$tmp",$tmp2)==1){
               event "iskill_swordmaster","global";
- You're freeing the vars and using them in the next line
Early to rise, early to bed makes a man healthy, wealthy and dead.
04.03.09 06:15:20 am
Up
CJ80
User
Offline Off
I've looked all over for an answer to this question but no dice, hoping someone here can find what I'm missing -

I can't kill my sheep. I can beat them for hours with any number of weapons that kill all the rest of the animals, but the sheep won't die. The unit file has been tinkered with heavily, but I can't seem to see what would make a sheep immortal. Any help would be appreciated - The code is below:


### Sheep
id=15
name=Sheep
group=animal
icon=gfx\sheep.bmp
model=gfx\sheep.b3d
colxr=25
colyr=16
scale=7
behaviour=animal
health=5
speed=0.4
turnspeed=0.5
ani_idle1=4,9,0.01
ani_idle2=9,11,0.01
ani_idle3=12,15,0.01
ani_move=2,3,0.02
ani_die=15,16,0.1
sfx=sheep
loot=9,2
loot=96,1
loot=4943,1
loot=4982,4

script=start
     //Spawn 2xWool at Start
     on:start {
          local $id, $milk;
          $id=create("item",48,0,0,2);
          store $id,"self";
          freevar $id;
          $milk= (random(4));
     }
     //Add 3xWool per Night
     on:changeday {
          if (count_stored("self",48)<15){
               local $id;
               $id=create("item",48,0,0,3);
               $milk++;
               store $id,"self";
               freevar $id;
          } local $sheep;
if ((count_inrange("unit",15,$mapz,"self"))<20){
$sheep+=count_inrange("unit",15,250,"self");
if ($sheep>2){
if ($sheep<6){
if (random(10)=1){
create "unit",15,getx("self"),getz("self");
}
}
}
freevar $sheep;
}
     }
     //Get Wool on Use
     on:use {
          if (getplayerweapon()==106){
               if (playergotitem(106)>0){
                    if (health("self")>0){
                         if ($milk>0){
                              play "sheep_idle1.wav";
                              freestored "unit",1,106,1;
                              find 4953;
                              $milk--;
                         }else{
                              speech "negative";
                              msg "This sheep is all out of milk.",3;
                         }
                    }
               }
          }elseif (getplayerweapon()==4945){
               if (playergotitem(4945)>0){
                    if (health("self")>0){
                         if ($milk>0){
                              play "sheep_idle1.wav";
                              freestored "unit",1,4945,1;
                              find 4952;
                              $milk--;
                         }else{
                              speech "negative";
                              msg "This sheep is all out of milk.",3;
                         }
                    }
               }
          }elseif (count_stored("self")>0){
               if (health("self")>0){play "sheep_idle1.wav";}
               exchange "self",0;
          }else{
               msg "It has no wool!",3;
               speech "negative";
          }
     }
     
     //Whipping
     on:hit {
          ai_center;
     }
     //Kill
     on:kill {
          event "iskill_hunt","global";
          $s2g_sheepskilled++;
     }
script=end
05.03.09 03:18:05 am
Up
Gradir
User
Offline Off
Seems I can't help CJ80. Maybe, what would be strange, it's something with that code that spawns another sheep in the place of the first one... But it makes no sense

-------------
I'm still playing with visible player equipment... So far I've made a sleeve model which spawns when player have a clothing item in his inventory, and he equips a falchion:
SCREEN
the problem I encountered is, that the red sleeve model disappears when player is going forward and looking down at specific degrees (was it "pitch"? - around 75 points)
but I guess there is no way to fix it
Early to rise, early to bed makes a man healthy, wealthy and dead.
05.03.09 01:22:15 pm
Up
Bloodshot
User
Offline Off
did u try debug mode when hitting the sheep?
It is better to fail and then succeed than to succeed in the first place IMG:http://i420.photobucket.com/albums/pp281/L31ch3/Userbars/Strandedgamerub.png
To the start Previous 1 2 ... 59 60 61 ... 121 122 Next To the start