As asked by blowfish i want to provide suggestions for lua in map entity handling.
In trem logic for map entities is handled by target(name) chain, meaning you specify a target and targename params with a string value.
The ones with target param will activate everything that has a targetname with the same values.
Copying this behaviour trough lua functions should be a piece of cake.
For starters we should obsolete trigger_always, which just fires at start.
We just need a generalized function, for example named trigger(target) that could do the job.
And have a callback in lua that could be overriden or a table to insert functions to call when the map starts.
Next would be target_delay, which when triggered just will trigger something else later, by adding a second argument to the triggering function being the delay, this one could be ditched too.
Of course for this to work we will to add a callback function when a player enters some area.
In netradiant there are quite a few, a basic, one for buildables, one for human equipment checks and alien classes.
We could squeeze all 4 of these entities into one callback function and make the designer chose what logic he likes.
Likewise will need to adapt the func_button, trigger_teleport and target_teleport in the same vain.
I havent fully checked if those are all triggering entities but it should outline the rough work.
The following output only entities could be replaced with simple function calls from the trigger functions.
We need just a handful functions to make a mappers life so easier, such as instakilling, adding damage to a player or healing him.
Then there are functions needed for printing text, teleporting players and team win triggers.
Plus a few i didnt mention.
Also lua functions for movement of entities would be quite nice.
This would provide a great start for serverside lua usage.
In addition it would partially get rid of forcing the mapper to go trough lengthy recompiling when adjusting entities in maps.
4 Likes
Some further ideas based on various maps I have seen (including AMP maps like operation blackout), and some things I have thought of:
-
Custom win conditions
-
Map entities that can be activated in the same kinds of ways as armory/hovel/teleporter/etc buildables. Which may include triggering custom menus with custom actions to choose from.
-
Destructible map entities, like barrels that might blow up that blow a whole in the wall, or break a part of a catwalk to result in a ramp (the operation black out map had exactly this).
-
The ability to make use of any existing “weapon”, as well as the ability to make custom weapons.
-
Weapon/upgrade racks that only supply specific weapons/upgrades (operation black out also had this).
-
Custom non-playable characters that might help only specific teams, or be an enemy to all, or help all, perhaps even have alliance based on which team gains control of something.
2 Likes
@Code_Man any examples of what a possible script might look like?
e.g., how might you want to program a button on a wall to activate an elevator?
We should probably have a map that we can easily prototype with
3 Likes
Ok suppose we have everything in a file called map.lua and use callback functions of some sort.
Ill just make some example code than what it would look like.
function onStart()
echo("hello") -- same as target_print entitiy
play("sounds/shittymusicloop.wav", true) -- annoy players as much as possible
target("mydoor", 600) -- lets open the door called mydoor in 10 mins assuming its a classic func_door
end
function onTrigger(name, player, class, item) -- callback for when any thing is triggred
if name == "needsuitckit" and class == "base" and item == "ckit" then -- guessed the names here
echo("get a bsuit")
kill(player)
elseif name == "blowfish_haxor" then
if getName(player) == "blowfish" then
heal(player, 100)
else
hurt(player, 50)
echo("this area is for blowfish only!")
end
else
kill(player, getName(Player) .. " Should not have gone there.")
echo("^1HAHAHHAHA", player)
end
end
function onConnect(player, time)
echo(getName(Player) .. " hi", player)
end
This is a fairly rough example but it should about illustrate what i mean.
I also have to point out that with changes like these we will also have to make adjustments to entities and quite possibly in the long future break compatibility.
5 Likes