Scripts / How do I get an item to show up after defeating the character?

Author
Message
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 15th Jul 2022 00:44
I made a gun into a key and link it to the wall, everything works fine on that end. However, when I attach it to the character and defeat her, I want the gun (key) to appear, is this possible? or not yet?

Attachments

Login to view attachments
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 15th Jul 2022 19:07 Edited at: 15th Jul 2022 19:07
Hi
I did some changes in character_attack.lua file to get something like you are looking for; so, you can:
1- Replace the attached script - most likely GGMax is going to rewrite it when updating.
2- Rename the attached script. (the script name should match the functions name)

Note: The attached script spawns items closets to the char position.
Follow the video steps.

https://youtu.be/ahUkh7O6qwg
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

Attachments

Login to view attachments
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 16th Jul 2022 01:21
Will this work with melee attack ? Which is what the behavior that character is using and thank you so much @3com
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Jul 2022 10:23 Edited at: 16th Jul 2022 10:24
@ Shadow_Master
Quote: "Will this work with melee attack ?"

It should do it, since the script controls the char death, and does it no matter how.
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
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 16th Jul 2022 15:43
Thank you so much, @3com
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 16th Jul 2022 15:51 Edited at: 16th Jul 2022 16:09
@3com — Quick question what line is the code on so I can copy and add it to the melee attack? Thank you so much again for all your help

So if I change the script name to melee attack, it should work as long as I change the function name?

Or did I misunderstood your instructions?

I am reading this guide for Lua scripting, https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
Will this guide still work for Max?
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Jul 2022 18:18 Edited at: 16th Jul 2022 18:18
@ Shadow_Master
Try this one below (untested yet)

Quote: "So if I change the script name to melee attack, it should work as long as I change the function name?
Or did I misunderstood your instructions?"


GG/GGMax scripts used to have 2 functions: init and main
body of the script:

Quote: "function mytable_init(e)
end

function mytable_main(e)
end"


Notice both functions are named "mytable" so the script should be called the same "mytable.lua"
So, if you want to change the script name so, you'll have to change the names of the functions, to match the script name.

Note: changing the script name, does not change the script behavior.
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

Attachments

Login to view attachments
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 17th Jul 2022 18:48
Works perfectly, thank you so much for your hard work @3com
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Jul 2022 20:10
@ Shadow_Master
You are welcome
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
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 18th Aug 2022 01:55 Edited at: 18th Aug 2022 01:56
@3com — with the new behavior from lee updates, your code does not work anymore. Also I really need something that I can use on all AI without going into the code. I am thinking of trying smallg’s lock script, that might work for my needs.

As soon as my back allows me to sit longer, I will start learning lua script and play around with scripting lol maybe by then vr will be done and they will finally get to RPG lol
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Aug 2022 10:48
assuming the gun already works as your key
what you want is the gun to drop like loot so try my loot script, if you assign the gun as the only loot for the character it should drop fine

an alternative is to use my quest system and assign the gun as the reward for completing the quest (the quest being to kill the character)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 18th Aug 2022 22:14 Edited at: 18th Aug 2022 22:16
@smallg — I made one of the hand gun bigger and assigned the key behavior to it. Now just need my fighter to drop it when the player defeat her in a fist fight (which is not easy, I play the test level today and was left with 80 health. Funny thing is the player has 2500 health and she has 500 health lol and still kicks the player butt lol)

Is there a way to have more than one behavior on an asset? Or a way for me to use your loot script without removing the key behavior script? Still learning about lua, as I deal with extreme back pain. So, I hope that my questions are not to dumb or to crazy
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Aug 2022 09:21
Quote: "Is there a way to have more than one behavior on an asset? Or a way for me to use your loot script without removing the key behavior script? Still learning about lua, as I deal with extreme back pain. So, I hope that my questions are not to dumb or to crazy "

it already works with any behaviour you want on the loot - the loot system has it's own logic that is controlled by other objects which link to the loot (such as the gun)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 19th Aug 2022 18:17
@smallg -- where can I find your loot script? Thank you so much
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Aug 2022 10:25
loot script
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-05-06 11:23:52
Your offset time is: 2024-05-06 11:23:52