Okay so I made a script that counts the number of enemies killed and a gate script that opens when a certain number is reached! This script should be easily adapted for a earning money or scoring script! Basically, my script is just a modded a few extra line of code in the provided ai_soldier script.
Ok the only thing we need to do is open the ai_soldier script (or whatever one you use the rpg or zombie).
look for this:
function ai_soldier_exit(e)
PlayCharacterSound(e,"onDeath")
end
replace that with:
function ai_soldier_exit(e)
PlayCharacterSound(e,"onDeath")
Killed = Killed + 1
end
Don't Declare the global here, just set it.
Now you need the gate script. The gate script is where I placed to global Killed.
Call the script "killdoor.lua"
--Exadion Script
--free to use for any use but please give credit!
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY'
-- runonce
if Runonce == 1 then
else
Killed = 0
Runonce = 1
end
local NessisaryKills = 3
function killdoor_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and Killed >= NessisaryKills and doorClosed ~= 1 then
CollisionOff(e)
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
g_Entity[e]['activated'] = 2
ActivateIfUsed(e)
doorClosed = 1
else
if PlayerDist < 200 and doorClosed ~= 1 then
Prompt("The door is locked untill the three guards are dead! " .. NessisaryKills - Killed .. "/" .. NessisaryKills .. " Remain")
end
end
end
Note the door will open automatically but only once the player is close to it!
The player doesn't need to be close to the door in order for it too count kills! But It only annouces how many kills/remaining when nearby.
Make sure the AI script you place the kill line in is the one your using for the AI (for example some will by default use ai_cover or ai_charge, you may add it to any or all of them).
Now as for money or exp simply declare the the globals (trigger or attached to a object) and add them into the AI script the same way!