Another door ?
#1
Posté 21 août 2010 - 07:48
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??
#2
Posté 21 août 2010 - 09:31
Hope it helps. Good luck.
Modifié par GhostOfGod, 21 août 2010 - 09:32 .
#3
Posté 21 août 2010 - 09:37
#4
Posté 21 août 2010 - 05:11
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 .
#5
Posté 21 août 2010 - 06:21
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.
#6
Posté 22 août 2010 - 03:38
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;
}
#7
Posté 01 septembre 2010 - 05:35
#8
Posté 01 septembre 2010 - 06:36
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.
#9
Posté 01 septembre 2010 - 06:42
#10
Posté 01 septembre 2010 - 02:49
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.
#11
Posté 01 septembre 2010 - 03:14
EDIT:Maybe a heartbeat script, but I think a trigger would be more effective.
Modifié par Redunct, 01 septembre 2010 - 03:14 .
#12
Posté 01 septembre 2010 - 06:41
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.
#13
Posté 01 septembre 2010 - 07:26
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.
#14
Posté 01 septembre 2010 - 08:24
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?
#15
Posté 02 septembre 2010 - 07:50
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).





Retour en haut






