View previous topic :: View next topic |
Author |
Message |
pjakub88
Junior Member


Joined: 05 May 2020 Posts: 43 Location: Poland 131 Bank Notes
Items
|
|
Hello everyone,
is there possible to make the enemies hostile towards the player when he has baseball bat in his hands? Maybe it could be done via scripting? I have some experience with using DCED2 and BSV6 editors. |
|
Back to top |
|
 |
zdenda55
Junior Member


Joined: 30 Sep 2017 Posts: 46 Location: Czech Republic 59 Bank Notes
Items
|
|
Maybe human_anyweaponinhand ? |
|
Back to top |
|
 |
pjakub88
Junior Member


Joined: 05 May 2020 Posts: 43 Location: Poland 131 Bank Notes
Items
|
|
zdenda55 wrote: | Maybe human_anyweaponinhand ? |
No. I already tried that command. It makes enemy hostile towards the player even if he has no firearm / melee weapon in hands. The problem is, that "Empty hands" are on the weapons list too with ID 0, so this is technically a weapon... |
|
Back to top |
|
 |
Frog_808
New Member


Joined: 13 May 2020 Posts: 16
44 Bank Notes
Items
|
|
I don't know who you mean as an enemy, but I think you have to list every enemy whose status you want to set in your script.
I experimented a little and came up with the following:
__________________________________________
dim_act 3
dim_flt 3
findactor 0, "Tommy"
label a
human_getiteminrhand 0,0
if flt[0] = 4,c,b
label b
weather_setparam ON,0
goto a
label c
weather_setparam ON,1
goto a
______________________________________________
Now it starts to rain when he has a baseball bat in his hand, and it
stops, when he put it away.
Of course, you can replace the weather_setparam with something else, for example with act_setstate. But I haven't tried it yet. |
|
Back to top |
|
 |
Frog_808
New Member


Joined: 13 May 2020 Posts: 16
44 Bank Notes
Items
|
|
Neutral script (not related to any object):
(Don't forget an object with the same name for this object definition script.)
_______________________________________________________
SCRIPTNAME
-------------------------
dim_act 3
dim_flt 3
findactor 0, "Tommy"
findactor 1, "ENEMY 1"
findactor 2, "ENEMY 2"
findactor 3, "....."
label a
human_getiteminrhand 0,0
if flt[0] = 4,c,b
label b
act_setstate 1, inactive
act_setstate 2, inactive
act_setstate 3, inactive
goto a
label c
act_setstate 1, active
act_setstate 2, active
act_setstate 3, active
goto a
__________________________________________________________
Add something like that to an enemy's script:
________________________________
ENEMY 1
--------------------
dim_act 2
findactor 0, "ENEMY 1"
findactor 1, "Tommy"
OTHER STUFF TO SCRIPT THE ENEMY....
act_setstate 0, inactive
enemy_action_fire 1, 100
enemy_setstate 9
OTHER STUFF TO SCRIPT THE ENEMY....
_____________________________________________________
It's not perfect, but something like that should work. |
|
Back to top |
|
 |
pjakub88
Junior Member


Joined: 05 May 2020 Posts: 43 Location: Poland 131 Bank Notes
Items
|
|
Thanks for all those script examples. I will look into them.
By "enemy" i mean the guards at the harbor in the Mission 18 "Just For Relaxation". By default they won't react when the player has baseball bat in his hands.
EDIT: I tried your script that triggers rain when player uses baseball bat. It didn't work for me - maybe i did something wrong? You made a brand new script or you just added those lines to an existing mission script? It would be easier if we could simply make all the melee weapons treated as firearms by AI, but it might be hardcoded. |
|
Back to top |
|
 |
Frog_808
New Member


Joined: 13 May 2020 Posts: 16
44 Bank Notes
Items
|
|
I have created a brand new script. It is important, however, that an object can be assigned to the script (with the same name). You must therefore open a mission in DC ED, click on "add a new Object" and then select Object \ Standard Object and name it (eg "Test Script").
Then you have your object. (which does not have to be created in the MWE).
Now create a new script as usual under "Object Definitions" with the same name as your object (test script). Check the connection with a right click on your script "switch to Object Definition" and back with "Switch to Object".
This script does not directly refer to an object. It is controlled by one actor and controls another itself. |
|
Back to top |
|
 |
pjakub88
Junior Member


Joined: 05 May 2020 Posts: 43 Location: Poland 131 Bank Notes
Items
|
|
Frog_808 wrote: | I have created a brand new script. It is important, however, that an object can be assigned to the script (with the same name). You must therefore open a mission in DC ED, click on "add a new Object" and then select Object \ Standard Object and name it (eg "Test Script").
Then you have your object. (which does not have to be created in the MWE).
Now create a new script as usual under "Object Definitions" with the same name as your object (test script). Check the connection with a right click on your script "switch to Object Definition" and back with "Switch to Object".
This script does not directly refer to an object. It is controlled by one actor and controls another itself. |
It finally works thanks! When i use baseball bat it starts the rain, but when i holster it the rain stops falling from the sky.
I also added the following script instead directly to one of the existing enemies scripts:
dim_act 2
dim_flt 1
findactor 0, "Tommy"
findactor 1, "Enemy"
label CHECK
human_getiteminrhand 0,0
if flt[0]=4,-1,CHECK
label AGGRO
enemy_action_fire 0
label LOOP
wait 1000
goto LOOP
end
It makes a particular enemy hostile towards the player as soon as he equips baseball bat. The only problem with that script is, that the enemy becomes hostile even when he didn't see the player (i.e. while being behind the enemy's back). |
|
Back to top |
|
 |
Frog_808
New Member


Joined: 13 May 2020 Posts: 16
44 Bank Notes
Items
|
|
Very good!
Maybe you should replace "enemy_action_fire" with "enemy_setstate 9"? |
|
Back to top |
|
 |
pjakub88
Junior Member


Joined: 05 May 2020 Posts: 43 Location: Poland 131 Bank Notes
Items
|
|
Frog_808 wrote: | Very good!
Maybe you should replace "enemy_action_fire" with "enemy_setstate 9"? |
To be honest, i received this script from a guy from the Discord community nicknamed "WRP_Beater".
When i replaced the "enemy_action_fire" with "enemy_setstate 9" nothing happened. The enemy didn't react while i had baseball bat in my hands.
I wonder, if there is a way to make all melee weapons be treated just like firearms by enemy AI (gangsters / police). I mean, putting a gun in player's hand immediately triggers a reaction from AI - while a melee weapon doesn't. |
|
Back to top |
|
 |
|
|