eq2emu/docs/lua_functions/GetInfoStructFloat.md

31 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

### Function: GetInfoStructFloat(spawn, field)
2025-05-04 14:34:15 -04:00
**Description:**
Retrieves a floating-point field from a spawns info data. Could be used for precise position, speed multipliers, etc. if stored there. See https://github.com/emagi/eq2emu/blob/main/docs/data_types/info_struct.md for a full list of options.
2025-05-04 14:34:15 -04:00
**Parameters:**
- `spawn` (Spawn) - Spawn object representing `spawn`.
- `field` (string) - String `field`.
2025-05-04 14:34:15 -04:00
**Returns:** Float The value of that field.
2025-05-04 14:34:15 -04:00
**Example:**
2025-05-04 14:34:15 -04:00
```lua
-- From SpawnScripts/Generic/SpiritShard.lua
function recovershard(NPC, Spawn)
local charid = GetShardCharID(NPC)
FindSpellVisualByID
if GetCharacterID(Spawn) == charid then
local DebtToRemovePct = GetRuleFlagFloat("R_Combat", "ShardDebtRecoveryPercent")
local DeathXPDebt = GetRuleFlagFloat("R_Combat", "DeathExperienceDebt")
local debt = GetInfoStructFloat(Spawn, "xp_debt")
local DebtToRemove = (DebtToRemovePct/100.0)*(DeathXPDebt/100.0);
if debt > DebtToRemove then
SetInfoStructFloat(Spawn, "xp_debt", debt - DebtToRemove)
else
SetInfoStructFloat(Spawn, "xp_debt", 0.0)
end
```