Mandrake on 29/3/2005 at 12:48
Some progress on my idea - making a fallen sword/weapon so you can pick it up is easy. In the actor class browser, going to properties on Actor->WorldObj->SetDressing->AIParts->Broadsword (as an example) and adding the property Highlight->HighlightDist and setting it to something like 128.
Now the sword can be picked up after its dropped. However it can also be picked right off the back of the AI in the same way that mages wands can be stolen :)
To get around that it should be possible to just leave the HighlightDist set to 0 by default, and use a Triggerscript attached to the weapon archetype that checks for the parent dying, and changes HighlightDist to 128 after a brief delay. Assuming I get that to work thats half the problem solved already.
The other part is making the weapon stay on the body if the weapon is not drawn at the time they are killed/knocked out. Assuming that the weapon detatching from the body is hard coded somewhere, it may be possible to use another triggerscript on the weapon archetype that when detecting that the parent object has died, and that the weapon was not drawn (AI alert status ?) that it should immediately reattach itself to the parent as a rigid attachment. A long shot perhaps, but worth a try :thumb:
Bumbleson on 30/3/2005 at 01:11
First of all, although being added via the weapon loadout, weapons seem to be attached to an AI with a normal RigidAttachment link. At least this is what the command "findlinks" told me.
I see several possible difficulties in your approach. I don't know how many of them really apply, but you should at least consider them:
- When an AI dies or gets knocked out, the attachment link gets destroyed. As far as I can see, all script conditions that detect events on other objects are working through links. It may be impossible for a sword to detect when the AI it belongs to gets killed or blackjacked, because the attachment link gets destroyed before it is able to query the state of the AI
- If it IS able to query the AI state in time, the next problem is to create a proper attachment link back to the AI, because after the link has been destroyed, the sword has no means of knowing which AI it was attached to.
- I tried to let the sword send a message to the AI, then delete itself and let the AI spawn and attach a new sword. It didn't work at all (which may be my fault), but what is more important: I found no way to define the bone I wanted to attach the sword to in the script.
Mandrake on 30/3/2005 at 04:28
Quote Posted by Bumbleson
First of all, although being added via the weapon loadout, weapons seem to be attached to an AI with a normal RigidAttachment link. At least this is what the command "findlinks" told me.
Cool. Is 'findlinks' a command in the console of the debug version of the executable ? I suspected it was just a standard RigidAttachment link, but one where it is hard coded rather than being explicitly listed.
The reason being, the weapon has to change attachment from the back (or side) to the hand when drawn and back again when put away.
Quote:
I see several possible difficulties in your approach. I don't know how many of them really apply, but you should at least consider them:
- When an AI dies or gets knocked out, the attachment link gets destroyed. As far as I can see, all script conditions that detect events on other objects are working through links. It may be impossible for a sword to detect when the AI it belongs to gets killed or blackjacked, because the attachment link gets destroyed before it is able to query the state of the AI
I thought about that too. My thinking at the moment is to have script on the sword that makes it dissapear when "dropped" from the body, and another script on the body that as part of the death sequence, attaches a new sword back onto the body. I can't see any reason why this wouldn't work, although it might cause a brief flicker of the sword.
(Happens anyway when the sword goes from its hilt to the AI's hand and back anyway :) )
Quote:
- If it IS able to query the AI state in time, the next problem is to create a proper attachment link back to the AI, because after the link has been destroyed, the sword has no means of knowing which AI it was attached to.
Taken care of as above.
Quote:
- I tried to let the sword send a message to the AI, then delete itself and let the AI spawn and attach a new sword. It didn't work at all (which may be my fault), but what is more important: I found no way to define the bone I wanted to attach the sword to in the script.
Really ? I didn't have any problems with that, I basically just followed the same procedure as manually adding a torch to a guard thats on the wiki.
I took a hammerite, removed his weapon from Edit Weapon loadout, then I added one back in manually - first I added an Actor->WorldObj->SetDressing->AIParts->Broadsword actor into the world, then I went to the actor links for the hammerite, add link, and created a rigidattachment link to the broadsword.
To get the sword to position itself on his back instead of *ahem* sticking up his ass :laff: I then went Edit selected link for the link between the two, properties->attachment, and set them to:
m_attachmentBone hp_itemattach
m_parentBone HP_Back
Now the sword appears on his back as it should. There are dozens of different parentBone choices for every conceivable position on his body you can think of. I'm not entirely sure what the distinction between m_attachmentBone and m_parentBone are, but my best guess is that m_attachmentBone refers to the bones on the child object (eg the sword) while m_parentBone applies to the bone on the parent. (eg the hammerite)
A simple model like the sword is probably a single bone, and hp_itemattach might be a "default" attachment point for a model, but if it was a more complex object it may allow you to specify which bone you're connecting to.
Maybe it would even be possible to link two guards together at the hip :ebil:
An interesting thing I noticed is that simply attaching the weapon using an Actor link was enough for the hammerite to be able to draw and use the weapon, even though it wasn't attached to the correct bone. Also if there is more than one weapon attached, he seems to choose one at random each time a weapon needs to be drawn.
It looks like the code for the AI simply scans all the actor attachments looking for one that has the flag WeaponStance not set to eWS_NONE and treats it as a weapon...
Manually adding the weapon as an actor attachment and setting the correct attachment bones seems to be functionally identical in game to placing it in the weapon loadout, but perhaps gives us a bit more controllability from Trigger Scripts, so I think my original idea might just work out... :)
nomad of the pacific on 30/3/2005 at 06:04
But how to define a bone attachment from within a script? That's the catch! :p
Mandrake on 30/3/2005 at 06:11
Quote Posted by nomad of the pacific
But how to define a bone attachment from within a script? That's the catch! :p
Well, how about the Triggerscript action that says:
Make a rigid attachment FROM bone [String] on object thru [LinkFlavour] TO bone [String] on [LinkFlavour]. Delete that object when I am destroyed: [Bool]
:cool:
The tooltip says it should be used for objects already instanced, so it should work by manually attaching a sword as a rigidlink attachment as in my previous message, and creating a triggerscript link between the AI body and the sword, then when they die, the triggerscript link will keep a reference between the two (so the sword "knows" who it belongs to) and a Triggerscript can be run at the time the AI dies to reattach the rigid attachment before it gets a chance to fall....
Off to try it...
nomad of the pacific on 30/3/2005 at 06:56
Didn't see that script! Cool! :)
Mandrake on 30/3/2005 at 09:16
Quote Posted by nomad of the pacific
Didn't see that script! Cool! :)
Drat. That script is broken :devil:
The second [LinkFlavour] cant be clicked, and the script editor wont accept the script. (It says not all the parameters are filled in) in fact sometimes it freezes the script editor.
Back to the drawing board...
Mandrake on 30/3/2005 at 10:54
I've confirmed that it looks like there is some hard coding in the engine somewhere that removes rigid attachments to actors that have the Weapon->Weaponstance property. :(
For example, connecting a barrel to an AI using a rigidattachment stays connected after the AI is knocked out. Looks like duplicating the barrel man of Calendras legacy will be easy in TDS :cheeky:
As soon as I add the property Weapon->WeaponStance (set to any value) to the barrel, it now falls off when the AI dies.
Maximius on 30/3/2005 at 15:21
Mandrake, here is a stupid question, but I take it that Hard Coded means Impossible to Change, is that correct?
Dark Arrow on 30/3/2005 at 17:07
This is rather easy to fix I believe.
Add the following property to the weapon:
Junk>IsJunk:True
Create the following script and place it to the weapons:
Condition:
When my object contacts the ground
Action:
Set[IsFrobbable] to [True] on linked objects of [Myself]
Set [HighLightDistance] to [128] on linked objects of [Myself]
This is a quick fix. The script may not function if the ground below is not actual ground but a static mesh (I never tested this on a static mesh).