Skip to content

Conversation

@LoneWolfHT
Copy link
Member

@LoneWolfHT LoneWolfHT commented Nov 27, 2018

#264

Could probably use testing by someone other than me. These grenades are also craftable (5 steel ingots + 1-2 coal lumps)

Todo:

  • Make Flashbang slow down players
  • Add sounds

@LoneWolfHT
Copy link
Member Author

I'm not sure how to fix the deathlist HUD bug. Could someone point me to the file where the shooter grenade was set to show up as a grenade img and not a sword?

@ClobberXD
Copy link
Contributor

Embarrassingly, this is hard-coded in registered_on_killedplayer callback in the ctf_pvp_engine sub-module. Fixing this would need another PR in https://github.com/MT-CTF/ctf_pvp_engine. Here's the relevant code:

https://github.com/MT-CTF/ctf_pvp_engine/blob/e2a59cef6eba80464af5414d89c4e1c6fbfd597c/ctf/teams.lua#L472-L492

		if player:get_hp() - damage <= 0 then
			dead_players[player:get_player_name()] = true
			local wielded = hitter:get_wielded_item()
			local wname = wielded:get_name()
			print(wname)
			local type = "sword"
			if wname:sub(1, 8) == "shooter:" then
				if wname == "shooter:grenade" then
					type = "grenade"
				else
					type = "bullet"
				end
			end
			if tool_capabilities.damage_groups.grenade then
				type = "grenade"
			end
			for i = 1, #ctf.registered_on_killedplayer do
				ctf.registered_on_killedplayer[i](player:get_player_name(), hitter:get_player_name(), type)
			end
			return false
		end

@ClobberXD
Copy link
Contributor

ClobberXD commented Nov 28, 2018

I've attempted at making the kill type a little more generic: MT-CTF/ctf_pvp_engine#26

However, that is irrelevant to this PR, as that is a completely different issue. Once the aforementioned PR gets merged, ctf_events should be updated to correctly detect the item used to kill, including grenades. I'll do that.

Copy link
Contributor

@ClobberXD ClobberXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor issues need addressing. Also, please convert indents from regular spaces to tabs. I'll test this soon and provide further feedback. Thanks.

@AKryukov92
Copy link
Contributor

Please describe features, that you expect to introduce with grenades.
What exactly should happen on use of each grenade?
When I will do testing, I need to know, what is bug and what is intented behaviour.

@ClobberXD
Copy link
Contributor

Please describe features, that you expect to introduce with grenades.

Good point. Preferably, this should be added to the first post...

@ClobberXD
Copy link
Contributor

Tested. Here are my thoughts, from the most important to the least important:

  • Grenades follow the same trajectory irrespective of player's rotation in the y-axis.
    • Personally, this would be a huge game-breaker for me, as I won't be able to "aim" with grenades - they'll just fall a couple of nodes ahead of me, however high up I look.
    • Players would expect grenades to land further away when they look higher up.
    • Not sure, but I think shooter sets the velocity/acceleration based on how high up the player is looking.
    • Grenades should also be faster in general.
  • Damage radius of regular grenade is too less, and does the same damage to all objects in range irrespective of their distance to it. Same applies to flashbangs.
    • Damage radius should be around 5-6 nodes, and the players should take lesser damage, the farther away they are.
  • I'm quite happy with smoke grenades, but the "smoke" causes a huge hit in my FPS.
    • Particles in MT are currently poorly optimized, and lavish use of particles will heavily tax the graphics processor.
    • As a trial, the individual particles could be made much bigger, and the total number of particles being displayed at the same time could be decreased. This will provide the same effect, but will go a little easy on the GPU.
    • The particle textures could also be made a little rounder to look nicer.
  • The fading-out effect of flashbangs could be improved.
    • It feels like there are only two overlays instead of three. This could probably be a result of my high gamma.
    • on_explode of flashbang adds three white HUD overlays of various intensities, and gradually removes them one-by-one with the strongest one removed first.
    • I'm sure the same effect can be achieved using a single texture, with the help of texture modifiers.

@LoneWolfHT
Copy link
Member Author

Tested. Here are my thoughts, from the most important to the least important:

* Grenades follow the same trajectory irrespective of player's rotation in the y-axis.
  
  * Personally, this would be a huge game-breaker for me, as I won't be able to "aim" with grenades - they'll just fall a couple of nodes ahead of me, however high up I look.
  * Players would expect grenades to land further away when they look higher up.
  * Not sure, but I think `shooter` sets the velocity/acceleration based on how high up the player is looking.

My throwing code was basically copied from the shooter mod's grenade and modified.

  * Grenades should also be faster in general.

* Damage radius of regular grenade is too less, and does the same damage to all objects in range irrespective of their distance to it. Same applies to flashbangs.

I increased the radius of regular grenades. They already do one less hp point per node away the player is

  * Damage radius should be around 5-6 nodes, and the players should take lesser damage, the farther away they are.

* I'm quite happy with smoke grenades, but the "smoke" causes a huge hit in my FPS.
  
  * Particles in MT are currently poorly optimized, and lavish use of particles will heavily tax the graphics processor.
  * As a trial, the individual particles could be made much bigger, and the total number of particles being displayed at the same time could be decreased. This will provide the same effect, but will go a little easy on the GPU.

You need lots of particles for it to do anything. I lessened the amount. (Now 15. IIRC I had put 100 before)
I, with my potato. Notice hardly any drop in FPS with multiple smoke grenades set off at once though

  * The particle textures could also be made a little rounder to look nicer.

* The fading-out effect of flashbangs could be improved.
  
  * It feels like there are only two overlays instead of three. This could _probably_ be a result of my high gamma.
  * `on_explode` of flashbang adds three white HUD overlays of various intensities, and gradually removes them one-by-one with the strongest one removed first.
  * I'm sure the same effect can be achieved using a single texture, with the help of texture modifiers.

I've made some changes to the flashbang. It uses a single texture now, opacity changes may still need some help, and I also set it up so it's enabled by default now

@LoneWolfHT
Copy link
Member Author

Please describe features, that you expect to introduce with grenades.
What exactly should happen on use of each grenade?
When I will do testing, I need to know, what is bug and what is intented behaviour.

Just mention anything you think I did wrong or you don't like. My 'intended behavior' is grenades that almost everyone likes

@LoneWolfHT
Copy link
Member Author

@ClobberXD Could you review/test again?

@ClobberXD
Copy link
Contributor

The latest commit only fixes the markdown in API.md, and does not add flashbangs to treasure chests and crafting.lua.

Also, re-tested after incorporating the latest changes.

  • The "smoke" from smoke grenades aren't messing with my FPS now. ✔️
  • Flashbang's overlay works just as before, but using texture modifiers instead. ✔️
  • But the issue of not being able to change the trajectory of grenades still persists. ❌

For the issue of non-varying trajectories, I'll experiment with the code and see what's to be done.

@ClobberXD
Copy link
Contributor

A settingtypes.txt is only useful for singleplayer at best, and won't be of much use in server-only environments without a GUI. I suggest removing this file, and modifying setting-checks in the code accordingly.

@ClobberXD
Copy link
Contributor

Here are my deductions on acceleration and it's components:

  • The y-component of acceleration refers to the grenade's acceleration along the vertical (up-down) axis. This is generally set to the value of gravity (~ -9.81), which is rounded to -10 in shooter, with the negative signage referring to downwards acceleration. Setting this to -20 means that the grenade will experience twice as much "gravity" as players do.
  • The x-component and z-component together account for drag/air-resistance, and are generally equal unless the code wants to account for phenomenon like wind.

Velocity on the other hand is quite simple. All three components are set to dir.<axis> * k, where k is a constant. Increasing/Decreasing k is all that's required to tune the velocity of the grenade.

I just realized grenades actually do change trajectory depending on how high they're thrown, but the strong "gravity" and low velocity confused me into thinking that wasn't the case.

@ClobberXD
Copy link
Contributor

ClobberXD commented Nov 29, 2018

More testing: Thanks to physical = true, grenades bounce off vertical surfaces, and even bounces off the ground at times. Instead of checking if node at grenade pos ~= "air", I suggest keeping a tab on the velocity, and triggering the explosion on collision (i.e. when velocity steeply drops due to impact).

I also experimented with velocity and acceleration. The following seems to be one of the most optimal combinations:

obj:set_velocity({x = dir.x * 40, y = dir.y * 40, z = dir.z * 40})
obj:set_acceleration({x = dir.x * -4, y = -10, z = dir.z * -4})

If this feels a tad too fast, the velocity multiplier can be changed to 35.

@LoneWolfHT
Copy link
Member Author

We don't want the grenade's throwing range to be too great or players could 'bomb' the enemy base without risking confrontation

@LoneWolfHT
Copy link
Member Author

@ClobberXD I think it's ready for another 'checkup'

@LoneWolfHT LoneWolfHT mentioned this pull request Nov 29, 2018
@LoneWolfHT
Copy link
Member Author

That's fixed. How are the new grenade physics? @ClobberXD

@LoneWolfHT
Copy link
Member Author

So. What needs to be done before this can be merged? @ClobberXD

@ClobberXD ClobberXD dismissed their stale review December 6, 2018 07:01

Outdated review

@ClobberXD
Copy link
Contributor

@LoneWolfHT

  • I feel the grenades are still a tad too slow.
  • They are also way too rare in the chests.
  • Flashbang's effect wears off a little too quickly.

As of now, I don't see any other issues.

@LoneWolfHT
Copy link
Member Author

@LoneWolfHT

* I feel the grenades are still a tad too slow.

* They are also way too rare in the chests.

* Flashbang's effect wears off a little too quickly.

As of now, I don't see any other issues.

Ok

Ok. I set them to have the same rarity as the current grenade. These grenades are craftable too. Unlike the current grenade. I will also need some help figuring out what all the arguments in the treasure registration do lol

Ok. I'll increase it slightly

@ClobberXD
Copy link
Contributor

Taken from mods/treasurer/README.md:


==== treasurer.register_treasure ====
Registers a new treasure (this means the treasure will be ready to be spawned by treasure spawning mods).

This function does some basic parameter checking to catch the most obvious
mistakes. If invalid parameters have been passed, the input is rejected and
the function returns false. However, it does not cover every possible
mistake, so some invalid treasures may slip through.

Rarity does not imply preciousness. A rare treasure may not neccessarily a
very precious one. A treasure chest with scorched stuff inside may be very
rare, but it’s certainly also very unprecious.

===== Parameters =====

  • name: name of resulting ItemStack, e.g. “mymod:item
  • rarity: rarity of treasure on a scale from 0 to 1 (inclusive). lower = rarer
  • preciousness : subjective preciousness on a scale from 0 to 10 (inclusive). higher = more precious.
  • count: optional value which specifies the multiplicity of the item. Default is 1. See count syntax help in this file.
  • wear: optional value which specifies the wear of the item. Default is 0, which disables the wear. See wear syntax help in this file.
  • treasurer_groups: an optional table of group names to assign this treasure to. If omitted, the treasure is added to the default group.

===== Return value =====
true on success, false on failure.

=== data formats ===
format of count type:
==== count ====
A count can be a number or a table

  • number: it’s always so many times
  • {min, max}: it’s pseudorandomly between min and max times, math.random will be used to chose the value
  • {min, max, prob_func}: it’s between min and max times, and the value is given by prob_func (see below)

==== wear ====
Completely analogous to count.

@LoneWolfHT
Copy link
Member Author

I think the flashbangs could still use a little touching up regarding the blindness. If someone could take a look at that when they test...

@ClobberXD
Copy link
Contributor

ClobberXD commented Jan 14, 2019

Sounds would make these grenades more enjoyable to use. Would you be able to add the appropriate sounds for each grenade? register_grenade could set a default sound if a grenade isn't registered with a custom one.

Also, this PR needs to be rebased.

@LoneWolfHT
Copy link
Member Author

Sounds would make these grenades more enjoyable to use. Would you be able to add the appropriate sounds for each grenade? register_grenade could set a default sound if a grenade isn't registered with a custom one.

Also, this PR needs to be rebased.

heh. I just finished those. I added them to the non-CTF mod though. So I'll have to copy them over.
While you wait you could use the mod to test out the sounds: https://github.com/LoneWolfHT/grenades

Will do

@ghost ghost mentioned this pull request Jan 25, 2019
@rubenwardy
Copy link
Member

rubenwardy commented Mar 5, 2019

I like this. I would be great to see #356 added to this too, but this can be later

When you kill a player with a grenade a sword is shown instead of a grenade in the deathlist HUD

This is no longer hard coded, so it may just work

Flashbang can be cheated by turning off HUD

Maybe decrease speed too? This would beg for a physics resolver too. I suggest just ignoring this issue for now

@ClobberXD
Copy link
Contributor

ClobberXD commented Mar 5, 2019

This would beg for a physics resolver too.

#289 :)

Merge conflicts, btw.

@LoneWolfHT
Copy link
Member Author

LoneWolfHT commented Mar 5, 2019

Ok. I'll get to work on this again lol
Just realized you can make the smoke and flashbang effects invisible with a texturepack too. May have to apply the slowness for when in smoke too...
That or look into using texture modifiers for it 🤔

@LoneWolfHT
Copy link
Member Author

Ok. Using [noalpha I fixed the texturepack problem with the flashbang HUD. Not sure how I'll do the smoke...

@LoneWolfHT
Copy link
Member Author

heh. I may need to make a new PR. Messed up the rebase...

@LoneWolfHT LoneWolfHT mentioned this pull request Mar 5, 2019
@LoneWolfHT
Copy link
Member Author

Moving to #357

@LoneWolfHT LoneWolfHT closed this Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants