new superman/flash/road runner etc speed drug
*warning can cause harmful side effects*
first you need to place an entity (in my case i used syringes but it should work with anything)
turn off physics
turn on always active
make sure it\'s dynamic (as with all objects running scripts)
enter into the name field any name you like
enter into the ifused field that same name (very important those 2 match and there are no repeats - i.e. you must use different names for each object, even those running this same script)
apply the script
now when you run the game you press e to pickup as normal and hold e for a while (setting changable in script) to activate
note you only need 1 script which you apply to every syringe or entity you want to give this effect (no need to rename or alter the script but you can change the settings which i have highlighted at the top)
also it should be possible to have different settings for different syringes but i didn\'t test that, you should be able to substitute the e with the actual entity number and it\'ll work however - if you wanted different speeds or durations etc)
picture for reference
video
code (sorry its very messy)
--script by smallg
--how many boosts to start with
local superman = 0
local duration = {}
local speed = {}
local activate_delay = {}
local active = {}
local delay = {}
local pressed = 0
local set = {}
local collected = {}
local time1 = {}
local time2 = {}
local timepassed = {}
local timeleft = 0
local temp = 0
function superman_init(e)
--how long effect will last for (in seconds)
duration[e] = 5
--how fast to travel
speed[e] = 1000
--how long to hold e before effect takes effect (in seconds)
activate_delay[e] = 1.75
--StartTimer(e)
active[e] = 0
set[e] = 1
delay[e] = 0
collected[e] = 0
time1[e] = 0
time2[e] = 0
timepassed[e] = 0
end
function superman_main(e)
--Prompt(\"charges remaining = \" .. superman)
CollisionOff(e)
if superman > 0 then
if active[e] == 1 then
timeleft = duration[e] - timepassed[e]
timeleft = round(timeleft)
end
Prompt(\"charges remaining = \" .. superman .. \" time left this charge = \" .. timeleft .. \"s\")
end
if GetPlayerDistance(e) < 80 then
if active[e] == 0 then
Prompt(\"Collect Superman syringe?\")
end
if pressed == 0 and g_KeyPressE == 1 and active[e] == 0 then
--StartTimer(e)
pressed = 1
collected[e] = 1
timeleft = duration[e]
superman = superman + 1
ResetPosition(e,0,0,0)
end
end
if g_KeyPressE == 1 and superman > 0 and collected[e] == 1 and temp == 0 then
if time1[e] == 0 then
time1[e] = g_Time
end
time2[e] = g_Time
timepassed[e] = (time2[e] - time1[e]) / 1000
if timepassed[e] > activate_delay[e] then
active[e] = 1
temp = 1
superman = superman - 1
time1[e] = 0
ResetPosition(e,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
Hide(e)
end
end
if g_KeyPressE == 0 then
if pressed == 1 then
pressed = 0
end
if timepassed[e] < activate_delay[e] and active[e] == 0 then
time1[e] = 0
end
end
if active[e] == 1 then
if time1[e] == 0 then
time1[e] = g_Time
end
time2[e] = g_Time
timepassed[e] = (time2[e] - time1[e]) / 1000
SetRotation(e,g_PlayerAngX,g_PlayerAngY,g_PlayerAngZ)
MoveForward(e,speed[e])
TransportToIfUsed(e)
if timepassed[e] >= duration[e] then
active[e] = 0
time1[e] = 0
ResetPosition(e,0,0,0)
temp = 0
end
--Prompt(timepassed[e] .. \" \" .. duration[e])
end
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
note there is no sound but i can add some if you wish.
also collision will be ignored, i can add a very basic system but unless we get a proper collision detection i can't really fix that, sorry
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11