Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)
8 hours ago, Dragofer said:

In that case you can specify a completion script for the objective in the objective editor, i.e. bienie_add_item. The script could look like below:


void bienie_add_item()
{
	$player1.replaceInvItem($bienie_custom_item_part1, $null_entity);
	$player1.replaceInvItem($bienie_custom_item_part2, $null_entity);
	$player1.replaceInvItem($bienie_custom_item_part3, $null_entity);
	$player1.replaceInvItem($bienie_custom_item_part4, $null_entity);
	$player1.addInvItem($bienie_custom_item_complete);
}

bienie_custom_item_complete would need to exist somewhere in your map, i.e. your blue room.

 

 

Thanks for that script, though it seems there is a problem. When it runs it gives me the error:  Entity not found for event 'replaceInvItem'. Terminating thread. I've made sure that the items are correctly named and correlate to the script (the objective ticks so it's not a mistype). edit: could this be another instance of the "items changing name when they stack in the inventory" bug?

If this is even going to be an objective I keep though I have to also figure out the second part of it. I need the item that is given to the player to teleport a specific AI in front of the player when it is "used", i.e. similar to using a key on a door or drinking a potion. I looked at using the stim/response system, but the teleport function there seems to only allow for teleporting to fixed locations? Basically there is no option for "relative to player" only "relative to origin of object being teleported". Also trying to make the stim/response system recognize the player "using" an item seems to be a problem? Couldn't find an appropriate stim category, as "frob" did nothing. Thoughts / Ideas?

Edited by Bienie
additional idea

My Fan Missions:

   Series:                                                                           Standalone:

Chronicles of Skulduggery 0: To Catch a Thief                     The Night of Reluctant Benefaction

Chronicles of Skulduggery 1: Pearls and Swine                    Langhorne Lodge

Chronicles of Skulduggery 2: A Precarious Position              

Chronicles of Skulduggery 3: Sacricide

 

 

 

Posted

Don't know exactly, but if I was doing it with scripting, I'd think about using $player1.getOrigin() and probably $player1.getViewAngles(), calculate the position I want the AI to appear, and then use setOrigin() to place it there. For the calculation, you could hardcode the distance, or create a more general script object and pass the distance as a spawnarg; the "trigger_look.script" might serve as an example of some of this. However, you have to arrange your trigger location environment to avoid the risk of trying to move your AI, say, to the middle of a wall. Maybe just living with a one or a few named teleport targets would be easier.

  • Like 1
Posted
2 hours ago, Bienie said:

Thanks for that script, though it seems there is a problem. When it runs it gives me the error:  Entity not found for event 'replaceInvItem'. Terminating thread. I've made sure that the items are correctly named and correlate to the script (the objective ticks so it's not a mistype). edit: could this be another instance of the "items changing name when they stack in the inventory" bug?

If this is even going to be an objective I keep though I have to also figure out the second part of it. I need the item that is given to the player to teleport a specific AI in front of the player when it is "used", i.e. similar to using a key on a door or drinking a potion. I looked at using the stim/response system, but the teleport function there seems to only allow for teleporting to fixed locations? Basically there is no option for "relative to player" only "relative to origin of object being teleported". Also trying to make the stim/response system recognize the player "using" an item seems to be a problem? Couldn't find an appropriate stim category, as "frob" did nothing. Thoughts / Ideas?

Try

$bienie_custom_item_part1.remove();

That removes the object completely (including from inventory). I've used this technique for getting rid of inventory items.

  • Like 1
Posted
9 hours ago, Bienie said:

Thanks for that script, though it seems there is a problem. When it runs it gives me the error:  Entity not found for event 'replaceInvItem'. Terminating thread. I've made sure that the items are correctly named and correlate to the script (the objective ticks so it's not a mistype). edit: could this be another instance of the "items changing name when they stack in the inventory" bug?

If this is even going to be an objective I keep though I have to also figure out the second part of it. I need the item that is given to the player to teleport a specific AI in front of the player when it is "used", i.e. similar to using a key on a door or drinking a potion. I looked at using the stim/response system, but the teleport function there seems to only allow for teleporting to fixed locations? Basically there is no option for "relative to player" only "relative to origin of object being teleported". Also trying to make the stim/response system recognize the player "using" an item seems to be a problem? Couldn't find an appropriate stim category, as "frob" did nothing. Thoughts / Ideas?

"could this be another instance of the "items changing name when they stack in the inventory" bug?"

This isn't a bug. When picking up items they are removed. The inventory item and the one the player interacts with differ. If the item is stackable, you can remove it by decreasing its inventory count down to zero.

 

Regarding your second problem. Frobbing and using are different. You can however specify what should be done when an inventory item is used in the items scriptobject. Check the playertools script file for instances (flashbomb etc...). There you can also see how to get the direction the player is looking at (see throwable items like again, the flashbomb) or you can take a look at my triggerlook script as suggested above.

 

The view angles are specified as euler anlges (why ever?!). They need to be transformed into a vector specifying the viewing direction. If you want to avoid that the ai is spawn or teleported into a wall, I would suggest to let the player throw a projectile to see whether the space in front of him is sufficient. There may be more convenient ways to do so, but I can't tell you how to do it in a different way because it is a secret I don't know how (never needed it myself).

  • Like 1

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

Posted
19 hours ago, joebarnin said:

Try


$bienie_custom_item_part1.remove();

That removes the object completely (including from inventory). I've used this technique for getting rid of inventory items.

Changing it to remove() instead gave me an error called "too many parameters"... I even tried to have it just do it once and it was still too many parameters 😕

12 hours ago, Obsttorte said:

"could this be another instance of the "items changing name when they stack in the inventory" bug?"

This isn't a bug. When picking up items they are removed. The inventory item and the one the player interacts with differ. If the item is stackable, you can remove it by decreasing its inventory count down to zero.

 

Regarding your second problem. Frobbing and using are different. You can however specify what should be done when an inventory item is used in the items scriptobject. Check the playertools script file for instances (flashbomb etc...). There you can also see how to get the direction the player is looking at (see throwable items like again, the flashbomb) or you can take a look at my triggerlook script as suggested above.

 

The view angles are specified as euler anlges (why ever?!). They need to be transformed into a vector specifying the viewing direction. If you want to avoid that the ai is spawn or teleported into a wall, I would suggest to let the player throw a projectile to see whether the space in front of him is sufficient. There may be more convenient ways to do so, but I can't tell you how to do it in a different way because it is a secret I don't know how (never needed it myself).

Gosh, that sounds far too complicated for me to make. Scripting is my biggest weak spot when it comes to mapping. I looked at the playertools script and it looked to me like it was just referencing other scripts in an unknown location. The triggerlook script might as well have been Chinese, I had no idea what was going on in there. I may have to abandon that idea, it was not central to my map in any way, little more than an easter egg.

My Fan Missions:

   Series:                                                                           Standalone:

Chronicles of Skulduggery 0: To Catch a Thief                     The Night of Reluctant Benefaction

Chronicles of Skulduggery 1: Pearls and Swine                    Langhorne Lodge

Chronicles of Skulduggery 2: A Precarious Position              

Chronicles of Skulduggery 3: Sacricide

 

 

 

Posted
2 hours ago, Bienie said:

Changing it to remove() instead gave me an error called "too many parameters"... I even tried to have it just do it once and it was still too many parameters 😕

Sorry, I was wrong about remove(); I don't think it works for inventory items? But I have had success with

$player1.replaceInvItem($bienie_custom_item_part1, $null_entity);

In my Heart of St. Mattis mission, you collect 3 key fragments and then they magically get combined into a special key. My script used replaceInvItem to remove the fragments from inventory.

I know this didn't work for you. One thing I noticed, the inventory items I'm getting rid of are non-droppable. Spawnarg "inv_droppable" = 0. Maybe that's a requirement? Anyway, try setting that on your bienie_custom_item_partN objects, see if that helps.

Posted
11 hours ago, Bienie said:

Gosh, that sounds far too complicated for me to make. Scripting is my biggest weak spot when it comes to mapping. I looked at the playertools script and it looked to me like it was just referencing other scripts in an unknown location. The triggerlook script might as well have been Chinese, I had no idea what was going on in there. I may have to abandon that idea, it was not central to my map in any way, little more than an easter egg.

Just so I get it correctly what you are aiming for:

 

The player has to collect four pieces of a specific item, that is stackable. Once the player has found all four pieces (so the inventory count should be four either), those pieces get removed from the inventory and replaced with another item, that, upon using it, will teleport an ai in front of the player. Is that correct?

 

In regards to you saying the code could as well have been Chinese. A programming (or in this case scripting) language is an own language, and even though it may not be as extensive as Chinese for example, one has to learn it. There is no way around that. But you also have to learn how to use the level editor, and you have managed to do so either, so I wouldn't give up upon scripting that fast :)

  • Like 1

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

Posted
10 hours ago, joebarnin said:

Sorry, I was wrong about remove(); I don't think it works for inventory items? But I have had success with

$player1.replaceInvItem($bienie_custom_item_part1, $null_entity);

In my Heart of St. Mattis mission, you collect 3 key fragments and then they magically get combined into a special key. My script used replaceInvItem to remove the fragments from inventory.

I know this didn't work for you. One thing I noticed, the inventory items I'm getting rid of are non-droppable. Spawnarg "inv_droppable" = 0. Maybe that's a requirement? Anyway, try setting that on your bienie_custom_item_partN objects, see if that helps.

The items were static items, so they were never dropabable to begin with so it can't be that unfortunately. It has something to do with the stacking I'm pretty sure. If I try to finish this thing I may have to figure out a way to make them go in to the inventory as single, separate items.

 

50 minutes ago, Obsttorte said:

Just so I get it correctly what you are aiming for:

 

The player has to collect four pieces of a specific item, that is stackable. Once the player has found all four pieces (so the inventory count should be four either), those pieces get removed from the inventory and replaced with another item, that, upon using it, will teleport an ai in front of the player. Is that correct?

 

In regards to you saying the code could as well have been Chinese. A programming (or in this case scripting) language is an own language, and even though it may not be as extensive as Chinese for example, one has to learn it. There is no way around that. But you also have to learn how to use the level editor, and you have managed to do so either, so I wouldn't give up upon scripting that fast :)

Your description of my proposed system is perfect! Specifically, it's 4 pieces of a medallion that I made a special model for (the stacking was only for minimizing inventory clutter, and not necessarily a must). The medallion should become an item in the player's inventory when all four pieces are found. When the player uses it, a specific undead builder guard appears who is on the player's team who can be used to cause mayhem on the map. It's not balanced for gameplay reasons, I guess it's more of a curiosity for players, probably those replaying the map, as it won't be easy to access. First you have to find the readable, and only then can you go hunting for the shards of the medallion spread out across the map.

As far as programming goes, I am aware that practice makes perfect, and I probably could learn it if I really tried. But I have tried many times before and I have a hard time to make it stick. I feel as though some people are more naturally adept at learning such things, probably related to math ability and hierarchical thinking more so even than language ability. I'm under no illusions that I should be expected to know some coding as a mapper, hence why I refer to it as a blind spot instead of saying I'm not a coder or Let the programmers do that! For small scale modding like this you really need to be a jack-of-all-trades type person, and that is kind of the charm of FMs in my opinion, because they have so much uniqueness and character imbued by the author.

My Fan Missions:

   Series:                                                                           Standalone:

Chronicles of Skulduggery 0: To Catch a Thief                     The Night of Reluctant Benefaction

Chronicles of Skulduggery 1: Pearls and Swine                    Langhorne Lodge

Chronicles of Skulduggery 2: A Precarious Position              

Chronicles of Skulduggery 3: Sacricide

 

 

 

Posted

In all fairness to yourself, trigger_look is a fairly sophisticated piece of coding. If you do decide to pursue it further, the wiki sheds some light, and includes near the end a link to Obsttort's video describing the math. I think, if this script was (re)written today, it could use calls to now-provided angle conversion functions, instead of doing all the math itself.

Regarding the AI that appears, maybe another approach is to have AI spawn at some fixed "station" location, and run like crazy to where the player is... you could have some special music & smoke effects play while waiting for him to arrive

  • Like 2
Posted

I think I'm starting to make some sense of the tdm_playertools scripts. I assume that I can copy a fair bit of the flashbomb setup, but I will have to change the projectile to something custom that causes a teleport of that AI to where the projectile lands. That should keep him from spawning into a wall as well I think, since the projectile should stop or bounce if it hits a wall. I'm not quite understanding the flashbomb projectile script, though maybe after reading it a few more times. Is it possible to have "teleport AI to point of impact" as a result from a projectile? It's probably possible to have him spawn, but I don't want multiple copies running around if used more than once. If that part can work I may be able to cobble together a script for this. But let's just say I'm in uncharted waters as far I'm concerned.

My Fan Missions:

   Series:                                                                           Standalone:

Chronicles of Skulduggery 0: To Catch a Thief                     The Night of Reluctant Benefaction

Chronicles of Skulduggery 1: Pearls and Swine                    Langhorne Lodge

Chronicles of Skulduggery 2: A Precarious Position              

Chronicles of Skulduggery 3: Sacricide

 

 

 

Posted (edited)
On 6/1/2020 at 2:25 PM, Geep said:

In all fairness to yourself, trigger_look is a fairly sophisticated piece of coding. If you do decide to pursue it further, the wiki sheds some light, and includes near the end a link to Obsttort's video describing the math. I think, if this script was (re)written today, it could use calls to now-provided angle conversion functions, instead of doing all the math itself.

Regarding the AI that appears, maybe another approach is to have AI spawn at some fixed "station" location, and run like crazy to where the player is... you could have some special music & smoke effects play while waiting for him to arrive

I didn't read all the discussion in detail, so sorry if this is totally not what you guys are discussing but if you guys are talking about knowing the direction the player is looking at, in relation to something else, then I do this:

I get the forward vector of the player view angles,

vector playerViewAngles = self.getViewAngles();

vector forwardVec = sys.angToForward(playerViewAngles); 

i do the same for the object then I do a dot product between the two vectors, the player forward vector and the object forward vector, I think whose vector is second is important, also both are normalized (they are length 1), if the dot product value is 1 player is looking in the same direction has the object, if is zero, player is looking in a perpendicular direction (90º left or right) if is -1, player is looking in opposite direction, one is looking forward the other backward.

Again hope this is what you want. 

 

Edited by HMart
Posted

HMart, I'm guessing that for Bienie, manipulation of a forward vector would be needed, but probably not the dot product. He wants the AI to spawn more or less in front him. When that happens, I imagine the AI should be looking at the player. That can be done by taking the difference between the two origins, normalizing it, and making that into the AI's forward vector.

Posted (edited)
2 hours ago, Geep said:

HMart, I'm guessing that for Bienie, manipulation of a forward vector would be needed, but probably not the dot product. He wants the AI to spawn more or less in front him. When that happens, I imagine the AI should be looking at the player. That can be done by taking the difference between the two origins, normalizing it, and making that into the AI's forward vector.

Hum in that case can't you just use the available AI script code?  Unless the TDM team changed totally the Doom 3 AI code, the original AI had this script functions, see if they are available (and work...). 

.faceEnemy();

.faceEntity();

.canSee();

.TurnTo();

.TurnToPos();

.TurnToEntity();

.LookAt(); // For the heads

.LookAtEnemy(); // for the heads

And others. 

Here is the code for the Doom 3 sentry robot, where some of those are used, here just as a guide, I don't claim any of this works on TDM but no harm in trying I guess. 

/*
=====================
char_sentry::state_Combat
=====================
*/
void char_sentry::state_Combat() {
	float attack_flags;

	eachFrame {
		faceEnemy();
		lookAtEnemy( 1 );
		
		if ( AI_ENEMY_DEAD || !getEnemy() ) {
			startSound( "snd_target_lost", SND_CHANNEL_VOICE, false );
			AI_ENEMY_DEAD = false;
			clearEnemy();
			setState( "state_Idle" );
		}
		
		attack_flags = check_attacks();
		if ( attack_flags ) {
			do_attack( attack_flags );
			continue;
		}
		
		if ( canReachEnemy() ) {
			combat_chase();
		} else if ( !find_attack_position() ) {
			ignore( getEnemy() );
			checkForEnemy( false );
		}
		
		waitFrame();
	}
}

 (edit): To make a entity spawn in front if the player, try something like this, change has needed to work on TDM: 

float someDistanceValue = 128.0; // Doom units tweek has needed

vector playerOrigin = self.getOrigin(); // player needs to exist in the world already

vector playerAngles = self.getAngles();

vector playerForwardVec = sys.angToForward(playerAngles);

vector enemySpawnPosition = playerOrigin + (playerForwardVec * someDistanceValue);

entity enemy = sys.spawn( "classname" );
enemy.setOrigin( enemySpawnPosition );

Not sure if the spawn code itself is correct at all. 

Edited by HMart
Posted

@HMart that looks promising, but it still leaves unadressed the greater problem of knowing whether that particular position is suitable for spawning an AI onto. What if the position is inside/behind a wall, or the AI's bounding box intersects with monsterclip.

There no doubt are methods for finding viable pathing locations (otherwise, how would AI be able to search for the player), but the question is whether and with how much work they can be accessed by scripting. A more convenient solution might be to have the mapper place teleportation entities in various suitable positions on the map, then have the script search for the one that's closest to the player and use it to teleport the AI in.

Posted (edited)

To solve that I would do a trace

"tracePoint( vector start, vector end, float contents_mask, entity passEntity )"
 

pseudo code

vector start = playerOrigin;

start_z += 10; // make the trace start some units above the floor

vector end = enemySpawnPosition;

end_z += 10;

tracePoint (start, end, MASK_SOLID | CONTENTS_RENDERMODEL, self);   // "self" is of course the player entity, you don't want to detect the player.

if the trace detects a entity:  // 10 units high or above

entity ent = sys.getTraceEntity();

if( ent ) do nothing 

else, there's enough open space in front of you, spawn the enemy;

Of course this doesn't take into account all corner cases, this can end very complicated, with more than one trace needed to really solve every case;

Just see this to see how tracing can be very powerful but also complicated:

http://blendogames.com/news/post/2013-01-02-qc-dev-001-ghost-cursor/

 

Edit:  your idea of setting teleport's by hand is not bad at all and the script would be less complicated, but of course less dynamic.

 

 

 

Edited by HMart
Posted (edited)

 

Model exporter in DR

1. I've created a "cargoboat" last year consisting of brushes, patches, cylinders, models. I then used "save selection as model" and could export the selection as .lwo file. Works perfectly - see attachment "cargoboat2.lwo"

2. To reduce entity count in my mission, I'd like to save selected pipe sections (see attached example "piping_1.pfbx") as models, too. The problem is, the saved selections do not get saved correctly anymore: the file format is missing (see attached file "piping_1") and nothing shows up in the editor.  Moreover, the "Use entity origin as export origin" field is greyed out now when I try to export the selection in question.

I've tried it with many other stuff, and the result is always the same.

What is my mistake?

cargoboat2.lwo piping_1.pfbx piping_1

Edited by JackFarmer
Posted (edited)

@JackFarmer

Did you try exporting as .ase ?

 

I can't get the .pfbx (my prefabs have .pfb as extention btw) in my editor, but I can get the piping_1 after adding the extention .lwo manually. The center it gives is not the centre of the pipes, but the model seems ok at first look.

Edited by STRUNK
Posted
47 minutes ago, STRUNK said:

@JackFarmer

Did you try exporting as .ase ?

 

I can't get the .pfbx (my prefabs have .pfb as extention btw) in my editor, but I can get the piping_1 after adding the extention .lwo manually. The center it gives is not the centre of the pipes, but the model seems ok at first look.

You are right; that works. It is a little bit cumbersome, but it is a workaround.

It seems DR 2.8.0 exports prefabs now with the ending "pfbx".

However, I wonder if the exporting problems are a bug in DR 2.8.0?

Posted

@JackFarmer

.pfbx is not backwards compatible it seems.

Did you try not making a prefab first, or ungrouping the prefab before exporting it as a model? Maybe you can fix the center problem that way ..

Posted
56 minutes ago, STRUNK said:

I can't get the .pfbx (my prefabs have .pfb as extention btw) in my editor

.pfbx is a new file format for prefabs that was introduced and made the default in DR 2.8, which preserves grouping information. You need DR 2.8 to open it.

4 hours ago, JackFarmer said:

the file format is missing

I believe you need to manually type in .lwo or .ase at the end of the file path when exporting a model. Can't say why your "Use entity origin..." option is greyed out.

On 6/3/2020 at 8:00 PM, JackFarmer said:

Don't custom entities become automatically highlighted when in frob distance?

See attached example. The properties "frob_distance" and "frobbox_size" seem not to change anything.

As Geep already suggested, the material used by the model (...sq_shield) is missing frob highlight stages. Those are the 2 blocks referencing parm 11 - you can copy-paste them from any other material and update that 1 line with "map     [file path]" so that it matches the diffusemap of your current material.

  • Like 1
  • Thanks 1
Posted
1 hour ago, Dragofer said:

 

I believe you need to manually type in .lwo or .ase at the end of the file path when exporting a model. Can't say why your "Use entity origin..." option is greyed out.

As Geep already suggested, the material used by the model (...sq_shield) is missing frob highlight stages. Those are the 2 blocks referencing parm 11 - you can copy-paste them from any other material and update that 1 line with "map     [file path]" so that it matches the diffusemap of your current material.

Thank you for the hints!

Posted
19 hours ago, STRUNK said:

@JackFarmer

.pfbx is not backwards compatible it seems.

Did you try not making a prefab first, or ungrouping the prefab before exporting it as a model? Maybe you can fix the center problem that way ..

Nope,  the attached prefab was just created for the attachment. In the map file itself, I just selected all relevant parts and used the "Save selection as model" command.

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

    • snatcher

      Author of the Visible Player Hands mod: please come forth and collect a round of applause!
      · 2 replies
    • nbohr1more

      Holiday TDM Moddb article is now up: https://www.moddb.com/mods/the-dark-mod/news/happy-holidays-from-the-dark-mod
      · 0 replies
    • nbohr1more

      Cool thing: Thanksgiving break means I don't have to get my son up before dawn

      Not cool thing: My son stays up all night on my PC so I don't get much TDM time...
      · 3 replies
    • datiswous

      Does anyone know if the mission/map in this video posted by @Springheel can still be found somewhere and played? Looks like fun.
       
      · 2 replies
    • taffernicus

      I'm curious about doom and thief multiplayer netcode 😂 or how these games handle networking for multiplayer in general
      a youtube channel called battle(non)sense sometimes posts about netcode analysis
      · 2 replies
×
×
  • Create New...