Skip to content

Commit

Permalink
Scripting: Added player methods
Browse files Browse the repository at this point in the history
- App.Player.shotAmmo()

Heretic only:
- App.Player.setFlameCount(tics)

IssueID #2375
  • Loading branch information
skyjake committed Jan 31, 2020
1 parent bb2a4d7 commit 22aa6a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 19 additions & 1 deletion doomsday/apps/plugins/common/src/common.cpp
Expand Up @@ -309,6 +309,20 @@ static de::Value *Function_Player_Power(de::Context &ctx, const de::Function::Ar
return new de::NumberValue(contextPlayer(ctx).powers[power]);
}

static de::Value *Function_Player_ShotAmmo(de::Context &ctx, const de::Function::ArgumentValues &)
{
P_ShotAmmo(&contextPlayer(ctx));
return nullptr;
}

#if defined(__JHERETIC__)
static de::Value *Function_Player_SetFlameCount(de::Context &ctx, const de::Function::ArgumentValues &args)
{
contextPlayer(ctx).flameCount = args.at(0)->asInt();
return nullptr;
}
#endif

//-------------------------------------------------------------------------------------------------

void Common_Load()
Expand Down Expand Up @@ -389,7 +403,8 @@ void Common_Load()
auto &playerClass = scr.builtInClass("App", "Player");
gameBindings->init(playerClass)
<< DENG2_FUNC_NOARG (Player_Health, "health")
<< DENG2_FUNC (Player_Power, "power", "type");
<< DENG2_FUNC (Player_Power, "power", "type")
<< DENG2_FUNC_NOARG (Player_ShotAmmo, "shotAmmo");

#if defined(HAVE_DOOM_ARMOR_BINDINGS)
*gameBindings
Expand All @@ -398,6 +413,9 @@ void Common_Load()
#endif

#if defined(__JHERETIC__)
*gameBindings
<< DENG2_FUNC(Player_SetFlameCount, "setFlameCount", "tics");

// Heretic: Powerup constants.
playerClass.set("PT_INVULNERABILITY", PT_INVULNERABILITY);
playerClass.set("PT_INVISIBILITY", PT_INVISIBILITY);
Expand Down
3 changes: 0 additions & 3 deletions doomsday/apps/plugins/heretic/src/p_pspr.c
Expand Up @@ -1254,9 +1254,6 @@ void C_DECL A_FirePhoenixPL2(player_t* player, pspdef_t* psp)

void C_DECL A_ShutdownPhoenixPL2(player_t *player, pspdef_t *psp)
{
if(IS_CLIENT)
return;

P_ShotAmmo(player);
}

Expand Down

0 comments on commit 22aa6a9

Please sign in to comment.