FAQFAQ    Board RulesBoard Rules    SearchSearch    LotteryLottery    RouletteRoulette    UsergroupsUsergroups
     RegisterRegister  ProfileProfile    Log in to check your private messagesLog in to check your private messages    Shop    Log inLog in 
View posts since last visitView your postsView unanswered posts

Weapons drawn - how to change enemy AI behaviour?

 
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding
View previous topic :: View next topic  
Author Message
pjakub88

Junior Member
Junior Member


Joined: 05 May 2020
Posts: 43
Location: Poland
131 Bank Notes
Items

PostPosted: Mon Jun 29, 2020 5:09 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message Send e-mail
zdenda55

Junior Member
Junior Member


Joined: 30 Sep 2017
Posts: 42
Location: Czech Republic
51 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 12:29 pm    Post subject: Re: Weapons drawn - how to change enemy AI behaviour? Reply with quote

Maybe human_anyweaponinhand ?
Back to top
View user's profile Send private message
pjakub88

Junior Member
Junior Member


Joined: 05 May 2020
Posts: 43
Location: Poland
131 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 12:35 pm    Post subject: Re: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message Send e-mail
Frog_808

New Member
New Member


Joined: 13 May 2020
Posts: 13

35 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 3:23 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message
Frog_808

New Member
New Member


Joined: 13 May 2020
Posts: 13

35 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 4:24 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message
pjakub88

Junior Member
Junior Member


Joined: 05 May 2020
Posts: 43
Location: Poland
131 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 4:34 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message Send e-mail
Frog_808

New Member
New Member


Joined: 13 May 2020
Posts: 13

35 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 5:51 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message
pjakub88

Junior Member
Junior Member


Joined: 05 May 2020
Posts: 43
Location: Poland
131 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 6:10 pm    Post subject: Re: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message Send e-mail
Frog_808

New Member
New Member


Joined: 13 May 2020
Posts: 13

35 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 7:01 pm    Post subject: Weapons drawn - how to change enemy AI behaviour? Reply with quote

Very good!


Maybe you should replace "enemy_action_fire" with "enemy_setstate 9"?
Back to top
View user's profile Send private message
pjakub88

Junior Member
Junior Member


Joined: 05 May 2020
Posts: 43
Location: Poland
131 Bank Notes
Items

PostPosted: Wed Jul 01, 2020 7:50 pm    Post subject: Re: Weapons drawn - how to change enemy AI behaviour? Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Ask a Modder - Modding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Generation Time: 0.024 | Queries: 18