Scripts / smartbomb powerup

Author
Message
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 11:41 Edited at: 19th Jan 2017 13:03





hi there i was wondering if anybody new how to do a smartbomb script ive tried using bits of Smallgs absorbing damage script but i cant get it to work what i want is a powerup that is collected and when you press a key it uses a smartbomb to kill all in my range here is the code im using i manage to pick up object which hides then attach itself to me so the script still runs when i go other places the prompts come up but when i press the v key nothing happens some help would be much appreciated thanks Bonesy23438




g_smartbomb_collected = 0
g_smartbomb_activated = 0
local smartbomb_damage = 2000
local blast_range = 5000
local input_key = "v"
local state = {}
local picked_up = 0
local pressed = 0
local smartbomb_activated = 0
local smartbomb = 1

function smartbomb_pickup_init(e)
state[e] = "pick up"
end

function smartbomb_pickup_main(e)
if state[e] == "pick up" then
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 60 and g_PlayerHealth > 0 and g_PlayerThirdPerson==1 then
Hide(e)
CollisionOff(e)
PlaySound(e,0)
picked_up = 1
g_smartbomb_collected = 1
state[e] = "init"
elseif state[e] == "init" then
SetPosition(e,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
end
end
if pressed == 0 and state[e] == "init" then
Prompt("press " .. input_key .. " to activate smartbomb, " .. smartbomb .. " smartbombs's remaining")
elseif g_InKey == input_key and g_PlayerHealth > 0 then
PlaySound(e,1)
pressed = 1
g_smartbomb_activated = 1
state[e] = "actvated"
end



if smartbomb_activated == 1 then
for a = 1, 19999 do
end
if g_Entity[a] ~= nil then
if GetPlayerDistance(a) <= blast_range then
if ai_soldier_state[a] ~= nil then
SetEntityHealth(a,g_Entity[a]['health'] - smartbomb_damage)
g_smartbomb_activated = 0
Destroy(e)


end
end
end
end
end
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 19th Jan 2017 14:08
This is not exactly what your looking for, but maybe worth take a look

hth

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Jan 2017 14:24
your 'for do' loop is set to trigger only if smartbomb_activated = 1 while the real variable is called g_smartbomb_activated
there's also a random 'end' that will finish the 'for do' loop early
actually a few of the 'end' are in the wrong place.
also fixed up the counter for you and made it so that it will only fire 1 at a time.

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 15:46
hi there thanks for the help but i cant get it to work everythings fine until i press v key which is the input key and nothing happens what am i doin wrong
PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 15:56
hang on managed it set the state to activated and it worked thanks so much cheers for the help
PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 16:34
hang on managed it set the state to activated and it worked thanks so much cheers for the help
PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 16:35
ive dont know whats happened but its stopped working now ive copied and pasted the code and set state to activated but nothings happening again now

PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 19th Jan 2017 17:10
sorry to be a pain but its working again now thanks
PM

Login to post a reply

Server time is: 2024-12-23 03:57:49
Your offset time is: 2024-12-23 03:57:49