• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Pieter's Disarm and Fist features

I have now been able to stop the sheeth sounds from playing if you have your fists equiped (because it sounds really silly). Only now the sound doesn't play synchronized with the sheething anymore.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  case "ChrFightMode":
     if(LAi_IsFightMode(pchar))
     {if(PChar.equip.blade!="bladeX4") PlaySound("OBJECTS\DUEL\sword_out_orig.wav");}
     else
     {if(PChar.equip.blade!="bladeX4") PlaySound("OBJECTS\DUEL\sword_sh_orig.wav");}
 break;<!--c2--></div><!--ec2-->
Does anyone know how to put a delay in the execution of the code? Such as "<i>if(PChar.equip.blade!="bladeX4" && Delay == 3) PlaySound("OBJECTS\DUEL\sword_out_orig.wav");</i>" or something like that?
 
BTW: My <a href="http://millenniumdock.bravepages.com/storage/others/punch_sounds.zip" target="_blank">punch sounds</a> <i>still</i> don't work with the game. I asked Mad Jack if he could help me, but he hasn't replied. Anyone please help! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
Not sure what you need help with... Coding? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> Not me then! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> The sound itself? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> Then I could possibly help...

<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
I need help with both. If you can help with the sound, could you make <a href="http://millenniumdock.bravepages.com/storage/others/punch_sounds.zip" target="_blank">these</a> work in the game. Now, if I try to use them, the game crashes to the desktop.
 
Heheh, already on that! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile2.gif" style="vertical-align:middle" emoid=":))" border="0" alt="smile2.gif" />

Here are the ones I <i>believe</i> will work! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />

What was wrong? Well, they were saved under wrong file format. Microsoft ACM Wave, not Microsoft PCM Wave!

<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/huh.gif" style="vertical-align:middle" emoid=":huh" border="0" alt="huh.gif" /> you may think! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />

I know, they all save as .wav, but there are actually tons of .wav formats, all of them different...! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" />

Here are they saved in the same format (PCM) as the other game-files seem to be.


[attachment=61:attachment]


Hope they will work. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" />
 
I can't download that file. When I try to open it, it gives an error message. It always does that when I try to download a .zip file from the forum. Can you please send it to my e-mail?
 
<!--QuoteBegin-Pieter Boelen+Jun 29 2005, 07:18 PM--><div class='quotetop'>QUOTE(Pieter Boelen @ Jun 29 2005, 07:18 PM)</div><div class='quotemain'><!--QuoteEBegin-->Can you please send it to my e-mail?<div align="right">[snapback]119940[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->
It is done. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="8)" border="0" alt="cool.gif" />
 
<span style='color:red'><span style='font-size:14pt;line-height:100%'>!!!!ALL HAIL HIGH SEA LASS!!!!</span></span>
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wavarr.gif" style="vertical-align:middle" emoid=":warr" border="0" alt="wavarr.gif" />
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" /> The sounds finally seem to work. COOOL! Be sure to check out the improved fistfighting mod in the upcoming modpack update tomorrow! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
Asch... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />

But hoorah for it working! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />

Looking forward to hearing the sound of my character, High Sea Lass, beating someone! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />

<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" />
 
<!--QuoteBegin-Pieter Boelen+Jun 30 2005, 03:01 AM--><div class='quotetop'>QUOTE(Pieter Boelen @ Jun 30 2005, 03:01 AM)</div><div class='quotemain'><!--QuoteEBegin--><span style='color:red'><span style='font-size:14pt;line-height:100%'>!!!!ALL HAIL HIGH SEA LASS!!!!</span></span>
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wavarr.gif" style="vertical-align:middle" emoid=":warr" border="0" alt="wavarr.gif" />
<div align="right">[snapback]119952[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->

I be saying that every day ... even when I don't have time to post!
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wavarr.gif" style="vertical-align:middle" emoid=":warr" border="0" alt="wavarr.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" />
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" /> WhooHOO! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" /> EXCELLENT! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/bow.gif" style="vertical-align:middle" emoid=":bow" border="0" alt="bow.gif" />
 
Pieter: You can do that two ways.
The first way is to create a questcase in q_r.c, call it say "playsheathesound"
and in it do the sound-playing code.
Then, in your code you post above, rather than directly playing the sound, use
LAi_QuestDelay("playsheathesound", 3000)
the number is in milliseconds, so 3 seconds = 3000 (or whatever time you want).

The other method is create a function. Add this code somewhere:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#event_handler("PlaySoundAfterDelay_event", "PlaySoundAfterDelay")
void PlaySoundAfterDelay()
{
    string soundname = GetEventData();
    PlaySound(soundname);
}<!--c2--></div><!--ec2-->

then, when you want to trigger the sound, do:
PostEvent("PlaySoundAfterDelay_event", 3000, "s", "whatever_sound");

The second way would be my preferred solution because it's a general solution (and can be used to play any sound after delay).
 
Thanks Nathan; that works. I'm not quite sure if I have synchronized the sounds properly now, but it'll have to do until it is improved. BTW: The way I'm trying to fix the sounds is causing all kinds of new bugs to show up:
- When the fightmode is enabled without the player pressing the "E" button (for example in a quest, when getting fencing lessons from Malcolm), the sounds will not play anymore.
- When you fire your gun, then immediately press the "E" button, the sheath sound will play, but because the firing animation was still playing, the sword isn't actually sheathed until you press the "E" button again when the firing animation <i>isn't</i> playing anymore.

Also: The fistfighting mod as a whole has stopped working properly as well:
- When you hit your enemy, the game seems to give a slight pause
- If you hit a random person in town, he/she will not notice
- Knocking a opponent out doesn't seem to happen anymore
- If you keep hitting your opponent until hp=0, the opponent will not die

This is the code I'm currently having; I hope someone will be able to make it work again:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  if( CheckAttribute(weapon, "fist" ) && enemy.chr_ai.group != LAI_GROUP_PLAYER )
 // PB: New weapons attribute, exclusively for your fists
 {
     int rank = makeint(attack.rank);
     int punch = rand (rank) + rank;
     // Calculates the strength of your punch; character's rank increases damage

     LAi_ApplyCharacterDamage(enemy, punch);
     // Applies damage to enemy

     switch(rand(2))
     {case 0: PlaySound("OBJECTS\duel\punch1.wav"); break;}
     {case 1: PlaySound("OBJECTS\duel\punch2.wav"); break;}
     {case 2: PlaySound("OBJECTS\duel\punch3.wav"); break;}
     // Play a random punch impact sound

     LAi_CheckKillCharacter(enemy); // Checks if this has killed the character

     if(!LAi_IsDead(enemy)) //checks if char now dead or not
     {
   if(rand(100)< punch + sti(attack.skill.Sneak))
   // Checks if punch knocks enemy out; character's rank increases chance
   {
       LAi_SetPoorTypeNoGroup(enemy);   // makes initial target collapse or cover
       enemy.stuntime = locTmpTime;   // stores the time of this, for reawakening
       enemy.stuntime.dialog.filename = enemy.dialog.filename;   // saves original dialog
       enemy.dialog.filename = "stunned_dialog.c";   // assigns "stunned" dialog during stuntime
       if(enemy.sex == "man") {PlaySound("OBJECTS\Voices\dead\male\dead1.wav")}   // groan
       else{PlaySound("OBJECTS\Voices\dead\female\dead_wom2.wav")}
       Log_SetStringToLog("WHACK! You knocked out your opponent!");

       float u, v, w;      // coordinates for effects
       GetCharacterPos(enemy, &u, &v, &w);    // determines position of initial target
       CreateParticleSystem("stars" , u, v+1, w, 0.0, 0.0, 0.0, sti(20) );
       // displays the "stars" particle effect on the victim
   }
   else
   {
             LAi_group_Attack(attack, enemy);  // makes victim and associates attack you
   }
     }
 }<!--c2--></div><!--ec2-->
 
About the not dying enemies: if people do not die below 0 HP try to add an additional HP check that kills them, like this


void Explosion (ref chr, int damage) // Explosion hurts character "chr" with "damage" hp
{
....
LAi_ApplyCharacterDamage(chr, damage); // damage is applied to chr

if (sti(LAi_GetCharacterHP(chr)) < damage+1) Lai_KillCharacter(chr);
// and if that's too much he is being killed
}


IIRC there is also a function called LAi_CheckKillCharacter , or something similar, which does the same.
 
Pieter: Why not rather than that, take over the function
LAi_type_player_CharacterUpdate in loc_ai\types\lai_player.c?
There's an if(fightmode) section.
Edit it to this:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    if(LAi_IsFightMode(chr))
    {
 if(!CheckAttribute(chr, "isinfightmode"))
 {
     PlaySound("whatever_unsheathe");
     chr.isinfightmode = true;
 }
 time = stf(chr.chr_ai.type.weapontime) + dltTime;
 chr.chr_ai.type.weapontime = time;
 if(time > 300.0)
 {
     chr.chr_ai.type.weapontime = "0";
     SendMessage(chr, "lsl", MSG_CHARACTER_EX_MSG, "ChangeFightMode", false);
 }
    }else{
 chr.chr_ai.type.weapontime = "0";
 if(CheckAttribute(chr, "isinfightmode"))
 {
     PlaySound("whatever_sheathe");
     DeleteAttribute(&chr, "isinfightmode");
 }<!--c2--></div><!--ec2-->
Replace playsound with a delayed playsound if you want to wait a sec.

I don't know how many times per second this function is run, but probably at least once per second.
 
Re: second bunch of code.
That's really odd--the code you post, other than adding the sounds, isn't any different SFAICT from the code you had before. Did that work, or did it also have these bugs?

Because CheckKillCharacter() is run in your code...
 
It once did work properly yes. Seems like somehow, something happened that stopped it from working.
 
<!--QuoteBegin-NathanKell+Jun 30 2005, 10:29 PM--><div class='quotetop'>QUOTE(NathanKell @ Jun 30 2005, 10:29 PM)</div><div class='quotemain'><!--QuoteEBegin-->Pieter: Why not rather than that, take over the function
LAi_type_player_CharacterUpdate in loc_ai\types\lai_player.c?
There's an if(fightmode) section.
...
I don't know how many times per second this function is run, but probably at least once per second.
<div align="right">[snapback]120181[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->
But if it's run at least once a second, is the sound going to be properly synchronised with the sword sheathing? And if it's run all the time, aren't the sounds going to be played all the time? Maybe I should just drop this whole fistfighting mod; it's never going to work in a way that is convincing; the swordfight animation just doesn't look like fistfighting. And I made this mod in the first place as a bugfix to the disarming mod*, which has also been dropped. And while we're at it: The Quick Equip button was also made because it was needed for the disarming mod**, so we don't really need that one either. That does remove almost all coding I did for the update, but then... they <i>ARE</i> not really useful features. So I should just go and try to code something that actually <i>is</i> useful for something.

* = With the disarming, you could end up with no sword equiped while still in fightmode. You couldn't open the F2 screen to equip a new sword because you were in the fightmode, and you couldn't turn the fightmode off by pressing "E" either, because you need to actually have a sword equiped to be able to do that. So I added your fists and made it so that if you were disarmed, your fists were automatically equiped, so you could always quit the fightmode. And to conceil the fact that the fists were actually nothing more than a bugfix, I tried to actually add some fistfighting-like feature to it, even though it is impossible to get it right.
** = If you were disarmed, you were basically already dead, because you couldn't defend yourself anymore. So to save yourself, you had to quit the fightmode (which was impossible until I added the fists <span style='font-size:8pt;line-height:100%'>(see * above)</span> ), then open your inventory, equip a new sword and start the fightmode again. That was very time-consuming and there was a good chance you'd already be dead before you managed to equip another sword. So I added the Quick Equip button, so that when you'd be disarmed, you had to press the "F" key quickly to save yourself.
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" /> Wow, Pieter, you really ARE talking and thinking like a modder! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />

It is interesting to see the thought process behind this mod - and <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" /> it makes perfect sense! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" />

Do you have to initialize the sounds like you do with a character - to assign them to an event? Maybe that's what's missing?

sound_alias.ini ? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
On the contrary, I think all three mods are neat and /well/ worth keeping.
Certainly quick equip is nice when you, for example, pick up a good sword from a dead body and swap while still in combat; and it's also good when you stock up at an itemtrader's and don't want to page through your entire inventory to find the good stuff you just bought and equip it.
Fist-fighting adds the ability to knock people out, an excellent addition for the nonlethally-inclined among us. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
And disarming ditto.

In terms of the sound: I don't see a way to solve the problem. The sound is played inside the DLL, and there's no good way to play it on change fight mode in the scripts. You can add a routine that runs many times a second and checks whethe the player has changed fight mode, but that will eat up resources; and if you do it less frequently it won't be timed right.
 
Back
Top