Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)

A thread for custom items which are not necessarily mines.

To get the ball rolling, here are a speed potion and slow-fall potion, approximating the T2 behaviour. Update: to get the latest version of the script component check the beta testing thread.

Default numbers aren't necessarily final, and of course, if you encounter any glitches please let me know. Defs go in /def/whatever.def, scripts go in /script/tdm_custom_scripts.script (or better still #include them). Also, if anyone's able and willing to create the missing art assets that would be great. :smile:

Speed potion. (Lacks an inventory icon.)

 

entityDef atdm:playertools_speed_potion {
	"inherit"						"atdm:playertool_stackable"
	"editor_usage"					"Speed potion: temporarily boosts walking/running speed and jump distance."
	"model"							"models/darkmod/player_equipment/speed_potion.lwo"
	"inv_icon"						"guis/assets/hud/inventory_icons/holywater_icon" // TEMP
	"inv_name"						"Speed Potion" // NOT MULTILANGUAGE
	"inv_category"					"#str_02393"
	"snd_swallow"					"potion_drink"
	"scriptobject"					"playertools_speedpotion"
	"duration"						"9"
	"editor_float duration"			"Time in seconds the speed potion is active."
	"speed_mod"						"9"
	"liquid_penalty"				"0.5"
	"editor_float speed_mod"		"The higher the number, the faster you walk/run. High speed leads to collision damage."
	"editor_float liquid_penalty"	"Multiplier between 0 and 1 for liquid drag, to prevent leaping out of water like a dolphin."
}

entityDef ShopItem_playertools_speed_potion {
	"inherit"			"atdm:shopitem_base"
	"editor_usage"		"Speed Potion"
	"displayName"		"Speed Potion"	// NOT MULTILANGUAGE
	"displayDesc"		"These usually enter the black market from military sources, but thieves use them to jump between rooftops or to make a swift escape."	// NOT MULTILANGUAGE
	"itemClassname"		"atdm:playertools_speed_potion"
	"image"				"guis/assets/purchase_menu/potion_speed"
	"price"				"30"
	"stackable"			"1"
}
/*
/*
* SPEED POTION scriptobject
*/
object playertools_speedpotion : player_tools {
	/**
	* [ Comment copied from health potion script object: ]
	* greebo: This is the method that gets called from within the SDK
	*		  when the player "uses" this tool as inventory item.
	*
	* @userEntity: the entity that is using this item, usually $player1
	* @frobbedEntity: the entity the player is currently frobbing, may be $null_entity
	* @buttonState: a float telling about the current button state (pressed, released)
	*/
	void inventoryUse(player userEntity, entity frobbedEntity, float buttonState);
	void update(player userEntity);
	
	float duration;
	float speed_mod;
	float liquid_penalty;
	float endTime;
};

/**
* =============== SPEED POTION ======================================
*/
void playertools_speedpotion::inventoryUse(player userEntity, entity frobbedEntity, float buttonState)
{
	// Callback to decrease the inventory stack count
	userEntity.changeInvItemCount(getKey("inv_name"), getKey("inv_category"), -1);

	// Play the activate sound
	userEntity.startSoundShader(getKey("snd_swallow"), SND_CHANNEL_VOICE);
	
	duration = getFloatKey("duration");
	speed_mod = getFloatKey("speed_mod");
	liquid_penalty = getFloatKey("liquid_penalty");
	
	endTime = (sys.getTime() + duration);
	
	update(userEntity);
}

void playertools_speedpotion::update(player userEntity) {
	sys.killthread("speed_potion");
	sys.threadname("speed_potion");
	
	while (sys.getTime() < endTime) {sys.wait(0.01);
		vector player_direction = userEntity.getViewAngles();
		float player_angle_h = player_direction_y;
		float player_angle_v = 0 - player_direction_x;
		vector player_movement = userEntity.getMove();
		vector player_movement_world = player_movement;
		vector boost_movement = '0 0 0';
		
		if ( userEntity.getImmobilization( "MantleMove" ) != 0 ) continue;
		
		if (userEntity.AI_ONGROUND) {
			player_movement_world_x = 
				(player_movement_x * sys.cos(player_angle_h)) 
				+ (player_movement_y * sys.cos(player_angle_h-90));
			player_movement_world_y = 
				(player_movement_x * sys.sin(player_angle_h)) 
				+ (player_movement_y * sys.sin(player_angle_h-90));
			
			boost_movement_x = player_movement_world_x * speed_mod;
			boost_movement_y = player_movement_world_y * speed_mod;
		}
		else if (userEntity.isInLiquid()) {
			player_movement_world_x = 
				(player_movement_x * sys.cos(player_angle_v) * sys.cos(player_angle_h)) 
				+ (player_movement_y * sys.cos(player_angle_v) * sys.cos(player_angle_h-90));
			player_movement_world_y = 
				(player_movement_x * sys.cos(player_angle_v) * sys.sin(player_angle_h)) 
				+ (player_movement_y * sys.cos(player_angle_v) * sys.sin(player_angle_h-90));
			player_movement_world_z = 
			(player_movement_x * sys.sin(player_angle_v)) + (player_movement_y * sys.sin(player_angle_v));
			
			// jump button
			if (player_movement_world_z < player_movement_z) player_movement_world_z = player_movement_z;
			
			boost_movement_x = player_movement_world_x * speed_mod * liquid_penalty;
			boost_movement_y = player_movement_world_y * speed_mod * liquid_penalty;
			boost_movement_z = player_movement_world_z * speed_mod * liquid_penalty;
		};
		
		userEntity.applyImpulse(userEntity,0,userEntity.getOrigin(),boost_movement);
	};
}

 



Slow-fall potion. (Lacks a model - or failing that a skin for an existing model - an inventory icon and shop art.)

 

entityDef atdm:playertools_slow_fall_potion {
	"inherit"					"atdm:playertool_stackable"
	"editor_usage"				"Slow-fall potion. Reduces falling damage but slows movement."
	"model"						"models/darkmod/player_equipment/speed_potion.lwo" // TEMP
	"inv_icon"					"guis/assets/hud/inventory_icons/breathpotion_icon" // TEMP
	"inv_name"					"Slow-fall Potion" // NOT MULTILANGUAGE
	"inv_category"				"#str_02393"
	"snd_swallow"				"potion_drink"
	"scriptobject"				"playertools_slowfallpotion"
	"duration"					"9"
	"editor_float duration"		"Time in seconds the slow-fall potion is active."
	"lift_force"				"900"
	"editor_float lift_force"	"The higher the number, the more lift you get while falling or underwater."
}

entityDef ShopItem_playertools_slow_fall_potion {
	"inherit"			"atdm:shopitem_base"
	"editor_usage"		"Slow-fall Potion"
	"displayName"		"Slow-fall Potion"	// NOT MULTILANGUAGE
	"displayDesc"		"Less tightly restricted than Potions of Levitation, their weakened cousin is sold by mages to roofers and mountaineers."	// NOT MULTILANGUAGE
	"itemClassname"		"atdm:playertools_slow_fall_potion"
	"image"				"" // MISSING
	"price"				"15"
	"stackable"			"1"
}
/*
* SLOW-FALL POTION scriptobject
*/
object playertools_slowfallpotion : player_tools {
	/**
	* [ Comment copied from health potion script object: ]
	* greebo: This is the method that gets called from within the SDK
	*		  when the player "uses" this tool as inventory item.
	*
	* @userEntity: the entity that is using this item, usually $player1
	* @frobbedEntity: the entity the player is currently frobbing, may be $null_entity
	* @buttonState: a float telling about the current button state (pressed, released)
	*/
	void inventoryUse(player userEntity, entity frobbedEntity, float buttonState);
	void update(player userEntity);
	
	float  duration;
	float  lift_force;
	vector lastPos;
	float  endTime;
};

/**
* =============== SLOW-FALL POTION ==================================
*/
void playertools_slowfallpotion::inventoryUse(player userEntity, entity frobbedEntity, float buttonState)
{
	// Callback to decrease the inventory stack count
	userEntity.changeInvItemCount(getKey("inv_name"), getKey("inv_category"), -1);

	// Play the activate sound
	userEntity.startSoundShader(getKey("snd_swallow"), SND_CHANNEL_VOICE);
	
	duration = getFloatKey("duration");
	lift_force = getFloatKey("lift_force");
	
	lastPos = userEntity.getOrigin();
	endTime = (sys.getTime() + duration);
	
	thread update(userEntity);
}

void playertools_slowfallpotion::update(player userEntity) {
	sys.killthread("slowfall_potion");
	sys.threadname("slowfall_potion");
	
	while (sys.getTime() < endTime) {sys.wait(0.01);
		vector newPos = userEntity.getOrigin();
		float  player_movement = newPos_z - lastPos_z;
		vector boost_movement = '0 0 0';
		
		if ( userEntity.getImmobilization( "MantleMove" ) != 0 ) {
			lastPos = newPos;
			continue;
		};
		
		if ( ( (player_movement < 0) && !userEntity.AI_ONGROUND && !userEntity.AI_ONLADDER ) || userEntity.isInLiquid() && !userEntity.AI_ONLADDER ) boost_movement_z = lift_force;
		userEntity.applyImpulse(userEntity,0,userEntity.getOrigin(),boost_movement);
		lastPos = newPos;
	};
}

 

 

Edited by VanishedOne
  • Like 3

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

Head-bob might feel a bit more noticeable because the scenery goes by faster.

 

Footsteps don't seem to be affected, which is a shame. I ran into a problem when I tried to modify the walkspeed directly, so instead the potion gets your current movement and gives you a push in the same direction. Judging by this bit of my Darkmod.cfg footstep sounds are also controlled by persistent cvars, so the same problem arises:

seta pm_min_stepsound_interval "200"
seta pm_stepvol_crouch_creep "-7"
seta pm_stepvol_crouch_run "4"
seta pm_stepvol_crouch_walk "-2"
seta pm_stepvol_creep "-5"
seta pm_stepvol_run "8"
seta pm_stepvol_walk "0"

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

It looks as though the threading code I added to the slow-fall potion today has diminished its potency somehow. :blink: It still works but the default "lift_force" spawnarg is now badly calibrated; something 900-ish looks about right.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

One question to the slow-fall potion: Does it invfluence jumping behaviour, when you apply the lift_force? I would assume, that you might increase jumping height as well as reducing fall speed.

Posted

One question to the slow-fall potion: Does it invfluence jumping behaviour, when you apply the lift_force? I would assume, that you might increase jumping height as well as reducing fall speed.

The lift isn't applied while you're jumping. (c0mputer-fr0d told me he might make a jump potion, though.)

 

@VanishedOne, can you organise a beta test please? As I would like to recomends these be added to the core mod.

Yes, after I try to work out why the last code change I made seems to have altered performance. I'm wondering whether the call to waitFrame() could make the boost vary with framerate - something it would definitely be good to check across different maps and machines - but if the framerate in my test map were that variable I'd expect to have noticed before.

 

If anyone would like to offer to beta-test, though, feel free to post to this thread now rather than wait. :smile:

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted (edited)

Well, I still don't know why the code change had that effect, but I've altered the slow-fall potion's default "lift_force" and replaced sys.waitFrame with sys.wait to be on the safe side. Now the question is how it works in other people's machines. I'll open another thread to request beta testers.

 

Edit: and here it is: http://forums.thedarkmod.com/topic/17370-beta-testers-sought-speed-potion-slow-fall-potion/

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

regarding the models and hud icons for both potions -

  • Speed - there is already a model and texture in the mod (just no working entity). I will make a hud icon.
  • Slow - will make a model amd hud icon.

bhm_banner.jpg

Posted (edited)

Hey, this is really cool, let me see if I can help you with those model and graphics. ;)

 

EDIT: Oh, Biker is on it.

Edited by RPGista
  • Like 1
Posted

Hey, this is really cool, let me see if I can help you with those model and graphics. ;)

 

EDIT: Oh, Biker is on it.

Well, optimally we also need a shop image for the slow-fall potion. (One already exists for the speed potion.) So you're welcome to volunteer for that... :smile:

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

Excellent!

 

By the way, the current status of the beta test is that there's a nasty bug in both potions that can't really be fixed while scripts have no way to know when the player's mantling (which would need a code change).

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted

By the way, the current status of the beta test is that there's a nasty bug in both potions that can't really be fixed while scripts have no way to know when the player's mantling (which would need a code change).

 

Hmm mantling sets an immobilization on the player to prevent the player changing weapon or attacking while mantling. That might be a way for scripts to pick it up. if ( $player1.getImmobilization( "MantleMove" ) != 0 )

 

The script reference for getImmobilization says "new feature, use at your own risk!" or words to that effect, but that note was added 10 years ago and I guess we can consider it a stable part of TDM by now :)

  • Like 1
Posted

 

Hmm mantling sets an immobilization on the player to prevent the player changing weapon or attacking while mantling. That might be a way for scripts to pick it up. if ( $player1.getImmobilization( "MantleMove" ) != 0 )

 

The script reference for getImmobilization says "new feature, use at your own risk!" or words to that effect, but that note was added 10 years ago and I guess we can consider it a stable part of TDM by now :)

Thanks for this! In a quick test the mantling problems seemed to have gone. I'll post the updated script to the beta test thread.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

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

    • Ansome

      Terribly difficult juggling map designing with work, but I'm still alive and chipping away at something very special. I'm actually making a collaboration of sorts with a friend, I make the map itself and he acts as my "Chief Scope Creep Consultant" that checks in every so often to make sure this project isn't getting out of hand. It's a good system!
      · 0 replies
    • JackFarmer

      We don't need artificial intelligence; we need artistic intelligence. 
      Ralf Hütter, Kraftwerk
      · 5 replies
    • taaaki

      The post editor for the dark themes should be working again. Apologies for the inconvenience.
      · 1 reply
    • jaxa

      Talk GabeCube:
      https://forums.thedarkmod.com/index.php?/topic/18055-2016-cpugpu-news/page/39/#findComment-508710
      · 3 replies
    • The Black Arrow

      Things have been so bad these days for me...
      Just a year ago, I've been feeling dizzy, I thought it was nothing, today's stress, that type of thing, went to sleep...Still dizzy! 9 more days dizzy, went to doctor (I would have gone on the first day if NOT for the long appointment time)
      Said it may be Neck Dizziness...I did exercises for 6 months, no changes.
      Went to a Physical Therapist, went to another, no changes.
      I've asked my doctor for a full check this time.
      I hated yesteryear so much due to personal reasons, this year might be the same.
      To be brutally honest, I'd rather have cancer or/and chronic pain than suffer dizziness any second longer, especially when nothing helps.
      Hard to enjoy Thief when you're dizzy so I was hoping this year, Winter will be best for me.
      · 7 replies
×
×
  • Create New...