Jump to content
The Dark Mod Forums

Single entity: multiple locations depending on difficulty


Bikerdude

Recommended Posts

"diff_1_change_1" "origin"

"diff_1_arg_1" "X Y Z" (new origin coordinates for difficulty 1)

 

"diff_2_change_1" "origin"

"diff_2_arg_1" "X Y Z" (new origin coordinates for difficulty 2)

 

The default origin for difficulty 0 is (of course)

"origin" "X Y Z"

Link to comment
Share on other sites

Ok that have of my problem solved, because after I tried to have a go i realise i havent got a clue.

 

the entity is a valve wheel, and i want the player to be able to pick it up, add it to inventory get the the correct room and place it on a valve axel. But Im assuming the valve wheel cant ne a turnable entity and be grabbed and placed, so a script would have the replaced the one the player picked up with one that can turn..?

Link to comment
Share on other sites

the entity is a valve wheel, and i want the player to be able to pick it up, add it to inventory get the the correct room and place it on a valve axel. But Im assuming the valve wheel cant ne a turnable entity and be grabbed and placed, so a script would have the replaced the one the player picked up with one that can turn..?

 

Yes.

 

You could probably place the turning wheel on the axle and hide it, then make it visible when the inventory wheel gets near the axle. Remove the inventory wheel from the game at that point. I don't know how to do this w/o a script, so if someone has a non-script solution, you should consider that first.

Link to comment
Share on other sites

You use the Objective system to do it, no scripting needed. Just like the doll in "Inn Business" if you'd like an example. (I wouldn't advise hiding something, as it's still physically there to be bumped in to, but simply teleport it in place at the time.)

 

You have two objects, the inventory version and the turnable version. You have one hidden objective set to Incomplete, a teleport, a func_remove, and a relay to activate it all.

 

Where the wheel should be placed, have an atdm:teleport.

 

The Objective is set to "Two entities are within a radius of each other". Entity is your wheel from inventory. Location entity is your atdm:teleport item. Check on Irreversible and Player Responsible (the latter might not be required for your case, I wanted to avoid accidents in mine).

 

Distance depends on what you want, I used 22. Clock I set to 0.3 which is very responsive without being too taxing.

 

Now add two more things, a func_remove and a trigger_relay.

 

The func_remove targets your inventory wheel. The trigger_relay is the Completion Target for your objective, it targets the func_remove, as well as the atdm:teleport (which in turn targets the turnable wheel).

 

So, to review, the player has the wheel in inventory, when it gets within 22 units of the port, it completes the Objective, which triggers it's Completion Target, the relay, activating the func_remove to make the wheel held in the player's hand disappear right as the turnable wheel appears in place.

 

Make sense?

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

That's how I have done it in Old Habits:

 

The valve the player can pick up has to be a key, the place were he can attach it is a door. Use a translating door and set the translation to a very low amount. Note that the door has to move for this to work. The door has the spawnarg "used_by" "name_of_the_valve"

 

 

Place a atdm:mover_door with the valve model at the location it should end up when attached and hide it ("hide" "1" IIRC).

 

Doors trigger their targets if they get opened. So you let it target a target_callscriptfunction entity which has the spawnarg "call" "attachValve" on it.

attachValve is the name of the function that handles the rest.

void attachValve()
{
 $player1.replaceInvItem($name_of_valve_key, $null_entity); //removes the valve key from the players inventory
 $name_of_valve_door.show(); //makes the valve become visible
}

Let the valve target the door it should open, as said doors trigger their targets when opened, and doors open when triggered.

 

Instead of a script ou can also use the S+R system.

 

Let the handle where the valve gets attached to emit a custom stim, and let the valve react to it. The valve should be an object that gets to the players hands. As a response to the stim it should have the following settings.

 

"move to position" "$name_of_valve_door" "new position"

"remove" "_SELF"

 

The first effect causes the valve door, which should be in a blue room at mission start, to end up at the intented position. The second one causes the valve the player has found in the mission to be removed. This may be the easiest solution. The valve to be found needs to be a custom_moveable_item, the valve attached to the wall is a mover_door as said.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Ok, using Obs valve test map and Graymans insutructions and am getting the following error

 

line 142: Functions may not be defined within other functions

 

Obs edit script is as follows -

 

void unhideValve()
{
$valve_wheel_actual.show();
}
void hideValve()
{
$valve_wheel_actual.hide();
}

 

First line is number 142

Link to comment
Share on other sites

#ifndef __CITY_GATE_SCRIPT__
#define __CITY_GATE_SCRIPT__
// greebo: State change script for lever: Custom behaviour for opening the city gate, taken from The Outpost
void state_change_lever_city_gate1(entity lever, boolean bOpen, boolean bLocked, boolean bInterrupted)
{
if (bOpen)
{
 $CityGateOpenButton_1.activate(lever);
}
else
{
 $CityGateCloseButton_1.activate(lever);
}
}
#endif /* __CITY_GATE_SCRIPT__ */

void    setAgitatedInvestigate( entity e )
{
   // get agitated investigate alert threshold
   float threshold = e.getFloatKey( "alert_thresh4" );
   // check for 0?

   e.setAlertLevel( threshold );
}
// setting the alert level to suspicious threshold will result in observant state because of immediate decrease of the alert level
void    setSuspicious( entity e )
{
   // get suspicious alert threshold
//    float threshold = e.getFloatKey( "alert_thresh2" );
   // get threshold of level following suspicious
   float threshold = e.getFloatKey( "alert_thresh3" );
   // check for 0?

   e.setAlertLevel( threshold - 0.1 );
}

void alphonseDead()
{
   // play voice
   sys.trigger( $trigger_voice_Alphonse_dead );
   //  update ojectives
   sys.wait( 1 );
   $player1.setObjectiveState( 3, OBJ_FAILED );

   //  close the gate
   sys.wait( 0.5 );
   $city_gate_machine_lever_1.Close();

   //  teleport in guards and make them search
//  teleport_offset on the guards doesn't work so instead of one teleport entity two have to be used
/*    sys.trigger( $teleport_alarm_guards );
   string  match = "";
   entity  target;
   boolean nextMatch = true;
   while ( nextMatch )
   {
    match = $teleport_alarm_guards.getNextKey( "target", match );
    if ( match == "" )
	    nextMatch = false;
    else
    {
	    target = $teleport_alarm_guards.getEntityKey( match );
	    setSuspicious( target );
	    target.addTarget( $gatehouse_corner_1 );
	    //setAgitatedInvestigate( target );
    }
   }
*/
   entity target1, target2;
   target1 = $teleport_alarm_guard_1.getEntityKey( "target" );
   target2 = $teleport_alarm_guard_2.getEntityKey( "target" );
   sys.trigger( $teleport_alarm_guard_1 );
   sys.trigger( $teleport_alarm_guard_2 );
   target1.addTarget( $gatehouse_corner_1 );
   target2.addTarget( $gatehouse_corner_2 );
//    sys.wait( 2 );
//    setSuspicious( target1 );
//    setSuspicious( target2 );  
}
// this routine is called when the player closes the note
// that tells him the portcullis machinery is broken. Change
// the wording on the "Enter Inner City" objective.
void portcullisFailure()
{
   $player1.setObjectiveState( 1, OBJ_FAILED );
$player1.setObjectiveText(2,"Since the portcullis is inoperable, find another way into the Inner City.");
}
void alphonseDeadPathCornerReached()
{
/*
   string  match = "";
   entity  target;
   boolean nextMatch = true;
   while ( nextMatch )
   {
    match = $teleport_alarm_guards.getNextKey( "target", match );
    if ( match == "" )
	    nextMatch = false;
    else
    {
	    target = $teleport_alarm_guards.getEntityKey( match );
	    setAgitatedInvestigate( target );
    }
}
*/
   sys.wait( 3 );
   sys.trigger( $start_alarm_gatehouse );
//    entity target;
//    target = $teleport_alarm_guard_1.getEntityKey( "target" );
//    setAgitatedInvestigate( target );
//  target.alert();
//    target = $teleport_alarm_guard_2.getEntityKey( "target" );
//    setAgitatedInvestigate( target );
//  target.alert();
void unhideValve()
{
$valve_wheel_actual.show();
}
void hideValve()
{
$valve_wheel_actual.hide();
}

Link to comment
Share on other sites

Grayman has a point

void alphonseDeadPathCornerReached()
{
/*
string  match = "";
entity  target;
boolean nextMatch = true;
while ( nextMatch )
   {
		match = $teleport_alarm_guards.getNextKey( "target", match );
		if ( match == "" )
				nextMatch = false;
		else
		{
				target = $teleport_alarm_guards.getEntityKey( match );
				setAgitatedInvestigate( target );
		}
   }  <-----------------(this one)
}

Edited by Lux
Link to comment
Share on other sites

you have 3 " } " on your post but on my post above there are only 2, Im confused.

 

However, its is missing or addition brackets then the following like of code might causing something to not work as intended..?

 

*/
   sys.wait( 3 );
   sys.trigger( $start_alarm_gatehouse );
//    entity target;
//    target = $teleport_alarm_guard_1.getEntityKey( "target" );
//    setAgitatedInvestigate( target );
//  target.alert();
//    target = $teleport_alarm_guard_2.getEntityKey( "target" );
//    setAgitatedInvestigate( target );
//  target.alert();

 

It dosent have a open or closed bracket, should it..?

Link to comment
Share on other sites

However, its is missing or addition brackets then the following like of code might causing something to not work as intended..?

yep.

 

void alphonseDeadPathCornerReached()
{
/*
  string  match = "";
  entity  target;
  boolean nextMatch = true;
  while ( nextMatch )
  {
	   match = $teleport_alarm_guards.getNextKey( "target", match );
	   if ( match == "" )
			   nextMatch = false;
	   else
	   {
			   target = $teleport_alarm_guards.getEntityKey( match );
			   setAgitatedInvestigate( target );
	   }
}
*/
  sys.wait( 3 );
  sys.trigger( $start_alarm_gatehouse );
//	entity target;
//	target = $teleport_alarm_guard_1.getEntityKey( "target" );
//	setAgitatedInvestigate( target );
//  target.alert();
//	target = $teleport_alarm_guard_2.getEntityKey( "target" );
//	setAgitatedInvestigate( target );
//  target.alert();

}  // <-- This one must be added!

 

So the fuction without all the remarks looks like this:

 

void alphonseDeadPathCornerReached()
{
  sys.wait( 3 );
  sys.trigger( $start_alarm_gatehouse );

}  // <-- This one was missing

"To rush is without doubt the most important enemy of joy" ~ Thieves Saying

Link to comment
Share on other sites

To fix the script, you can put the missing

}

on a new line before the line that says

void unhideValve()

 

Yes, those 2 lines at the top of the bit you quoted are the ones that are missing their closing brace. They do have an opening brace -- it's the one just after "void alphonseDeadPathCornerReached()" but there's a load of inactive text in between that makes it harder to see. That text has been been commented out so it gets ignored by the script runner. Ditto for the text after those two lines but before void unhideValve().

Link to comment
Share on other sites

Glad to see you got it straightened out.

 

As for learning scripting, as long as you have several people here to help you out, there's no need. Focus on your own strengths. We come to you for performance help and architecture, and you come to us for scripting.

 

Should we all disappear, and you find yourself with no one to help you, then that's the time to dive into the world of scripting.

Link to comment
Share on other sites

Indentation doesn'T play a role in TDM scripting, or did you mean something else?

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Indentation doesn'T play a role in TDM scripting, or did you mean something else?

Lux set the curly bracket into the remaked part of the code. So it couln't work.

I guess that's what was meant by Lux ;)

"To rush is without doubt the most important enemy of joy" ~ Thieves Saying

Link to comment
Share on other sites

Lux set the curly bracket into the remaked part of the code. So it couln't work.

I guess that's what was meant by Lux ;)

 

Negative. I inserted the wrong brace because generally brace pairs are aligned by indent to be easier to read. I was just noting that I was confused as the closing brace for the one above it weren't on the same indent.

 

Does it matter? No. Is it easier to read? Yeah, but to each their own.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 1 reply
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...