FOnline Development > Questions and Answers
FOnline SDK - Question
E3245:
--- Quote from: Wipe on May 25, 2013, 12:44:09 pm ---Sound is made when engine calls reserved critter_action function (ACTION_USE_WEAPON). Just make scripts skip PlaySound() when specific weapon is used.
--- End quote ---
Can you show me how to script this in the weapon? I am new to this.
Wipe:
--- Code: (client_main.fos, 1557) ---case ACTION_USE_WEAPON:
if( cr.IsLife() && valid( proto ) )
{
int use = ( actionExt & 0xF );
int aim = ( ( actionExt >> 4 ) & 0xF );
bool fail = ( ( ( actionExt >> 8 ) & 1 ) != 0 );
cr.ClearAnim();
cr.Animate( 0, ANIM2_PREPARE_WEAPON );
if( proto.ProtId != PID_E3245_STOLE_MY_SOUND )
PlaySound( 'W', SOUND_WEAPON_USE, _WeaponSoundId( proto, use ), use != 1 ? '1' : '2' );[/b]
cr.Animate( 0, _WeaponAnim2( proto, use ), item );
if( fail )
cr.Animate( 0, ANIM2_DAMAGE_FRONT, item );
else
cr.Animate( 0, ANIM2_TURNOFF_WEAPON );
}
break;
--- End code ---
Blocks sound for specific PID only
--- Code: (_defines.fos, 1428) ---#pragma bindfield "const bool ProtoItem::Weapon_NoSound -> 273
--- End code ---
--- Code: (ObjectEditor/Custom.cfg) ---[CreateTab]
TopTab=Weapon
ItemTab=WeaponCustom
Text=Custom
[Common]
ItemTab=WeaponCustom
Space=75
[Field]
Text=No sound
FieldName=Weapon_NoSound
DataType=bool
--- End code ---
--- Code: (client_main.fos, 1557) ---case ACTION_USE_WEAPON:
if( cr.IsLife() && valid( proto ) )
{
int use = ( actionExt & 0xF );
int aim = ( ( actionExt >> 4 ) & 0xF );
bool fail = ( ( ( actionExt >> 8 ) & 1 ) != 0 );
cr.ClearAnim();
cr.Animate( 0, ANIM2_PREPARE_WEAPON );
if( !proto.Weapon_NoSound )
PlaySound( 'W', SOUND_WEAPON_USE, _WeaponSoundId( proto, use ), use != 1 ? '1' : '2' );[/b]
cr.Animate( 0, _WeaponAnim2( proto, use ), item );
if( fail )
cr.Animate( 0, ANIM2_DAMAGE_FRONT, item );
else
cr.Animate( 0, ANIM2_TURNOFF_WEAPON );
}
break;
--- End code ---
Blocks sound for many proto items, allows to set which weapons should be silent via ObjectEditor (creates "Weapon"->"Custom" tab, where it can be set).
If you still want attacker to hear some sound like in typical action movies (pling!), you need to tune server scripts a bit. I'm not doing combat stuff, so i won't even guess where, but call itself can be something like that.
--- Code: (media.fos) ---void PlaySound( Critter& cr, string& soundName )
{
if( cr.IsPlayer() )
cr.RunClientScript( "_PlaySound", 0, 0, 0, soundName, null );
}
--- End code ---
--- Code: (client_main.fos) ---void _PlaySound( int, int, int, string@ soundName, array<int>@ )
{
if( valid(soundName) && soundName.length() > 0 )
PlaySound( soundName );
}
--- End code ---
--- Code: ---void PlaySoundRange( Critter& cr, string& soundName, uint16 range )
{
if( soundName.length() == 0 )
return;
Map@ map = cr.GetMap();
if( valid(map) )
map.PlaySound( soundName, cr.HexX, cr.HexY, range );
}
--- End code ---
All that is just a fast c/p fest, i didn't actually test if it works at all :)
E3245:
Thank you Wipe. What about the second question
--- Quote from: E3245 on May 25, 2013, 09:27:14 am ---2) How can I make the weapon shoot out grenades without wasting the bullet, as if the grenade doesn't count as a shot fired, or the grenade launcher uses separate ammo from the gun?
--- End quote ---
I don't really know how to explain it without making it 2 weapons. I tried to add it as Attack 3 in the Object Editor but Single and Burst only shows up.
Ganado:
This might end up being a ridiculously easy answer, but what is the proper way to wipe the server? Some changes I did don't seem to be putting into effect.
And also specifically when is wiping the server needed?
JovankaB:
--- Quote from: Dishonest Abe on June 05, 2013, 11:01:40 pm ---This might end up being a ridiculously easy answer, but what is the proper way to wipe the server?
--- End quote ---
You just have to delete some files where server data is saved:
http://fodev.net/forum/index.php/topic,28429.msg245155.html#msg245155
--- Quote from: Dishonest Abe on June 05, 2013, 11:01:40 pm ---And also specifically when is wiping the server needed?
--- End quote ---
Wiping server is basically like starting a game from the beginning. There might be different reasons, for example if you make big changes in game, for example in economy starting from "clean" situation when players don't have thousands of items from previous economy might make the most sense. Or in case if perk system is changed to not have character accounts from previous system. Or for example if we completely reworked base system, without wipe we would still have hundreds of bases from previous system.
It's actually almost never necessary even with big changes, it just might be desirable to not have new versions of game featuers polluted with outcomes of previous versions.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version