Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

I've got a func_static model to do what you want, but the moveable I tested on falls through the floor and flops around...

Here's the script I used:

while(1) {
		vector playerPos = $player1.getOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		
		$thing.setAngles(sys.VecToAngles(diff));
		sys.waitFrame();
	}

Edit: if the crow you mentioned was an AI, it probably used faceEntity() or similar: only available for AI, according to the script docs.

 

Edit 2: maybe you could bind a func_static to an invisible moveable and make them frob peers? I suspect that trying to set the angles of the moveable itself is making its collision model clip through surfaces, and there's no rotateTo() for moveables. The bound func_static would probably either have to levitate or clip into things sometimes, though.

Edited by VanishedOne
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

You can get the player's f.o.v. and view angles in a script; presumably the simplest option would be to get the angle, imagine lines going left and right of it at 90° and assume the player can't see anything behind those lines.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I've got a func_static model to do what you want, but the moveable I tested on falls through the floor and flops around...

 

Here's the script I used:

while(1) {
		vector playerPos = $player1.getOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		
		$thing.setAngles(sys.VecToAngles(diff));
		sys.waitFrame();
	}

Edit: if the crow you mentioned was an AI, it probably used faceEntity() or similar: only available for AI, according to the script docs.

 

Edit 2: maybe you could bind a func_static to an invisible moveable and make them frob peers? I suspect that trying to set the angles of the moveable itself is making its collision model clip through surfaces, and there's no rotateTo() for moveables. The bound func_static would probably either have to levitate or clip into things sometimes, though.

 

I've changed the situation so that the model is only a func_static object now instead of a moveable. I'll give this script a try, thank you!

 

edit: I just placed it into my scripts and changed the "$thing" to "$func_static14" however it doesn't work.. is there anything else you did to get it working? I also tried doing a "reloadscript" command and it returned no error so the script should be working. All of my other scripts needed an entity to call on them but I assume the "while(1)" part is just an ongoing thing.

Edited by Goldwell
Link to comment
Share on other sites

It's inside my map script's main(); I didn't know where you'd want to deploy it so I omitted that.

 

Oh I added it in there and the func_static follows me however it's facing away from the player. It seems that it doesn't factor in rotation and just resorts to whatever the default rotation angle is (but still follows the player as they move around).

 

edit: to show you what I mean.. add this into your map and change the entity name accordingly

 

 

 

Version 2
// entity 0
{
"classname" "info_player_start"
"name" "info_player_start_1"
"angle" "-1.4033418253411173e-014"
"origin" "-3296 368 -56"
}
// entity 1
{
"classname" "func_static"
"name" "func_static_18"
"origin" "-3192 363 -3"
"model" "models/darkmod/graveyard/bones/skull2.ase"
}

 

 

Edited by Goldwell
Link to comment
Share on other sites

I expect setAngles() overrides the rotation spawnarg.

while(1) {
		vector playerPos = $player1.getOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		vector angle     = sys.VecToAngles(diff);
		vector rotation  = '0 270 0'; // adjust to suit
		angle            = angle + rotation;
		
		$thing.setAngles(angle);
		sys.waitFrame();
	}

Edit: hmm, it does seem to turn on its side when I get close. Jumping increases the effect, so it must be because of the relative heights of our origins, and the script making $thing turn to face me in all three axes. Jumping on top of it is like a bucking bronco.

Edited by VanishedOne
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I was trying to get to where VanishedOne was going, but also not making the moveable slide around. Instead I created a murder machine.

vector upabit = '0 0 8';
	while(1) {
		vector thingPos  = $thing.getOrigin();
		vector updatedPos = upabit + thingPos;
		$thing.setOrigin(updatedPos);
		sys.waitFrame();
	}

I suggest you try this piece of code with a heavy moveable, like a crate. Best to unleash it next to some friendly AI.

PS: Do not attempt to touch the rampaging crate, it makes it angrier.

 

EDIT: Video footage of the disaster has surfaced.

Edited by Spooks
  • Like 3

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

I expect setAngles() overrides the rotation spawnarg.

while(1) {
		vector playerPos = $player1.getOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		vector angle     = sys.VecToAngles(diff);
		vector rotation  = '0 270 0'; // adjust to suit
		angle            = angle + rotation;
		
		$thing.setAngles(angle);
		sys.waitFrame();
	}

Edit: hmm, it does seem to turn on its side when I get close. Jumping increases the effect, so it must be because of the relative heights of our origins, and the script making $thing turn to face me in all three axes. Jumping on top of it is like a bucking bronco.

 

I have the same problem, as I move closer it seems to effect the rotation angle in more ways then one. If I rotate the func_static to face towards the player it has a rotation field that's a bit different then the XYZ "0 -1 0 1 0 0 0 0 1" which might have something to do with it

Link to comment
Share on other sites

I wonder whether the problem is just that the player's viewpoint/eyeline is higher than the player's origin... Edit: no, that wouldn't account for a sideways twist.

 

Maybe it's a problem of rotation around the world's axis versus $thing's own axis?

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I would guess you need to not rotate around the X and Y axes if the skull is just supposed to look at you laying flat on some surface, rather than on a spike or something. Kind of like a grass sprite vs a lamp glow sprite. Then the tilting would not be present, but of course, that may not be ideal if the skull is supposed to track you on all 3 dimentions rather than on a level field.

Edited by Spooks

My FMs: The King of Diamonds (2016) | Visit my Mapbook thread sometimes! | Read my tutorial on Image-Based Lighting Workflows for TDM!

 

 

Link to comment
Share on other sites

Yes, it seems a 2D pivot will work if you add a line that resets angle_x to 0 before calling setAngles(). (However, you'll still get flung about if you jump onto $thing.)

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Yes, it seems a 2D pivot will work if you add a line that resets angle_x to 0 before calling setAngles(). (However, you'll still get flung about if you jump onto $thing.)

 

You could perhaps set the func_static with a spawnarg of "is_mantleable" = 0 which would make it impossible to climb onto the object or a player clip surrounding it is another possibility

Link to comment
Share on other sites

Okay, I think I've got rid of the weird tilt. (The mantling problem still exists, but if the player doesn't need to be able to touch it then the playerclip solution should work fine.)

while(1) {
		vector playerPos = $player1.getOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		vector angle     = sys.VecToAngles(diff);
		vector rotation  = '0 270 0'; // adjust to suit
		angle_z          = abs(angle_x);
		angle_x          = 0;
		angle            = anglemod360(angle + rotation); // anglemod probably isn't needed; I added it for more readable debug output
		
		$thing.setAngles(angle);
		sys.waitFrame();
	}

Edit: hmm, I notice the skull keeps looking upwards when I move near it and crouch. Maybe you could bind something to the player's head and use its origin instead of $player1's...?

 

Edit2: no, still not right: if I put the skull up high, it still looks upwards instead of downwards when I move near.

 

Edit3: I've added a call to abs() which I think solves this. However, it's hard to be certain because of the player-origin-versus-eyeline question. If I noclip and fly around the skull, it looks upwards when I'm above it, provided I'm high enough. Put it near my eyeline and walk up to it, and it looks downwards.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Okay: place a func_static (here named "player_skull") over the player's start point, set "hide" "1" and "solid" "0" on it, and use this updated script:

$player_skull.bindToJoint($player1,"Head",1);
	while(1) {
		vector playerPos = $player_skull.getWorldOrigin();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		vector angle     = sys.VecToAngles(diff);
		vector rotation  = '0 270 0'; //adjust to suit
		angle_z          = abs(angle_x);
		angle_x          = 0;
		angle            = anglemod360(angle + rotation);
		
		$thing.setAngles(angle);
		sys.waitFrame();
	}

$thing will now look right at you (once player_skull is suitably positioned) even when you crouch. It's also possible to stand on it now, for the most part.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

What is the purpose of $player_skull?

 

If it's only to establish where the player's eyes are, even when crouching, you can get that in a much simpler way:

 

vector playerPos = $player.getEyePos();

 

A couple efficiency comments:

 

vector thingPos = $thing.getOrigin();

 

should be moved before the loop if $thing never changes its origin.

 

vector rotation = '0 270 0'; //adjust to suit

should be moved before the loop, since it's a constant. (What's this for, btw?)
  • Like 1
Link to comment
Share on other sites

It's to replace the rotation spawnarg if $thing is facing away from the player in its natural orientation, since setAngles() appears to override the angles initially set (and rotation isn't a simple vector key).

 

Edit: though with the assignment outside the loop, maybe getAngles() would also work. It's awkward in that what's wanted isn't rotation relative to the world as seen in DR, but a modifier to make $thing face the player.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I'm trying to run the script on a simple test map, and I'm getting game error "Line 1: 'player_skull' is not a type", despite there being a func_static named "player_skull" in the map, situated directly above the player start (as prescribed). Am I doing something wrong?

Link to comment
Share on other sites

Presumably, but since since grayman informed us of a better way, just dispense with player_skull and run this version:

 

while(1) {
		vector playerPos = $player1.getEyePos();
		vector thingPos  = $thing.getOrigin();
		vector diff      = thingPos - playerPos;
		vector angle     = sys.VecToAngles(diff);
		vector rotation  = '0 270 0'; // adjust to suit
		angle_z          = abs(angle_x);
		angle_x          = 0;
		angle            = anglemod360(angle + rotation);
		
		$thing.setAngles(angle);
		sys.waitFrame();
	}
(Still the unoptimised code; anyone wanting to optimise it should try removing the call to anglemod360(), since it's only there to make debug output easier to read.)
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Found the problem: forgot the main method 'cus I'm an idiot :P

 

The above script works (and is super creepy!), but still causes rotation on the z-axis, at least with the statue I'm using.

Link to comment
Share on other sites

What's the object that's supposed to "look" at the player?

 

Is it like a skull that sits on a table/floor/pedestal and would even look at the player when he's going up and down stairs (i.e. exhibits pitch and yaw changes), or is it like a statue that would look silly trying to do that, and so is limited to yaw changes only?

Link to comment
Share on other sites

Also, you don't want to put the while() loop inside the main() routine, in case you want the main() routine to execute code after the while() loop.

 

It's better to do this:

 

void trackPlayer()

{

while(1)

{

<code to track Player>

}

}

 

main()

{

<some code>

thread trackPlayer();

<some code>

}

  • Like 1
Link to comment
Share on other sites

Goldwell's is a skull; Aosys wanted to adapt it for something like a Weeping Angel.

 

@Aosys Try replacing abs(angle_x); with 0;

 

Worked like a charm, thanks!

 

Also, you don't want to put the while() loop inside the main() routine, in case you want the main() routine to execute code after the while() loop.

 

Yeah, I figured as much. For now, I'm just doing it for testing purposes. In my actual WIP I'll be sure to create a separate method, and hopefully be able to call it after a specific event.

  • Like 1
Link to comment
Share on other sites

That works perfectly, thank you!

Edited by Goldwell
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

    • nbohr1more

      In addition to voting for TDM, let's help our friend Skacky garner some Moddb recognition for the momentous release of "The Black Parade" https://www.moddb.com/mods/thief-the-black-parade
      · 0 replies
    • peter_spy

      I don't think The Last of Us part I is a good game; it is something else in terms of pure audio-visual experience though. The attention to detail is insane, especially in sound and animation.
      · 0 replies
    • snatcher

      TDM Modpack v3.8 released!
      Introducing the SHOCK MINE!
      · 1 reply
    • JackFarmer

      If you find the new Beatles song "Now and Then", which was created with the help of AI, totally boring, then you should better play the mission of the same name by our esteemed mission maker friend joebarnin, because the latter is actually a creative milestone!
      · 4 replies
    • datiswous

      Idea: Thief 3 style missions.
      One of the great features of Thief 3 are missions defided in small segments with loading screens when you move from segment to segment. We all miss those right? I was thinking of mapping only horizontal, so not stacked. When you go up or down (stairs or elevator), you get a 20 seconds fake loading screen where you can play a minigame (The Builder's Blocks?). After that you get teleported to a different area that seems to be on top of the first, but actually isn't in the map file. It's much easier mapping, because you can see everything in one glance from above. This could also give more freedom building, because it doesn't have to fit. Everything is predictable because guards don't move to different sections.
      This could be used for the Thief 3 contest possibly..
      · 7 replies
×
×
  • Create New...