Conversation
…n their inventory after MOD_CONF overrides.
| // Internal types need to be included in this case. | ||
| #include <TFE_Jedi/InfSystem/infTypesInternal.h> | ||
| #include <TFE_Jedi/Renderer/jediRenderer.h> | ||
| #include <TFE_DarkForces/Scripting/gs_player.h> |
There was a problem hiding this comment.
I would be uncomfortable doing this.
I think referencing scripting functionality from the base-game is a pattern best avoided.
Scripting has a dependency on the base-game; the reverse should not be true.
(what do you think @luciusDXL ?)
What you could do instead is use the existing player_hasWeapon() function in player.cpp
Note that this function (annoyingly) does not use the WeaponId Enum as its parameter, it instead uses weaponIndex which appears to be based on the keyboard hotkeys, i.e. fist = 1, pistol = 2, rifle = 3....
So you will have to translate from WeaponId to weaponIndex -- but AFAICS it is simply a matter of adding 1 to the WeaponId.
So this should work:
if (!player_hasWeapon(s_playerInfo.curWeapon + 1))
{
There was a problem hiding this comment.
Yes, factor out any common functions and use those. Don't call script functions from within the game (unless it is related to scripting).
jerethk
left a comment
There was a problem hiding this comment.
Couple more issues buddy - thanks
|
|
||
| default: | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Hi @ifeldshteyn
Can you please revert this -- you can't directly use player_hasWeapon from player.cpp because the argument it takes is not based on the same data.
The argument here is the WeaponId enum where
FIST = 0
PISTOL = 1
RIFLE = 2
etc.
Whereas player.cpp player_hasWeapon uses the keyboard numbers
FIST = 1
PISTOL = 2
RIFLE = 3
...
There are also a couple of other minor differences -- eg. player_hasWeapon also assesses whether you have detonator and mines ammo.
And the return value is JBool instead of primitive bool
So it is best to just leave the gs_player function as is.
| public: | ||
| bool scriptRegister(ScriptAPI api) override; | ||
| }; | ||
| bool hasWeapon(s32 weapon); |
There was a problem hiding this comment.
This can now be reverted too, it doesn't have to be exposed
| } | ||
|
|
||
| // Don't start the game with a weapon you don't have after overrides. | ||
| if (!player_hasWeapon(s_playerInfo.curWeapon)) |
There was a problem hiding this comment.
I think this will have to be s_playerInfo.curWeapon + 1 to work correctly
But you should double check to be sure.
jerethk
left a comment
There was a problem hiding this comment.
This all looks good now, thanks Karjala
Prevents you from starting the level by holding a weapon that is removed during MOD_CONF overrides.