SetNpcCombatConfig: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Release G1R:MP 0.1.5 BUILD144 / Protocol 37; update availability and migration
Document upcoming 0.1.7: optional server TTS, 33 functions, 4 events, English voice/setup guides and NPC meleeSkillTier; not a release
Line 31: Line 31:
== Notes ==
== Notes ==
* Server-side only. Mutations require the NPC to belong to the calling resource; getters do not grant control.
* Server-side only. Mutations require the NPC to belong to the calling resource; getters do not grant control.
* Since 0.1.5. Use the matching 0.1.5 client and server (Protocol 37).
* Introduced in 0.1.5. Use matching client/server versions; the meleeSkillTier extension below requires upcoming 0.1.7.
* Use matching updated client and server. See [[NPC scripting]] for lifecycle, defaults, combat examples and collision limitations.
* Use matching updated client and server. See [[NPC scripting]] for lifecycle, defaults, combat examples and collision limitations.
* Fields: range (metres 1..40, default 15), dexterity (0..100000, default 10), skillTier (integer 0..2, default 0), aimTimeMs (integer 150..30000, default 600), cooldownMs (integer 360..60000, default 1000), consumeAmmo/consumeMana (booleans, default true). Spell range/cooldown still apply. Configuration changes interrupt pending preparation. Disabling consumption still requires sufficient initial resources.
* Fields: range (metres 1..40, default 15), dexterity (0..100000, default 10), skillTier (integer 0..2, default 0), aimTimeMs (integer 150..30000, default 600), cooldownMs (integer 360..60000, default 1000), consumeAmmo/consumeMana (booleans, default true). Spell range/cooldown still apply. Configuration changes interrupt pending preparation. Disabling consumption still requires sufficient initial resources.
Line 38: Line 38:
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:NPC Functions]]
[[Category:NPC Functions]]
<!-- melee017:start -->
== NPC melee skill tiers (upcoming 0.1.7) ==
The functions themselves remain available since 0.1.5. '''Only the additions below are new in upcoming 0.1.7'''; they are not available in public 0.1.6.
* [[setNpcCombatConfig]] accepts optional <code>meleeSkillTier</code>: integer 0 (untrained, default), 1 (trained) or 2 (master). [[getNpcCombatConfig]] includes this field in its result table.
* <code>skillTier</code> remains the separate ranged-combat tier. Changing the melee tier does not overwrite ranged settings. Omitted fields keep their existing values; invalid/unknown fields reject the entire change.
* This selects ordinary melee presentation/timing for the NPC's equipped family, not its weapon or damage. It does not enable combat, select a target or increase strength/damage. Existing resource ownership and combat controls still apply.
* A strike already admitted keeps its captured animation/impact deadline. A melee-only or unchanged update does not restart unrelated projectile preparation; changing ranged settings still affects that separate configuration.
* Use matching updated client/server support to see the new tier presentation, including observers and late join. Players continue using the existing [[setPlayerSkill]] API; no new setPlayerCombatStyle function was added.
<syntaxhighlight lang="lua">
-- npcId is an existing NPC owned by this server resource.
local ok = setNpcCombatConfig(npcId, {meleeSkillTier=2})
if ok then
    local config = getNpcCombatConfig(npcId)
    if config then outputDebugString("NPC melee tier: " .. config.meleeSkillTier) end
end
</syntaxhighlight>
<!-- melee017:end -->

Revision as of 22:49, 8 October 2026

setNpcCombatConfig

AVAILABLE FROM UPDATE 0.1.5
This function is available in G1R:MP 0.1.5 and later. The contract below includes the compatibility guarantees introduced in that update.

Updates NPC projectile combat configuration atomically.

Syntax

setNpcCombatConfig(npcId, settings)

Parameters

Name Type Required Description
npcId int yes Server-assigned NPC ID returned by spawnNpc; not a player ID.
settings table yes Partial configuration table; unknown fields and invalid values reject the whole change. See details below.

Returns

Returns true when accepted, false for a rejected request. Acceptance is not proof of a rendered animation, projectile release or hit.

Examples

setNpcCombatConfig(npcId, {range=3, aimTimeMs=600, consumeMana=true})

Notes

  • Server-side only. Mutations require the NPC to belong to the calling resource; getters do not grant control.
  • Introduced in 0.1.5. Use matching client/server versions; the meleeSkillTier extension below requires upcoming 0.1.7.
  • Use matching updated client and server. See NPC scripting for lifecycle, defaults, combat examples and collision limitations.
  • Fields: range (metres 1..40, default 15), dexterity (0..100000, default 10), skillTier (integer 0..2, default 0), aimTimeMs (integer 150..30000, default 600), cooldownMs (integer 360..60000, default 1000), consumeAmmo/consumeMana (booleans, default true). Spell range/cooldown still apply. Configuration changes interrupt pending preparation. Disabling consumption still requires sufficient initial resources.

NPC melee skill tiers (upcoming 0.1.7)

The functions themselves remain available since 0.1.5. Only the additions below are new in upcoming 0.1.7; they are not available in public 0.1.6.

  • setNpcCombatConfig accepts optional meleeSkillTier: integer 0 (untrained, default), 1 (trained) or 2 (master). getNpcCombatConfig includes this field in its result table.
  • skillTier remains the separate ranged-combat tier. Changing the melee tier does not overwrite ranged settings. Omitted fields keep their existing values; invalid/unknown fields reject the entire change.
  • This selects ordinary melee presentation/timing for the NPC's equipped family, not its weapon or damage. It does not enable combat, select a target or increase strength/damage. Existing resource ownership and combat controls still apply.
  • A strike already admitted keeps its captured animation/impact deadline. A melee-only or unchanged update does not restart unrelated projectile preparation; changing ranged settings still affects that separate configuration.
  • Use matching updated client/server support to see the new tier presentation, including observers and late join. Players continue using the existing setPlayerSkill API; no new setPlayerCombatStyle function was added.
-- npcId is an existing NPC owned by this server resource.
local ok = setNpcCombatConfig(npcId, {meleeSkillTier=2})
if ok then
    local config = getNpcCombatConfig(npcId)
    if config then outputDebugString("NPC melee tier: " .. config.meleeSkillTier) end
end