ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
CoP-Cs features in SoC

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  23:24:26  20 January 2013
profilee-mailreply Message URLTo the Top
Muad'Dib
Senior Resident
 

 
On forum: 01/24/2011
 

Message edited by:
Muad'Dib
01/20/2013 23:27:00
Messages: 421
CoP-Cs features in SoC

Hey Stalkers,

I would like to transfer some features from CoP and CS to SoC.

The first one is the medic npc dialogs. I taked dialog and script from CoP.

When the actor.health is <1, the dialog is running perfectly, the health is restoring.
But if i speak with health =1, i obtain this CTD:

[error]Expression : fatal error
[error]Function : CScriptEngine::lua_error
[error]File : E:\stalker\sources\trunk\xr_3da\xrGame\script_engine.cpp
[error]Line : 73
[error]Description : <no expression>
[error]Arguments : LUA error: ...shadow of chernobyl3\gamedata\scripts\dialogs.script:279: attempt to compare number with nil


The script is:
function medic_magic_potion(first_speaker, second_speaker)
db.actor.health = 1
db.actor.power = 1
db.actor.radiation = -1
db.actor.bleeding = 1
end

function actor_needs_bless(first_speaker, second_speaker)
if db.actor.health < 1 or
db.actor.radiation > 0 or
db.actor.bleeding > 0 (this is the line 279)
then
return true
else
return false
end
end

function actor_is_damn_healthy(first_speaker, second_speaker)
return not actor_needs_bless(first_speaker, second_speaker)
end


I know actor.health, actor.radiation and actor.power in SoC, but i don't know if actor.bleeding is the good writing.

Maybe someone know more thing about it.
  23:33:44  20 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
In Lua_help i see th function "get_bleeding()" for a game_object, so this may work, bt I`m just guessing. Also how to set it I dont know, maybe needs packets seeing as it is not a property.
  23:43:58  20 January 2013
profilee-mailreply Message URLTo the Top
xRatx
Senior Resident
 

 
On forum: 06/18/2008
 

Message edited by:
xRatx
01/20/2013 23:55:31
Messages: 1592
I've "ported" that CoP Feature a while ago.
Take a look at it

Script Part

-- CSFM Medic Script File
-- Ported from S.T.A.L.K.E.R. Call of Pripyat
-- Ported by xRatx with the help of Lijenstina
-- Date of creation : 27/06/2012 (Day/Month/Year)

-- Removes Radiation and Bleeding and restores Health.
function medic_healing(first_speaker, second_speaker)
	db.actor.health = 1
	db.actor.radiation = -1
	db.actor:eat(db.actor:object("bandage"))
end

function bandage_medic_spawn(first_speaker, second_speaker)
	alife():create("bandage", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), db.actor:id())
end

-- Checks if player need to be healed
function actor_needs_healing(first_speaker, second_speaker)
	if db.actor.health < 1 or
			db.actor.radiation > 0 or
			db.actor:get_bleeding() > 0 then
		return true
	end

	return false
end

-- Player don't need to be healed!
function actor_dont_need_healing(first_speaker, second_speaker)
	return not actor_needs_healing(first_speaker, second_speaker)
end

-- Payment to Medic NPC Function
function payment_for_medic_healing(actor, npc)
	dialogs.relocate_money(actor, 1000, "out")	
end



Dialog Part :


<dialog id="csfm_medic_dialog">
	<phrase_list>
		<phrase id="0">
			<text>Doctor, I need medical assistance.</text>
			<next>1</next>
		</phrase>
		<phrase id="1">
			<text>Let's have a look ... </text>
			<next>2</next>
		</phrase>
		<phrase id="2">
			<text>*The doctor is taking a look at me*</text>
			<next>21</next>
			<next>22</next>
		</phrase>
		<phrase id="21">
			<text>I'll do something for you now.</text>
                	<precondition>csfm_medic.actor_needs_healing</precondition>
			<action>csfm_medic.bandage_medic_spawn</action>
			<next>211</next>
		</phrase>
		<phrase id="22">
			<text>You don't need any medical assistance stalker!</text>
                	<precondition>csfm_medic.actor_dont_need_healing</precondition>
		</phrase>
		<phrase id="211">
			<text>That's better doc. Thank you!</text>
			<action>csfm_medic.medic_healing</action>
                	<action>dialogs.break_dialog</action>
		</phrase>
	</phrase_list>
</dialog>

  23:49:36  20 January 2013
profilee-mailreply Message URLTo the Top
Muad'Dib
Senior Resident
 

 
On forum: 01/24/2011
 

Message edited by:
Muad'Dib
01/20/2013 23:50:43
Messages: 421
I saw it in lua_help, but it is not the same writing as function health or function radioation.

I deleted "db.actor.bleeding > 0 " in the script and it correct the CTD.

In CoP lua_help, it is:
property bleeding;
property health;
property morale;
property power;
property psy_health;
property radiation;

But the property bleeding; doesn't exist in SoC lua_script.

I hope that health restoring stop bleeding in SoC.

EDIT: THANKS YOU XRATX
  22:33:08  17 January 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
01/18/2014 1:41:21
Messages: 319
Hi guys.

I got a problem with this:


db.actor:eat(db.actor:object("bandage"))




No matter where I call it from, it doesn't seem to work for me.
I tried "medkit" too but no joy

Any ideas?
  22:48:20  17 January 2014
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
01/17/2014 22:48:58
Messages: 6349
use
<pre></pre> (but with [] not <>)

to show script properly

Also you must first check if actor actually has one before he eats it.
  01:42:26  18 January 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
 

Message edited by:
SacriPan
01/18/2014 1:49:04
Messages: 319
I did spawn a bandage (or a medkit) before doing this but it doesn't do anything.

The object spawns in the actor's inventory, and if I manually use it, it has the intended effect (bandage...), but the function eat(object) doesn't make the actor use the damn bandage.

Am I suppose to rely on a divine intervention or does this function work for some of you?

  02:04:27  18 January 2014
profilee-mailreply Message URLTo the Top
SacriPan
Senior Resident
 

 
On forum: 09/20/2009
Messages: 319
Ok I got it working.

It's weird though.

I had to spawn the item in the inventory (in my custom script, like before), but then use the eat() function in the bind_stalker.update() function.

How come I can't do this like xRatX in his script? I'm definitely missing something here :\
  14:25:37  18 January 2014
profilee-mailreply Message URLTo the Top
TKGP
Senior Resident
 

 
On forum: 01/25/2013
 

Message edited by:
TKGP
01/18/2014 14:31:30
Messages: 454

---QUOTATION---
I had to spawn the item in the inventory (in my custom script, like before), but then use the eat() function in the bind_stalker.update() function.
---END QUOTATION---


I find this to be the case very often, for instance I wanted to create a weapon and then adjust some of its properties; but if you try to do it immediately the object doesn't seem to exist yet. I suppose it's just some lag time between different levels of the engine.
As a general solution you can record the object when it's created and check for it periodically, like so:


--my_script.script
local tempObject = nil
function makeBandage()
	tempObject = alife():create("bandage", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), db.actor:id())
end
function update()
	if tempObject then
		db.actor:eat( tempObject )
		tempObject = nil
	end
end

--in bind_stalker's update function
my_script.update()


So update is always checking for the item to see if you tried to create it, and if so performs the logic and then wipes the reference so it doesn't repeat.
  18:31:20  18 January 2014
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
Messages: 158
There's an addon for OGSE by Jek@n that has a medic included in the Bar.

These are the functions he uses to determine whether or not the actor needs healing:


function need_healing(first_speaker, second_speaker)
	if db.actor.health < 1 or db.actor.radiation > 0 or	db.actor:get_bleeding() > 0 then
		return true
	end
	return false
end

function lechenie(first_speaker, second_speaker)
	db.actor.health = 1
	db.actor.radiation = -1
	db.actor.bleeding = 1
end



As you can see, it uses "db.actor.bleeding" but OGSE itself uses the spawn bandage/eat bandage method to stop bleeding in its autodoctor features etc, and I'd be more inclined to go for that method rather than the bleeding setting.

It's slightly inelegant, but sometimes you have to be with stalker. I'd imagine it would be better to create a new "bandage" item that has a 0 size icon so it doesn't take up space in the inventory, that is functionally identical to a regular bandage but completely heals, then use that as a workaround. Otherwise you might get into situations where the medic doesn't fully "heal" you if it just uses a regular bandage etc.
 
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-2020 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.