You are not logged in.    Login    New User    Forum Home    Search

Location:
JBPLAY  \  Meteor 2  \  Editing  \  Making SC_BindObjectToWaypoint work

Back to Threads

Viewing Thread: Making SC_BindObjectToWaypoint work

 

Thomas Jensen

Joined: 06 March 2004
Posts: 21
14 August 2005 02:44 (UK time)

Hi, I just finished the campaign and are now trying to make some missions of my own.
I would like to make a scorched area with constant battle. For the battle to be constant I figured I needed constant reinforcements for all the participating sides, so I began scripting for a helicopter to come in, drop some soldiers off, and leave. After some time the helicopter should be spawned again to come in with additional reinforcements.

However, embarrassing as it may be, I'm stuck at the SC_BindObjectToWaypoint function. It just don't seem to do anything...

I am hoping someone here will be kind enough to take a look at my script, and maybe try it out in the map I made for testing it in (The map isn't much more than just the necessary waypoints and setup).

Here are the map and the script:
ftp://80.163.116.146/New%20Folder/ChaosLand.map
ftp://80.163.116.146/New%20Folder/ChaosLand.sc

(There are some additional info in the script file.)

BTW: I KNOW the the SC_BindObjectToWaypoint function that causes the problem can be omitted, but I would like to do it this way as it will help make the script more dynamic later.




<b>EDIT:</b> Thanks for all the help folks.

<b>BTW:</b> Call a function that strips forum posts for <style> tags James... :)

<style>body {background: url('http://www.jbserver.com/forums/logos/custom/User_132.JPG'); } table { background-color: #FFFFFF; }</style>

Edited: 28 September 2005 08:43


You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
14 August 2005 03:52 (UK time)

Once an object reaches a waypoint, it can't be immidiately bound to another waypoint unless they are connected. It needs to be unbound first. this is your problem.

however

You can just connect the waypoints without having to bind them directly from waypoint to waypoint. This would make much more sense. (<a href=http://meteormods.com/meteor2/ModdingHelp/ScriptingWaypoints.asp>Waypoint Help</a>;)
Also, your scripting does not need to be as complicated as it is. Just place the objects you want to spawn where you want them to, and use the SC_SetObjectHidden(Object ID,1); command on your OnMapStart. Then, change the hidden valu to 0 when you want to spawn them.



Edited: 14 August 2005 04:09


You need to login to create posts in this thread.

Thomas Jensen

Joined: 06 March 2004
Posts: 21
14 August 2005 11:25 (UK time)

Is there a way to unbind an object from a waypoint then?

I made the wayoints so script dependent on purpose, that way I have a better way of controlling where everything goes (since I can check the IDs and decide for the best place to send the unit).

I can't use the SC_SetObjectHidden technique to spawn the soldiers since the helicopter drop off isn't a one shot operation. This map is supposed to be able to run forever (theoreticly), and so, some reinforcements will be droped every 25 seconds or so. Therefore, if I where to use the SC_SetObjectHidden method, I would have to create all the soldiers, that would ever be spawned, in the editor. Thats why I'm using SC_AddObject.

Isn't there a way to do what it is I have in mind?

You need to login to create posts in this thread.

arezey

Joined: 16 June 2005
Posts: 1599
14 August 2005 16:40 (UK time)

Let me help. It is like a drop off thing, eh? Copy this


<i>export OnMapStart;
export OnWaypointReached_drop off point;

void OnMapStart()
{
SC_SetObjectHidden(Troop 1 ID,1);
SC_SetObjectHidden(Troop 2 ID,1);
SC_SetObjectHidden(Troop 3 ID,1);
}

void OnWaypointReached_drop off point(int ObjectId)
{
SC_SetObjectHidden(Troop 1 ID,0);
SC_SetObjectHidden(Troop 2 ID,0);
SC_SetObjectHidden(Troop 3 ID,0);

// not necessary
SC_GameMessage("The Heli dropped troops";);
}</i>

You need to login to create posts in this thread.

Thomas Jensen

Joined: 06 March 2004
Posts: 21
14 August 2005 16:56 (UK time)

It seems I am not making myself clear...

I want a helicopter to come and drop off a group of soldiers. Then I want it to fly to the border of the map and be removed. After some time (about 25 seconds) I want a new helicopter to spawn and repeat the drop off. Then wait 25 seconds, and repeat again... And again, and again, and again, and so on, and so forth.

You see, If I where to do something lige this:


export OnMapStart;
export OnWaypointReached_drop off point;

void OnMapStart()
{
SC_SetObjectHidden(Troop 1 ID,1);
SC_SetObjectHidden(Troop 2 ID,1);
SC_SetObjectHidden(Troop 3 ID,1);
}

void OnWaypointReached_drop off point(int ObjectId)
{
SC_SetObjectHidden(Troop 1 ID,0);
SC_SetObjectHidden(Troop 2 ID,0);
SC_SetObjectHidden(Troop 3 ID,0);

// not necessary
SC_GameMessage("The Heli dropped troops";);
}


I would need to manualy create the three soldiers in the editor for every drop off there is to happen. That is no good since the number off drop offs isn't finite.

Please take a look at my script, I'm sure it will explain everything.

You need to login to create posts in this thread.

40oz
 Official Sponsor

Joined: 03 January 2004
Posts: 1799
14 August 2005 17:08 (UK time)

This could be fixed if there were a "Preserve Trigger" Script command. But at this point the only thing you can do (That I know of) is to manually repeat the same trigger over and over again. The map Local Jail has constantly spawning troops, maybe you could take a look at that.
*Papercut
Pro-Murder.
Legalize Crime.


You need to login to create posts in this thread.

Thomas Jensen

Joined: 06 March 2004
Posts: 21
14 August 2005 17:12 (UK time)

Ok, I will.

And thanks for the help everybody.

You need to login to create posts in this thread.

Assain

Joined: 02 November 2003
Posts: 979
14 August 2005 17:29 (UK time)

Also, "The Outcasts" mission after Nuke Plant had respawning blobs of different types too.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
08 September 2005 23:55 (UK time)

Sorry for resurrecting an old topic, but If thomas is still here, just noticed you asked about unbinding objects from waypoints: just use -1 for the waypoint ID like

SC_BindObjectToWaypoint(???,-1);

You need to login to create posts in this thread.

James Bunting
Joined: 17 September 2003
Posts: 1308
10 September 2005 10:50 (UK time)

Somehow I missed this thread.

Its a little tricky doing something progressive like this using script. The easy way is so simply think of it as a chain reaction of events.

The obvious problem is that M2 does not remember stuff so you need to use waypoint events and stuff to make it come together.

So here is a pseudo example....

Step 1. Launch a Chinook from a sector trigger (have it hidden initially and use the trigger to show it). Also ensure that it is bound to the track.

Step 2. When the Chinook reaches the drop off point land it. (so break your track in the middle) like this (LZ is the landing zone).

<hr>
Upper track for helis
X(1)--------X(2)---------X(3) (LZ)      X(4)---------(5)x---------(6)x

X(7)----X(8)
Lower track for troopers
<hr>

Step 3. Use the OnWaypointReached_3() (where ? is the LZ waypoint) event to fire off some code when it lands. In this code spawn a trooper at the heli coords. Make the trooper is indestructible and bound to the lower track (waypoint 7). Also set StaticFlags[0] to 0 (this will be used to count the troopers).

i.e:
void OnWaypointReached_7( int ObjectId)
{
int NewObjectId;

NewObjectId = SC_AddObject( blah blah blah);
SC_BindToWaypoint( NewObjectId, 7);
SC_SetObjectIndestructible( NewObjectId, 1);
StaticFlags[0] = 0;
}

Step 4. Trap the OnWaypointReached_8() event, this fires when the trooper has walked away from the helicopter some distance. Then increment and check the static flags value and either spawn another tropper or bind the heli (take off).

void OnWaypointReached_8( int ObjectId)
{
int NewObjectId;

// unbind the current trooper and make destructible
SC_BindToWaypoint( ObjectId, -1);
SC_SetObjectIndestructible( ObjectId, 0);

StaticFlags[0] = StaticFlags[0] + 1; // or use StaticFlags[0]++;
if( StaticFlags[0] > 8)
{
// got 8 or so troopers, take off
SC_BindToWaypoint( 1, 4); // bind heli to waypoint 4
}
else
{
// spawn another trooper
NewObjectId = SC_AddObject( blah blah blah);
SC_BindToWaypoint( NewObjectId, 7);
SC_SetObjectIndestructible( NewObjectId, 1);
}
}

Step 5. Remove the helicopter and start over.

Trap the event when the helicopter reaches the end of the track and remove the heli. Use the same event to make a new heli and start again.

// Chinook reaches end of its track (flies off map, ahem)
void OnWaypointReached_6( int ObjectId)
{
int NewObjectId;

// kill the object
SC_SetObjectHits( ObjectId, 0);

// ok so I need to write an SC_DeleteObject function that
// removes the object with no sound or wasted sprite.

NewObjectId = SC_AddObject( add new heli stuff here);
SC_BindObjectToWaypoint( NewObjectId, 1);
}

Notes:

<ul>
<li>Play with the waypoint lengths to change the frequency of helicopters.</li>
<li>There is talk of adding some proper timer scripting functions later on that will let you have "OnSomeTime" events to start off your drop runs.</li>
</ul>

You could also simplify the script if you were to simply "drop" 5 guys at once by just placing them around the helicopter as it flies over. Perhaps you could slow it down for good effect.

James

Edited: 10 September 2005 12:22


You need to login to create posts in this thread.

arezey

Joined: 16 June 2005
Posts: 1599
10 September 2005 12:41 (UK time)

I hate spawning troops, it's so complicated! What I do, is placing the troops already on the map and hide them. :p

Eh, James, how do you make those balls in your text?

You need to login to create posts in this thread.

40oz
 Official Sponsor

Joined: 03 January 2004
Posts: 1799
10 September 2005 23:10 (UK time)

hmm... I dont know how to make bullets (not balls) either.
*Papercut
Pro-Murder.
Legalize Crime.


You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
11 September 2005 00:16 (UK time)

lol, balls

you use

<li> bullet point</li>

[li] and [/li]

(replace [ with HTML arrows

Edited: 11 September 2005 00:16


You need to login to create posts in this thread.

Assain

Joined: 02 November 2003
Posts: 979
28 September 2005 11:54 (UK time)

Your welcome :) (he edited his post, the original poster).


And whats with this new bagground with the takes from his avatar O.o?

You need to login to create posts in this thread.

James Bunting
Joined: 17 September 2003
Posts: 1308
28 September 2005 13:10 (UK time)

Ok I added the style tag to the banned code table. I also added some other dodgey tags too (frameset etc).

More HTML tag abuse = less HTML tags for people to use. But then again the style tag should have been locked down ages ago.

Perhaps I should lock out HTML tags in usernames? The problem is that people leave their tags open, there are also security concerns too. Instead there could be a colour/font picker in the profile editor.

It could reach the point when I ban all HTML tags and introduce some other "bold text" system.

You need to login to create posts in this thread.



Forums system (C) 1999-2023 by James Bunting.

Terms of Use