Mandrake on 30/3/2005 at 19:57
Quote Posted by Dark Arrow
This is rather easy to fix I believe.
Add the following property to the weapon:
Junk>IsJunk:TrueCreate 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).
Yep, I've had no trouble making the weapon frobbable, (for cases when the AI was holding it when they were killed and therefore should be able to drop it) but the stumbling point seems to be reattaching a weapon with a rigid attachment if they die when the weapon is still sheathed. The only triggerscript action that looks like it could easily reattach it, is broken :(
Thats not to say its impossible though...
Bumbleson on 31/3/2005 at 00:30
The same happened to me :p
I found that trigger action, but it seemed to be unusable (and I didn't quite understand what exactly it was supposed to do).
But somehow I'm at war with scripts anyway, mostly because of their ambiguous wording. Terms like "my object" (the object the script is attached to or what?) "when I receive ... stim ..." (who is "I"? the object? the script?) confuse me and often I'm not sure whether I put together a useful script or complete nonsense. So far none of my self-made scripts ever worked, not even the simple ones, which is not very encouraging. :(
ascottk on 31/3/2005 at 01:29
The my object, I, and other stuff refer to the object the script is attached to. When you put a script on an object, the object owns the script or does the script own the object? As in: When I (the object the script is attached to) receive this condition I'll do this action.
Bumbleson on 31/3/2005 at 02:22
A partial success: I was able to spawn and attach a sword to a guard (CastleGuard) when he gets blackjacked. I didn't pay attention to any other conditions yet (weapon not drawn etc.), I just concentrated on attaching the weapon. The trick was to make a RigidAttachment link from the guard to the weapon archetype *in addition* to the weapon in the loadout, attached to the same bones. The second sword won't appear on the guard (I'm not sure why, but who cares) unless spawned and attached by a script. This is what I did:
Script on the Longsword archetype (my first working script, yay! :D):
Condition: When my object contacts the ground
Action: Delete linked object(s) MYSELF
RigidAttachment link FROM the (concrete) guard TO the Longsword archetype. Link properties:
Attachment/m_attachmentBone = hp_itemattach
Attachment/m_parentBone = HP_LeftHip
Link/m_name = gimme_my_sword
Script on the (concrete) guard:
Condition: When AI is disabled by the player with stimulus type Blunt
Action: Spawn and attach object type at end of Rigid Attachment Link(s) with name [gimme_my_sword] to me
Now when the guard gets blackjacked, his weapon will fall to the ground and vanish. Then a new sword will appear on his left hip. This is far from perfect (the sword shouldn't fall, but I don't know how to prevent this), but it's a start. See what you can make out of it. I'm going to bed now :bored:
Mandrake on 31/3/2005 at 11:00
Quote Posted by Bumbleson
Now when the guard gets blackjacked, his weapon will fall to the ground and vanish. Then a new sword will appear on his left hip. This is far from perfect (the sword shouldn't fall, but I don't know how to prevent this), but it's a start. See what you can make out of it. I'm going to bed now :bored:
Good work :thumb: I'll have a look tommorow and see if I can improve on it.
Bumbleson on 1/4/2005 at 01:08
I think I'm very close to the solution! Today I managed to prevent the weapon from falling. At the moment it works perfectly when I blackjack or backstab an unsuspecting guard, and even when I kill an already unconscious guard. The only thing left to do is to include the "do nothing when AI has weapon drawn" condition. I see a couple of possible ways to accomplish this, but I think I need some help with the correct use of the logic operators first.
If I want a condition like this:
perform action when A is true OR B is true, but NEVER when C is true
How would I write this in the script manager?
Mandrake on 1/4/2005 at 07:48
Quote Posted by Bumbleson
I think I'm very close to the solution! Today I managed to prevent the weapon from falling. At the moment it works perfectly when I blackjack or backstab an unsuspecting guard, and even when I kill an already unconscious guard. The only thing left to do is to include the "do nothing when AI has weapon drawn" condition. I see a couple of possible ways to accomplish this, but I think I need some help with the correct use of the logic operators first.
If I want a condition like this:
perform action when A is true
OR B is true, but
NEVER when C is true
How would I write this in the script manager?
I havn't tried it, but the way I would probably do it would be to put a Logic AND operator on the condition, and attach to the first level below that a test for C being "False" or "NotEqualTo" (depending on whether you're checking a bool or a value) then as the second attachment to the AND condition, put an OR condition, and then attach to that checking if A is true, and then checking if B is true.
This is if my understanding of how the scripting works is right :)
Care to share what you've done so far ?
Oh and by the way (I might start a new thread for this, but...) does anyone know how to easily export and import scripts ? It would be REALLY nice if it was possible to export scripts to a file, and upload them somewhere so that people could share scripts directly in an error free way, rather than the tedious and error prone explanation of how to manually duplicate scripts we're seeing on tutorials now...
Jadon on 1/4/2005 at 09:50
Your scripts should be in \content\T3\TriggerScript\Defs and its looking like you best luck will be with notepad (atleast thats the luck I had with it.) Theres a lot more special formating and characters when I tried other programs to read them. And I don't know how to import or edit outside the editor because of the special characters and I'm no <strike>programer</strike> code writer.
Forgot to mention you can right-click on you script in the script browser and it will tell you the filename of your script.
Bumbleson on 1/4/2005 at 23:48
Waaah! It's all so easy! No need for complicated scripts and messages.
There's even a property that keeps guards from dropping their weapon. :D :thumb: I really agonized over this problem before I found this property by pure chance :tsktsk: But first things first.
First I made another link (triggerscript) to the sword and let the guard send a message over it when being killed or blackjacked. The sword would delete itself when receiving the message and at the same time the guard would spawn a new sword and attach it to himself. The transition was undiscernible and the sword didn't fall. So far so good. But when I tried to incorporate the state of the AI, I nearly pulled my hair out. There seems to be no way to detect if an AI that is being killed or blackjacked was in an alerted state (i.e. had a weapon drawn) before, because when the condition ["AI is killed" OR "AI is blackjacked] fires, the state of the AI has already changed and it no longer makes sense to additionally check for an alert state.
But those are things of the past :)
As I said, there's a property to keep guards from dropping their weapon when they die or get blackjacked. It's Inventory -> DontDropOnDeath. Add this to a weapon archetype and set it to TRUE and a guard who carries it will cling to his weapon forever.
So how can we get him to drop it when he's killed during combat? Make two simple scripts (and forget about all the other scripts and links I listed in earlier posts):
Script: DropWeapon
Condition: When my behavior state changes to [STATE_EQUIP_WEAPON]
Action: Set [DontDropOnDeath] to [FALSE] on linked objects [RigidAttachment]
Script: KeepWeapon
Condition: When my behavior state changes to [STATE_HOLSTER_WEAPON]
Action: Set [DontDropOnDeath] to [TRUE] on linked objects [RigidAttachment]
Put these scripts on the guard archetype. Now the guard will keep his weapon when it was sheathed and lose it when dying during a fight.
Note: This might lead to unwanted side effects on other objects attached via RigidAttachment (health potions etc.). I have not yet tested this thoroughly so be careful. Maybe it's better to make an additional TriggerScript link and change the link flavor in the scripts. Try it.
The rest of it (make weapon frobbable and noticeable to other guards) should not be too hard to accomplish. I may write a wiki tutorial on this when I have more time. :)
Mandrake on 2/4/2005 at 00:24
Quote Posted by Bumbleson
Waaah! It's all so easy! No need for complicated scripts and messages.
There's even a property that keeps guards from dropping their weapon. :D :thumb: I really agonized over this problem before I found this property by pure chance :tsktsk: But first things first.
Great work! I continue to be amazed by what is possible with the scripting and properties system in this game.
Quote:
As I said, there's a property to keep guards from dropping their weapon when they die or get blackjacked. It's Inventory -> DontDropOnDeath. Add this to a weapon archetype and set it to TRUE and a guard who carries it will cling to his weapon forever.
DOH. I didnt find that one either :thumb:
Quote:
So how can we get him to drop it when he's killed during combat? Make two simple scripts (and forget about all the other scripts and links I listed in earlier posts):
Script: DropWeapon
Condition: When my behavior state changes to [STATE_EQUIP_WEAPON]
Action: Set [DontDropOnDeath] to [FALSE] on linked objects [RigidAttachment]
Script: KeepWeapon
Condition: When my behavior state changes to [STATE_HOLSTER_WEAPON]
Action: Set [DontDropOnDeath] to [FALSE] on linked objects [RigidAttachment]
Err, I think that should be TRUE, not FALSE on your KeepWeapon script.
Quote:
Put these scripts on the guard archetype. Now the guard will keep his weapon when it was sheathed and lose it when dying during a fight.
Note: This might lead to unwanted side effects on other objects attached via RigidAttachment (health potions etc.). I have not yet tested this thoroughly so be careful. Maybe it's better to make an additional TriggerScript link and change the link flavor in the scripts. Try it.
Yeah, what you have at the moment will cause them not to drop the health potions, but you know what ? I think thats a good thing - in the first two games if you knocked out a guard carrying a health potion or coin bag, it stayed on the guard (why would it fall anymore than a holstered weapon just because he's unconcious ?)
As long as the item can be frobbed off the guard, thats fine by me. Oh, your script would also currently make health potions fall if they have their weapon drawn, but not if it wasn't drawn :) (side effect)
If you want to use triggerscripts to set properties on only the weapons, then you'd have to manually equip the weapon on the guard - if you use the edit weapon loadout, you can't attack a link to the weapon. (AFAIK) But if you just manually place a weapon actor in the world and attach it to the right bone with a rigid attachment you can.
I'm doing it this way at the moment anyway so that I can add scripts and properties directly to an instance of the weapon instead of modifying the global weapon archetype.
Quote:
The rest of it (make weapon frobbable and noticeable to other guards) should not be too hard to accomplish. I may write a wiki tutorial on this when I have more time. :)
Yeah, making the weapon frobbable on death isn't too hard, I'll finish working out the details of that...
Great work, hopefully FM's now won't have to have that awful sword falls to the floor when knocked unconcious behaviour. (Assuming an FM author also doesn't like it)