From ecf178866edd62c4dfdc8bf094a35e51882bf609 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 3 Oct 2015 14:42:54 +0200 Subject: [PATCH] new command addentity addentity Adds an entity of the specified type at the current camera position and returns the index number of the new entity, so that the other attributes can be set by editentity. DOCREF addentity --- config/scripts.cfg | 1 + source/src/world.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/config/scripts.cfg b/config/scripts.cfg index e2a43f8a..0634a9dc 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -72,6 +72,7 @@ complete demo demos dmo looplist [ listoptions "" newent ents + addentity ents clearents ents closestenttype ents enumentities ents diff --git a/source/src/world.cpp b/source/src/world.cpp index 0f25f2bc..4c16a2d3 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -445,6 +445,18 @@ void deleteentity(char *ns) } COMMAND(deleteentity, "s"); +void addentity(char *what) // type +{ + int type = findtype(what); + if(noteditmode("addentity") || multiplayer(true) || type == NOTUSED) return; + entity e((int)camera1->o.x, (int)camera1->o.y, (int)camera1->o.z, type, 0, 0, 0, 0); + e.spawned = true; + intret(ents.length()); + ents.add(e); + unsavededits++; +} +COMMAND(addentity, "s"); + void editentity(char **args, int numargs) // index x y z a1 a2 a3 a4 ... { string res = "";