Skip to content

Changing dice that are being rolled

LordPasLordPas Member Posts: 47
I got a tricky question here.
I am wondering if it's possible to change AC and make it a random dice roll instead of a set number. So, instead of AC being 10+dex bonus+Armour bonus, I want to make it, for example, 5 + d 20 vs attacks.

Or

Can I make it so attack rolls are opposed by the opposing characters attack roll instead of the AC?

I get the feeling I'm asking for something that might not be possible but I figured I'd try anyways.

Comments

  • TerrorbleTerrorble Member Posts: 179
    No way in the base game that I'm aware of.
  • LordPasLordPas Member Posts: 47
    Is it possible to make an Item that gives a player a random AC bonus every round?
  • FreshLemonBunFreshLemonBun Member Posts: 909
    Your last suggestion is certainly possible.

    Your previous suggestion is possible through work around scripting and some caveats. For example it would probably be easier with NWNXEE, on the other hand you can replace the attack dialog lines in dialog.tlk but keep in mind doing so does not really play nice. It will mean you only play your own module, in that case you're hiding what is going on, which you then combine with creating a scripted alternative to combat, and then you output that instead. The issue with that is you're working against the engine.

    The suggestion has been made that Beamdog opens up all combat events but they didn't and there was some concern custom combat could be buggy and slower than normal combat. Of course the alternative is orders of magnitude worse, so I'm not sure why they didn't, but they didn't.


    Probably a very simple approach to your last suggestion would be to use the module heartbeat. If the character is in combat then apply the random bonus for 6 seconds, and probably apply a similar bonus to whoever their target is, or apply a bonus to any npc within a certain range.
  • TerrorbleTerrorble Member Posts: 179
    I use the module heartbeat event to see if a character is in combat and determine the number of enemies near them. If there are more than 3 and they fail a tumble check then they get an AC penalty for a couple rounds. It works pretty well (that swarm of relatively weak little spiders just got dangerous).

    Here's the code snippet:
    
            if( GetIsInCombat(oPC) )
            {
                    int n = 3;
                    object oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oPC,n);
                    while( oEnemy != OBJECT_INVALID && GetDistanceBetween(oPC,oEnemy) < 7.5 )
                    {
                        n++;
                        oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oPC,n);
                    }
                        if( n > 3 )//this means we had at least 4 enemies in range. n will be 1 larger than the # of enemies
                        {
                          SendMessageToPC(oPC,"You fight to maintain your space as enemies crowd you.");
    
                          if( GetLevelByClass(CLASS_TYPE_DWARVEN_DEFENDER,oPC) < 5 )
                          {
    
                            int nOppRoll = 10 + (n-2)*5;//the DC is at least 20
                            int nMyRoll  = d20() + GetSkillRank(SKILL_TUMBLE,oPC);
                                    if( GetHasFeat(FEAT_MOBILITY,oPC) )         nMyRoll += 4;
                                    if( GetHasFeat(FEAT_SPRING_ATTACK,oPC) )    nMyRoll += 6;
                                    //Large bonus for having an ally close by
                                    //re-using oEnemy
                                    oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND,oPC,1);
                                    if( oEnemy != OBJECT_INVALID && GetDistanceBetween(oPC,oEnemy) < 10.0 ) nMyRoll += 10;
    
                                if( nMyRoll < nOppRoll )
                                {
                                    effect eSwarm = EffectACDecrease(n-2);//Minimum AC decrease of 2
                                    eSwarm = SupernaturalEffect(eSwarm);
                                    effect eVis = EffectVisualEffect(VFX_IMP_HEAD_EVIL);
                                    ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oPC);
                                    ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSwarm,oPC,12.0);
    
                                    SendMessageToPC(oPC,"You roll: "+IntToString(nMyRoll)+" vs. DC"+IntToString(nOppRoll));
                                    FloatingTextStringOnCreature("You are swarmed and unable to maneuver well, making you an easy target.",oPC,FALSE);
                                }
                                else
                                {
                                    SendMessageToPC(oPC,"You roll: "+IntToString(nMyRoll)+" vs. DC"+IntToString(nOppRoll));
                                    FloatingTextStringOnCreature("You are able to maintain your space.",oPC,FALSE);
                                }
                          }
                          else FloatingTextStringOnCreature("Your Dwarven Defender Defensive Awareness allows you to fight unhindered amongst the enemies.",oPC);
                        }//if >3 enemies
    
            }
    
  • LordPasLordPas Member Posts: 47
    Your last suggestion is certainly possible.

    Your previous suggestion is possible through work around scripting and some caveats. For example it would probably be easier with NWNXEE, on the other hand you can replace the attack dialog lines in dialog.tlk but keep in mind doing so does not really play nice. It will mean you only play your own module, in that case you're hiding what is going on, which you then combine with creating a scripted alternative to combat, and then you output that instead. The issue with that is you're working against the engine.

    The suggestion has been made that Beamdog opens up all combat events but they didn't and there was some concern custom combat could be buggy and slower than normal combat. Of course the alternative is orders of magnitude worse, so I'm not sure why they didn't, but they didn't.


    Probably a very simple approach to your last suggestion would be to use the module heartbeat. If the character is in combat then apply the random bonus for 6 seconds, and probably apply a similar bonus to whoever their target is, or apply a bonus to any npc within a certain range.

    This looks pretty promising.
    By random number I mean a randomized number. So every round the game will randomly pick a number and apply it to AC.
    So, combat starts, the on heartbeat script activates and both player and enemy one heartbeat script activates and a random number is assigned to player AC and another Random number is assigned to enemy AC. They then attempt their attack rolls.

    I'd prefer if the the random number = the attack roll but that would mean that the character who is attacked first would not have rolled yet nor gained an AC bonus yet.
  • LordPasLordPas Member Posts: 47
    edited August 2020
    Terrorble wrote: »
    I use the module heartbeat event to see if a character is in combat and determine the number of enemies near them. If there are more than 3 and they fail a tumble check then they get an AC penalty for a couple rounds. It works pretty well (that swarm of relatively weak little spiders just got dangerous).





    Can the AC penaly be Randomized instead of a set number?
  • TerrorbleTerrorble Member Posts: 179
    Randomizing the penalty should be straight forward.

    If a PC is in combat with some number of enemies around them, what would the penalty calculation to the PC look like? What would the penalty calculation to the enemy look like?
  • LordPasLordPas Member Posts: 47
    I answered too quickly last time. It was late and I didn't want to leave the subject undiscussed.

    It occurred to me after that I do know that it can be randomized.
    What I'm thinking for the AC calculation is:
    (AC - Attack bonus) = penalty to AC.
    Then roll 1d20 and add to AC.

    It's not perfect but it represents a contested AC roll.

    Btw, as I understand it, setting a script to heartbeat can slow down a module, is that correct?
  • FreshLemonBunFreshLemonBun Member Posts: 909
    No, that's incorrect, a lot of old advice was overly cautious about things. A heartbeat script is just scheduled to run at regular intervals. Some things such as having many elaborate heartbeats run at the same time could affect performance but it's usually something that could have been done differently. The module heartbeat is a perfectly fine way to handle some things that need regular checking, like checking states for all players.

    As for AC/Attack contests I'm not really sure what you want to achieve. There are some ways you can change the spread of results but if you're essentially just staying with checks in a positive linear scale then you can keep it simple. For example if you just want the average result for 1d20 vs 1d20 then you can add +10 to AC permanently following the rule of always floor decimals down. On the other hand if you want to keep the same scale and have a stochastic variable on both sides then it's just -10 + 1d20 AC. Subtracting the opposed attack bonus and adding 1d20 instead will just mean it favors defenders at lower levels and attackers at higher levels.

    It helps to describe what you want to achieve and then find the numbers which will model that.
  • LordPasLordPas Member Posts: 47
    The system I am trying to base this uses contested attack rolls to determine the winner of the round. The higher roll wins the combat round.
    That's a bit difficult to pull off in NwN.
    Instead, what seems to be a better idea is that characters make a standard attack roll vs AC +1d20.
    I want AC to = BAB + str bonus (or dex bonus for dex fighters.)

    What would help more is if I can make the attackers 1d20 roll get added to his AC (replacing the +1d20 on heartbeat) and The defenders +1d20 to AC become his attack roll.

    So, heart beat script goes off, Character A does his attack, (str + BaB +1d20) vs Character B's AC + 1d20(from heartbeat script). On Character B's turn he attacks. I would like for character B's attack to be (str +BaB +1d20(from heartbeat script) vs Character A's AC + 1d20 (from attack roll).

    If not I'll settle for both having individual attack rolls and heartbeat script adding +1d20 to their AC.

Sign In or Register to comment.