bobbing script

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

bobbing script

Post by Luke » September 28th, 2005, 3:47 pm

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?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: bobbing script

Post by Drofder2004 » September 28th, 2005, 5:25 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 28th, 2005, 5:42 pm

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

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2005, 5:56 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 28th, 2005, 5:58 pm

oh, it says bad syntax, didnt see that before :?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2005, 6:14 pm

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);
}
} 
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2005, 6:15 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 28th, 2005, 6:49 pm

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

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2005, 11:57 pm

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);
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 29th, 2005, 11:47 am

it don't work without that line :? but oh well, it works thats the main thing :wink:

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 29th, 2005, 4:46 pm

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.)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

hehe

Post by Pwn-Rikku » October 1st, 2005, 3:08 pm

drofger how u do a double post??
rikku
Rikku - Old skool
Image
Image

User avatar
MuRpHy*
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 2159
Joined: May 10th, 2005, 11:02 pm
Location: Tha A.T.L Baby ;)

Post by MuRpHy* » October 1st, 2005, 3:17 pm

a double post is where you just post twice in a row without someone else postin . So like someone does 2 posts in arow.
Image
Image

Pwn-Rikku
CJ Spammer!
CJ Spammer!
Posts: 679
Joined: August 15th, 2005, 7:58 pm

no no no

Post by Pwn-Rikku » October 1st, 2005, 3:19 pm

no no no murphy drofger has done a double post
rikku
Rikku - Old skool
Image
Image

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » October 1st, 2005, 6:29 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests