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

Location:
JBPLAY  \  Meteor 2  \  Help and Guidance  \  Scripting question

Back to Threads

Viewing Thread: Scripting question

 

mike323
Joined: 23 January 2005
Posts: 745
27 April 2005 05:08 (UK time)

OK, i'm baffled. Whats wrong with this?

-------------------------------------------------------
#title "Mountain Infiltration"
#author "Michael"

#include meteor2

// tell M2 which functions it can use
export OnWaypointReached_11;
export OnMapStart;


void OnMapStart()
{
// map start code here
SC_SetObjectIndestructible(1,1);
SC_GiveItem("SMG",1);
SC_GiveItem("Rocket Launcher",1);
SC_SetObjectHidden(15,1);
}

// Make elite get out of banshee
void OnWaypointReached_11(7)
{
// uncover him
SC_SetObjectHidden(15,0);
}
---------------------------------------------

I have checked the object IDs and waypoint IDs and I still cant figure out why its not working.

You need to login to create posts in this thread.

Zable Fahr

Joined: 04 November 2004
Posts: 74
27 April 2005 07:28 (UK time)

"void OnWaypointReached_11(7)"

Unless there's a crazy shortcut that I'm not aware of, that 7 shouldn't be there. Stuff inside the parentheses when you're making a new function are parameters and are replaced when the functions _runs_ and not when you write it. I believe that 7 should read "int objectID" and there would then be a part in the function that checks if (objectID == 7).

It should probably read:
<pre>

void OnWaypointReached_11(int ObjectID)
{
// Object 7 reaches waypoint 11
if (ObjectID == 7) {
// uncover him
SC_SetObjectHidden(15,0);
}
}

</pre>

Edited: 27 April 2005 07:31


You need to login to create posts in this thread.

Dave Man

Joined: 19 October 2003
Posts: 374
27 April 2005 13:31 (UK time)

While reading this post I noticed that you put the map name where it says map name"...". Can you actually do that?

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
27 April 2005 22:19 (UK time)

I dunno, I just filled in the blanks...

thanks all!

Edited: 27 April 2005 23:41


You need to login to create posts in this thread.

Zable Fahr

Joined: 04 November 2004
Posts: 74
28 April 2005 07:47 (UK time)

I may be wrong, but I think the map name in the script file only shows up in a console message when the map loads. Otherwise, it uses the name in the map file. At least that's what I remember happening.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
28 April 2005 17:58 (UK time)

Okay, I just figured out the reason some of my scripts werent working...its was because of...erm...that.

You need to login to create posts in this thread.

me_mantis

Joined: 26 September 2003
Posts: 1152
28 April 2005 20:50 (UK time)

Just to speed up script testing, I always include this line in my "OnMapStart" thingy. SC_GameMessage("The Script is working!!";);
It saves me countless hours of walking to the first trigger.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
29 April 2005 06:05 (UK time)

Cool idea...

I have another problem. I can't figure out how to use the SC_GetPlayerObjectID function. Could someone use it in an example or explain how to use it?

You need to login to create posts in this thread.

Dave Man

Joined: 19 October 2003
Posts: 374
29 April 2005 13:32 (UK time)

The SC_GetPlayerObjectId has its uses but they are limited. Basically the function jsut tells you the player object's id. You could use that to transport the player to a different place or set it indestruticble like this:
SC_SetObjectIndestructible(SC_GetPlayerObjectID(),1);
I'm not specifically sure that "ID" should be Id or ID and I'm not sure about the "()" at the end.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
29 April 2005 22:44 (UK time)

Huh, this is what I'm trying to do.

SC_SetObjectCoords(SC_GetPlayerObjectID(),1942,4180);

it says in the console error no. 4 and it says GetPlayerObjectID is undeclared.

Edited: 29 April 2005 22:46


You need to login to create posts in this thread.

Dave Man

Joined: 19 October 2003
Posts: 374
30 April 2005 15:37 (UK time)

Yeah, it would say that because you don't have the right code.
It should be: SC_GetPlayerObjectId()-notice the small "d".
Try that and if that doesn't work you could always use this code:
int Player SC_GetPlayerObjectId();
to save the Player's Id as the vairable Player and then use "Player" in the objectid box.

You need to login to create posts in this thread.

James Bunting
Joined: 17 September 2003
Posts: 1308
30 April 2005 20:39 (UK time)

Yes the old “ID” whoopsie, an easy hole to fall down but remember…

The capital letters thing is strictly for "words" only (regardless of acronyms). Therefore "Id" is always “Id” and never “ID”, its easier to read this way. You will find that this is consistent throughout the scripting commands.

For example if there was a command called “SC_GetIDOfPlayer()” it would look pants compared to “SC_GetIdOfPlayer” IMHO. The consistency thing is the key.

The title in the script file is actually the script title, this is basically provided by the SeeR scripting library but Meteor 2 ignores this value.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
01 May 2005 06:00 (UK time)

Oh, okay.

Gee, this is turning into the help-me thread lol

Next question is...

I have an OnObjectDie trigger. Here's how I set it up:
export OnObjectDie_17;

void OnObjectDie_17()
{
SC_GameOver("The extraction warthog has been destroyed!";);
}

The weird thing is, there's this switch next to a force field. I used the openforcefield command and for the wierdest, strangest, most wacko reason, when I open the force field it runs the onobjectdie trigger and I don't have the slightest idea why.

Any ideas?

You need to login to create posts in this thread.

James Bunting
Joined: 17 September 2003
Posts: 1308
01 May 2005 10:23 (UK time)

I am glad that you bought this up.

During recent testing of M2's more advanced campaign missions similar problems have been observed.

These have so far being restricted to OnObjectDie events firing for a second time, long after the object had died.

Oddly enough at least one map in question has a forcefield that is opened some time before this problem occours using SC_OpenForcefield.

I will need to look into it. If this happens all the time then you should send me your map (don't worry about sending the modded objects etc, I can substiture those) as I can not replicate this problem on demand.

James.

You need to login to create posts in this thread.

mike323
Joined: 23 January 2005
Posts: 745
02 May 2005 00:38 (UK time)

Whew, then it's not me being an idiot. I'll send you the map James

You need to login to create posts in this thread.



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

Terms of Use