• 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!

Fixed Rewrite Musket on Shoulder Code

Jason

Buccaneer
Storm Modder
Playing the June 23 version the only thing I have noticed is the characters with long weapons. muskets, musketoons, and the master battle axe (which looks like a halberd to me) have them at their waist not on their shoulders. I think the change crept in in May version of WIP.
 
Playing the June 23 version the only thing I have noticed is the characters with long weapons. muskets, musketoons, and the master battle axe (which looks like a halberd to me) have them at their waist not on their shoulders. I think the change crept in in May version of WIP.
The shoulds only ever worked for muskets and musketoons.
The battle axe would for sure always be generated at the waist.

Nothing related to this should have changed, but that feature has always been quite unreliable. Let me make a Bug Tracker issue for it.
 
At the moment this code is handled through quest cases, which doesn't work well when there are multiple occurrences for several characters at the same time.
Ideally this should be changed to use event handlers instead so this can be handled individually per character.
 
Sure we can. I've used event handlers before and I think that should give the right solution in the end.
Actually, this here is quite a nice self-contained example:
Code:
void KrakenAttack(aref rCharacter, int iSwimQuantity)
// Character and number of tentacles
{
   if (!bSeaActive) return;
   ref pchar = GetMainCharacter();
   int delay = 0;
   for (int i=0; i < iSwimQuantity; i++)
   {
     PostEvent("CreateKrakenTentacle", delay, "i", rCharacter);
     delay = delay + rand(1000);
   }
   if(IsMainCharacter(rCharacter)) LogIt("Captain, we're being attacked by the Kraken!");
   else
   {
     LogIt("Captain, the " + rCharacter.ship.name + " is under attack by the Kraken!");
     pchar.KrakenAttack = true;
   }
   PostEvent("KrakenAttackFinished", delay, "i", rCharacter);
}

#event_handler("KrakenAttackFinished", "FinishKrakenAttack");
void FinishKrakenAttack()
{
   ref pchar = GetMainCharacter();
   aref rCharacter = GetEventData();
   LogIt("Captain, the Kraken has finished its attack on the " + rCharacter.ship.name + "!");
   if(CheckAttribute(pchar, "KrakenAttack"))   PostEvent("EnableKraken", 5*60*1000);
}
PostEvent starts a delay and rCharacter is sent along with it so that after the delay, the correct character can be used.
This is then later found again in the next function with GetEventData() .

Let me know if this does/doesn't make sense to you and if you need any more details.
 
it's not that hard. I dont know for sure anymore but I believe we used i for the shotgun mode also. Or we still need to, dunno for sure anymore :p.
 
it's not that hard. I dont know for sure anymore but I believe we used i for the shotgun mode also. Or we still need to, dunno for sure anymore :p.
You used LAi_QuestDelay for that, which the current system for the muskets is based on too.
Generally a good solution, but it needs to know what character to apply the code to.
If it is always the same one, such as the player for Shotgun Mode, that is fine.
But when it could be any character in the game that happens to carry a musket, it might get mixed up.
That's what I *think* is the main problem with the muskets anyway.... :oops:
 
I have started to change the code using Postevents instead. So far nobody has fired
backwards over their shoulder like they used to.
Maybe another day on it and then I need help with testing. :guns:
 
I have rewritten the code a bit again so that it uses less variables.
The copies weren't needed, because "GetEventData()" gets its stuff in order and doesn't care about the variable names. :doff
 
I'm not sure what you mean with copies though. Situations like this?

PostEvent("mket_on_back", 1000, "i", attack);
PostEvent("mguns_extra_check", 1000, "i", attack);
 
Yep, because PostEvent("mket_on_back", 1000, "i", PChar); works for me too.
 
Line 1 was the normal end of firing a shot. Shooter resets his musket on the back.

Now if for ex 2 officers fired at about the same time one of them very often
ended up with his musket still on the hip.
Line 2 checks all characters in the location and resets those not in fightmode but still with their
rifles on the hip. Could be enemies as well.

Also characters who draw their blades (and by that muskets to hip) but never got to fire their weapons
needed to be reset.

A similar (and second) check for all characters is done when pchar sheaths his blades.

I was very careful when checking this Pieter.


Or did you mean only the change from "attack" to "Pchar" in line 1?
If so does it cover officers and npchars firing?
 
See attached for my copy of the file. As far as I can tell, this works just as fine as what you had; it just uses a few less lines of code.
Shouldn't make much of a difference one way or another though.
 

Attachments

  • seadogs.zip
    19.2 KB · Views: 138
Back
Top