RE: Thrown Weapons - Is This Possible?
#1
Posté 09 février 2013 - 03:31
I have changed throwing axes and darts so that are single stack items that function pretty much identically to their pnp counterparts. I can recover them from corpses just fine, but I can't wrap my head around how to recover them in the case of a miss.
In the event of a miss, Is it possible to create a copy of the item - which the PC can recover later - in a location near the target without using a custom spell script (and thus modifying 2da files)?
#2
Posté 09 février 2013 - 04:07
#3
Posté 09 février 2013 - 04:13
Modifié par Pstemarie, 09 février 2013 - 04:25 .
#4
Posté 09 février 2013 - 04:21
[Edit] Another potential issue is throws that deal no damage, depending on your item props, and depending on how you're planning to handle hits (you said you had that down).
Funky
Modifié par FunkySwerve, 09 février 2013 - 04:24 .
#5
Posté 09 février 2013 - 04:22
How about turning that around... Mark it for cloning on the ground near-by and (if it *doesn't* damage target, clone it there. If it does, clone it in inventory of target.
Edit: Funky's quick! :-)
I'd let determinecombatround do the timing, but, either way, mark it as going *somewhere* and then let OnDamage change the destination from ground (spell cone - nice!) to inventory.
<...negligently>
Modifié par Rolo Kipp, 09 février 2013 - 04:25 .
#6
Posté 09 février 2013 - 04:26
Heh. If it dealt no damage, the axe bounced off :-)
<...on his toes>
#7
Posté 09 février 2013 - 04:34
#8
Posté 09 février 2013 - 04:36
FunkySwerve wrote...
Onunaquired, if the pc is in combat, set a local object var on the pc with the local object as the item in mainhand, and delaycommand a check to see if the var, Thrown, is still set a half-second later. In a generic (modwide) ondamaged, check damager for var, and if set, delete. When the delayed var check fires, if the var is still set and the pc, you have a miss, and you can copyobject and setstacksize, placing the item in a spellcone in front of the pc. Only likely issue I can see is getting the timing down - a half second could be too short or to long, though troubleshooting to eliminate other unacquires might take some time and code.
[Edit] Another potential issue is throws that deal no damage, depending on your item props, and depending on how you're planning to handle hits (you said you had that down).
Funky
Ye lost me...
#9
Posté 09 février 2013 - 04:36
henesua wrote...
I really like this idea, and I'm gonna steal it.
Good when you figure out the miss part, I'll "steal" it back
#10
Posté 09 février 2013 - 04:59
And do the same thing with arrows & bolts, with a chance for "lost" or "broken". :-) Then you can raise the cost of ammunition to something less absurd than 1gp for a hundred! Generate economy ;-)
<...to the poor bowyers>
#11
Posté 09 février 2013 - 09:25
Darts, Throwing Axes, and Shuriken = 5
Arrows = 10
Bolts and Bullets = 20
Therefore, I've gone with what Sharona Curves posted over in this thread.
Unfortunately, it doesn't allow for misses but I think I'll be able to figure out what Funky was talking about - it makes a little more sense now.
Modifié par Pstemarie, 09 février 2013 - 09:30 .
#12
Posté 09 février 2013 - 10:09
Most of what I have been looking at ( off and on ) went with the assumption that the items where no longer stacked.
Let me start some other tests in reguards to the items being stacked. Reguardless you will most likely need to use the OnPhysicalyAttacked event to track the weapon leaving the target. Once 4 attacks per round are reached It will most likely fire only one time per fury.( 3 max furys per round) giving more then one item lost per OnPhysicalyAttacked event.
#13
Posté 09 février 2013 - 10:33
Lightfoot8 wrote...
by making the thrown items stackable, it removes the ability to get the item leaving the player by the unequip and unaquire events. they will only fire when the last item in the stack is used.
Most of what I have been looking at ( off and on ) went with the assumption that the items where no longer stacked.
Let me start some other tests in reguards to the items being stacked. Reguardless you will most likely need to use the OnPhysicalyAttacked event to track the weapon leaving the target. Once 4 attacks per round are reached It will most likely fire only one time per fury.( 3 max furys per round) giving more then one item lost per OnPhysicalyAttacked event.
Gah, sorry I messed you up LF. I can easily revert if you can work something out.
#14
Posté 09 février 2013 - 11:11
I'm not sure if OnPhysicalAttacked fires on misses, but that's still likely the NPC script I'd hook, rather than OnDamaged. However, if GetAttemptedAttackTarget() works for PCs, you could handle all of it from the OnUnaquire script, just creating the weapon on the ground every time instead of in the target creatures inventory.
#15
Posté 09 février 2013 - 11:52
// Check if oAttacker "missed" the caller with a dart or handaxe attack
object oAttacker = GetLastAttacker();
object oDamager = GetLastDamager();
SendMessageToPC(GetFirstPC(), GetName(OBJECT_SELF)+ " Attacker = " +GetName(oDamager));
SendMessageToPC(GetFirstPC(), GetName(OBJECT_SELF)+ " Damager = " +GetName(oDamager));
if (oDamager == oAttacker)
{
//do nothing - we hit
}
else
{
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oAttacker);
if (GetIsObjectValid(oItem))
{
if (GetBaseItemType(oItem) == BASE_ITEM_DART || GetBaseItemType(oItem) == BASE_ITEM_THROWINGAXE)
{
location lLoc = GetRandomLocation(GetArea(OBJECT_SELF), OBJECT_SELF, 3.0);
object oThrown = CopyObject(oItem, lLoc);
SetItemStackSize(oThrown, 1);
SetIdentified(oThrown, 1);
}
}
}
The only oddity I've noiticed is that on the first attack oAttacker and oDamager seem to both = OBJECT_INVALID as the SendMessageToPC output is empty.
Modifié par Pstemarie, 09 février 2013 - 11:55 .
#16
Posté 10 février 2013 - 01:54
// Check if oAttacker "missed" the caller with a dart or handaxe attack
object oAttacker = GetLastAttacker();
if (GetIsObjectValid(oAttacker) && GetDamageDealtByType(DAMAGE_TYPE_PIERCING) <= 0 ||
GetDamageDealtByType(DAMAGE_TYPE_SLASHING) <= 0)
{
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oAttacker);
// Check the stack size - starting at 2 - to make sure you don't get back more
// ammo than you started with
if (GetIsObjectValid(oItem) && GetItemStackSize(oItem) > 2)
{
if (GetBaseItemType(oItem) == BASE_ITEM_DART || GetBaseItemType(oItem) == BASE_ITEM_THROWINGAXE)
{
location lLoc = GetRandomLocation(GetArea(OBJECT_SELF), OBJECT_SELF, 3.0);
object oThrown = CreateObject(OBJECT_TYPE_ITEM, GetResRef(oItem), lLoc);
SetItemStackSize(oThrown, 1);
SetIdentified(oThrown, 1);
}
}
}
Modifié par Pstemarie, 10 février 2013 - 02:06 .
#17
Posté 10 février 2013 - 02:04
OnPhysicalAttacked Event happens first. No damage has yet been done.
If it was the last item in the stack. unequip fires followed by unaquire.
Hit roll then happens
if damage is done then the OnDamage event fires.
Doing everything in the on OnPhysicalAttacked can not catch the damage for the current attack.
At least that is my current understanding.
You are going to need to use more then one event and mostlikely a delayed event to chtch the miss for the current attack
#18
Posté 10 février 2013 - 02:12
OnPhysicalAttacked only handles a miss while OnDamaged uses Sharona's function to drop the missile in the target's inventory.
I'm not sure why GetDamageDealtByType is catching anything in the OnPhysicalAttacked but my SendMessage debugs - which I removed show 0 damage on a miss. I have run several tests using full stacks and partial stacks with all attacks hitting and all attacks missing. So far everything works.
#19
Posté 10 février 2013 - 02:17
Testing.
#20
Posté 10 février 2013 - 02:21
I do recall GZ saying something on the old forums about certain function calls being able to rearrange the way events fire, something about priorities and what not. I didn't really understand it, but I think it was why bioware tagged some functions with "Use only this Event" or "Only works in this Event".
The only glitch I have noticed is if you fire the last shot the PC will charge the target. Then if you draw another weapon while charging the PC stops then jumps to the target on the next Heartbeat. Looks like lag to me, but I'm not sure.
Modifié par Pstemarie, 10 février 2013 - 02:26 .
#21
Posté 10 février 2013 - 02:35
Your first attack on a target is going to gove you the damage done the attack before. So if the target has not been attacked before the first attack is always going to regester as a miss.
reguardless of wether the next attack hits or misses it is going to use the round before as the indecator of the hit or miss.
#22
Posté 10 février 2013 - 02:45
EDIT - Ran some more tests doing what you said. It is flawed like you say, but I can live with it since you never get back more ammo than you threw. At this point I'm really just trying to avoid a PC that throws say 5 handaxes or darts at a target and collects back more than 5 between the monster's corpse and the missed axes lying about the ground. While I did have one test that came up one axe short, the rest have all come up with no more than what the PC started with. So, I'll take what I get and move onto the next hack.
If you can't beat it, hack it :innocent:
Modifié par Pstemarie, 10 février 2013 - 03:20 .
#23
Posté 10 février 2013 - 06:30
#24
Posté 10 février 2013 - 08:51
Failed.Bard wrote...
Would it work doing it as a subroutine on a 0.01 delay, or would that get messed up worse once multi-attack flurries are taken into account?
It seems that any variation from what I have posted in the "final" code above results in too much ammo being created on a miss.
#25
Posté 10 février 2013 - 06:30
Pstemarie wrote...
Failed.Bard wrote...
Would it work doing it as a subroutine on a 0.01 delay, or would that get messed up worse once multi-attack flurries are taken into account?
It seems that any variation from what I have posted in the "final" code above results in too much ammo being created on a miss.
Try this. In the OnAttacked event for creatures replenish the ammunition for this weapon no matter what. In the
EDIT: Actually, since the creature can be damaged by spells, it would be better to replace the OnDamaged decrement with an On Hit decrement given as a unique power to the weapon.
Modifié par WhiZard, 10 février 2013 - 06:39 .





Retour en haut







