fodev.net
FOnline Development => General Discussion => Topic started by: muhoooool 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
-
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.
-
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!
-
_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
-
_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.
-
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?
-
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.
-
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
#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 );
}
-
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
#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
-
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 .. ??
-
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?
-
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.