static void G_TouchEdict_f (void) { edict_t *e, *ent; int i; if (gi.Cmd_Argc() < 2) { gi.DPrintf("Usage: %s <entnum>\n", gi.Cmd_Argv(0)); return; } i = atoi(gi.Cmd_Argv(1)); if (!G_EdictsIsValidNum(i)) return; e = G_EdictsGetByNum(i); if (!e->touch) { gi.DPrintf("No touch function for entity %s\n", e->classname); return; } ent = G_EdictsGetNextLivingActor(NULL); if (!ent) return; /* didn't find any */ gi.DPrintf("Call touch function for %s\n", e->classname); e->touch(e, ent); }
static void G_UseEdict_f (void) { edict_t *e; int i; if (gi.Cmd_Argc() < 2) { gi.DPrintf("Usage: %s <entnum>\n", gi.Cmd_Argv(0)); return; } i = atoi(gi.Cmd_Argv(1)); if (!G_EdictsIsValidNum(i)) { gi.DPrintf("No entity with number %i\n", i); return; } e = G_EdictsGetByNum(i); if (!e->use) { gi.DPrintf("No use function for entity %s\n", e->classname); return; } gi.DPrintf("Call use function for %s\n", e->classname); e->use(e, NULL); }
/** * @brief Get an entity by it's number * @param[in] num The entity's index in the array of entities */ Edict* G_EdictsGetByNum (const int num) { if (!G_EdictsIsValidNum(num)) { gi.DPrintf("Invalid edict num %i\n", num); return nullptr; } return g_edicts + num; }
static void G_DestroyEdict_f (void) { edict_t *e; int i; if (gi.Cmd_Argc() < 2) { gi.DPrintf("Usage: %s <entnum>\n", gi.Cmd_Argv(0)); return; } i = atoi(gi.Cmd_Argv(1)); if (!G_EdictsIsValidNum(i)) return; e = G_EdictsGetByNum(i); if (!e->destroy) { gi.DPrintf("No destroy function for entity %s\n", e->classname); return; } gi.DPrintf("Call destroy function for %s\n", e->classname); e->destroy(e); }