FOnline Development > General Discussion
[ How to ] Script - Respawn item, inventory(barter npc)
muhoooool:
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:
--- Quote from: muhoooool 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?
--- End quote ---
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.
muhoooool:
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: ---#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 );
}
--- End code ---
Mr Feltzer:
--- Quote from: muhoooool 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: ---#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 );
}
--- End code ---
--- End quote ---
Yeah Just look at trader.fos
muhoooool:
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 .. ??
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version