Author Topic: Another door ?  (Read 580 times)

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« on: August 21, 2010, 08:48:16 am »


               One mystery down so heres another...

I have gone back to my onAttack door script to set hardness by attack type (slash, blunt, pierce) but always come back to the same thing... is there a way to slip this in BEFORE damage is dealt?

Right now it works... as soon as the door is attacked it checks for one of the 3 and then sets its dr to the appropriate level. This happens AFTER it takes damage from the first attack. So, first attack takes full damage (if door property has dr set over 0). I would like to see the new hardness set before damage is done.. just havent found the how yet...

Any help??
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Another door ?
« Reply #1 on: August 21, 2010, 10:31:44 am »


               Hmm..pretty sure OnDamaged and OnPhysicalAttacked only fire AFTER damage is taken so I don't think any of the events for the door would work. Off the top of my head only thing I can think of would be to maybe put a trigger on the ground just outside the door that gets the type of weapon that the person has equipped when they enter the trigger then changed the door hardness based on that. Kinda sketchy though. What if 2 people enter the trigger to beat up the door and one has a slash and one has a blug. Unless this is a single player mod. Then you wouldn't have to worry about that. You could also do something similar with the doors Heartbeat I supposed. Get nearest creatures equipped weapon type and set the hardness but again it aint perfect.

Hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 21 août 2010 - 09:32 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Another door ?
« Reply #2 on: August 21, 2010, 10:37:58 am »


               OnPhysicalAttacked shoul fire before, however I dont like this solution because it does fire also when character dont even hit the door (roll 1). Try to look at my door system scripts LINK IIRC it will give you the option to set all doors to plot via 3rd party tool - letoscript and set their scripts to my ones...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Another door ?
« Reply #3 on: August 21, 2010, 06:11:42 pm »


               I guess the OnPhysicalAttacked is a bit confusing. To me it seems that this is saying that it still happens after the attack. But it doesn't matter if damage was taken or if the hit missed?

From the lexicon:

OnPhysicalAttacked

The script attached to this
event fires each time the object takes physical damage.  This could be
used for a reaction to the attack such as changing weapons, fleeing,
surrendering, etc.

Trigger

A physical attack is brought against a creature, door, or placeable object. It doesn't need to hit or damage to trigger it.


               
               

               


                     Modifié par GhostOfGod, 21 août 2010 - 05:12 .
                     
                  


            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #4 on: August 21, 2010, 07:21:25 pm »


               

ShaDoOoW wrote...

OnPhysicalAttacked shoul fire before, however I dont like this solution because it does fire also when character dont even hit the door (roll 1). Try to look at my door system scripts LINK IIRC it will give you the option to set all doors to plot via 3rd party tool - letoscript and set their scripts to my ones...


Setting a new hardness doesn't really matter if there is a hit or not just so long as it is set based on the damage type inflicted by the PCs weapon.  There are two ways I have thought about running this.

1. Getting the type of weapon used and checking it before damage (BASE_ITEM_*)  to set hardness or..

2. Getting damage type after first hit (DAMAGE_TYPE_PIERCING etc)

The problem though is that option one requires A LOT more code such as

int GetSlashingWeapon(object oItem)
{
    //Declare major variables
    int nItem = GetBaseItemType(oItem);
    if((nItem == BASE_ITEM_BASTARDSWORD) ||
      (nItem == BASE_ITEM_BATTLEAXE) ||
      (nItem == BASE_ITEM_DOUBLEAXE) ||
      (nItem == BASE_ITEM_GREATAXE) ||
      (nItem == BASE_ITEM_GREATSWORD) ||
      (nItem == BASE_ITEM_HALBERD) ||
      (nItem == BASE_ITEM_HANDAXE) ||
      (nItem == BASE_ITEM_KAMA) ||
      (nItem == BASE_ITEM_KATANA) ||
      (nItem == BASE_ITEM_KUKRI) ||
      (nItem == BASE_ITEM_LONGSWORD)||
      (nItem == BASE_ITEM_SCIMITAR)||
      (nItem == BASE_ITEM_SCYTHE)||
      (nItem == BASE_ITEM_SICKLE)||
      (nItem == BASE_ITEM_TWOBLADEDSWORD) ||
      (nItem == BASE_ITEM_DWARVENWARAXE) ||
      (nItem == BASE_ITEM_THROWINGAXE) ||
      (nItem == BASE_ITEM_WHIP)
      )
   {
        return TRUE;
   }
   return FALSE;
}


and setting up the same for blunts and piercing. The above function is from x2_i0_spells. There is another function close to that one for blunts but relies on a call to a 2da instead of constants (I think)

In any event.. we can wait and get the info from damage type or by getting the type of weapon the attacker used to damage the door.

My secondary concern is the script firing each time it is attacked.. I think I have a way around part of the problem but no easy or even logical solution has presented itself.. I will check out your script set a bit later today shadooow. Thanks for the input.

***NOTE***
I am building this script so that when a door is bashed certain ypes of damage are more effective. A piercing weapon (stabbing, thrusting) will not cause as much damage as a slashing or blunt attack.

Its pretty sad a crossbow bolt can take out a stone door just as easily as a warhammer. 

The next script in the set i'm going to complete is on weapon breakage I think. A non-magical weapon used to bash in a stone door has n% chance to break each hit.
               
               

               
            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #5 on: August 22, 2010, 04:38:43 am »


               I've tested repeatedly and it does fire before damage is dealt but does not seem to apply the new hardness until AFTER damage is subtracted from the doors HP. Heres the section that fires before

if (hp == maxhp)

   {

       object oPC = GetLastAttacker(OBJECT_SELF);

       object oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);

       SpeakString("In main IF");



       if (GetSlashingWeapon(oItem))

       {

           SetHardness(SLASH_DR, OBJECT_SELF);

           SpeakString("Set DR to Slash");

           int currentdr = GetHardness();

           string s1 = IntToString(currentdr);

           SpeakString(s1);

           return;

       }

       if (GetBludgeoningWeapon(oItem))

       {

           SetHardness(BLUNT_DR, OBJECT_SELF);

           SpeakString("Set DR to Blunt");

           int currentdr = GetHardness();

           string s1 = IntToString(currentdr);

           SpeakString(s1);

           return;

       }

       if (GetPiercingWeapon(oItem))

       {

           SetHardness(PIERCE_DR, OBJECT_SELF);

           SpeakString("Set DR to Pierce");

           int currentdr = GetHardness();

           string s1 = IntToString(currentdr);

           SpeakString(s1);

           return;

       }

       return;

   }


               
               

               
            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #6 on: September 01, 2010, 06:35:49 am »


               Setting a new hardness BEFORE damage is applied doesn't seem to work.. may have to try EffectDamageResistance or EffectDamageReduction
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Another door ?
« Reply #7 on: September 01, 2010, 07:36:12 am »


               One other thing I would recommend. Instead of using :

object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);

You should try to use:

object oItem = GetLastWeaponUsed(oPC);

The reason being that if someone is dual wielding and it is the left hand weapon that hits, the weapon type might be different. You will also probably want to add a check with this. If it returns OBJECT_INVALID then the player does not have a weapon equipped. which would mean they are using their fists. Could be a monk. In that case you may want to consider OBJECT_INVALID as bludgeoning damage.

Just some thoughts. Good luck.
               
               

               
            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #8 on: September 01, 2010, 07:42:06 am »


               Good catch on the fists.. forgot about that kind of attack. LastWeaponUsed makes more sense, but initial testing I just did a copy/paste of get item in slot.
               
               

               
            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #9 on: September 01, 2010, 03:49:55 pm »


               EffectDamageResistance works better i think though I am still getting the same problem of it setting AFTER initial damage even though the speakstring call prints after the hit roll. Oh well.. guess just leave the doors hardness alone and let the script set to 0 before the resist call. Not a perfect solution but workable I guess. Now piercing weapons are not the best choice to bash a door with! Never did like that... A mace should have an easier time bashing a door than an arrow or a dagger or even a spear.



I think the best way to do it would be to check on a group of weapons for each door type but that gets into a lot more script work and dont know if it would really be worth it.
               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Another door ?
« Reply #10 on: September 01, 2010, 04:14:25 pm »


               The only way you're gonna get the weapon before they attack it is to put a trigger right in front of the door.

EDIT:Maybe a heartbeat script, but I think a trigger would be more effective.
               
               

               


                     Modifié par Redunct, 01 septembre 2010 - 03:14 .
                     
                  


            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #11 on: September 01, 2010, 07:41:17 pm »


               Using effectdamage with a standard door (dr 5 for wood) works for the most part. Most piercing weapons are d4 or d6 so at most only a few points will leak through.



As this is a set of generic door functions a hb is out of the question due to the number or cycles it would consume (doors outnumber pretty much everything else). As for a trigger... its workable but requires more time on the builders part to make it all work.
               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Another door ?
« Reply #12 on: September 01, 2010, 08:26:15 pm »


               

DarkStormInc wrote...

 As for a trigger... its workable but requires more time on the builders part to make it all work.


If you're looking for shortcuts here, you're gonna get inneffective scripts..

How about a local int on the onItemEquip script? Have the script set the int, then have the int change the resistence.
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Another door ?
« Reply #13 on: September 01, 2010, 09:24:13 pm »


               @DarkStormInc



I just gotta ask why you are trying to even use scripts like this?

I'm not seeing the point of doing it.

I'm sure you must have a special needs use for it, but I find it hard to believe you need this much work when you could have a simplified script that just alters Plot on or off.

That along with altering the HP of the door would be much simpler.



I'm just curious as to why you are trying to go this route?
               
               

               
            

Legacy_DarkStormInc

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Another door ?
« Reply #14 on: September 02, 2010, 08:50:51 am »


               Ok, so you turn plot on and alter the HP of the door. Now, inbetween this what are you using to calculate the damage range for a given weapon type? You have piercing, slashing, and blunts. Any door you bash will be destroyed faster by a given damage type (above): blunt > slash > pierce.



I was using 3 functions to determine the damage type using toolset base_item_* constants. It worked, but an earlier post stated that OnAttack might fre BEFORE damage was dealt. This ended up not being the case. So, an alternate solution was looked into. It uses far less code for the same effect. Plus, I no longer need to make a call to Get2DA when haks are involved.



My point in this was posted in this reply and above. In door properties the hardness (5 for wood) affected ALL weapons and I wanted something that would more easily createa  more realistic and dynamic damage threshold based on damage type rather than a blanket DR for everything. Its something I worked on and nearly finished 5 years ago (and lost, along with my other door scripts) and am finally getting ready for a release (though by now it's not likely to get much use).