Scripts / How to Kill a character entities by pressing a key

Author
Message
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Apr 2021 10:14

Hello,

I'm trying to make a script that provoke the death of a character by pressing a key on the keyboard.

Ideally, the script would be like that:



etc...
But I have difficulties.

1- I don't know how to get the ID of the character by his name.

I've found this script on the board:


but I don't know where to insert it...

-2- I need to intercept keyboard key pressing

But even this simple script, attached to an active object, doesn't work:




Anyone can help on -1 or -2 or both?
Cry \"Havoc!\" and let slip the dogs of war
PM
3com
7
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 30th Apr 2021 11:44 Edited at: 30th Apr 2021 11:47
@ LeGugusse
Ignore what exactly do you want to do, anyway, I'm going to dare to guess about. I'm just focusing on you want to kill someone by their name, via pressing the E key.

In fact, you do not need the entity id, just kill the entity by his name. I've added the entity id (myID = {}) just if you want to dive on to get the entity id.

Please, try this script as is before doing nothing, when you are sure about it working, then make a copy and work your changes over the copy.



Working on GG



hth


edit: sorry, fixing video link.
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
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Apr 2021 19:16
3com, that's great!
It would be exactly what I need except the original ennemy character is not active anymore, because the Ai_soldier.lua script has been replaced by the Killing_by_Name script.
Do you think there is a possibility of making a script, attached to an active object, that provoke the death of several characters when a specific Key is pressed?
Or may I integrate your script into the AI_Soldier.lua script that my character used.

This way, my Character would act according to the AI_Soldier script and die when I press the E key.

Explanations:
I'am working on a kind of "home shooting simulator" ( an humble version of VirTra 300 or more precisely Virtra 100 because I've only 1 screen) and I need to create and record scenarios where I control:
- The camera movement
- The death of ennemies

I've made some basic Shoot / NoShoot targets scenario with AGK, but now I want to design some more elaborate scenarios using GameGuru.

I use the gg "hideHuds.lua" script to hide the Hud and I've modified an existing weapon to have no weapon, no player's hands appearing on the screen.

Then, I record and I've some rushed to elaborate my Shooting Simulator Scenario.

I'll try to modify your script to obtain the good result.
Thank you very much for the help!



Cry \"Havoc!\" and let slip the dogs of war
PM
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Apr 2021 20:04
I found a solution.
Not very elegant, but it works.

I create several AI_SOLDIER.LUA scripts. One script for each ennemy.
Ai_Soldier1.lua attached to Ennemy1
Ai_Solder2.lua attached to Ennemy2
etc...

The init function of each script has such a modification:




Your modified script killing_By_name.lua is attached to an active object:



Then:
- The 2 ennemies are attacking the player
- I can record the scene in video and kill the ennemies when I want, by pressing E or F.

If someone has a more elegant idea, I will take it.

3com, thank you again so much for the help !!


Cry \"Havoc!\" and let slip the dogs of war
PM
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Apr 2021 20:53 Edited at: 30th Apr 2021 20:53
In fact, this works great!

My KillByName script has become:



So I can manage 6 ennemies by scene. That's enough for my simulator scenarios.
Cry \"Havoc!\" and let slip the dogs of war
PM
3com
7
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 30th Apr 2021 21:37
Quote: "So I can manage 6 ennemies by scene. That's enough for my simulator scenarios."
[quote=]
If so, then all is ok.
Anyway, you can compact that script a bit, if you want to.
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
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Apr 2021 21:53
You mean by using a kind of "switch"?

http://lua-users.org/wiki/SwitchStatement
Cry \"Havoc!\" and let slip the dogs of war
PM
3com
7
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 1st May 2021 18:45
@ LeGugusse

Since you figure out some simple scenario you want to achieve, then, I 'm keeping the script as simple as possible.

Copy the above script within your scriptbank folder. BACKUP ALL YOUR FILES.

How to
1- attach the below script to each soldier you want to kill via keyboard.
2- You should to know your soldiers ids, if does not, jut select one and get the id at the bottom of the screen, in my case, I've attached the script to the soldier in the middle and his id is 3 (please, refer to the pic below), so, when I want to kill him I press the key 4 (your entity id+1).





hth


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
LeGugusse
14
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 1st May 2021 21:25

Nice idea! I'll try this.
Thank you !
Cry \"Havoc!\" and let slip the dogs of war
PM

Login to post a reply

Server time is: 2022-01-25 05:08:42
Your offset time is: 2022-01-25 05:08:42