Page 1 of 2

Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 2:48 am
by David Ward
I'm making "secondaryActions" for weapons and, when testing these actions, they don't seem to add any strength or dexterity to their attack power. Example:

Code: Select all

defineObject{
	name = "taw_small_sword_d_rapier",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/rapier.fbx",
		},
		{
			class = "Item",
			uiName = "Rapier",
			gfxIndex = 338,
			gfxIndexPowerAttack = 429,
			impactSound = "impact_blade",
			weight = 4.5,
			secondaryAction = "hardthrust",
			description = "A lightweight, thin-bladed favourite of pirates and highwaymen the world over.",
			traits = { "dagger" },
		},
		{
			class = "MeleeAttack",
			attackPower = 16,
			pierce = 10,
			cooldown = 4.0,
			swipe = "thrust",
			attackSound = "swipe_light",
			requirements = { "lgt_weapons", 2 },
		},
		{
			class = "MeleeAttack",
			name = "hardthrust",
			uiName = "Thrust",
			energyCost = 15,
			pierce = 100,
			attackPower = 16,
			buildup = 2,
			cooldown = 4,
			swipe = "thrust",
			attackSound = "swipe",
			requirements = { "lgt_weapons", 2 },
			gameEffect = "Buildup: 2.0 seconds      A strong attack that deals increased damage and negates armor entirely.",
		},
	},
	tags = { "weapon" },
}
The "Thrust" secondaryAction special attack has attackPower = 16, but it does not add Strength as the standard "MeleeAttack" action does.

Is there a way to add Strength or Dexterity to the attack power for class = "MeleeAttack", or even "RangedAttack" or "ThrowAttack"?

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 3:11 am
by minmay
baseDamageStat = "strength"

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 3:24 am
by David Ward
Naturally, piece of cake. Now, is there a way to multiply that? Like adding strength x 2?

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 3:31 am
by minmay
no

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 4:15 am
by Azel
David Ward wrote:Naturally, piece of cake. Now, is there a way to multiply that? Like adding strength x 2?
Hmm, maybe during the attack swing you can increase the characters strength, then reduce it again after the attack ends? Could be a fun work-around :mrgreen:

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 5:50 am
by David Ward
Azel - What would be the best way to go about that in terms of actual coding?

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 6:24 am
by Azel
Not sure what the "best" way would be, but I will tell you the route I would take to explore the possibility:

1) Review the Party Hooks by JKos: viewtopic.php?f=22&t=7642#p78368

2) Focus on the Attack Hook:
onAttack = function(party,champion,weapon)
print(champion:getName(),'is attacking with',weapon.go.id)
end,

3) Replace that "print" section with something similar to the delayedCall function:

Code: Select all

   champion:upgradeBaseStat("strength", 1)   
   delayedCall("yourscript",20,"yourfunction",champion:getOrdinal())
viewtopic.php?f=22&t=8952&p=88045&hilit ... tat#p88072

Just set the Strength Upgrade as desired (in your case, add the current value to itself), and then make sure the delay interval is about 1 second (probably safe as long as it is less than the weapon cooldown).

... yeah that's where I'd start. But don't tell minmay (sshhhh) cause he'll accuse me of breaking Mod's :shock:

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 7:32 am
by David Ward
I appreciate the mod-breaking attempt, Azel. I'll give a closer look on what you've suggested and see if it can work. Thank you.

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 10:03 am
by minmay
temporarily modifying weapon damage/stats/critical/etc is a bad idea since it means the attack power/critical/whatever display on the character sheet will be incorrect

if you want to change stat scaling for all weapons the same way, there is strictly speaking no reason to do something like that since you can just adjust weapon/spell base attack power and monster/obstacle health instead to get the same balance effect (unarmed and bear form being exceptions I suppose)
if you want to change it differently for different weapons (why) this is still a pretty terrible way to do it; making the attack power display wrong is the sort of thing that should be considered a major, release breaker bug. instead you should hold the base attack power of the weapon itself at the correct value for your modified stat bonus (and include a gameEffect field that notes the different scaling); just run a hook every frame that goes through wielded weapons and applies the adjustment. adding a TimerComponent to the party object definition with an interval of 0.00001 or something is the easiest way to do this; timers activate a maximum of once per frame, and a TimerComponent attached to the party will always be on the same level as the party so it will always update. don't use onRecomputeStats here since you won't get correct stat values since they're in the middle of being computed (this should really be obvious but I've already seen one person try to do it...). you also shouldn't use onDrawGui (or any other onDraw hook) because onDrawGui is not actually called every frame; it is not called during frames where the player is free-looking or other places where the HUD is disabled.

i can't imagine any circumstance where you would want to involve delayedCall (or connectors in general) in this.

Re: Weapon "secondaryAction" Stats

Posted: Sat May 02, 2015 10:45 am
by Azel
I'm sure there is some truth to this being a bad idea, but often times you do say something is bad just because you don't like it; which doesn't really make it bad. Assuming this is really bad (and not just minmay bad), then some things dont really add up at first glance...

In my suggestion I am talking about temporarily modifying the Strength attribute of a Champion, yet the premise of your reply explicitly implies that I was suggesting modifying Attributes of the Weapon itself. Apples n oranges?

The Rage potion temporarily modifies the Strength Attribute of a Champion - which temporarily increases the damage output of all Strength-based weapons; according to you that is a bad idea...? In my suggestion I am basically brainstorming through the concept of applying the Rage Potion effect to a Champion in such a way that it only activates during a weapon attack (and deactivates when the attack is complete). Simple concept that involves combining 2 default Grimrock features; all this requires is an appropriate scripting approach. Granted, I do not know what the proper script is to accomplish this (yet), but the things you suggested seem way off base.

You brought up an inconsistent character sheet; but that is obviously not a problem when the Rage Potion is involved. So I can only assume then that this character sheet issue becomes a concern when instead of drinking a Rage potion before an attack, the player is using the Rage Potion feature during the attack. If so, I have a hard time believing that a problem really exists. Also, implementing a hook for "every frame" seems like unnecessary over-head.

Rage Potion effect as part of an attack VS frame-by-frame hook for damage modification? With all due respect to Lord Minmay, I still like my idea better :twisted: