Sign in to follow this  
Salk

[KotOR] Detect actor setting trap

Recommended Posts

Hello!

Does anyone know if there is a way to check in a script whether a mine was set by a party member and, if that is the case, which one in particular?

Thanks!

Share this post


Link to post
Share on other sites
// 533: Get the creator of oTrapObject, the creature that set the trap.
// - oTrapObject: a placeable, door or trigger
// * Returns OBJECT_INVALID if oTrapObject was created in the toolset.
object GetTrapCreator(object oTrapObject);

You may also find the following useful in order to grab the trap in the first place:

// 488: Get the trap nearest to oTarget.
// Note : "trap objects" are actually any trigger, placeable or door that is
// trapped in oTarget's area.
// - oTarget
// - nTrapDetected: if this is TRUE, the trap returned has to have been detected
//   by oTarget.
object GetNearestTrapToObject(object oTarget=OBJECT_SELF, int nTrapDetected=TRUE);

Since GetTrapCreator returns an Object, just do a GetTag on that and then you can do some simple if checks against the party member tags.

  • Thanks 1

Share this post


Link to post
Share on other sites

That's very useful, thanks!

I'll have to test it but I hope that my modification to the k_trp_generic script will work. I wanted to add a bonus to damage and DC to mines set by party members that have Heavy Weapon Feat Proficiency or better:

float fBonus = 1.0;
int nBonus = 0;
object oNPC = GetTrapCreator(OBJECT_SELF);

//Add damage multiplier bonus if the mine was set by a party member with Heavy Weapons Feat
float TP_DamageBonus(object oNPC, float fBonus)
{
    if (IsObjectPartyMember(oNPC))
    {
        if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_HEAVY_WEAPONS, oNPC))
        {
            fBonus += 0.05;
            if (GetHasFeat(FEAT_WEAPON_SPECIALIZATION_HEAVY_WEAPONS, oNPC))
            {
                fBonus += 0.10;
                if (GetHasFeat(FEAT_WEAPON_FOCUS_HEAVY_WEAPONS, oNPC))
                {
                    fBonus += 0.25;
                }
            }
        }
    }
    return fBonus;
}

//Add DC bonus if the mine was set by a party member with Heavy Weapons Feat
int TP_DCBonus(object oNPC, int nBonus)
{
    if (GetIsPC(oNPC))
    {
        if (GetHasFeat(FEAT_WEAPON_PROFICIENCY_HEAVY_WEAPONS, oNPC))
        {
            nBonus += 1;
            if (GetHasFeat(FEAT_WEAPON_SPECIALIZATION_HEAVY_WEAPONS, oNPC))
            {
                nBonus += 3;
                if (GetHasFeat(FEAT_WEAPON_FOCUS_HEAVY_WEAPONS, oNPC))
                {
                    nBonus += 5;
                }
            }
        }
    }
    return nBonus;
}

Unfortunately it seems the Gas Mines have neither DC nor damage value to improve upon so I'm just wondering what I can do to improve their effectiveness.

Cheers!

EDIT: Looking better at the original k_trp_generic script I wonder if there are a couple of problems? 

Isn't the DC for the Flash Mine fixed at 15, no matter what the nDC value is set to?

Spoiler

 

    //FLASH STUN MINE
    if( nTrapID == TRAP_BASE_TYPE_FLASH_STUN_MINOR ||
        nTrapID == TRAP_BASE_TYPE_FLASH_STUN_AVERAGE ||
        nTrapID == TRAP_BASE_TYPE_FLASH_STUN_DEADLY )
    {
        //The only difference between the flash traps is the DC.  Therefore I am
        //using 1 section of the if statement.
        if(nTrapID == TRAP_BASE_TYPE_FLASH_STUN_MINOR) {nDC = 15 ;}
        if(nTrapID == TRAP_BASE_TYPE_FLASH_STUN_AVERAGE) {nDC = 20 ;}
        if(nTrapID == TRAP_BASE_TYPE_FLASH_STUN_DEADLY) {nDC = 25 ;}

        effect eStun = EffectStunned();
        oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 3.3, lTrap, TRUE);
        while(GetIsObjectValid(oTarget))
        {
            if(!WillSave(oTarget, 15) && GetRacialType(oTarget) != RACIAL_TYPE_DROID && !GetIsNeutral(oTarget, OBJECT_SELF))
            {
                ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eStun, oTarget, RoundsToSeconds(3));
            }
            oTarget = GetNextObjectInShape(SHAPE_SPHERE, 3.3, lTrap, TRUE);
        }
    }

 

and similarly, the Gas Mines should have a Fortitude ST to resist their effect but I can't see it here: 

Spoiler

 

 //GAS POISON TRAP
    else if(nTrapID == TRAP_BASE_TYPE_POISON_GAS_MINOR ||
                       TRAP_BASE_TYPE_POISON_GAS_AVERAGE ||
                       TRAP_BASE_TYPE_POISON_GAS_DEADLY)
    {
        effect ePoison;
        //The only difference between the poison traps is the poison type.  Therefore I am
        //using 1 section of the if statement.
        if(nTrapID == TRAP_BASE_TYPE_POISON_GAS_MINOR) {ePoison = EffectPoison(POISON_DAMAGE_MILD);}
        if(nTrapID == TRAP_BASE_TYPE_POISON_GAS_AVERAGE) {ePoison = EffectPoison(POISON_DAMAGE_AVERAGE);}
        if(nTrapID == TRAP_BASE_TYPE_POISON_GAS_DEADLY) {ePoison = EffectPoison(POISON_DAMAGE_VIRULENT);}

        oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 3.3, lTrap, TRUE);
        while(GetIsObjectValid(oTarget))
        {
            if(GetRacialType(oTarget) != RACIAL_TYPE_DROID  && !GetIsNeutral(oTarget, OBJECT_SELF))
            {
                ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoison, oTarget);
            }
            oTarget = GetNextObjectInShape(SHAPE_SPHERE, 3.3, lTrap, TRUE);
        }
    }

 


 

Share this post


Link to post
Share on other sites

Well, it seems that there is a bug also with the Adhesive Grenades.

There is supposed to be a saving throw vs DC 25 while instead there is none:

Spoiler

 

   else if(nSpell == 92) //Adhesive
    {
        nVFX = 3008;
        effect eDex = EffectEntangle();
        eDex = SetEffectIcon(eDex, 43);
        effect eGoo = EffectVisualEffect(1038);

        oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 4.0, GetSpellTargetLocation());
        while(GetIsObjectValid(oTarget))
        {
            if(!GetIsNeutral(oTarget))
            {
                SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), SWFP_HARMFUL));
                if(!GetIsLinkImmune(oTarget, eDex) || GetRacialType(oTarget) == RACIAL_TYPE_DROID)
                {
                    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDex, oTarget, 15.0);
                    DelayCommand(0.8, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eGoo, GetLocation(oTarget)));
                }
            }
            oTarget = GetNextObjectInShape(SHAPE_SPHERE, 4.0, GetSpellTargetLocation());
        }
    }

 

but I would like some confirmation I'm seeing right before opening a K1 CP issue. 

Share this post


Link to post
Share on other sites

From some preliminary testing it seems the DC and damage for poison grenades and gas mines are both hardcoded.

I tried to set flash mines of different power and there was no feedback to read in the message window when enemies triggered them.

The adhesive grenade is the only grenade that doesn't seem to allow for a saving throw (I locally have added DC 15 because it doesn't make sense to me).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this