Author Topic: [ How to ] Script - Respawn item, inventory(barter npc)  (Read 7250 times)

[ How to ] Script - Respawn item, inventory(barter npc)
« on: June 16, 2012, 08:45:45 pm »

How do i use this script ?
(from respawn_item.fos)
Do i add it to scripts and function in mapper?
Or do i make a new script file and add that script in mapper ?

void SetItemRespawn (Item & item, uint mode, uint respTime)
{
    item.Val5 = mode;
    item.Val4 = respTime;
    item.SetEvent (ITEM_EVENT_SKILL, "e_ItemOnSkill");
    item.SetScript ("_RespItemInit");
    item.Update ();
}

Dont use respawn_item script for barter npc-
that script is on the bottom
« Last Edit: June 25, 2012, 08:11:03 pm by muhoooool »

JovankaB

  • Guest
Re: Script - Respawn item, inventory, container
« Reply #1 on: June 17, 2012, 08:09:54 am »
There is a function there _RespItemInit that inits item respawning. That's what you are supposed to use in the Crapper, I mean Mapper. To check out an example, open map sf_tanker2 and click the knife on hex 136,94. Check out ScriptName, FuncName and Value4 in the item properties window. Value4 is respawn time.

To do this from a script for existing item object I guess you would have to simply call SetItemRespawn.

For cases other than stuff on ground like respawning in containers you have to set Val5/Value5 of the item. Translate ruski comment on top of the module for details.
« Last Edit: June 17, 2012, 09:10:11 am by JovankaB »

Re: Script - Respawn item, inventory, container
« Reply #2 on: June 17, 2012, 03:40:51 pm »
hello!
Thaks for your solution and tips. ( also thanks for taking the time to transfer my posts here !! )
I tried _RespawnItemInit, it didnt seem to work.
I will test this out and get back on this post!
Thanks again!

Re: Script - Respawn item, inventory, container
« Reply #3 on: June 17, 2012, 06:05:55 pm »
_RespItemInit Works great!!
value is the number of in-game minutes.. for 100 will respawn about 3 seconds..

One more thing,
Where do i set VAL5/VALUE5 ?

-thanks

JovankaB

  • Guest
Re: Script - Respawn item, inventory, container
« Reply #4 on: June 17, 2012, 06:57:38 pm »
_RespItemInit Works great!!
value is the number of in-game minutes.. for 100 will respawn about 3 seconds..

One more thing,
Where do i set VAL5/VALUE5 ?

I'm afraid val5 and higher you have to add manually in a text editor. But map files are just text, so it shouldn't be a big problem.
« Last Edit: June 17, 2012, 06:59:26 pm by JovankaB »

Re: Script - Respawn item, inventory, container
« Reply #5 on: June 25, 2012, 06:54:01 pm »
Hello,
I've added the val5 in the text map file, but it doesnt seem to work with NPCs (1).
How do i use this script for NPCs such as barter characters?

JovankaB

  • Guest
Re: Script - Respawn item, inventory, container
« Reply #6 on: June 25, 2012, 07:11:41 pm »
Hello,
I've added the val5 in the text map file, but it doesnt seem to work with NPCs (1).
How do i use this script for NPCs such as barter characters?

I think this module can't do it (unless you add it by yourself). Check out the function RespawnItemAnyCritter - the NPC where the item respawns is a random NPC on the same map. The same with container mode.
« Last Edit: June 25, 2012, 07:15:23 pm by JovankaB »

Re: Script - Respawn item, inventory, container
« Reply #7 on: June 25, 2012, 08:06:36 pm »
That makes sense!
Thanks a lot.

I made a simple script for merchant character that respawns items.. Pretty much just coppied the original trader script

Code: [Select]
#include "_macros.fos"
#include "respawn_item.fos"

void _TraderInit( Critter& npc, bool firstTime )
{
npc.StatBase[ ST_TALK_DISTANCE ]      = 5;
npc.StatBase[ ST_MAX_TALKERS ]        = 6;
npc.StatBase[ ST_REPLICATION_TIME ]   = 30;
npc.SkillBase[ SK_BARTER ]            = 60;
npc.ModeBase[ MODE_NO_ITEM_GARBAGER ] = 1;
npc.ModeBase[ MODE_NO_BARTER ]        = 0;
npc.ModeBase[ MODE_NO_DROP ]          = 1;
npc.ModeBase[ MODE_NO_STEAL ]         = 1;
npc.ModeBase[ MODE_NO_LOOT ]          = 1;
npc.ModeBase[ MODE_NO_ENEMY_STACK ]   = 1;
npc.SetEvent(CRITTER_EVENT_IDLE,"_TraderIdle");
Log ("Critter init");
}

void _TraderIdle (Critter& npc)
{
Item@[] items;
npc.GetItems( SLOT_INV, items );
DeleteItems( items ); // deletes all items in inventory
npc.Wait (1000); // howmuch time before all of this happens
npc.AddItem( PID_BEER, 1 ); //items that u get
npc.AddItem( PID_CIGARETTES, 1 ) ;
npc.AddItem( PID_JET, 4 );
}
« Last Edit: June 25, 2012, 08:51:37 pm by JovankaB »

Offline Mr Feltzer

  • FOnline: Australia
    • The Core Gaming Australia's Website
Re: Script - Respawn item, inventory, container
« Reply #8 on: June 27, 2012, 12:13:55 pm »
That makes sense!
Thanks a lot.

I made a simple script for merchant character that respawns items.. Pretty much just coppied the original trader script

Code: [Select]
#include "_macros.fos"
#include "respawn_item.fos"

void _TraderInit( Critter& npc, bool firstTime )
{
npc.StatBase[ ST_TALK_DISTANCE ]      = 5;
npc.StatBase[ ST_MAX_TALKERS ]        = 6;
npc.StatBase[ ST_REPLICATION_TIME ]   = 30;
npc.SkillBase[ SK_BARTER ]            = 60;
npc.ModeBase[ MODE_NO_ITEM_GARBAGER ] = 1;
npc.ModeBase[ MODE_NO_BARTER ]        = 0;
npc.ModeBase[ MODE_NO_DROP ]          = 1;
npc.ModeBase[ MODE_NO_STEAL ]         = 1;
npc.ModeBase[ MODE_NO_LOOT ]          = 1;
npc.ModeBase[ MODE_NO_ENEMY_STACK ]   = 1;
npc.SetEvent(CRITTER_EVENT_IDLE,"_TraderIdle");
Log ("Critter init");
}

void _TraderIdle (Critter& npc)
{
Item@[] items;
npc.GetItems( SLOT_INV, items );
DeleteItems( items ); // deletes all items in inventory
npc.Wait (1000); // howmuch time before all of this happens
npc.AddItem( PID_BEER, 1 ); //items that u get
npc.AddItem( PID_CIGARETTES, 1 ) ;
npc.AddItem( PID_JET, 4 );
}

Yeah Just look at trader.fos
Founder of Fallout Online Australia

Re: [ How to ] Script - Respawn item, inventory(barter npc)
« Reply #9 on: June 27, 2012, 04:58:03 pm »
The problem with this script is that if you attack the npc, after the npc goes back to its place the items respawn at that time.
I guess you have to set a time event.. Instead of using IDLE .. ??

Offline Gob

  • The Good
Re: [ How to ] Script - Respawn item, inventory(barter npc)
« Reply #10 on: September 16, 2012, 09:32:48 am »
So if I put a Gaus Rifle in a locker and attach that script to the weapon it will respawn in that locker after some time?

JovankaB

  • Guest
Re: [ How to ] Script - Respawn item, inventory(barter npc)
« Reply #11 on: September 16, 2012, 09:44:41 am »
So if I put a Gaus Rifle in a locker and attach that script to the weapon it will respawn in that locker after some time?

No, in a random container on the same map.
But of course you can implement respawning in the same container.