Scripts / is there a script for winning game at an enemies exact health status?

Author
Message
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 23rd Jul 2017 12:00
So, i want the player to win the level by shooting the enemy until the enemies health reaches a certain point and then you win that level.

So the enemies health is 100% and when it reaches 50% you win the game.

Looking for a script that can do this.

THANK YOU
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 23rd Jul 2017 20:05
Attach this script to the winzone.



Script is well commented, if you've some question don't hesitate to ask, anyone here can help'u, even me. LOL



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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 24th Jul 2017 06:24
I really do appreciate the script, 3com.
Now im wondering, how can i have the player beat the level when the only enemy's health gets low?

Im making a level with a bear.
When the player attacks the bear, the health for that bear should go down (Which it does) and when the bear reaches 50 health, the player wins that level.

So the scenario is that the BEAR is a boss.
The boss has lots of health.
When the player damages the bear enough, the level should be won (TO SKIP TO NEXT LEVEL)

I'm basically just asking how can i edit the script or maybe there already is one, when the enemy gets damaged to a certain point, the player won that level.

THANK YOU VERY MUCH FOR THE HELP!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 24th Jul 2017 13:35 Edited at: 24th Jul 2017 13:36
Quote: "So the scenario is that the BEAR is a boss.
The boss has lots of health.
When the player damages the bear enough, the level should be won (TO SKIP TO NEXT LEVEL) "

That script already does. You don't see me jumping to the next level, because I haven't next level, just one level , for try the script (JumpToLevelIfUsed(e))

Script



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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 24th Jul 2017 16:27
What do you mean by the number of the entity?
How many entities there are?
I only have 1 entity in the map so do i put 1?

I did that and it didnt work.

I just edited the stuff you told me to edit and it doesnt work.

Maybe theres something im not understanding here.

Thank you for helping me out through this, i do have some more questions after i get this figured out btw
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 24th Jul 2017 17:51
Each entity has it's own number so that gameguru can identify it, you have to change it to the number of your entity. The first item you place is 1, then 2, then 3, and so on, so the 26th entity you place is number 26. To find out the number of an entity hover the cursor over it in entity mode, if you look at the bottom bar of gameguru, towards the left it should give you the id number of the entity you are targeting.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 24th Jul 2017 19:16
I tried using both scripts and one of them gives me an error.

I did everything instructed..
I know i shouldn't really be involved in scripting since i don't know how to script myself.
I have successfully edited a script before. but that was awhile ago.


Can anyone give me great detail on what to do.
Or maybe theres something im forgetting?
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 24th Jul 2017 19:32
You've a bear, so you should have a script to handle bear behaviour, if so then add this piece of code to the bear script a the very start of the _main(e) statement:



Go to the bear properties panel, and type your next level name in the ifUsed field.

About the other way I've pointed above, taking into account than if you place player marker and then your bear, then your bear is most likely number 2, since the player is number 1, because you've placed player firts.

Do not stress, stay calm and everything will look different.

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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 24th Jul 2017 21:48 Edited at: 24th Jul 2017 21:50
So i did what 3com said with the bear script and put that line at the start of _main(e)
It gave me an error so i put it at the end "i put it under _main(e)"
And it didn't give me an error but it didnt work either.

Now with the (JumpToLevelIfUsed(e)) script, it gave me an error as well.
i did what it told me to do in the script as well and its giving me this error
BTW i really do appreciate you helping me out with this.
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 25th Jul 2017 13:14 Edited at: 25th Jul 2017 13:15
Quote: "So i did what 3com said with the bear script and put that line at the start of _main(e)
It gave me an error"


Can't you post the error?
Not the script, since it is a store item thought.

Quote: "Now with the (JumpToLevelIfUsed(e)) script, it gave me an error as well."

Can you post "jumpToLevelIfUsed(e)) script" ?

Firts, ignore why you named script that way, since "JumpToLevelIfUsed(e)" is a LUA command, and most important LUA is case sensitive, you can't name a script like "JumpToLevelIfUsed(e).LUA", since you are using capital letters in _init(e ) and _main(e) statement, so you most likely get a LUA error.

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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Mrimtheleader1
7
Years of Service
User Offline
Joined: 9th May 2016
Location:
Posted: 25th Jul 2017 18:58 Edited at: 25th Jul 2017 18:58
The the error for the bear says "scriptbank/dagored/bear.lua:56: attempt to index field '?' (a nil value)"

Here is the script for "JumpToLevelIfUsed(e).LUA" BTW after i removed the LUA from the title, it didnt give me an error.


-- LUA Script - precede every function and global member with lowercase name of script

function winzone_health_init(e)
end

function winzone_health_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 2000 then
if g_Entity[1]['health'] <= 50 then JumpToLevelIfUsed(e) end -- change "i" by your entity number (the bear) - if the bear is number 5 it should look: if g_Entity[5]['health']<= 50
end
end --PlayerDist
end --main


BTW i replaced the i with 1, which is the number for the entity
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 25th Jul 2017 19:25 Edited at: 25th Jul 2017 19:31
Quote: "Here is the script for "JumpToLevelIfUsed(e).LUA" BTW after i removed the LUA from the title, it didnt give me an error."

There is something I don't understand; why you rename script as "JumpToLevelIfUsed(e).LUA"?

Script should name as _init/_main statement, ie: if your script say..



Your script should name: "winzone_health.lua" (notice there is not capital letters), or you will get a LUA error.

don't change nothing in the script I gave you, open a new empty map, add a soldier firts, after add the player, so the soldier will be number 1, add some barrel and attach the script to it, and try it.



If you decide to try with your bear level remember you must type the next level name to the bear properties, into the ifUsed field.

You must have a least 2 levels, guessing they naming level1 and level2; in the level1 you has to type "level2", in the ifUsed field of the bear properties.

And where script say:



it shoul look like this:



since"e" is the bear and their script is attached to him.

Hard to help with unknown script like your, and I can't see it since it is a store item, and I don't own the dagored bear, perhaps if you pm him, would be better.

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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Jul 2017 15:05
I recommend reading the guide in my signature for a quick introduction to scripting in GG, definitely worth taking 5mins to learn the basics
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-04-25 12:07:39
Your offset time is: 2024-04-25 12:07:39