Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 65 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Moving boat
Drullburk
General Member
Since: Nov 16, 2008
Posts: 4
Last: Dec 30, 2008
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 11:01 am
Hey guys.

Im currently working on a multiplayer map and i was thinking that it would mainly be a CTF Map, two seaparate islands with one team on each and a headquarter with the flag and some trenches and stuff to defend it. Anyway, to get between those islands i i want there to be a small dock or something on each island, containing a boat to load an small "invasion force" on and sail to the opponents island.

Anyway, thats a hard thing to do for me as a beginner. Ive made one boat to start with and made it a script_brushmodel. Ive created one origin where the boat is supposed to land and the soldiers should be jumping out and a trigger_use on the boat to start moving the boat.

Now the problems is how to make it work, and thats what i would like help with.

Boat targername is simply boat, origins targetname is Origin and the trigger is boattrigger. Could you help me with a script?
Share |
LynxVice
General Member
Since: Apr 26, 2008
Posts: 35
Last: Jun 7, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 11:21 am
Your script_brushmodel and origin brush needs the same targetname. Then you need to get your entity so you can use it in the script with:
Code:
invasion = getentarray ( "boat ", "targetname”);


You also need to get your trigger:
Code:
trig = getent ("boat_trigger ", "targetname”);


Now you want to tell the script to wait untill the trigger is hit and do a selected movement, you could use movez, movey or movex to move along what ever axis you want, so movez would move along the Z axis.

All of those commands use the following args: (< units >, < time >, < accel >, < decel >)

So your script would looks something like:

Code:
invasion_force()  // name of function
{
invasion = getent (" boat ", "targetname”);  // targetname of boat
trig = getent ("boat_trigger ", "targetname”);  // trigger
while (1)
{
trig waittill ("trigger");  // wait for trigger
invasion movex (80, 2, 0, 0.5);  // move on x axis 80 units
invasion waittill ("movedone”);  // wait till move has finished
wait (4);  // wait 4 seconds
invasion movex (-80, 2, 0, 0.5);  // move back 80 units
invasion waittill ("movedone”);  // wait till move has finished
}

}

That would move your boat 80 units on the x axis, wait 4 second then move it back to where it started.
Share |
LynxVice
General Member
Since: Apr 26, 2008
Posts: 35
Last: Jun 7, 2011
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 11:29 am
Forgot you can also use movetoif you want to specify an exact location rather than x amount of units.

moveto (< vector >, < time >, < accel >, < decel >)

Code:
boat moveto (( X, Y, Z ), < TIME>); 


All you need to do is specify the coordinates and the time to complete the move.
Share |
Drullburk
General Member
Since: Nov 16, 2008
Posts: 4
Last: Dec 30, 2008
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 11:32 am
Should i have 2 script_origins, one with the same name as the boat and one at the destination where i want it to arrive?
Share |
Drullburk
General Member
Since: Nov 16, 2008
Posts: 4
Last: Dec 30, 2008
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 11:58 am
This is how my script looks like now.

main()
{
maps\mp\_load::main();

setExpFog(0.0001, 0.55, 0.6, 0.55, 0);
// setCullFog(0, 16500, 0.55, 0.6, 0.55, 0);
ambientPlay("ambient_france");

game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";

setCvar("r_glowbloomintensity0", ".25");
setCvar("r_glowbloomintensity1", ".25");
setcvar("r_glowskybleedintensity0",".3");

}

invasion_force()
{
invasion = getent (" boat ", "targetname”);
trig = getent ("boat_trigger ", "targetname”);
while (1)
{
trig waittill ("trigger");
invasion movex (80, 2, 0, 0.5);
invasion waittill ("movedone”);
wait (20);
invasion movex (-80, 2, 0, 0.5);
invasion waittill ("movedone”);
}

Im sure ive done something wrong here, and i get a error message about line 24 (invasion = getent (" boat ", "targetname”);) what's wrong?
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Tuesday, Dec. 30, 2008 12:23 pm
"an error message" is not very precise... what is the exact error message you're getting?

My guess would be a syntax error, as the last " after targetname is a different ". (The same goes for the next line with the trigger.

invasion = getent (" boat ", "targetname);
trig = getent ("boat_trigger ", "targetname);

See?


A few other things about your script:

you don't call the invasion_force() function in your main script. so the boat will never move.
You're missing a } at the end of your invasion_force() function.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»