Jump to content

backstabibility


lynx

Recommended Posts

Good, that leaves some room for patching things. :beer:

 

By the way, I did implement the backstab flag. (Bit 25 in the item ability flags.)

The patch also checks the launcher if the flag is not set in the ammunition.

Reviving this in terms of implementing into TobEx. Taimon's hack uses the same bit to allow backstabbing using ranged weapons and for non-thief weapons. However, this doesn't allow a modder to make the following item:

 

1. I want a back-stabbing ranged weapon but I only want thieves to be able to backstab with it

 

Is this a pertinent problem?

Link to comment
1. I want a back-stabbing ranged weapon but I only want thieves to be able to backstab with it

 

Is this a pertinent problem?

I don't think anybody is going to be interested in making such an item; even if you wanted to, you can simulate it by using EFF targeting to have everybody but thieves receive a -10 to the backstab multiplier (ok, it's not enough if the ranged ability can be used for backstabbing only by thieves and the melee ability can be used for backstabbing by everyone, but hopefully modders aren't interested in that sort of rule lawyering).

Link to comment
1. I want a back-stabbing ranged weapon but I only want thieves to be able to backstab with it

There is no support for allowing items to cause backstabs if wielded by class X and no backstabs otherwise. If an item is suitable for backstabbing, then anyone who has a backstab multiplier can backstab with it.

Link to comment
There is no support for allowing items to cause backstabs if wielded by class X and no backstabs otherwise. If an item is suitable for backstabbing, then anyone who has a backstab multiplier can backstab with it.

Asc is talking about splitting Taimon's flag in two different things:

 

standard bg2 code is

can_backstab = item.usableBy(THIEF) && ! ability.ranged

Taimon's code is

can_backstab = ability.bit24 || (item.usableBy(THIEF) && ! ability.ranged)

Asc wants to turn it to something like

can_backstab = (ability.bit24 || item.usableBy(THIEF)) && (ability.bit25 || ! ability.ranged)

Link to comment

If it cannot be used by a thief, who would want to use it for backstab.

Ninjas?

 

Anyway, probably the same trick that worked at the helmet could be used here too. (single bit toggle)

 

[edit]

Maybe not, i didn't really think about this for long :beer:

I will just go with the results.

Link to comment

A weapon can either be suitable for backstabbing, or unsuitable for it. We can't make weapons unsuitable for backstabbing with these flags, but we can:

 

Make some ranged weapons suitable for backstabbing

Make all ranged weapons suitable for backstabbing

Make some additional melee weapons suitable for backstabbing

Make all melee weapons suitable for backstabbing

 

None of these tasks require more than setting a single "backstabbing" flag on the appropriate item abilities. (We could even turn off the "single-class thief usable => suitable for backstabbing" rule if it was done at the same time as a global patch, but it's probably not worth the trouble.)

 

If it cannot be used by a thief, who would want to use it for backstab.

Ninjas?

Fighter/Thieves, F/M/Ts, Cleric/Thieves, and Stalkers all have backstabbing and access to more weapons than single-class thieves. When Full Plate & Packing Steel's "Backstabbing for All" component is installed, the list gets larger.

 

If the "stab" is not taken literally, maces, morningstars, and war hammers might be appropriate weapons with which to ambush someone. Unwieldy things like Two-Handed swords stretch the believability of accomplishing anything sneaky with them, which is why current mods that alter their backstabiness give them harsh penalties.

 

standard bg2 code is

can_backstab = item.usableBy(THIEF) && ! ability.ranged

Taimon's code is

can_backstab = ability.bit24 || (item.usableBy(THIEF) && ! ability.ranged)

Asc wants to turn it to something like

can_backstab = (ability.bit24 || item.usableBy(THIEF)) && (ability.bit25 || ! ability.ranged)

Shame on you for trying to confuse me with logic.

Link to comment

As I see the way this discussion is going, the issue is more about 'Can this weapon be used for backstabbing?' moreso than 'Can I let any class backstab?' The latter appears to be able to achieved without any hacking (Full Plate and Packing Steel), although I haven't used that mod to know whether the standard hard-coded backstabbing stuff is used. Traditionally, all non-ranged weapons usable by thieves can be used for backstabbing. In essence, we just want to give the option of making any weapon available for backstabbing without resorting to the side effect of allowing thieves use of the weapon (particularly in multi-class/dual-class scenarios, not so much new classes/kits).

 

At this point in time, I have designed the hack to detour the entire backstab checking code. I can use any information about the source creature, target creature, orientation of source to target, launcher item, and main item (or more if required) to determine whether a backstab is performed. As as result, the possibility of something more ideal is present if required.

 

For example, if you really want to make a weapon usable by thieves, but want to disable backstabbing, I sure can do. The question here is whether we can use this 'toggle' bit or is another required.

 

I'll post the original pseudocode when I get home.

Link to comment

The code looks a bit like this...

BOOL CCreatureObject_TryBackstab(CCreatureObject& creSource, CItem& itmMain, ItmFileAbility& abilMain, ItmFileAbility& abilLauncher, WORD orTarget, WORD orToTarget, CCreatureObject& creTarget) {
CDerivedStats& cds = creSource.GetDerivedStats();

if ((abilMain.attackType != ITEMABILITYATTACKTYPE_RANGED) &&
	(cds.stateFlags & STATE_INVISIBLE || cds.m_BackstabEveryHit) &&
	cds.m_BackstabDamageMultiplier != 1) {

	if (creSource.o.EnemyAlly > EA_GOODCUTOFF || //not good
		cds.m_BackstabEveryHit ||
		ObjectCommon_InBackstabPosition(orTarget, orToTarget)) {

		if (!(creTarget.GetKitUnusableFlag() & KIT_BARBARIAN) ||
			!creTarget.GetDerivedStats().m_BackstabImmunity) {

			if (!(itmMain.GetUnusableFlags() & ITEMUNUSABLE_THIEF)) {
				//success, game prints event message and calculates multiplier
				return TRUE;
			} else {
				creSource.PrintEventMessage(EVENTMESSAGE_BACKSTAB_WEAPON_UNSUITABLE, 0, 0, 0, -1, FALSE, IECString());
				return FALSE;
			}
		} else {
			creSource.PrintEventMessage(EVENTMESSAGE_BACKSTAB_FAIL, 0, 0, 0, -1, FALSE, IECString());
			return FALSE;
		}
	}
}

return FALSE;
}

Link to comment
ObjectCommon_InBackstabPosition(orTarget, orToTarget)

While you're there, can this check be ||ed against some [Tweak] ini value?

 

You want some (joinable) creature to be able to backstab from front?

If yes, then just attach a backstab every hit effect.

Link to comment
You want some (joinable) creature to be able to backstab from front?

If yes, then just attach a backstab every hit effect.

I want backstab to always work while invisible (like how it worked in pre-TotSC BG1). The 'backstab every hit' effect would work even while non-invisible.

Link to comment
You want some (joinable) creature to be able to backstab from front?

If yes, then just attach a backstab every hit effect.

I want backstab to always work while invisible (like how it worked in pre-TotSC BG1). The 'backstab every hit' effect would work even while non-invisible.

I suppose so. Are you certain that this cannot be achieved using existing modding tools? I'd like to try and avoid modifying the exe too much.

Link to comment
I suppose so. Are you certain that this cannot be achieved using existing modding tools? I'd like to try and avoid modifying the exe too much.

I could use scripts to apply 'backstab every hit' while invisible and remove it while not invisible, but that's not what I'd call 'straightforward'. Besides, the reason why I asked is that I thought that TobEx had to rewrite the full function (even if all you're doing is changing a single value); under that architecture, once you've rewritten CCreatureObject_TryBackstab to add an hack, adding another hack to the same function is essentially 'free' - or am I missing something?

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...