Skip to content

Commit

Permalink
World|Scripting: Added World.Thing.recoil()
Browse files Browse the repository at this point in the history
IssueID #2349
  • Loading branch information
skyjake committed Dec 11, 2019
1 parent 03f7ddf commit f566571
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doomsday/apps/client/src/world/base/bindings_world.cpp
Expand Up @@ -63,6 +63,20 @@ static Value *Function_Thing_StartSound(Context &ctx, const Function::ArgumentVa
return nullptr;
}

static Value *Function_Thing_Recoil(Context &ctx, const Function::ArgumentValues &args)
{
mobj_t & mo = ClientServerWorld::contextMobj(ctx);
const double force = args.at(0)->asNumber();

const angle_t angle = mo.angle + ANG180;
const float angle_f = float(angle) / float(ANGLE_180) * PIf;

mo.mom[MX] += force * cos(angle_f);
mo.mom[MY] += force * sin(angle_f);

return nullptr;
}

void initBindings(Binder &binder, Record &worldModule)
{
// Global functions.
Expand All @@ -81,8 +95,8 @@ void initBindings(Binder &binder, Record &worldModule)
binder.init(thing)
<< DENG2_FUNC_NOARG(Thing_Id, "id")
<< DENG2_FUNC_NOARG(Thing_Health, "health")
<< DENG2_FUNC_DEFS (Thing_StartSound, "startSound", "id" << "volume", startSoundArgs);

<< DENG2_FUNC_DEFS (Thing_StartSound, "startSound", "id" << "volume", startSoundArgs)
<< DENG2_FUNC (Thing_Recoil, "recoil", "force");
}
}

Expand Down

0 comments on commit f566571

Please sign in to comment.