Scripts / Win the game when a particular group of enemies are all killed?

Author
Message
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Feb 2017 10:37
Thanks for explaining the pairs and ipairs stuff, I had no idea how that worked either, basically taught myself with GG and AGK so have a hard time understanding advanced code like your own, it always looks like a form of short hand writing to me
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 10:57
Not sure why this is occuring, but when I use the script for killing the enemies to win, it blurs the enemy count at the top of the screen. Now I'm sure you know what it should look like (readable at the very least), so I'll attach a screenshot of this. Also, in the same level, my toggleHUD script if you remember from yesterday only works in certain areas of the map, with no association to trigger zones. I'm so confused!
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080

Attachments

Login to view attachments
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Feb 2017 11:27
The text call doesn't belong inside a loop like that or it'll be called multiple times per sync (sync = each game loop, a script is generally called once per sync/game loop)

text is automatically removed each sync so you call it every script sync to keep it on screen though.

The blur is because you actually have a whole bunch of the same text on top of each other.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 11:31 Edited at: 18th Feb 2017 11:32
So how would I go about changing that in my code? Because it seems to work just fine in all other levels. Thanks for the reply.
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Feb 2017 11:40 Edited at: 18th Feb 2017 11:42


for scripts to work all over the map they must be on an object that is set always active = yes (scripts get disabled based on player range otherwise to improve performance)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 11:44 Edited at: 18th Feb 2017 11:45
Try this:



Lol, we're both a bit keen this morning.
Been there, done that, got all the T-Shirts!
PM
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 11:48
Thank you! Do you know how I would fit the panel to the enemy count? I commented it out last night as I spent about an hour playing with the numbers but with no hope, I could not get it to fit!
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 11:56 Edited at: 18th Feb 2017 11:59
Pretty much just trial and error, as your text is centred on 50 x and 10 y the panel numbers should be around there somewhere, try starting off with 35,5,65,15 and see how that looks then just tweak it to fit.
Been there, done that, got all the T-Shirts!
PM
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 11:57
Will do. What two numbers will i change to center it though? Thansk for the start.
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 12:07
The numbers refer to the corners of the panel so the first two are top left corner and second pair are bottom right. Remember that top left of screen is 0,0 and bottom right of screen is 100,100.

Been there, done that, got all the T-Shirts!
PM
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 12:12
I can't seem to get my head round this. I thought by changing the numbers I am moving the panel, but sometimes it moves and sometimes it changes shapes. Such an odd thing to have percentages rather than simple x and y coordinates apart from the obvious problem being differing screen sizes.
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 18th Feb 2017 12:15 Edited at: 18th Feb 2017 12:21
That panel works really nicely, but I need to make it a bit thinner and shorter, I cannot work out how to scale this properly, its driving me crazy! I checked the forums, and its not just me, so that makes me feel a little less dumb

EDIT:

I worked out that the 1st and 3rd must make 100, so I think both of my panels work now! I used Panel(45,5,55,15) for the enemy count (a bit tall but i dont want to ruin it) and Panel(35,5,65,15) for the end game message.
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 14:23
If it is a bit tall you can lower the top by changing the '5' to '6' or raise the bottom by changing the '15' to '14', does that help you understand how it works?

I'm not sure how the panel is generated but it would be nice to have some different options, i.e. control the thickness of the edge, colour of it etc. But it does give a more professional look to text boxes and sprites.

Ignore the 'Font' commands btw, they don't work at the moment, not sure when they will be fixed.
Been there, done that, got all the T-Shirts!
PM
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 18th Feb 2017 16:33 Edited at: 18th Feb 2017 16:36
After you learn lua, here is another solution:
win.lua:


and then make a copy from ai_soldier.lua in another folder and change following lines:
1.

to

2.

to

3.

to

and at least name you enemies in the property field name(for standard character there stand "Combat Soldier")
to "KillToFinish". If you want to name them different, go to 1. and change the name here


what I did:
1. The script count the Counter up if the AI dies
2. Add a new local array to the context(
3. We get the name of the entity with _init_name(e,name) and save it in an array at the position e (e is the entity number)

If you want more than 3 enemies should die to finish the game change the line with the 3 in win.lua:


Edit:
Seems like I am too late
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 19:02
Making changes to any of the standard scripts is not a good idea unless you turn off auto-updates as Lee has a habit of updating them himself and you suddenly find his has overwritten your changes. Making a copy of them and changing that is one way around it but then you have to either go and change all the fpe files or remember to change the script every time you use an entity.

This is one reason why I haven't put my ai scripts up on the forums yet, the other being I am waiting to see what Lee changes, pointless putting mine up and then finding he has change everything under the hood and they no longer work properly!
Been there, done that, got all the T-Shirts!
PM
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 18th Feb 2017 21:45
Quote: "Making a copy of them and changing that is one way around it but then you have to either go and change all the fpe files or remember to change the script every time you use an entity."

Place the entity in the editor, change all Properties to your needs, then extract it and place it with shift+left mouse-click. But your way is easier and I just want to show him an alternative. Also I would not use a for-loop every frame and call globals over and over again. I learned from you that this is very bad for performance, isnĀ“t it?

Quote: "This is one reason why I haven't put my ai scripts up on the forums yet"

If you did some great work with the AI you could wrote Lee a mail and talk what you need, to make them even better and maybe you could release them with the new update, if you want to.
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Feb 2017 22:54
No I wouldn't do it every frame, I'd use my scheduler to only run it every 10th of a second or so, depends on what the code is doing. But when learning you have to start somewhere and it's best to keep it simple.

Judging by the game level ZephaHD has shown us I expect our young pedawan will be a quick learner.

Oh, and I am constantly emailing Lee (and vice-versa) and have already offered him my services but it is his engine so I expect he wants to do things his way for now. I'll probably get back to the AI improvements after I've finished Pirate Mykes chuff-chuffs unless something else takes my fancy.
Been there, done that, got all the T-Shirts!
PM
ZephaHD
8
Years of Service
User Offline
Joined: 19th Mar 2016
Playing:
Posted: 19th Feb 2017 14:53
Thanks for the alternative answers guys! It has been interesting seeing this problem solved with many, many different solutions. Just goes to show theres always a way to solve something in GameGuru Hahaha I'd like to think I am a quick learner! My LUA coding is definitely not usable yet with more complex scripts (actually extremely simple scripts but in my skill set its high level to me xD) but eventually I'm sure I'll get there! I still have many more questions to ask though so look out for another 1000 more posts from me
GTX 970 Strix, Intel I7 870 (4 cores) -2.9GHz, 16GB RAM, 1920x1080

Login to post a reply

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