Scripts / chain_combo_kills

Author
Message
bonesy23438
8
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 30th Jan 2017 15:46
hi there i was dabbling in lua again to see if i could get a script working like when you kill a certain amount of enemies in an area close together in a certain time you activate chain combo kill and get awarded bonus point ive tried but couldnt get it to work my lua scripting is very basic help would be much appreciated thanks Andy
PM
Corno_1
GameGuru Tool Maker
13
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 30th Jan 2017 18:44
Show us what you have, then we can show what you maybe did wrong and you can learn from your mistakes

Dont be shy
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
bonesy23438
8
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 1st Feb 2017 05:17
hi there here is the code ive worked out but not working i do have problems putting the ends in the right places
function assualt_mech_exit(e)

if g_score_multiplier == 0 then
g_score = g_score + 100
elseif g_score_multiplier == 1 then
g_score = g_score + 100 * 2
end
if g_chain_combo_count == 0 and TimerReset12 ~= 1 then
TimerReset12 = 1
StartTimer(e)
g_chain_combo_count = g_chain_combo_count + 1
end
if g_chain_combo_count > 1 and GetTimer(e) < 2000 then
g_score = g_score + 200 * g_chain_combo_count
else if GetTimer(e) > 2000 then
g_chain_combo_count = 0
TimerRest12 = 0
end
end
end
PM
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 1st Feb 2017 16:02
bonesy..
looking at your code.. I see..

1. It is the [ assualt_mech_exit(e) ] function..
2. It uses the StartTimer(e) and GetTimer(e) functions..

Information...
How does a GG lua script run...( this is what I think when I code)
1. The script is attached to a mech model.

2. At run test level GG will call the [ assualt_mech_init(e) ] function.
once at the very start up.(for each mech with this script)

3. GG will then call the [ assualt_mech_main(e) ] function.
every FPS that the level is running.. (for each mech with this script)

4. When the mech [e] is killed GG will call the [ assualt_mech_exit(e) ] function.
Just the once .. it is dead it is no more it is a dead parrot.. mech I mean..

So do you see..
there is no way to use the Timer(e) code in exit function as this exit is only ever called once for [e].
I have not looked at the other parts of your code but thought it helpful to share this..
Hope this helps..
PM
bonesy23438
8
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 1st Feb 2017 17:15
ok mate thanks for the heads up im still learning to script in game guru thought id have a go most of my ideas have workrd escept for this code and a smartbomb code but Smallg sorted that out for me so it cant be done ok thanks
PM
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 1st Feb 2017 18:15
No I'm not saying your combo kill can't be done..

I am just trying to get you to think of another way..
maybe move the timer to another entity that is always active in the level..
so this entity has code to control the timer and for your combo code..

I have not tried or thought about doing this myself.. but on seeing the timer in your exit function
I just thought.. I don't think you can do it that way..




PM
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 2nd Feb 2017 11:29
Thinking about your code last night..

maybe it could work if you replaced the StartTimer(e) and GetTimer(e)
with the global system clock..

add this line at start of your exit function
myTimeNow = os.clock()

then
replace StartTimer(e) with myTimeStart = myTimeNow (global variables)

then
replace [ and GetTimer(e) < 2000 then ]
with
(myTimeNow - myTimeStart) < 2 then

I think the os.clock() returns seconds so only 2 no the 2000 ticks that GetTimer(e) uses..

worth a try...
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Feb 2017 14:42
here you go and add

to the exit(e) part of any ai script you are using like
Quote: "function ai_soldier_exit(e)
if ai_soldier_state[e] ~= "deathanim" then
PlayCharacterSound(e,"onDeath")
end
StartTimer(score_counter)
killed_count = killed_count + 1
end"

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
bonesy23438
8
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 2nd Feb 2017 20:00
hi there thanks once again Smallg it works a treat my lua skills are vry basic and my maths skills as well lol
thanks Bonesy
PM

Login to post a reply

Server time is: 2024-04-27 02:52:36
Your offset time is: 2024-04-27 02:52:36