Aller au contenu

Photo

weaponsounds.2da


  • Veuillez vous connecter pour répondre
27 réponses à ce sujet

#1
Ubai

Ubai
  • Members
  • 88 messages

Hello,

 

I've created a custom weapon and I have run into an odd problem with the sounds it makes during combat. The weapon (a musket) plays its sounds when it misses, but not when it hits. Since the sounds play when I miss I can assume it isn't the sound files or the hak file, but I'm not sure what else it can be. Can anyone provide any insight? I tried googling but couldn't find much info on weaponsounds.2da.

 

Thanks!

Matt



#2
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

I think you need to fill all the columns (leather, chain, ecc...) with the proper sound file.

Those columns probably refer to what sound is played when the weapon hits a certain type of surface.

For example leather0 and leather1 is played when your weapon hits leather, ecc..

I would just copy what's done for all other weapons if you don't have another sound file for that. they all seem to use the same files anyway.
Except thrown and projectiles that use nothing.



#3
Ubai

Ubai
  • Members
  • 88 messages

I tried that but still no luck. First I tired the cannon sound and it did nothing, then I used the sound for the blades category. Still nothing. The only thing I can think of is that it has something to do with the range (I am using a melee weapon as a ranged weapon), but I don't see how that would make any difference to what sound is played.

 

Thanks,

Matt



#4
Ubai

Ubai
  • Members
  • 88 messages

Well, I have emptied out my override folder just in case it was causing trouble but no joy. Am I the only person that has ever run into this problem?



#5
Ubai

Ubai
  • Members
  • 88 messages

Well, I've also tried changing the row number in weaponsounds.2da based on a nwn1 hak pack I found, but then all the sounds stopped playing. I also made a new version of the file just to be safe. Still no luck.



#6
Ubai

Ubai
  • Members
  • 88 messages

Victory! Well, sort of. :P I couldn't figure out why it wasn't working, but then I realized that if it made noise on a miss I just needed to use the onHit item property and some tag based scripting to get the sound to play on a hit. After wrestling with playSound I finally made an .sef file that just plays the sound and then used ApplyEffectToLocation and voila, my hand cannon goes boom!

 

Now for the trickier problem of ammo usage, I'll need to find a way to decrease the player's ammo whether they hit or miss, preferably without using heartbeat scripts.


  • Tchos aime ceci

#7
4760

4760
  • Members
  • 1 204 messages

Now for the trickier problem of ammo usage, I'll need to find a way to decrease the player's ammo whether they hit or miss, preferably without using heartbeat scripts.


Yes, that's why I haven't released my firearms (not overriding the crossbows or slings). Either the count gets decreased only when the target is hit, or it's decreased each time but twice upon hits.

#8
Ubai

Ubai
  • Members
  • 88 messages

I think I'm going to use a pseudo-heartbeat in each area to prevent firing when the gun isn't loaded, and then I will use the onPhysicalAttack script to decrease the ammo count, as this fires whether you hit or not. That should keep the overload low, as the pseudo heartbeat will only run in areas where there are players and I can check a little faster if I need to.

 

If I can get this working well then you may even be able to dual wield pistols, which is unrealistic but kind of fun. :)



#9
Tchos

Tchos
  • Members
  • 5 030 messages

You don't need to use pseudo heartbeats in NWN2.  You can actually set the speed of an individual object's heartbeat to whatever frequency you want.  But I might suggest trying a user-defined event for the firing instead.



#10
Ubai

Ubai
  • Members
  • 88 messages

Thanks for the suggestion, but how would I use the user defined events in this case? My nwscript is a bit rusty but I thought those were mostly used when spawning in an NPC.



#11
Tchos

Tchos
  • Members
  • 5 030 messages

User defined events can be used at any time, and few have taken advantage of their power.  It allows you to do exactly what it says: create new events for a game whose scripting is event-based.  You don't have to wait for one of the existing events that don't entirely match what you want to happen (like On Physically Attacked) to fire to piggyback code onto them -- you can create an "On Gun Fired" event that runs your code only when you fire a gun, and at that instant.

 

You may have thought that they're used for spawning because the spawn script is normally where you set up an object to be able to fire these custom events.



#12
Ubai

Ubai
  • Members
  • 88 messages

I tried to refresh my memory on user defined events after I read your reply, but I still don't see how to "hook" the player firing a gun without using a heartbeat. All the research I have done suggests that the only way to prevent a player from attacking with a melee weapon (assuming you don't want to alter factions) is to run a heartbeat script that checks to see if they are in combat and then call ClearAllActions(). There isn't anything to fire off an event of any kind that I can see, but as I said my nwScript is rusty and I would be happy to be proved wrong. :)

 

Perhaps I'm misunderstanding what you're saying, could you give a quick example of how to do this?

 

I did wake up with an alternate idea, but I have to work today so I can't test it right away. I am thinking of using the Daze effect on a player when the gun runs out of bullets, and the effect is dispelled if they reload, change weapons, get disarmed, or get polymorphed. The only downside I see to this is that they would have to switch weapons to cast spells, since daze doesn't allow spellcasting. If this works it wouldn't require any heartbeat scripting at all!



#13
Tchos

Tchos
  • Members
  • 5 030 messages

I don't think repeatedly calling ClearAllActions() when a player is in combat would be a good thing.  That would also cause the player to stop moving on each heartbeat during combat when they're just trying to move around the battlefield.  I don't know how your guns are set up.  Are they considered mêlée weapons, and that's why you want to stop the player from mêlée attacks?  How do you attack with your guns?



#14
Ubai

Ubai
  • Members
  • 88 messages
Yes, the "guns" are melee weapons with a 30 meter range that I added to baseitems.2da. The idea is to make a ranged weapon that doesn't replace any of the "real" ranged weapons. That part works beautifully, but if you want to limit their ammo you have to keep the player from attacking when they're out of bullets.

Like I said, decreasing the player's ammo is easy because the onPhysicalAttack event fires whether you hit or not, so you can just run a bit of code to check and alter variables on the player's weapon. The really hard part (for me) is finding a good way to force the player to stop attacking when holding an unloaded gun.

Thanks again for helping me figure this out! :)

Matt

#15
Tchos

Tchos
  • Members
  • 5 030 messages

Right, I thought you were still stuck on the ammo reduction part.  In the case of running out of ammo, why not just force the gun to unequip when you're out of ammo?



#16
Ubai

Ubai
  • Members
  • 88 messages

I thought of that as well, and that is definitely still on the table, but I want to try the Daze thing, since it feels more immersive to not forcibly disarm the player. Then again, unequipping might be better mechanics wise, since the player could immediately equip something else or cast a spell or reload, or whatever they want. It's also super simple to implement and has little overhead.

 

I think you may have just talked me into it. :P



#17
Tchos

Tchos
  • Members
  • 5 030 messages

The daze idea is/was good, but it would mean that the player would only be able to walk, not run, and that wouldn't be a logical consequence of simply running out of ammo.



#18
Ubai

Ubai
  • Members
  • 88 messages

The unequip idea works perfectly mechanics wise, but the player unequips the gun so fast it looks a bit odd. I wonder if there is an animation that would approximate the player putting the gun away?



#19
Tchos

Tchos
  • Members
  • 5 030 messages

Animations can vary a bit depending on the race or gender, I think, but maybe "gettable" would work?

From the list: http://nwn2.wikia.co...t_of_animations


  • Ubai aime ceci

#20
kamal_

kamal_
  • Members
  • 5 238 messages

play the equip animation in reverse (speed of -1).


  • Ubai aime ceci

#21
Ubai

Ubai
  • Members
  • 88 messages

It never occurred to me that you could play an animation backward, that's fun!



#22
4760

4760
  • Members
  • 1 204 messages

Yes, that's why I haven't released my firearms (not overriding the crossbows or slings). Either the count gets decreased only when the target is hit, or it's decreased each time but twice upon hits.

Actually I got the ammo part working (and I also used the unequip option to prevent the use of a rifle with an empty magazine). The reason for not releasing the pack was that I wanted specific animations (for aiming, firing, equipping, etc.).
I started working on them, but am probably only half way.

#23
Ubai

Ubai
  • Members
  • 88 messages

I think this "bare bones" version will be good enough for my purposes, Now that I have the basics done I can add feats and configurable magazines and load times. I'll probably also make a little puff of smoke effect for the black powder weapons too.

 

I'd like to make pistols dual wieldable, I wonder if I can just set it up so that it only unequips the pistols when both are out of ammo? I think that will work, but there may be problems with high level players who have multiple attacks. I'll probably just have to test and see.

 

I'm looking forward to seeing your fancier version! As I've said, all this was inspired by one of your earlier forum posts. :)

 

-Matt



#24
Ubai

Ubai
  • Members
  • 88 messages

Hm, I have run into a weird issue, I can't delay the unequip animation no matter what I try. Here is my most recent attempt:

 

void ReallyPlayCustomAnimation(object oObject, string sAnimationName, int nLooping, float fSpeed = 1.0f)
 {
    PlayCustomAnimation(oObject, sAnimationName, nLooping, fSpeed);
 }


void main()
{
object oPC = GetLastAttacker();
if (!GetIsPC(oPC))
	return;

string sName = GetName(oPC);
SpeakString("I have been attacked by " + sName);
object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
string sWeapon = GetName(oWeapon);
string sTag = GetTag(oWeapon);
SpeakString("Attacker's weapon: " + sWeapon);
int nOldLoad = GetLocalInt(oWeapon, "nLoaded");
SendMessageToPC(oPC, "nLoaded is " + IntToString(nOldLoad));
SetLocalInt(oWeapon, "nLoaded", 0);
int nNewLoad = GetLocalInt(oWeapon, "nLoaded");
SendMessageToPC(oPC, "nLoaded is now " + IntToString(nNewLoad));
AssignCommand(oPC, ClearAllActions(TRUE));
DelayCommand(1.0, ActionDoCommand(ReallyPlayCustomAnimation(oPC, "*equipW", 0, 0.2)));
DelayCommand(1.3, AssignCommand(oPC, ActionUnequipItem(oWeapon)));
}

No matter what I do, the unequip animation always fires right after the attack, nothing seems to create a delay. I've tried sticking it in the action queue and using delay command by itself, but nothing seems to work. What am I missing?

 

Thanks,

Matt



#25
Tchos

Tchos
  • Members
  • 5 030 messages

Try putting an ActionWait in front of it.