MCPcopy Create free account
hub / github.com/NetHack/NetHack / lspo_gas_cloud

Function lspo_gas_cloud

src/sp_lev.c:4928–4965  ·  view source on GitHub ↗

gas_cloud({ selection=SELECTION }); */ gas_cloud({ selection=SELECTION, damage=N }); */ gas_cloud({ selection=SELECTION, damage=N, ttl=N }); */

Source from the content-addressed store, hash-verified

4926/* gas_cloud({ selection=SELECTION, damage=N }); */
4927/* gas_cloud({ selection=SELECTION, damage=N, ttl=N }); */
4928int
4929lspo_gas_cloud(lua_State *L)
4930{
4931 coordxy x = 0, y = 0;
4932 struct selectionvar *sel = NULL;
4933 int argc = lua_gettop(L);
4934 int damage = 0;
4935 int ttl = -2;
4936
4937 create_des_coder();
4938
4939 if (argc == 1 && lua_type(L, 1) == LUA_TTABLE) {
4940 lua_Integer tx, ty;
4941 NhRegion *reg;
4942
4943 lcheck_param_table(L);
4944
4945 get_table_xy_or_coord(L, &tx, &ty);
4946 x = tx, y = ty;
4947 if (tx == -1 && ty == -1) {
4948 lua_getfield(L, 1, "selection");
4949 sel = l_selection_check(L, -1);
4950 lua_pop(L, 1);
4951 }
4952 damage = get_table_int_opt(L, "damage", 0);
4953 ttl = get_table_int_opt(L, "ttl", -2);
4954 if (!sel) {
4955 reg = create_gas_cloud(x, y, 1, damage);
4956 } else
4957 reg = create_gas_cloud_selection(sel, damage);
4958 if (ttl > -2)
4959 reg->ttl = ttl;
4960 } else {
4961 nhl_error(L, "wrong parameters");
4962 }
4963
4964 return 0;
4965}
4966
4967
4968/*

Callers

nothing calls this directly

Calls 8

create_des_coderFunction · 0.85
lcheck_param_tableFunction · 0.85
get_table_xy_or_coordFunction · 0.85
l_selection_checkFunction · 0.85
get_table_int_optFunction · 0.85
create_gas_cloudFunction · 0.85
nhl_errorFunction · 0.85

Tested by

no test coverage detected