English Scripting Questions

2,429 replies
Goto Page
To the start Previous 1 2 ... 9 10 11 ... 121 122 Next To the start
28.10.07 10:21:41 pm
Up
Satis
User
Offline Off
thanks for the info Lfying Lizard


I have runned into a problem with my research stuff.

I have made the code smallere so it should run faster and I used the event function like Flying Lizard told me aboud.

when I start the game I only get an error saying:
Code:
1
Invalid GAME Property 'if (($combiwoodarrow'


My research code looks like this:
NOTE The dots is not in my original code, this is just to tap them in this code box
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
on:doresearch {
 . . . .if ($researchinprogress == 0) {
 . . . . . .$tmp=getplayerweapon();
 . . . . . .$tmp2=skillvalue("research");
 . . . . . .$tmp3=count_stored("unit",1,$tmp);
 . . . . . .$tmp4=skillvalue("alchemy");
 . . . . . .if (($tmp > 0) && ($tmp3 > 0)) {
 . . . . . . . . .if ($tmp2 < 75) {
 . . . . . . . . . . . .if ($tmp2 >= 50) {  $tmp2=$tmp2+random(0,7); }
 . . . . . . . . . . . .elseif ($tmp2 >= 25) { $tmp2=$tmp2+random(-2,5); }
 . . . . . . . . . . . .else { $tmp2=$tmp2+random(-5,0); }
 . . . . . . . . . . . .$restime=5000;
 . . . . . . . . . . . .if ($tmp == 24) { event "resbranch1","global"; }              //Branch
 . . . . . . . . . . . .elseif ($tmp == 57) { event "resfeather1","global"; }         //Feather
 . . . . . . . . . . . .elseif ($tmp == 21) { event "respebbles1","global"; }         //Pebbles


The events looks like this:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
on:resbranch1 {
 . . . $cbr = 0;

    //Wooden Arrow
 . . . if (($combiwoodarrow == 0) &&  ($tmp2 >= 0)) {
 . . . . . . .unlockcombi "woodenarrow";
 . . . . . . .$combiwoodarrow = 1;
 . . . . . . .$ammorecipenr++;
 . . . . . . .$cbr++;
 . . . }

 . . . if ($cbr == 0) {
 . . . . . . .process "Researching Branch",$restime,"researchfail25";
 . . . . . . .freestored "unit",1,$tmp,1;
 . . . . . . .$researchinprogress = 1;
 . . . } else {
 . . . . . . .process "Researching Branch",$restime,"researchsuccess";
 . . . . . . .freestored "unit",1,$tmp,1;
 . . . . . . .$researchinprogress = 1;
 . . . }
}


it actualy made the same error with the $cbr value.

any clue what is going wrong here ??

Kind regard
Satis

>>>>>> EDIT<<<

LOL Stupid me

Forgot to input a script=start and script=end command

never mind then
4 years PHP coding ½-1 year Delphi Pascal Coding
28.10.07 11:18:44 pm
Up
Satis
User
Offline Off
Flying Lizard has written:
well, I got some big codes too. I worked around bugs like that this way:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
on:keyhit01 {
if (stuff==stuff) {
event "1";
}
else {
event "2";
}

on:1 {
all the big scriptingstuff
}

on:2 {
all the big scriptingstuff
}


Okay after some time fitling with this and convertet all my research functions over to this way, it still run as slow as before. I have made a new file where I added all the new events into and if I remove that file so I cant use the events, it runs alot faster.

It's like it still runs all the events eaven that I'm telling it not to :S

any idear what that could be ??

new question related to this....
I made some checks before runing the item compare, that should skip the rest of the code if that statement is true.

What is the corect function to use to skip the rest of the code, so it wont run it ??

here is the 2 files I'm using, so you guys can have a fully look at them
http://www.satis.dk/files/game_anw_research.inf
http://www.satis.dk/files/game_anw_research_events.inf

//Satis

PS. Sorry for the doubble post
4 years PHP coding ½-1 year Delphi Pascal Coding
29.10.07 03:42:38 pm
Up
Mc Leaf
Super User
Offline Off
Satis has written:
What is the corect function to use to skip the rest of the code, so it wont run it ??

s2 cmd skip

For example
Code:
1
if ($tmp==0) { skip; }
user DC has written:
I'm actually working on Stranded III now with highest priority even though I said that I planned to release the next CC update first.
30.10.07 04:26:18 pm
Up
Ice
I want to react to when the player hit something with his bare hands.
Like for the axe, I want to modify the damage the fists does vs different materials. For instance, I want it to do minimal damage vs wood (because cutting down a tree with bare hands is somewhat strange...)

Only prob is, whatever on: event I try, they never trigger...

What event I must use, and where?

I tried on:hit and on:impact in both units.inf and game.inf. And there is no "hands" section in tools...
30.10.07 04:30:18 pm
Up
Flying Lizard
User
Offline Off
try on_attack1 in combination with those:

s2 cmd scantarget
s2 cmd targetclass
s2 cmd targetid
s2 cmd targetx
s2 cmd targety
s2 cmd targetz
s2 cmd targetdistance
Worte sind wie Pfeile, man kann sie nicht zurücknehmen.
30.10.07 04:35:10 pm
Up
Mc Leaf
Super User
Offline Off
Ice has written:
I want to react to when the player hit something with his bare hands.
Like for the axe, I want to modify the damage the fists does vs different materials. For instance, I want it to do minimal damage vs wood (because cutting down a tree with bare hands is somewhat strange...)

Only prob is, whatever on: event I try, they never trigger...

What event I must use, and where?

I tried on:hit and on:impact in both units.inf and game.inf. And there is no "hands" section in tools...

You'll have to check, whether the player uses a weapon and which material the hit object is made of. For example
Code:
1
2
3
4
5
on:hit {
     if ((getplayerweapon()==0) && (compare_material("self","wood")==1)) {
          msg "Player has no weapon and the material is wood";
     }
}

The event will be triggered at the object hit by the player.
user DC has written:
I'm actually working on Stranded III now with highest priority even though I said that I planned to release the next CC update first.
30.10.07 04:54:29 pm
Up
Ice
thx, it help, but is not the perfect solution.
The problem is the "target" is what is right in the middle of the crosshair, while the hitbox is larger.
So the player could still hit a tree while looking a little away, and so the script would not trigger
30.10.07 04:56:37 pm
Up
Guest
Mc Leaf has written:
You'll have to check, whether the player uses a weapon and which material the hit object is made of. For example
Code:
1
2
3
4
5
on:hit {
     if ((getplayerweapon()==0) && (compare_material("self","wood")==1)) {
          msg "Player has no weapon and the material is wood";
     }
}

The event will be triggered at the object hit by the player.


The prob is the "on:hit" never trigger...
30.10.07 05:43:37 pm
Up
Satis
User
Offline Off
on:hit only works on those items you are trying to hit, so the code should go there.
If you want to have the script in the player script, you should use:
on:attack

//Satis

>>EDIT<

Have anyone checked my source code for my research function and found any lag errors ??

Realy hope some one can help me in my problem.

//Satis
edited 1×, last 30.10.07 05:54:10 pm
4 years PHP coding ½-1 year Delphi Pascal Coding
30.10.07 08:11:29 pm
Up
Ice
User
Offline Off
ok, I finnaly subscribed, as I have more and more interest in this game and its language.

My goal is to have a more realistic game, a little like the old Robinson Requiem (horribly hard, but still fun!)
For this, I started with small things, like better recipes:

Hammer = stick+stone+cord or vine
Sharp Stone = Stone x2 + hammer
Spear = Stick + Sharp Stone + cord or vine
Crude Axe = stick + Sharp Stone x2 + cord or vine

Then, while thinking about recipes, I thought that it was kinda strange that the player could chop whole trees with his bare hands. So here I am with my little coding problems (still unsolved, as a on_hit event on all tree objects is tedious, and the on_attack event dont give the info I need on the target. The on_impact event give the correct info, but is not happening on bare hands...)

I also thought about a better health system (as the present one is quite... minimal). I would like to implement sickness from drinking still water, from being in bad weather without protection, from being in winter without warm clothes, etc...

I only start coding, and am not installing the other big mods, even if they seems quite interesting. I prefer to start little, with my own code, and I'll add mods when I'll be ready (or I'll quit when I'll be bored... we'll see).

A little comment about the core: is there any way to peek a look to the original code? Not 5 minutes in modding, I tumbled on something quite annoying: that 255 ID limitation... Any way to lift it?

A last thing: as I'm starting only today, I'm still a big noob and know nearly nothing about the scripting and modding. Worse, I dont speak german (only french and english) but hopefully, babelfish is here to help a little. But I work as a proggramer, and I usually learn very well new languages, so I hope I'll be of some use soon;
30.10.07 08:21:58 pm
Up
bizzl
User
Offline Off
That problem is simple to solve.
Just add following lines to game.inf:
Code:
1
2
3
limit_objects=4000
limit_units=200
limit_items=4000


limit_objects and limit_items can be much higher, but unluckily buildings and units can't be more than 200 I think.
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
30.10.07 08:24:23 pm
Up
Ice
User
Offline Off
Satis has written:
on:hit only works on those items you are trying to hit, so the code should go there.
If you want to have the script in the player script, you should use:
on:attack

//Satis

>>EDIT<

Have anyone checked my source code for my research function and found any lag errors ??

Realy hope some one can help me in my problem.

//Satis


Funny thing, I'm a delphi coder

About your problem, could you give more details? When you say it lag, its any time you do a research? Whatever research you do? And the lag is important? One second, two, ten?
30.10.07 08:56:59 pm
Up
Ice
User
Offline Off
a stupid question (and i'll ask a lot more...): how can I get the value of a variable in execution? I want to know the value of the damage the player does with his hands. I can modify it with player_damage, but how can I "get" it?

Nevermind, I think I found it... I need to experiment a little with those "class" but it should be ok
edited 1×, last 30.10.07 09:09:44 pm

Admin/mod comment:

please don't make double posts /Flying Lizard
30.10.07 10:10:35 pm
Up
Satis
User
Offline Off
bizzl has written:
That problem is simple to solve.
Just add following lines to game.inf:
Code:
1
2
3
limit_objects=4000
limit_units=200
limit_items=4000


limit_objects and limit_items can be much higher, but unluckily buildings and units can't be more than 200 I think.


In Massive Mod those values have been set to:
limit_objects=5000
limit_units=500
limit_items=5000
and it seams to work as well.


Ice has written:
Satis has written:
on:hit only works on those items you are trying to hit, so the code should go there.
If you want to have the script in the player script, you should use:
on:attack

//Satis

>>EDIT<

Have anyone checked my source code for my research function and found any lag errors ??

Realy hope some one can help me in my problem.

//Satis


Funny thing, I'm a delphi coder

About your problem, could you give more details? When you say it lag, its any time you do a research? Whatever research you do? And the lag is important? One second, two, ten?


Em sure.... read the other postes I made from the start on this problem
my first post aboud this problem is here:
http://www.unrealsoftware.de/forum_posts.php?post=53302&start=160#post63294

oh btw: I'm a delphi programmer too, so I know a litel around codes

//Satis
4 years PHP coding ½-1 year Delphi Pascal Coding
30.10.07 11:24:20 pm
Up
Ice
User
Offline Off
I was saying it was funny because I saw your sig :p

For your problem, the lag is not happening when you rename the "game" part in game_anw_research_events.inf

Of course, it doesn't work anymore after that, and I know too little to give you a working solution...
What I can guess is when you call a global event, it search in all "game*.inf" files to find the correct event to trigger. Since you have big files, it lag...

This would explain why you have the lag even with the Use key on land or to plant, since it also call a global event.

Maybe its possible to play with the Loadfile function to load the script you need. I dont know
31.10.07 10:26:06 am
Up
bizzl
User
Offline Off
There could be a simple solution:
Move all the research code into an info definition, and add following code to the on:load event in the game.inf:
Code:
1
if (count("info",59)==0) { create "info",59; }

Also, I you have a lot of repeating code (didn't get a look at the files, so I don't know) you can try to use variables for all hardcoded values (e.g. within range and height checks) and get the values via s2 cmd defparam in the earlier parts of your script.
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
31.10.07 11:58:53 am
Up
Ice
User
Offline Off
I need some help about the "addscript" command.
When translating the info with google, I get:

Addscript "class", ID, "Source"
Categories: objects
Adds a script about a particular object. If this item already has a script, this overwritten (use extendscript a script to an existing script to hang).
Enter at the source of an ID information in order to use the text or a file name to the text from the file to load.

I dont understand the "source" part, wich is quite badly translated, and my few tries are not working. Here is the code:

Code:
1
2
3
4
5
$tmp=create("object",240); 
     addscript "object",$tmp,"anw_research.inf";
     msg "test",3;
     event doresearch,"object",$tmp;
     free "object",$tmp;


the msg dont even show, so I guess the addscript is crashing. Can someone help me?

>Edit<

Ok, nevermind, I found it. By looking the original code, I found that it needed .s2s files. I changed the file type, and it worked!
edited 1×, last 31.10.07 12:13:56 pm
31.10.07 12:32:02 pm
Up
bizzl
User
Offline Off
Ice has written:
Ok, nevermind, I found it. By looking the original code, I found that it needed .s2s files. I changed the file type, and it worked!

It doesn't explicitly need *.s2s Files, it just has to be a Text file containing S2S-Code, and most *.inf simply doesn't
You should stick to the s2s file-suffix, though

About the Source: You can either, like you found out, load from a file (except for the sound commands, all parameters which can be file names and pathes must be relative to the mods root directory) or from any type of info (e.g. a text container) if you give an integer.
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
31.10.07 01:30:00 pm
Up
Ice
User
Offline Off
I have some hard time with the variables.
I want to "give" an object ID to another object, so this one can then call an event with this ID

My first tries with "setlocal" are not working. I get a 0 each time. A little help plz?

Maybe I could explain what I'm doing here.
I'm working on Satis "lag" problem.
So far, I no longer have lag when researching, but in doing so, I broke the end of the research, with the "success!" or "fail" part.

What I did was this: When I hit the key, it create an object, attach to it the main research script, and call its doresearch event. This script also create another object and attach to it a specific script for the object in hand. That way, the research code is broke in many .s2s files, one for each material researchable. Therefore, the code loaded is minimal, and there is no lag at all.
The problem is at the end of the research, the final script call an event in the main script, to conclude the research. But the specific research object dont "know" the ID of the main research one!
And this is where i'm stuck
edited 1×, last 31.10.07 01:39:44 pm
31.10.07 01:38:54 pm
Up
bizzl
User
Offline Off
Ice has written:
I have some hard time with the variables.
I want to "give" an object ID to another object, so this one can then call an event with this ID

My first tries with "setlocal" are not working. I get a 0 each time. A little help plz?

You actually should be able to do this via setlocal. Perhaps you tipped something wrong, but without code I can't tell for sure.
But using a global variable is much simpler, anyway. Just use a not so common name, like $ice_id_carrier
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
To the start Previous 1 2 ... 9 10 11 ... 121 122 Next To the start