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

1 2 3
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  20:17:19  28 January 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
 

Message edited by:
Belasco1968
01/28/2013 20:19:22
Messages: 13
Modify fighting distance between actor and ennemies

Hello everyone !

Since last year, I’m busy to modify the Complete 2009 mod to integrate the elements from other mods which interest me.

I’m a noob but I always try to understand the code of all these modders. So, I can modify existing code but not create a brand new one.

All is ok for my game: money and corpse looting, flamethrower, minigun, blowout, repair kit with limitation, hud for suits, free choice for the wishes, …

But I have a last problem…

I would like to modify the behavior of the npc’s according to the suit which the actor wears.

There is a special suit in the DMX mod (the meceniy outfit) and I integrated it in my mod.
But … it’s only a visual effect.

My wish is to modify the “distance to fight” for the npc’s when the actor wears this suit.
The player could approach the enemies within a certain distance (eg : 16 meters) without enemies detect him.
I wish only ‘play’ with the ‘see actor’ aspect and not with the ‘noise’ aspect. You can be ‘invisible’ but you make always so much noise.

So, my idea is doing a script file wich contains something like :

function name_function()

local actor = db.actor
local outfit_act = db.actor:item_in_slot(6)
If outfit_act:section()=="meceniy_outfit_new" then
If enemy: position():distance_to_sqr(npc: position()) >= 16
local enemy = db.storage[npc:id()].enemy
return enemy:id() == actor:id()
end
else
If enemy: position():distance_to_sqr(npc: position()) < 16
local enemy = db.storage[npc:id()].enemy
return enemy and enemy:id() ~= actor:id()
end
else

If outfit_act:section()== nil or outfit_act:section()~="meceniy_outfit_new" then
local enemy = db.storage[npc:id()].enemy
return enemy:id() == actor:id()
end

end

Can someone tell me if this function is correct?
Do I also add a call to this function in the “bind_stalker” script ?

Thanks to all for your advice and/or correction !
  20:50:07  28 January 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
 

Message edited by:
ThunderFreak
01/28/2013 20:56:49
Messages: 685
I made something similar.

class "relations"
function relations:__init()
	self.actor_prev_suit = ""
end

function relations:update()
	local suit_name = get_suit_stats("name") or "no_suit"
	if self.actor_prev_suit ~= suit_name then
		db.actor:set_character_community(system_ini():r_string("suit_by_community", suit_name), db.actor:id(), 0)
		self.actor_prev_suit = suit_name
	end
end

function get_suit_stats(indx)
	local suit = db.actor:get_current_outfit()
	if suit ~= nil then 
		if indx == "name" then
			return suit:section()
		elseif indx == "condition" then
			return suit:condition()
		end
	end
end

function change_community()
        return relations:update()
end



Call from outside will be

local suit_comm = {script_name}.change_community()
if suit_comm == nil then printf("Naked actor detected.:-D") end --Just a joke



In the ltx file I have the suits listed.

;; relation settings for suit to community ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[suit_by_community]
novice_outfit			= actor
stalker_outfit			= actor
svoboda_light_outfit	= freedom
dolg_outfit				= dolg
scientific_outfit		= ecolog
cs_heavy_outfit			= freedom
svoboda_heavy_outfit	= freedom
specops_outfit			= military
military_outfit			= military
dolg_heavy_outfit		= dolg
exo_outfit				= stalker
no_suit					= actor

;SoC suits
bandit_outfit			= bandit
protection_outfit		= ecolog
dolg_scientific_outfit	= dolg
monolith_outfit			= monolith
killer_outfit			= killer
ecolog_outfit			= ecolog
military_stalker_outfit	= military
military_commander_outfit = military
soldier_outfit			= miltary

The entries in the LTX are "outfit" = "community".

It's working pretty good in my mod project.
The only hope I have, I didn't miss something as I was extracting this from my mod project.
  18:05:27  30 January 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13
Hello Mister Thunderfreak !

What a pleasure to read you

I used a mix of your hud.ltx en atmen.ltx for my game.
And it's great

I had the same idea than yours about the relation system between the suit player wears and the community 'of this suit'.

But, with this system, the reaction of the npc's isn't the one I want.
In this configuration, the player is neutral (or friend) with the faction.
So, the player can approach the 'enemies' and self talk to them.

In my idea, wearing a specific suit (so, only this suit) the player is not detectable by enemies (or neutral, friends) except on a certain distance (5 of 10 meters). Then, the npc's can interact again with the player (enemies attack, friends can talk, ...).

Can you say me what you think about my code.
I only know that he doesn't work
If I add a call to function 'name_of_my_ltxfile.name_function' in the bind_stalker.ltx under 'actor_binder:update(delta)', the game crash and the log talk about 'a nihil value'.
So, this is not a good way.

Would you be willing to send me by email a sample of your files about your system of relation between communities and suits ?

I'd like to try to make some changes. Maybe I'll get a result that satisfies me...

Thank for all !
I am very impressed by your job
  19:28:55  30 January 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
 

Message edited by:
ThunderFreak
01/30/2013 19:50:04
Messages: 685
In my script for the relations, I make the actor member of this faction where the suit is from. This means that friends to this particular faction will be friends to the actor as well unless the actor is changing his suit then it can be that your "friends" now turn to "enemies" immediately.
This system is good for stealth and sneak tasks.

If you like I make a package with the suit relation scripts for you.

I am sorry to say but the function you put in your first post cannot work at all.

I try to get it running for you.

/EDIT:
Check this out.

function name_function(npc_id)
	local enemy = db.storage[npc_id].enemy
	if IsStalker(enemy) == false or npc_id == nil then return end
	local actor = db.actor
	local outfit_act = actor:get_current_outfit()
	if outfit_act:section() == "meceniy_outfit_new" then
		if distance_between(db.actor,enemy) >= 16 then
			return true					-- returns 'true' when distance is more or equal to 16
		end
	end
	return false						-- returns false when distance below 16
end

To call this function from bind_stalker.script file you have to put this line into the function actor_binder:update(delta) of the bind_stalker file.

name_function(self.object:id())

  20:31:25  30 January 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
 

Message edited by:
Belasco1968
01/30/2013 20:59:46
Messages: 13
Hello Thunderfreak !

Yes, sure !
I'm always interested to acquire new knowledges, so your files are welcome.
I think that the only way to acquire a little bit more experience is to analyze and understand the codes of good developers.
So, thank you in advance for your files.

For my idea of code, don't be sorry
It was just a little bit of this and that to show what I wish to make.
As I said in my post: I'm just a noob and ... a old man (45 years next month. Pfffff... Hey, but playing Stalker made younger!).

For my code, your help is also welcome !

Once I have finished the mod, I'll upload it with all explainations.
I am busy writing a sort of manual in French (currently 10 pages without screenshots) of all changes included in my version (based on Complete 2009 for the game in French).
As the players whose first language is French, can understand and reproduce much of the mechanics of the game and create their own version. Like this, everyone will have his pleasure.

Good evening


I just tested your code.

1 file (meceniy_work.ltx) with

function stealthy_approach(npc_id)

local enemy = db.storage[npc_id].enemy
if IsStalker(enemy) == false or npc_id == nil then return end
local actor = db.actor
local outfit_act = actor:get_current_outfit()
if outfit_act:section() == "meceniy_outfit_new" then
if distance_between(db.actor,enemy) >= 16 then
return true -- returns 'true' when distance is more or equal to 16
end
end
return false -- returns false when distance below 16
end

And, in de bind_stalker:

function actor_binder:update(delta)
object_binder.update(self, delta)

-- DEBUG slowdown
-- slowdown.update()
hud.checkmysuithud()
hud.atmen() You see ! I'm using your work
meceniy_work.stealthy_approach(self.object:id())
blowout.GetBlowout():Update()
local time = time_global()

game_stats.update (delta, self.object)

-- àïäåéò ïîãîäû
self.weather_manager:update()

-- àïäåéò ñõåìû äåòåêòîðà
self.actor_detector:update() ..................

When I load my seved game: crash

Error log:

Expression : fatal error
Function : CScriptEngine::lua_error
File : E:\stalker\sources\trunk\xr_3da\xrGame\script_engine.cpp
Line : 73
Description : <no expression>
Arguments : LUA error: ...ow of chernobyl\gamedata\scripts\bind_stalker.script:239: attempt to index global 'meceniy_work' (a nil value)

If I only write 'stealthy_approach(self.object:id())' in the bind_stalker, I got the same error log but with '....\bind_stalker.script:239: attempt to index global 'stealthy_approach' (a nil value).

Am I wrong ?

Also another question about your code:

Your code check only if ennemies are in certain distance (>= 16 m of < 16m). Ok, I understand.
But, there is no reference to a "see or not see the player" (and so, there will be no reaction from the npc's).
Is it right ?
  22:32:41  30 January 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
You are talking about old men at an age of 45? I am already 55.

Where did you put the function stealthy_approach()? Into the bind_stalker.script or referring to your post in the file meceniy_work.script?

And yes this function is checking only if enemies are in a certain distance like your code tried to do as well.

If this code is part of a bigger script then call for the script isn't in the right place. Then I need your scripts to give you the right position for the call.
  00:19:36  31 January 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
probably the problem is here

---QUOTATION---
1 file (meceniy_work.ltx) with
---END QUOTATION---

  06:51:29  31 January 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13
I simply create a scrip file (.ltx) in the folder 'gamedata->scripts'.
This file is called 'meceniy_work.ltx'.
This file contains the following code:
function stealthy_approach(npc_id)

local enemy = db.storage[npc_id].enemy
if IsStalker(enemy) == false or npc_id == nil then return end
local actor = db.actor
local outfit_act = actor:get_current_outfit()
if outfit_act:section() == "meceniy_outfit_new" then
if distance_between(db.actor,enemy) >= 16 then
return true -- returns 'true' when distance is more or equal to 16
end
end
return false -- returns false when distance below 16
end

I also add a call to this function in the file 'bind_stalker', just under function actor_binder:update(delta)
object_binder.update(self, delta)
like this : 'meceniy_work.stealthy_approach(self.object:id())'

And then, on loading saved game: see my error log.

So, what do I wrong ?
  07:30:56  31 January 2013
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
Messages: 2230
rename it .script.
  07:10:19  1 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13
Hello Alundaio !

Yes, you'r right.

Sorry. I'm totally stupid

The error log don't appear again.


The problem is not solve.

This what I made:

1° Create un file 'meceniy_work.script' with the following code:

function stealthy_approach(npc_id)

local enemy = db.storage[npc_id].enemy

if IsStalker(enemy) == false or npc_id == nil then
return end
-- check for enemies only--

local actor = db.actor
local outfit_act = actor:get_current_outfit()

if outfit_act:section() == "meceniy_outfit_new" then
-- player wears this camouflage suit--
bind_stalker.hide_weapon()
-- player cannot equip weapons because he wears a camouflage suit--
if distance_between(db.actor,enemy) >= 16 then
-- if distance between player and ennemies is >= 16 meters--
xr_conditions.dont_fighting_actor(db.actor, enemy)
-- then player is 'undectable' and enemies don't attack him--
end
else
-- otherwise--
if distance_between(db.actor,enemy) < 16 then
-- player wears the camouflage suit but distance between him and ennemies is < 16 meters--
xr_conditions.fighting_actor(db.actor, enemy)
-- then the player is 'detected' and enemies attack him
end--
else
If outfit:section()== nil or outfit:section() ~="meceniy_outfit_new" then
-- player wears no suit of a different suit than the camouflage suit--
bind_stalker.restore_weapon()
-- player can equip weapons--
xr_conditions.fighting_actor(db.actor, enemy)
-- then enemies attack the player--
end
end

2° I add the line 'meceniy_work.stealthy_approach' in de bind_stalker file, under the function 'actor_binder:update(delta)'.


Result: on the game load, crash.

This time, the error log is: "..... Arguments : LUA error: ...ow of chernobyl\gamedata\scripts\bind_stalker.script:239: attempt to index global 'meceniy_work' (a nil value)"

I suppose that's in relation withe these lines 'xr_conditions.fighting_actor(db.actor, enemy)' but I don't see how to write this part.

Any idea ??
  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
  18:29:03  3 February 2013
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
 

Message edited by:
Alundaio
02/03/2013 18:35:06
Messages: 2230

if (enemy:id() == db.actor:id()) then
	local outfit = db.actor:item_in_slot(6)   
	if (outfit == "meceniy_outfit_new") then
		local dist = obj:position():distance_to_sqr(enemy:position())
		if (dist > 25) then
			return false
		end
	end
end



Just try only this in xr_combat_ignore.script at the top of is_enemy function. If it works just build on it. If you want to keep the actor hiding weapon for example place it in the actor_binder:update function. But evaluation of NPCs enemies should be handled directly in xr_combat_ignore.

Eventually you'll need to add a cooldown timer to it so the actor just doesn't go "invisible" when re-equipping the outfit in combat or going out-of-distance.
  09:28:40  4 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349

---QUOTATION---

if (enemy:id() == db.actor:id()) then
	local outfit = db.actor:item_in_slot(6)   
	if (outfit == "meceniy_outfit_new") then
		local dist = obj:position():distance_to_sqr(enemy:position())
		if (dist > 25) then
			return false
		end
	end
end



Just try only this in xr_combat_ignore.script at the top of is_enemy function. If it works just build on it. If you want to keep the actor hiding weapon for example place it in the actor_binder:update function. But evaluation of NPCs enemies should be handled directly in xr_combat_ignore.

Eventually you'll need to add a cooldown timer to it so the actor just doesn't go "invisible" when re-equipping the outfit in combat or going out-of-distance.
---END QUOTATION---



I agree, the simpler the better. Although, my code will work if implemenyted correctly and may have done you some good to get it working for a learning experience
  17:58:35  7 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13
Hello Alundaio,
Hello Vintar,

I took a few days to test your two different suggestions of code.
Unfortunately, I get no change in the game.
I tried to reduce the distance at which enemies can see me, but without success.
I also tested to remove the lines of code about the distances. So, I haved a single parameter (if I wear the outfit, the enemies do not attack me).
No change in the game: enemies detect and attack me.

It seems like the game take no count of the code.


With the code of VINTAR:

I only made a change (distance_between(db.actor,enemy) >= 16 instead of <=16) because I wish that enemies cannot detect me on a distance more than 16 meters.
So, I also reverse the lines about hide/restore weapon.

Without call to the function in the bind_stalker (actor_binder:update(delta)), the game load but there is no difference in game.

With a call to the function (meceniy_work.stealthy_approach(npc_id)), the game crash on the load of the saved game with this error:
LUA error: ...ow of chernobyl\gamedata\scripts\bind_stalker.script:240: attempt to index global 'meceniy_work' (a nil value).

With the code of ALUNDAIO:

If I put only the code in xr_combat_ignore, there is no change in game. Enemies detect and attack me at the same distance as usual.

If I delete the two lines about the distance (to test only the reaction of enemies when I wear the suit), the game crash and the error log is:
LUA error: ...shadow of chernobyl\gamedata\scripts\xr_logic.script:226: attempt to index global 'xr_combat_ignore' (a nil value).
So, this time the error is in association with the xr_logic script.

If I put the complete code in xr_combat_ignore and a call to this function (xr_combat_ignore.is_enemy( obj, enemy, st )) in the bind_stalker (under function actor_binder:update(delta)),the game also crash on loading a saved game and now the error is:
LUA error: ...f chernobyl\gamedata\scripts\xr_combat_ignore.script:8: attempt to call method 'id' (a nil value).

I'm completely lost ....
None of the codes produce a change in the behavior of enemies in game.
Ok but WHY ?

Your two codes seem to me logical but they don't show a result in game.

Do you have any idea what I'm doing wrong ??

Thank you in advance !
  22:26:52  7 February 2013
profilee-mailreply Message URLTo the Top
Vintar
a bit of this and a lot of that
(Resident)

 

 
On forum: 08/08/2008
Messages: 6349
Just seems you are not familiar with scripting and are implementing it incorrectly. First mistake you made was naming the script with a .ltx extension. I assume this is fixed. The second mistake you are making must be in the script itself IE syntax errors because your script is not parsed and returning nil. Thirdly, I`m not sure why you changed the distance in my example. you clearly stated that if you are wearing the suit and are less than 16m from any npc then they must not attack you. if you want it so that no-one will attack you further than 16m, well i say its impossible and unrealistic.
  15:39:50  12 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
 

Message edited by:
ThunderFreak
02/12/2013 15:41:21
Messages: 685
I think I found a very simple way to get it done.

Take my relation scripts (already send to you) and as long as the actor is wearing a suit of a particular faction, the actor is member of that faction. This should be on large distances only. When the actor is approaching a faction put the actor back in his original faction and then the actor is treated on his original game relation to that faction. Illusion on distance.

Mission accomplished. 8)

For the distance when the actor should be back in his original faction you can set a variable distance to simulate that the faction member detecting you has good eyes or not so good.
  00:23:46  13 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Take my relation scripts (already send to you)
---END QUOTATION---


Hey ThunderFreak, can you send me a copy of those, as well?


Thanks!
  09:24:05  13 February 2013
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
I modified my relation script so the actor when wearing a specific suit is detected as a member of the faction the suit is belonging to on large distance and when close at a distance of 17 the actor is detected by his original faction.

Here is the link to my sky drive: https://skydrive.live.com/#cid=839FA75832089767&id=839FA75832089767!268
  04:51:16  14 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
I modified my relation script so the actor when wearing a specific suit is detected as a member of the faction the suit is belonging to on large distance and when close at a distance of 17 the actor is detected by his original faction.

Here is the link to my sky drive: https://skydrive.live.com/#cid=839FA75832089767&id=839FA75832089767!268
---END QUOTATION---


Thank you, sir!
  20:50:22  14 February 2013
profilee-mailreply Message URLTo the Top
Belasco1968
(Novice)
 
On forum: 01/28/2013
Messages: 13
And so:

1° Creation of a new faction which is neutral with other faction;

2° Attribute the camouflage suit (meceniy_outfit_new from the Stalkersoup Mod) to this new faction;

Everything is working perfectly !

Now, with a selected suit, you can get closer to enemies without being detected by them unless you're too closer of them.
Then you're real community is detected and if you are enemy, npc's try to kill you.

Here's a screenshot of the meceniy suit (camouflage):
[link]http://www.hostingpics.net/viewer.php?id=528980sspascal021413190131l01escape.jpg[/link]

Thanks to all of you for your invaluable help !
 
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-2022 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.