Jump to content
The Dark Mod Forums
grayman

[SOLVED] How to 'remove' blackjack and sword?

Recommended Posts

Has anyone figured out how to make the player drop his blackjack and sword?

 

I've figured out how to 'drop' the arrows, but there are no direct scripting methods to drop the bj and the sword.

 

No joy after searching the forum and the scripting wiki and the source code.

 

Thanks.

Share this post


Link to post
Share on other sites

How do you let the player drop the arrows? And what are you aiming for exactly? Is it like drop your weapon at a specific spot or container (maybe for an ai to lend him your weapon)?

 

Maybe getCurrentWeapon() and remove or a change in inventory count?!

 

EDIT: There is a function for dropping a weapon in the game code, but no script function to access it. I guess the code was originally implemented for multiplayer mathces, so that a player who dies drops its weapon (unsure, never played Doom 3 mp).


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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


Link to post
Share on other sites

Maybe the same way you make keys droppable? - "inv_droppable" "1"

 

No joy. Weapon inventory isn't handled the same as item inventory.

 

How do you let the player drop the arrows? And what are you aiming for exactly? Is it like drop your weapon at a specific spot or container (maybe for an ai to lend him your weapon)?

 

Maybe getCurrentWeapon() and remove or a change in inventory count?!

 

EDIT: There is a function for dropping a weapon in the game code, but no script function to access it. I guess the code was originally implemented for multiplayer mathces, so that a player who dies drops its weapon (unsure, never played Doom 3 mp).

 

I'm "dropping" arrows by clearing their ammo count. (Not intuitive; it took a lot of experimentation.)

 

Since the blackjack and sword don't use ammo, they can't be handled the same way. Dropping their "ammo count" from 1 to 0 does nothing.

 

I'm aware of the multiplayer feature of dropping weapons for teammates to use, but--as you say--it's not available to scripts.

 

I could write the missing script functions, but I'm trying to rely on 2.05 and not 2.06.

Share this post


Link to post
Share on other sites

The case for inventory items and weapons being droppable is part of the immersive sim ethos that, as much as possible, we should think of objects as actual real-world objects you can manipulate in intuitive ways to address issues like it's a real world problem and not just to solve a pre-constructed puzzle the author wants to feel clever about constructing.

 

The case against it is that the player could drop a required item (key or sword) in a way that breaks their ability to meet the objectives, if they drop it in a place they can't retrieve it (although that can be made avoidable by design), which goes against another principle of never allowing a player to enter into an unwinnable situation.

 

Generally speaking, I'm on the immersive sim side of the coin so think everything should be droppable by default.


What do you see when you turn out the light? I can't tell you but I know that it's mine.

Share this post


Link to post
Share on other sites

instead of dropping them, could you hide them and spawn some dummy ones in so it looks as if the player has lost the weapons. Its how it was done in the half-life games and some other games, as player doesn't actually lose them or have them removed, they're just hid and the player can't use hidden items.

  • Like 1

Share this post


Link to post
Share on other sites

The case for inventory items and weapons being droppable is part of the immersive sim ethos that, as much as possible, we should think of objects as actual real-world objects you can manipulate in intuitive ways to address issues like it's a real world problem and not just to solve a pre-constructed puzzle the author wants to feel clever about constructing.

 

The case against it is that the player could drop a required item (key or sword) in a way that breaks their ability to meet the objectives, if they drop it in a place they can't retrieve it (although that can be made avoidable by design), which goes against another principle of never allowing a player to enter into an unwinnable situation.

 

Generally speaking, I'm on the immersive sim side of the coin so think everything should be droppable by default.

For inventory items you havea "dropable" spawnarg, if you feel the need to prevent the player from dropping it for story purpose. So, this could also be applied to weapons, you think are needed.

Unwinnable situations can easily occur in TDM, when you create situations that need a certain item/weapon. Especially arrows (e.g. rope arrows) can always have been used already. Or maybe the player is just a bad shot and misses the target too often until he runs out of the arrow he needs. So, this argument is, in my opinion, not really a problem. Also, regarding the sword and blackjack, most mappers enable the player to ghost the mission, so dropping these weapons should not result in unwinnable situations.

Share this post


Link to post
Share on other sites

 


I'm "dropping" arrows by clearing their ammo count. (Not intuitive; it took a lot of experimentation.)

Thought so. Do you let the player "drop" them by pressing a button or is this context-sensitive (like frobbing a container to store the arrows there or so)?


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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


Link to post
Share on other sites

Ok, so

string $player1.getCurrentWeapon();

returns the def name of the weapon the player is currently holding ("atdm:weapon_blackjack" or "atdm:weapon_shortsword" in your case).

void $player1.selectWeapon(string weaponname);

switches to a weapon of your choice. The string weaponname is NOT the defname but the name defined under "inv_weapon_name" (unarmed, shortsword etc...). (At least I think so ;) )

 

So if you want a player to not be able to draw a certain weapon, you can make a check whether the player currently selected that weapon and then switch back to the previously hold one. You can do this every frame or in the weapon scriptobjects, preferably in Lower() as this gets called when the player attempts to switch the weapon. Also Idle() runs every frame so you would have to alter that either, and you would have to do this for all weapon scriptobjects available in your mission. So even though the latter would be the more "clean" solution, having an infinite loop checking the status every frame is probably the easier way to go.

 

Hope that helps :)

  • Like 1

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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


Link to post
Share on other sites

I had blackjack to be picked up as a mission objective once, but I deleted it from player's inventory. The player had to follow an NPC, who was leaving it for another character, but all I did was two scripts: one making invisible blackjack visible in pre-determined spot when NPC was performing an animation; second one made blackjack model disappear after frobbing and the proper item was added to player inventory. That assumes you need a scripted and controlled event though. More systemic approach might be more tricky.

Share this post


Link to post
Share on other sites

It's a bit clunky but you can look at how SteveL and I handled disabling melee weapons for A House of Locked Secrets. We had to do that since it was possible for players to have picked up the weapons in the physical world but not have picked them up in the spiritual world. If that was the case, we had to disable the use of any picked-up melee weapons when they switched realms. If you are able to duplicate that method, then having a physical object be dropped to the ground to complete the illusion (and toggle weapon use on/off) would be easy.

Edited by Moonbo
  • Like 1

But you should walk having internal dignity. Be a wonderful person who can dance pleasantly to the rhythm of the universe.

-Sun Myung Moon

 

My work blog: gfleisher.blogspot.com

Share this post


Link to post
Share on other sites

So if you want a player to not be able to draw a certain weapon, you can make a check whether the player currently selected that weapon and then switch back to the previously hold one. You can do this every frame ...

 

getCurrentWeapon() reports the current weapon once it's fully raised, so what I see is the weapon raising, then being lowered after it's done raising.

 

Investigating the second method.

Share this post


Link to post
Share on other sites

I should clarify that I'm not trying to give the player the ability to drop his melee weapons.

 

I'm trying to take his weapons away from him, with the intent that he be able to get them back at a later time.

 

Think of someone getting tossed into jail.

Share this post


Link to post
Share on other sites

"Target Remove Weapons" entity?

 

idTarget_RemoveWeapons

scriptEvent void activate(entity activator);

 

Activates this entity as if it was activated by a trigger.

 

activator: the entity that caused the action (usually the player)

 

https://modwiki.xnet.fi/Target_removeweapons_%28entity%29


Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Share this post


Link to post
Share on other sites

I should clarify that I'm not trying to give the player the ability to drop his melee weapons.

 

I'm trying to take his weapons away from him, with the intent that he be able to get them back at a later time.

 

Think of someone getting tossed into jail.

DisableWeapon() / enableWeapon (called on the player)?!

 

The script for the safe in A New Job does something similar. It temporarely disables the weapons.


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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


Link to post
Share on other sites

idTarget_RemoveWeapons

Close, but no cigar.

 

The code for the target is in the SDK.

 

I had to create the def file for the entity.

 

However, the target code calls this:

void idPlayer::RemoveWeapon( const char *weap )
{
     if ( weap && *weap )
     {
     // greebo: Not yet implemented for TDM inventory
     //inventory.Drop( spawnArgs, spawnArgs.GetString( weap ), -1 );
     }
}

Share this post


Link to post
Share on other sites

DisableWeapon() / enableWeapon (called on the player)?!

 

The script for the safe in A New Job does something similar. It temporarely disables the weapons.

 

Did that survive to the final version? I'm not seeing it.

Share this post


Link to post
Share on other sites

You are welcome. :)

  • Like 1

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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


Link to post
Share on other sites

In a July 26, 2017 post, @grayman indicated achieving this effect:

"getCurrentWeapon() reports the current weapon once it's fully raised, so what I see is the weapon raising, then being lowered after it's done raising. "

That's exactly the effect I need, assuming that -

  • the player initiates the raising
  • the lowering is automatic
  • (and ideally there's an opportunity in the script to show a gui message in-between)

But I don't understand from the surrounding discussion with @Obsttorte exactly what that script fragment looks like and how it's invoked. Similarly with the alternative (and for me somewhat less desirable in terms of behavior) method using

$player1.disableWeapon();

since in my case I would need the weapon-raise event to trigger a script function.

Any help, e.g., sample script fragment, would be great. Or point me to a pertinent FM

Share this post


Link to post
Share on other sites

BTW, I realize that what grayman sought was the disabling of a weapon NOT initiated by the player (i.e., an exterior script), so my use case is somewhat different.

I did post a request about this topic to the Newbie thread a while ago, with code of what I had tried unsuccessfully. Crickets.

Share this post


Link to post
Share on other sites
On 10/30/2019 at 8:35 PM, Geep said:

In a July 26, 2017 post, @grayman indicated achieving this effect:

"getCurrentWeapon() reports the current weapon once it's fully raised, so what I see is the weapon raising, then being lowered after it's done raising. "

That's exactly the effect I need, assuming that -

  • the player initiates the raising
  • the lowering is automatic
  • (and ideally there's an opportunity in the script to show a gui message in-between)

But I don't understand from the surrounding discussion with @Obsttorte exactly what that script fragment looks like and how it's invoked. Similarly with the alternative (and for me somewhat less desirable in terms of behavior) method using

$player1.disableWeapon();

since in my case I would need the weapon-raise event to trigger a script function.

Any help, e.g., sample script fragment, would be great. Or point me to a pertinent FM

I most say that i'm not a TDM mission maker nor I even made that much scripts for TDM so I don't really know how they handle their weapon system, if it is similar to the Doom 3 way you could try this idea below.

warning: This code is untested code, based on the way Doom 3 works and could be totally wrong for TDM, don't take it as a plug and play sort of thing, is just something for you to try, a direction of sorts.  Btw if it throws any error at game startup post here and me and I hope others will try to help. I'm very busy so it could take some time for me to reply tho be patient.  

 

// in the player script file (if the TDM player script looks anything like the Doom 3 one...)
object player : player_base {
...
// Create a thread handle
float discardthreadNumber;
...
...

// create a new function
// NOTE: notice the float data type, threads always return a float id number
float DiscardWeapon(entity ent); 
};

void player::init() {
...
discardthreadNumber = 0; // init the thread handle to zero
...
}

float player::DiscardWeapon(entity ent) {
	eachFrame{
		// NOTE: a gui parm, is a variable in a entity gui (fullscreen or otherwise) that looks something like this, gui::parmName,
		// so, for this to work the player hud gui, most have a onNamedEvent or a windowDef 
		// where a gui text cmd, is updated by a gui::message parm.
		// In Doom 3 idSoftware used gui::parm1, gui::parm2, etc but you can use any name you want.
		// BTW you cannot access any other script variable, using script or the engine c++ code but those, using 
		// the gui:: naming convention, so no use trying to access a float defined inside a gui script,
		// those are only to be used by the gui code itself.   
		self.setGuiParm("message", "Theres something wrong with this weapon!");
		
		wait( 5 );
		
		// clear message
		self.setGuiParm("message", "");
		
		disableWeapon();
		
		waitFor(ent);
		
		// kill the thread function
		if(ent.weaponHolstered()){
			sys.terminate(discardthreadNumber);
			discardthreadNumber = 0;
		}
	}
}


void player::RaiseWeapon() {
	weapon = getWeaponEntity();
	animState( ANIMCHANNEL_TORSO, "Torso_RaiseWeapon", 2 );
	
	// Did not used weapon.getName() because that returns the entity name has defined in the editor
	// and not the weapon name has defined in the player def file, don't know if they match.
	string weaponName = getCurrentWeapon();
	if(weaponName == "weapon_pistol"){
		// start the thread function
		if(!discardthreadNumber){
			discardthreadNumber = thread DiscardWeapon(weapon);
		}
	}
}

 

Edited by HMart

Share this post


Link to post
Share on other sites

Thanks, HMart. I understand what you propose. What you are suggesting is an extension of the code in tdm_base01\script\tdm_player.script

A concern: as a noob fan mission dev, not an engine dev, I'm reluctant to alter that code directly.  Because, for example, even if I could package & distribute the change properly, wouldn't it be lost on the next TDM update from 2.07 to 2.08 ?

I wonder if it's possible to override a base-script function body with a custom function of the same name (either in the <fm>.script file or a separate script in the "script" folder, referenced by tdm_custom_scripts.script) ? It would have to part of the player object, that is, with a fully qualified signature like

void player::RaiseWeapon()

If so, then I wouldn't have to alter the base script, and I'd be a much happier camper trying out your method.

Share this post


Link to post
Share on other sites

nbohr1more posted elsewhere:

"...you can override scripts ... and an number of things that are global by packing them in the corresponding sub-folders in your mission package."

So I guess I could copy the entire tdm_player.script file and alter that.  (Not as surgical as just over-riding particular functions, tho. Future checked-in updates to other functions in the file would be overriden by the old stuff in my copy too). It's a direction!

Share this post


Link to post
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.


×
×
  • Create New...