MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Script_Unit_SetSpeed

Function Script_Unit_SetSpeed

src/script/unit.c:381–394  ·  view source on GitHub ↗

* Set the speed of a Unit. * * Stack: 1 - The new speed of the Unit. * * @param script The script engine to operate on. * @return The new speed; it might differ from the value given. */

Source from the content-addressed store, hash-verified

379 * @return The new speed; it might differ from the value given.
380 */
381uint16 Script_Unit_SetSpeed(ScriptEngine *script)
382{
383 Unit *u;
384 uint16 speed;
385
386 u = g_scriptCurrentUnit;
387 speed = clamp(STACK_PEEK(1), 0, 255);
388
389 if (!u->o.flags.s.byScenario) speed = speed * 192 / 256;
390
391 Unit_SetSpeed(u, speed);
392
393 return u->speed;
394}
395
396/**
397 * Change the sprite (offset) of the unit.

Callers

nothing calls this directly

Calls 1

Unit_SetSpeedFunction · 0.85

Tested by

no test coverage detected