ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Modify fighting distance between actor and ennemies

« Previous 10 events | 1 2 3 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  08:17:32  1 February 2013
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
 

Message edited by:
Alundaio
02/01/2013 8:23:17
Messages: 2230
If it is saying meceniy_work is nil and the script is definitely in the folder then there is an error in the script that prevents it from loading.

I see a few errors. You have an if statement with a capital 'I' and you are missing a few end statements for them. But I'm afraid that script isn't going to do what you want because xr_conditions.dont_fighting_actor doesn't force an NPC to stop fighting the actor. The person who wrote the function should have named it not_fighting_actor. It just checks if the NPC's current enemy is the actor.


You might want to modify xr_combat_ignore.script directly. Simply check if actor is wearing that outfit and return false.


Next time post your code using the 'pre' tags.
  22:22:48  1 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
 

Message edited by:
Vintar
02/01/2013 22:24:53
Messages: 6349
Try this one :
function stealthy_approach(npc_id)

	if not npc_id then return end

	local enemy = db.storage[npc_id].enemy
	if enemy and enemy:id() == db.actor:id() then    -- only check if actor is the enemy
		local outfit_act = db.actor:get_current_outfit()
		if outfit_act:section() == "meceniy_outfit_new" then
			if distance_between(db.actor,enemy) <= 16 then  -- distance less or equal to 16m
				db.storage[npc_id].enemy = nil  -- ignore actor
				if not db.actor:is_weapon_hidden() then
					db.actor:hide_weapon()   -- only hide weapon here, else if actor detected he will be defenceless
				end
			else  -- further than 16m
				if db.actor:is_weapon_hidden() then
					db.actor:restore_weapon()
				end
			end
		else
			if db.actor:is_weapon_hidden() then   -- just incase
				db.actor:restore_weapon()
			end
		end
	end
end

  15:08:05  2 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
 

Message edited by:
Belasco1968
02/02/2013 15:12:03
Messages: 13
Hello Vintar !

Many thanks for your code.
But it gave me no change in game (but no crash on loading game). Actor is always detected and attacked by enemies.
I modify your code (reversing two parts of it) because I wish that the player (wearing the suit) is ignoring by enemies on a distance more or equal to 16 meters.
On a distance less than 16 meters, the player is automaticaly detected and attacked by enemies.
So, your code is now:

function stealthy_approach(npc_id)

	if not npc_id then return end

	local enemy = db.storage[npc_id].enemy
	if enemy and enemy:id() == db.actor:id() then    -- only check if actor is the enemy
		local outfit_act = db.actor:get_current_outfit()
		if outfit_act:section() == "meceniy_outfit_new" then
			if distance_between(db.actor,enemy) >= 16 then  -- distance more or equal to 16m
				db.storage[npc_id].enemy = nil  -- ignore actor
					if db.actor:is_weapon_hidden() then
						db.actor:restore_weapon()
					end
			else  -- less than 16m
				if not db.actor:is_weapon_hidden() then
					db.actor:hide_weapon()   -- only hide weapon here, else if actor detected he will be defenceless
				end
			end
		else
			if db.actor:is_weapon_hidden() then   -- just incase
				db.actor:restore_weapon()
			end
		end
	end
end


And I haven't forgotten to write the line 'meceniy_work.stealthy_approach(npc_id)' in de bind_stalker.script under the function 'actor_binder:update(delta)'.

And ... now I have a crash when I load the saved game (bind_stalker.script:239: attempt to index global 'meceniy_work' (a nil value)).
What am I doing wrong?
And why this 'system of distance' doesn't work?

I'm starting to go crazy !

I continue to test other versions of your code.

Thanks!
  16:32:39  2 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
I would suggest you post the code you did here. Use www.pastebin.com to upload the code and post the link here.

Then Alundaio, Vintar or me can take a look at your code to find out what is wrong.
  17:05:51  2 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
 

Message edited by:
Belasco1968
02/02/2013 18:25:50
Messages: 13
Hello Thunderfreak, Vintar and Alundaio !

Here is the link to the code.

Hoping that one of you can untangle my knots...
I'm hopeless.

[link]http://pastebin.com/PEq3Cakj[/link]

Many thanks !

Post scriptum: How do you do that 'link' does not appear in your post?
  07:40:46  3 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
 

Message edited by:
Belasco1968
02/03/2013 18:23:22
Messages: 13
Hello everyone !

Just for the story:

At first I wanted to use the 'invisibility suit' (meceniy_outfit_new) created by Monnoroch that exists in the mod 'Narodnaya Soljanka DMX'.
For visual aspects, everything is good.

For the functions that manage the phenomenon of invisibility, here's what I found:

1° The 'meceniy_work.script' which contains de main code:http://pastebin.com/CCCyjqk5

2° In the '_g.script', there are lines that replace the original lines under the function 'IsStalker (object, class_id)' and addition of two new functions:
'IAmAStalkerInit()'
'IAmAMonsterInit()'.
See lines 1112 to 1152:http://pastebin.com/16ZXzNFm

3° In the file 'db.script', adding of the lines for the variables. Lines 28 to 34.
http://pastebin.com/TrevEZfP

4° In the file 'bind_stalker.script', adding of the line 'meceniy_work.set_invisible()' under the function 'actor_binder:update(delta)' (line 239). http://pastebin.com/sTFV57Yd

5° In gamedata - config - ui: adding lines 'cs_inviz' to create the window that displays messages.

I prefer to post the entire file on pastebin so you can see the code in its global context.

What results in the game?

When I load my saved game, all is ok. No crash.
When I put the meceniy suit, the white screen effect appears and my weapon is set in his holster. The message about invisibility also appears.
90 seconds before the end of the invisibility, the message is displayed on screen. Same thing when invisibility is ended.

Changing suit causes no crash and the weapon can be taken in hand again.

However, there are some minor problems with the messages:
Sometimes the messages are not relevant to the situation.
When you wear the invisibility suit and you put another outfit or no outfit at all, the messages are correct.
If you change your suit again, the messages no longer fit the new situation. They are identical to the first messages.
It did not matter. I displayed messages only to test the function.
The only important messages are those that warn you that 'you will soon be visible' and 'you are visible'.

So far, all is right.

But, when I approach enemies with this suit, there is no change. Enemies can detect me as fast (and easily) as when I wear another suit (and, of course, attack me).

It seems that the local variable 'range' does not work. I tried to switch to '0' (instead of '2'), but no difference in game.

I looked everywhere on the web but these files are specific to this mod and nobody talk about this function (yeah, I know, one or two posts on russian and polish site, but no further).
I opened and read all the scripts but I haven't found anything else that is related to one aspect of this function.

This is the reason why I decided trying to make a simpler function that made the player 'undetectable' by enemies until he is very close to them (+/- 10 meters).
Then, enemies detect automaticaly the player and attack him.

But I prefer the original version of the mod (the function that restricts invisibility in time is really nice and give a little stress in the game).

Voilà, voilà ... This is the story. A poor story.
  14:46:00  3 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685

---QUOTATION---
Hello Thunderfreak, Vintar and Alundaio !

Here is the link to the code.

Hoping that one of you can untangle my knots...
I'm hopeless.

[link]http://pastebin.com/PEq3Cakj[/link]

Many thanks !

Post scriptum: How do you do that 'link' does not appear in your post?
---END QUOTATION---



Took a quick look on your script. Found two bugs.
Must be
db.actor:restore_weapon()

instead of
db.actor.restore_weapon()


and
db.actor:hide_weapon()

instead of
bind_stalker.hide_weapon()



If I find something moew, I'll post it.
  15:25:21  3 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13

---QUOTATION---
Hello Thunderfreak, Vintar and Alundaio !

Here is the link to the code.

Hoping that one of you can untangle my knots...
I'm hopeless.

[link]http://pastebin.com/PEq3Cakj[/link]

Many thanks !

Post scriptum: How do you do that 'link' does not appear in your post?

Took a quick look on your script. Found two bugs.
Must be
db.actor:restore_weapon()

instead of
db.actor.restore_weapon()


and
db.actor:hide_weapon()

instead of
bind_stalker.hide_weapon()



If I find something moew, I'll post it.
---END QUOTATION---



Hello Thunderfreak !

Try the code with your correction.
Game crash on loading saved game.
The log is : LUA error: ...ow of chernobyl\gamedata\scripts\bind_stalker.script:240: attempt to index global 'meceniy_work' (a nil value)
Decidedly, it really is not as easy as it looks.
The code of Vintar doesn't cause a crash but make no change in game.
But when I reverse it -> CTD

I continue to search in the files script of the DMX mod and hope to find inspiration (or the solution to make this one fully operational).

Thanks and have a good sunday !
  16:59:54  3 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
When I check your script 'meceniy_work' from this post [qoute]1° The 'meceniy_work.script' which contains de main code:http://pastebin.com/CCCyjqk5
---END QUOTATION---
I can't find a function with the name 'stealthy_approach(npc_id)'. Tell us where did you place this function?
  18:20:48  3 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13

---QUOTATION---
When I check your script 'meceniy_work' from this post [qoute]1° The 'meceniy_work.script' which contains de main code:http://pastebin.com/CCCyjqk5 I can't find a function with the name 'stealthy_approach(npc_id)'. Tell us where did you place this function?
---END QUOTATION---


Quite normal.
My post with 4 links shows the files that I extracted from the mod DMX (which came this meceniy outfit).

This is my original test.

I also explain what happens in the game with these files.

I have given them to you so you can see what Monnoroch had originally planned in this mod (which has been very successful even though it is full of bugs).

As many people play with this mod, I guess this 'invisibility outfit' working properly.
But, as I said in my post, only certain aspects of the function 'set_invisible' seem to be functional (the variable 'range' that determines the distance between the player and the enemy does not work but the 'white screen effect', the counter and the display of messages are functional).

So, either I haven't been able to find all script files that play a role for this outfit or that outfit is not functional.

Sorry if this post has caused confusion
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2021 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.