Page 1 of 2

bobbing script

Posted: September 28th, 2005, 3:47 pm
by Luke
Well i thought it was about time i had a go at scripting, but i'm a complete noob so i need some help lol. so far i've followed this tut to do bobbing http://www.modsonline.com/Tutorials-read-185.html except i used script_brushmodels, which works fine, but i also want to add another script_brushmodel to move side to side, but i'm not sure how you add another thread or whatever to make them both work together..here is the script i use for the bobbing:

main()
{
maps\mp\_load::main();
maps\mp\map_efx::main();
thread boatbobbing();
}
boatbobbing()
{
boat = getent("boat","targetname"); // Get the name of the script_model
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
org = (-64, 96, 72); // Define Origin or Location of Your Boat/script_model
timer = 3; // Speed of the Bobbing - Higer Number Slower Bobbing
while (1)
{
boat moveto (org + (0,0,500), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
wait (timer);
boat moveto (org + (0,0,-500), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
wait (timer);
}
}

this works fine on its own, but how do i add a different scrip_brushmodel? i've tried adding this to it:


thread boatbobbing2();
}
boatbobbing()
{
boat2 = getent("boat","targetname"); // Get the name of the script_model
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
org = (-64, 96, 72); // Define Origin or Location of Your Boat/script_model
timer = 3; // Speed of the Bobbing - Higer Number Slower Bobbing
while (1)
{
boat2 moveto (org + (300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
wait (timer);
boat2 moveto (org + (-300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
wait (timer);
}
}

but i get script compile error :( what am i doing wrong?

Re: bobbing script

Posted: September 28th, 2005, 5:25 pm
by Drofder2004
Luke wrote:Well i thought it was about time i had a go at scripting, but i'm a complete noob so i need some help lol. so far i've followed this tut to do bobbing http://www.modsonline.com/Tutorials-read-185.html except i used script_brushmodels, which works fine, but i also want to add another script_brushmodel to move side to side, but i'm not sure how you add another thread or whatever to make them both work together..here is the script i use for the bobbing:

main()
{
maps\mp\_load::main();
maps\mp\map_efx::main();
thread boatbobbing();
}
boatbobbing()
{
boat = getent("boat","targetname"); // Get the name of the script_model
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
org = (-64, 96, 72); // Define Origin or Location of Your Boat/script_model
timer = 3; // Speed of the Bobbing - Higer Number Slower Bobbing
while (1)
{
boat moveto (org + (0,0,500), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
wait (timer);
boat moveto (org + (0,0,-500), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
wait (timer);
}
}

this works fine on its own, but how do i add a different scrip_brushmodel? i've tried adding this to it:


thread boatbobbing2();
}
boatbobbing()
{
boat2 = getent("boat","targetname"); // Get the name of the script_model
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
org = (-64, 96, 72); // Define Origin or Location of Your Boat/script_model
timer = 3; // Speed of the Bobbing - Higer Number Slower Bobbing
while (1)
{
boat2 moveto (org + (300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
wait (timer);
boat2 moveto (org + (-300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
wait (timer);
}
}

but i get script compile error :( what am i doing wrong?
To narrow down the error, simply scroll up in the console. It will tell you the exact line that the error is on.
Post that up, im taking a look through the code, but that wouldspeed it up.

Posted: September 28th, 2005, 5:42 pm
by Luke
I looked right through the console after the error, but i dont know what i'm looking at..theres nothing there that looks like anything to do with the scripts.. might be something simple since i was just taking a stab in the dark

Posted: September 28th, 2005, 5:56 pm
by Drofder2004
Luke wrote:I looked right through the console after the error, but i dont know what i'm looking at..theres nothing there that looks like anything to do with the scripts.. might be something simple since i was just taking a stab in the dark
It should be right above the error, or below. But either way, right next to it.

Posted: September 28th, 2005, 5:58 pm
by Luke
oh, it says bad syntax, didnt see that before :?

Posted: September 28th, 2005, 6:14 pm
by Drofder2004
Im going to go through your code and add explanations in bold beneath each section/line.

main()
{
maps\mp\_load::main(); This is used to load some of the stock cod effects, e.g minefields
maps\mp\map_efx::main(); This will look for a file in the maps/mp folder called map_efx
thread boatbobbing(); This will load the thread called boatbobbing
}

boatbobbing() Boatbobbing thread starts here
{
boat = getent("boat","targetname"); Gets the script_brushmodel w/ targetname "boat"
wait (randomfloat (1.5)); Generates a number between 0 and 1.5 and waits that time
org = (-64, 96, 72); This is the origin of you script_brushmodel
timer = 3; Speed of the bobbing cycle

while (1) This will create a looping script
{
boat moveto (org + (0,0,500), timer, timer*0.5, timer*0.5); This will move the boat on the z axis by 500
timer = time it takes, timer*0.5 = acceleration and decceleration
wait (timer); Wait the length of time specified by "timer"
boat moveto (org + (0,0,-500), timer, timer*0.5, timer*0.5); Same as above, but downwards 500
wait (timer); Same as above
}
} End of boatbobbing

This is where things go wrong

thread boatbobbing2(); This should be at the top of the script, inside the main() section
}
boatbobbing() Typo, this wil certainly cause errors, change to boatbobbing2()
{
boat2 = getent("boat","targetname"); // Get the name of the script_model
wait (randomfloat (1.5)); // Generate a random Number of Seconds Between Bobbings
org = (-64, 96, 72); // Define Origin or Location of Your Boat/script_model
timer = 3; // Speed of the Bobbing - Higer Number Slower Bobbing
while (1)
{
boat2 moveto (org + (300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Above Original Location
wait (timer);
boat2 moveto (org + (-300,0,0), timer, timer*0.5, timer*0.5); // 2 is the number of units to go Below Original Location
wait (timer);
}
}



Problems are...
maps\mp\map_efx::main();
^What is that? Do you have a file called "map_efx" as this would cause errors.

Same targetname.
boat2 = getent("boat","targetname");
you cannot use 2 different names for the same targetname.

Basically, this script is telling "boat" to do 2 different things at the same time.
If you have another boat, change the targetname to "boat2"
and change the line above to
boat2 = getent("boat2","targetname");
you will also need to change the origin of the 2nd boat
org = (-64, 96, 72);

A final script should look something like this.

Code: Select all

main()
{
maps\mp\_load::main();
thread boatbobbing();
thread boatbobbing2();
}

boatbobbing()
{
boat = getent("boat","targetname");
wait (randomfloat (1.5));
org = (-64, 96, 72);
timer = 3;
while (1)
{
boat moveto (org + (0,0,500), timer, timer*0.5, timer*0.5);
wait (timer);
boat moveto (org + (0,0,-500), timer, timer*0.5, timer*0.5);
wait (timer);
}
}

boatbobbing2()
{
boat2 = getent("boat2","targetname");
wait (randomfloat (1.5));
org = (-##, ##, ##);
timer = 3;
while (1)
{
boat2 moveto (org + (300,0,0), timer, timer*0.5, timer*0.5);
wait (timer);
boat2 moveto (org + (-300,0,0), timer, timer*0.5, timer*0.5);
wait (timer);
}
} 

Posted: September 28th, 2005, 6:15 pm
by Drofder2004
Luke wrote:oh, it says bad syntax, didnt see that before :?
It will be a little more specific then that.. e.g

Line 57
}

Bad Syntax

The little } would be the problem, which you would need to find and fix.

Posted: September 28th, 2005, 6:49 pm
by Luke
wow thanks drofder you're a legend, your script works, thanks for the explanation :). btw, it didnt say which line in the console for syntax error, and i spotted those typos :P
i think maps\mp\map_efx::main(); was there coz i've been trying to get fire and custom sounds, i guess one of them uses that, i dont know, but yea it shouldnt be there, might have been the cause :P

and does this line org = (-64, 96, 72); actually do anything? it seems whatever i put in there it doesnt make no difference, and i put the same origin numbers in for both and they are working lol

Posted: September 28th, 2005, 11:57 pm
by Drofder2004
Luke wrote:and does this line org = (-64, 96, 72); actually do anything? it seems whatever i put in there it doesnt make no difference, and i put the same origin numbers in for both and they are working lol
I doubt they do anything other than set the origin. But everytime I do my scripts, I use the origin texture in the mapping to set the origin.

Remove them and use this code, see if it works.

Code: Select all

main()
{
maps\mp\_load::main();
thread boatbobbing();
thread boatbobbing2();
}

boatbobbing()
{
boat = getent("boat","targetname");
wait (randomfloat (1.5));
timer = 3;
while (1)
{
boat moveto (boat.origin + (0,0,500), timer, timer*0.5, timer*0.5);
wait (timer);
boat moveto (boat.origin + (0,0,-500), timer, timer*0.5, timer*0.5);
wait (timer);
}
}

boatbobbing2()
{
boat2 = getent("boat2","targetname");
wait (randomfloat (1.5));
timer = 3;
while (1)
{
boat2 moveto (boat.origin + (300,0,0), timer, timer*0.5, timer*0.5);
wait (timer);
boat2 moveto (boat.origin + (-300,0,0), timer, timer*0.5, timer*0.5);
wait (timer);
}
}

Posted: September 29th, 2005, 11:47 am
by Luke
it don't work without that line :? but oh well, it works thats the main thing :wink:

Posted: September 29th, 2005, 4:46 pm
by Drofder2004
Luke wrote:it don't work without that line :? but oh well, it works thats the main thing :wink:
Ofcourse :)

It probably dont work as the boat hasnt been given an origin brush. Without the brush it doesnt have an origin (unless the origin is defined by the script, for example, the script you posted.)

hehe

Posted: October 1st, 2005, 3:08 pm
by Pwn-Rikku
drofger how u do a double post??
rikku

Posted: October 1st, 2005, 3:17 pm
by MuRpHy*
a double post is where you just post twice in a row without someone else postin . So like someone does 2 posts in arow.

no no no

Posted: October 1st, 2005, 3:19 pm
by Pwn-Rikku
no no no murphy drofger has done a double post
rikku

Posted: October 1st, 2005, 6:29 pm
by Luke
lol who cares, sometimes we do it to let others know of a new post in the topic if other topics are above it. if you just edited it ppl aren't gonna notice sometimes