Please ask your basic (newbie) questions in here. - by scumble
Mandrake on 29/4/2005 at 10:59
Quote Posted by Crispy
I've created my own subclass of an existing weapon, and I want to give it to my AIs. It's not available in the weapon loadout window, though. I've tried connecting it to the AI using a RigidAttachment, but it just causes the weapon to be attached to the AI - the AI refuses to actually use it as a weapon. (I've taken away its usual weapon.) Is it actually possible to give custom weapon classes to AIs as weapons, or do I have to modify the existing class?
Edit: Hm, never mind. Turns out it was because I'd changed the WeaponStance; presumably the actor I'm editing doesn't support that WeaponStance. How annoying. I don't suppose there's any way around this?
Also, how do you actually modify what the weapon does? (Its range, its damage, whether it's a melee weapon, etc.)
In my experimentation, it seemed that all you needed to do to make a weapon functional was to make sure blsWeapon = True, and that WeaponStance was set to one of the valid choices. In fact the WeaponStance seemed to be the more important of the two.
Many of the weapon stance choices don't seem to work, so make sure that you're actually using one that works. (By copying off an existing weapon)
As far as I know, all the humanoid AI's seem to be able to use each others weapons (although I havn't tried every possible combination....) for example you can give a sword to a hamerite, or a hammer to a cityguard.
They automatically get the appropriate animations due to the WeaponStance setting, so it looks like we may be stuck with a fixed set of possible weapon action types, unless someone comes up with some more animation frames and a way to activate them.
By the way, attaching an instance of a weapon actor to the appropriate "bone" of an AI works just as well as using the weapon loadout, (they "know" to use the weapon) which means you can directly edit the properties of the instance of the weapon instead of editing the archetypes all the time, which is very handy while experimenting.
You can also add more than one weapon this way. For example try giving a guard both a hammer and a sword, (be sure to attach them to the right bones) and they will carry both holstered. When the AI draws its weapon it seems to choose one at random. One time it will chose the hammer, another time the sword :cheeky:
The same applies for having both a bow and a sword/hammer, unfortunately I havn't found a way to tell the AI *which* weapon to draw based on something, such as the reachability of the player. (Making them draw a sword if you're near, or the bow if you're up a ladder)
Also the AI wont put away the sword and get the bow if necessary, although someone may figure out a way to script it...
Crispy on 29/4/2005 at 11:16
Yeah, I did some more poking around in the gamesys since I posted that and came up with similar conclusions.
It seems my problem is that even humanoid AIs don't support the blackjack animation. (I really should have guessed that myself... but I can hope, right? Right. :rolleyes:) I'll have to make do with dagger or hammer (probably dagger, since its meant to be a one-handed weapon).
Mandrake on 29/4/2005 at 20:30
Quote Posted by Crispy
Yeah, I did some more poking around in the gamesys since I posted that and came up with similar conclusions.
It seems my problem is that even humanoid AIs don't support the blackjack animation. (I really should have guessed that myself... but I can hope, right? Right. :rolleyes:) I'll have to make do with dagger or hammer (probably dagger, since its meant to be a one-handed weapon).
Ah yes, the blackjack doesn't work with any of the AI's.... I thought you were trying to exchange weapons between AI's - which does work.
I'm guessing that the player is a special case in the code and that there are no animation schemas for the blackjack for AI's.
I'm not sure that AI's using blackjacks is all that useful anyway. They would have to have additional scripting to know they need to sneak up on someone else for it to work, otherwise you'll just see thugs with blackjacks attacking guards to the response of "cutest little hit I ever got!", and "is that supposed to hurt!" :cheeky:
Crispy on 30/4/2005 at 09:07
Oh, I wasn't giving them blackjacks - I was giving them my own customised weapon, which would have looked good with a blackjack-like animation. :)
I'm using the sword animation at the moment. It's not perfect, but it'll do.
Hogwash on 1/5/2005 at 17:11
Quick question:
Is there any way I can remove the compass from the HUD and thus have no visible interface?
Maximius on 2/5/2005 at 13:51
Mandrake, how does an AI know whether or not to swing its weapon at Garrett? What I mean is, the AIs obviously "know" when Garrett is within range of their weapons because they dont start swinging or firing arrows when he's not in range. So what tells a Hammerite that its time to start swinging the hammer, cause Garretts right in front of him? Something must tell the AI its time to swing, its seems to me. Either the AI knows or the weapons itself perhaps?
IF these assumptions are correct, then would it not be possible to construct a decision priority tree for range/melee AIs? For example:
Guard sees Garrett. Guard or its weapon "knows" that Garrett is X distance away or at least out of range. If X > the bows range, then Guard runs towards Garrett, sounding alarms and threats. If (or when) X = max. bow range or X < max. bow range, Guard uses ranged fire. For all intents and purposes its a ranged AI until such time as Garrett comes within Y, the range of the melee weapon. When the Guard or the weapon detect Garrett at Y, a new value triggers a new script and weapons are switched, melee commences, until the time that Garrett moves to a distance > Y. ( There would have to be a delay for the AI to switch from melee to range though because the player could exploit the switch, keeping the AI in a permanant state of exchanging weapons while pumping arrows into him.)
I have no idea how to script such a thing but again assuming that somehow the AI knows the distance, or at least whether or not Garrett is within reach of a particular weapon class, it seems that those values could be used to initiate a chain of reactions like the above.
Crispy on 5/5/2005 at 12:30
Sounds reasonable. There's a property (don't quite remember the name now) that lets you override the distance over which AIs consider melee to be possible. I'm not sure what happens if you don't override it; possibly the distance is extrapolated from the animation and the size of the weapon mesh.
In any case, the condition "While linked object(s) [MYSELF] are within [Float] unreal units from linked object(s) [PLAYER]" sounds like it should work for detecting range.
Then, to swap the weapons, the most straightforward way would be to destroy one weapon and create the other, possibly using these actions:
To destroy the old weapon: Delete linked object(s) [RigidAttachment]
To create the new weapon: Spawn object of [Class] and create a [RigidAttachment] link from spawned object to this object
Unfortunately, this would also delete all other rigidly attached objects; like eyeballs and teeth. This might look slightly odd. :joke:
You could probably write a script to recreate those other objects ("Spawn object type at end of [LinkFlavor] at hard point [String] on linked object(s) [LinkFlavor]" perhaps), but I can't think of a way to do so seamlessly; you'd have to specify every individual RigidAttachment object. And so the scripting required would vary between AI types. :erg:
Don't have time to test it myself right now; I'll do so later if nobody decides to take up the challenge in the meantime. :)
Maximius on 5/5/2005 at 17:47
Hmmm, Im betting there isnt any kind of animation or scripting for the bowmen to "sling bow" across their backs or anything. Is tht why you have to destroy it?
Crispy on 6/5/2005 at 07:51
There are draw/sheath weapon animations; to see one, just alert a guard so he draws his weapon. Then run away, and hide somewhere where you can see him searching, and eventually he'll sheath it. :) It is possible to play animations through scripts; you'd just have to find the name of the appropriate animation.
Anyway, I wasn't even thinking about animations when I wrote that; I propose deleting the weapons only so that we're assured of the AI using the weapon we want them to use. If they're using a sword and we just give them a bow, it will probably just keep using the sword (and I don't see any way to tell them to switch weapons). But if we also delete the sword, they'll have no choice but to select the bow.
Maximius on 6/5/2005 at 13:29
Crispy, are you saying that the AIs are only aware of the first weapon they have attached to them? They dont even know they have the other, its just "glued" to their hips? In other words, each AI only has one memory "slot" for a weapon? If so, yikes.
BUT I still want to know how the AIs know how far away Garrett is, why they dont start swinging swords and hammers and firing arrows even if hes only just in sight, not range. I if we can identify the coding that governs how the AIs "know" Garretts range, maybe some kind of loop could be coded that even after the AI has unsheathed a particular weapon, it will continue to check for Garretts range even as it attacks.(e.g. firing bow) When the AI receive a particular new value from its "scan" it fires a command to sheath weapon, then somehow make the thing "forget" its bow and trigger unsheath sword. If the AI only has one "slot" for memory, somehow we have to find a way to trigger a sequence that will actively pop different values in and out of that "slot."
I know the swords/hammers have animations for sheathing, I could not remember about the bowmen though. BTW how would one access these animations? I would like to try to tweak a hammerite to see if I can increase the frequency of the overhead swing attack, to try to deal with the crouching defense.