Author Topic: Polymorph crashing Linux NWServer?  (Read 695 times)

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« on: January 07, 2011, 09:04:20 am »


               Something a couple players seemed to discover by accident for me.  The ability to crash the by unshifting while near death, seems to locking up NWServer on a Linux install.

I tested against a windows box and didn't get the same crash.

Is this a known issue?  Is there fixes?  Does anyone have any more detailed information for me?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #1 on: January 09, 2011, 04:36:14 am »


               Yes, this is a known issue, and why we block unshifting if it would kill the player. Unfortunately this also means blocking shifting direct from form to form without deshifting first, something that didn't thrill our shifter players.



Funky
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #2 on: January 10, 2011, 12:19:12 am »


               Thanks for the heads up Funky.  Exactly where did you fix this problem?



I was thinking in the various impact scripts that fired polymorphs, but maybe I'm thinking about it wrong.





You'd more want to perform the check when someone tries to use the unpolymorph button?



If you feel like sharing would you PM me on where to start, or offer some insight on this please, I'd rather not give players the power to crash a server.
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #3 on: January 10, 2011, 01:00:24 am »


               I R so smrt.  Just found your other post in scripting section Funky.  Still not sure how you go about the basic implementation though....



Shifter Crash
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #4 on: January 10, 2011, 11:33:04 pm »


               Posted by request, the method for blocking polymorphing that would lead to death. I'm going to go one script per post to avoid confusion due to lack of codeboxes.

First, you must use nwnx_events to hook, among other things, the feat use event, so that you can block direct polymorph from one form to the next. Here's the (heavily edited for simplicity) code for our events event, showing how this is done.


//::////////////////////////////////////////////////////////////////////////:://
//:: SIMTools V3.0 Speech Integration & Management Tools Version 3.0        :://
//:: Created By: FunkySwerve                                                :://
//:: Created On: April 4 2006                                               :://
//:: Last Updated: March 27 2007                                            :://
//:: With Thanks To:                                                        :://
//:: Dumbo - for his amazing plugin                                         :://
//:: Virusman - for Linux versions, and for the reset plugin, and for       :://
//::    his excellent events plugin, without which this update would not    :://
//::    be possible                                                         :://
//:: Dazzle - for his script samples                                        :://
//:: Butch - for the emote wand scripts                                     :://
//:: The DMFI project - for the languages conversions and many of the emotes:://
//:: Lanessar and the players of the Myth Drannor PW - for the new languages:://
//:: The players and DMs of Higher Ground for their input and playtesting   :://
//::////////////////////////////////////////////////////////////////////////:://
//This script is only used by Linux users, to tell what conversation node was selected in the popup menus.
//The other events shown will work with the Linux version but are commented out

//#include "aps_include"
//#include "nwnx_events"

#include "hg_inc"

#include "fky_chat_instant"


void main() {
    int nEventType = GetEventType();
    int nSubType;
    string sCommand;
    location lTarget;
    object oTarget, oItem;

    switch (nEventType) {
        case EVENT_TYPE_CAST_SPELL:
//... note break; removed too
        case EVENT_TYPE_USE_ITEM:
//... note break; removed too

        case EVENT_TYPE_USE_FEAT:
            nSubType = GetEventSubType();
//...other feats removed
            if (FindSubString(" 304 305 335 336 337 338 339 340 341 342 872 873 898 900 901 902 903 1060 1061 ", " " + IntToString(nSubType) + " ") >= 0) {
                if (GetHasEffectOfType(EFFECT_TYPE_POLYMORPH, OBJECT_SELF)) {
                    FloatingTextStringOnCreature("You cannot change shape while already polymorphed!", OBJECT_SELF, FALSE);
                    BypassEvent();
                }
            }

            break;

        case EVENT_TYPE_USE_SKILL:
//... note break; removed too

        case EVENT_TYPE_TOGGLE_MODE:
//... note break; removed too

        case EVENT_TYPE_PICKPOCKET:
//... note break; removed too

        case EVENT_TYPE_QUICKCHAT:
//... note break; removed too
    }
}

Funky
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #5 on: January 10, 2011, 11:45:51 pm »


               We also block polymorphing in our general polymorph spell script, which handles all spell polymorphs:


    if (GetHasEffectOfType(EFFECT_TYPE_POLYMORPH, pi.caster)) {
        FloatingTextStringOnCreature("You cannot change shape while already polymorphed!", pi.caster, FALSE);
        return;
    }

               
               

               


                     Modifié par FunkySwerve, 10 janvier 2011 - 11:46 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #6 on: January 10, 2011, 11:55:11 pm »


               Shifters are left to use the !cancel poly simtools command to cancel polymorphs, which checks their hp:


                                } else if (sCancel == "poly") {
                    int nHP = 20 + (GetAbilityModifier(ABILITY_CONSTITUTION, oCPC) * GetHitDice(oCPC));
                    if (GetCurrentHitPoints(oCPC) < nHP)
                        FloatingTextStringOnCreature(COLOR_RED + "Unshifting now would kill you!" + COLOR_END, oCPC, FALSE);
                    else if (RemoveEffectsOfType(EFFECT_TYPE_POLYMORPH, oCPC, oCPC) > 0)
                        AssignCommand(oCPC, ClearAllActions());
                    return;
                }

Funky
               
               

               


                     Modifié par FunkySwerve, 10 janvier 2011 - 11:55 .
                     
                  


            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #7 on: January 12, 2011, 06:17:17 am »


               

effect EffectPolymorph(
    int nPolymorphSelection,
    int nLocked = FALSE
);
Parameters
nPolymorphSelection
POLYMORPH_TYPE_*
nLocked
If TRUE, player can't cancel polymorph (Default: FALSE)

Description
Returns a new effect object that when applied to a target will transform them into one of the types defined in the POLYMORPH_TYPE_* constant group, from the "polymorph.2da" file, where new ones can be added via. a hakpack.

A new polymorph will cancel out an existing one, and if nLocked is TRUE, there is no "Cancle Polymorph" in the radical menu, so it cannot be removed automatically by a PC, only by the duration running out, or (if applied via. a spell) it being dispelled.

The target this effect is applied to must be a creature for it to work. The target this effect is applied to must be a creature for it to work.


Funky, would applying nLocked to True for all polymorphs, and then setting up a chat command to force an unpolymoph work?  (like your simTools command above)

Might have to use RemoveSpecificEffect(EFFECT_TYPE_POLYMORPH, oPC);


               
               

               


                     Modifié par Calvinthesneak, 12 janvier 2011 - 06:24 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #8 on: January 12, 2011, 07:35:46 am »


               According to the lexicon, that just has no Cancel Poly icon:



"A new polymorph will cancel out an existing one, and if nLocked is TRUE, there is no "Cancle Polymorph" in the radical menu, so it cannot be removed automatically by a PC, only by the duration running out, or (if applied via. a spell) it being dispelled."



That wouldn't block use of another shifter feat, so far as I know. I can't say for certain, however, since acaos coded our shifter blocking. I assume he did it the way he did for a reason, but I could always be mistaken - feel free to try it.



Funky
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #9 on: January 12, 2011, 06:36:25 pm »


               Hmmmm interesting, could adding a check to the code to see if they're polymorphed first work.  I could see that it would decrement the spell/feat regardless.  I don't know I'll have to play at this point to see what I can do.
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #10 on: January 13, 2011, 12:33:58 pm »


               

FunkySwerve wrote...

According to the lexicon, that just has no Cancel Poly icon:

"A new polymorph will cancel out an existing one, and if nLocked is TRUE, there is no "Cancle Polymorph" in the radical menu, so it cannot be removed automatically by a PC, only by the duration running out, or (if applied via. a spell) it being dispelled."

That wouldn't block use of another shifter feat, so far as I know. I can't say for certain, however, since acaos coded our shifter blocking. I assume he did it the way he did for a reason, but I could always be mistaken - feel free to try it.

Funky



Ahhh I forgot the way shifting from one form to another worked.  It unshifts you momentarily, then shifts to new form.  Looks like you and Acaos have probably done it the only way it's going to be possible.  I was trying to catch it in the code to see if they were polymorphed already, and then return.
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #11 on: January 14, 2011, 03:49:39 am »


               Sadly my idea didn't work as well as I'd wanted. What's the saying, close only counts in horseshoes and hand grendades?


Anyhow what I did in each polymorph script was try this.

string badShifter = StringToRGBString("You cannot shift while already shifted!", STRING_COLOR_RED);

//check to see if we are polymorphed already and dissallow so we cannot
//blow the server up and ruin everyone's fun

if(GetLocalInt(oTarget, "IOS_POLY"))
{
SendMessageToPC(oTarget, badShifter);
return;
}


And then after the polymorph was provided, set the int...

    //Flag as in polymorph form
    SetLocalInt(OBJECT_SELF, "IOS_POLY", 1);


and then the only way to cancel is using the chat command:

    else if (sSecondaryCommand == "poly") {
        if(GetHasEffect(EFFECT_TYPE_POLYMORPH, oPC)==FALSE)
            SendMessageToPC(oPC, "You are not currently polymorphed.");
        else
        {
            int nHP = 20 + (GetAbilityModifier(ABILITY_CONSTITUTION, oPC) * GetHitDice(oPC));
            if (GetCurrentHitPoints(oPC) < nHP)
                FloatingTextStringOnCreature(badShifter, oPC, FALSE);
            else
            {
                //if they are under DM punishment as chicken, don't let them unpoly
                if(GetAppearanceType(oPC)==31)
                    return;
                else
                {
                    RemoveSpecificEffect(EFFECT_TYPE_POLYMORPH, oPC);
                    AssignCommand(oPC, ClearAllActions());
                    //Clean up variables
                    DeleteLocalInt(oPC, "IOS_POLY");
                }
            }
        }
    }


               
               

               


                     Modifié par Calvinthesneak, 14 janvier 2011 - 03:53 .
                     
                  


            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #12 on: January 14, 2011, 03:56:39 am »


               The only part I see that fails is on the shape to shape shift, it auto unpolys, and I am guessing there is no way to disable that or hook it to perform an HP check and stop it before it it depolymorphs, save how FunkySwerve did with the nwnx_events.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Polymorph crashing Linux NWServer?
« Reply #13 on: January 14, 2011, 04:34:31 am »


               

Calvinthesneak wrote...

The only part I see that fails is on the shape to shape shift, it auto unpolys, and I am guessing there is no way to disable that or hook it to perform an HP check and stop it before it it depolymorphs, save how FunkySwerve did with the nwnx_events.

That was acaos' code, not mine, but I suspect you're right.

Funky