-
Notifications
You must be signed in to change notification settings - Fork 0
KAI_Emplacement
This is the base class for emplacements, useful for easily creating static* emplacements, such as turrets, mortars, etc. Emplacements can be used by both KAI_Humanoid NPCs and players. Emplacements work by morphing NPCs and players into the desired actor, normally a version of the NPC or player manning the emplacement. It's effectively a special reusable morph power up.
*Though they can also be used to make moving things, such as using it as a base for a basic vehicle system, but that's up to you to do.
Both NPCs AND players are able to use emplacements. KAI_Humanoid NPCs do so by calling EnterEmplacement() on the emplacement, and players can do so by simply pressing use on the emplacement. Players can exit by simply pressing use again, while NPCs can call ExitEmplacement().
Since emplacements work through morphs. Different NPCs can (And have to, if you have sprites of multiple said NPCs using the emplacement) be morphed into their own unique morph classes to use the emplacement. Which besides allowing different NPCs to visually use the emplacement. Can also be used to give each NPC different behaviors while on the emplacement.
A player with a custom skin and color and an Imp on a turret. Since there's no sprites of either that particular skin or Imp using the turret. The emplacement spawns fake operator sprites of those two operators instead.
If a non-explicitly supported NPC, or player with custom skin, etc. Enters the emplacement. You can have the emplacement spawn a fake VisualThinker, that uses the first valid See: state sprite of the operator it can find. To produce the visual effect of the operator using the emplacement without needing custom sprites. Which is useful for fallback NPC morphs and the likes.
Prevents players from being able to enter this emplacement.
Prevents NPCs from being able to use this emplacement.
The KAI_Humanoid class the emplacement should morph a non-explicitly supported NPC trying to use it.
The KAI_EmplacementPlayer class the emplacement should morph players trying to use it.
The sound that should play when an actor enters the emplacement, if any.
Type: Map <String, KAI_EmplacementNPC class instance>
The map list that stores supported NPC class names (As strings), and the KAI_EmplacementNPC class that NPC should morph to when entering the emplacement.
Type: Actor pointer
A pointer to THE ORIGINAL player or NPC actor that is on the emplacement, if any. Keep in mind that this is specifically a pointer to the original, unmorphed version of the actor.
Type: Actor pointer
A pointer to the current morph of the NPC or player using the emplacement. That is to say, a pointer to the KAI_EmplacementNPC or KAI_EmplacementPlayer currently manning it.
Type: Vector3
A Vector3 storing the relative position of the operator from the emplacement at the time that the operator had entered. Used when exiting to put the operator back in the same relative position and orientation they had entered from.
- User: The actor entering the emplacement.
- Returns true if User successfully entered the emplacement.
This is a virtual function that handles making players and KAI_Humanoid NPCs enter the emplacement. It handles behavior like morphing the actor, caching the relative position they entered from, setting pointers, transferring health, moving the User to the emplacements' position, etc.
Makes the emplacements Operator exit the emplacement. This just unmorphs the actor. The actual status changes are performed by DoExitEmplacement(), for reasons specified on that functions' section.
Handles the actual status changes of unmorphing the emplacements' operator. This is handled separately from the ExitEmplacement() virtual, being automatically handled in KAI_EmplacementNPCs' and KAI_EmplacementPlayers' built-in PostUnmorph() virtuals. The reason for this is because the operator might unmorph outside of ExitEmplacement() being called. Such as unmorphing because the morphed player or NPC died, or because the duration of the morph effect somehow ran out.
This is the virtual override both KAI_EmplacementNPC and KAI_EmplacementPlayer use to handle exiting emplacements on their own:
Override Void PostUnMorph (Actor Mo, Bool Current)
{
Super.PostUnMorph(Mo, Current);
If (Emplacement) Emplacement.DoExitEmplacement();
}
- NPCClass: A string of the name of the NPC class that is supported.
- MorphClass: The class instance of KAI_EmplacementNPC that an NPC operator of NPCClass should morph into.
- Returns true if the NPCMap key was successfully added. Returns false alongside a console warning if the NPCClass has already been mapped to a MorphClass.
Adds an entry to NPCMap of what KAI_EmplacementNPC to morph NPCClass into if they try entering the emplacement. Used to pass entries for explicitly supported NPCs, PostBeginPlay() would be the most logical time to define new entries at.
This function call will ensure that if a MyCoolSmartZombie tries using the emplacement, they'll do so by morphing into MyCoolSmartZombieOnATurret, instead of falling back to the NPCFallback morph, or failing to enter at all if there's no fallback.
Override Void PostBeginPlay()
{
Super.PostBeginPlay();
AddNPCMorph("MyCoolSmartZombie", "MyCoolSmartZombieOnATurret");
}
- NPCClass: The NPC to find a valid morph class of.
Returns the KAI_EmplacementNPC class to morph NPCClass into during EnterEmplacement()'s Morph() call.
This is how EnterEmplacement() uses the function to get the correct NPC to morph the will-be NPC operator into:
Bool Morbed = User.Morph (Self,PlayerMorph,GetNPCMorph(User.GetClassName()),INT.MAX/2,MRF_UNDOBYDEATH|MRF_LOSEACTUALWEAPON|MRF_FULLHEALTH|MRF_KEEPARMOR,Null,Null);
- Offsets: The coordinates to offset the visual thinker by, relative to the emplacement itself.
- Returns a pointer to the created VisualThinker, if any.
Creates a KAI_EmplacementFakeOperator VisualThinker. To allow the emplacements' operator to sort-of appear to be using the emplacement without requiring custom graphics of said operator using the emplacement. This can be useful for cases such as:
- An NPCFallback that can make just about any NPC sort-of appear to be using the emplacement, even if you've got no custom sprites of them actually manning said emplacement.
- For that matter, it can also be used for custom NPC morphs too. If you got no sprites of that particular NPC using it. Like if you've got a
SmartBaron
you want using some kind of stationary demonic weapon, but have no sprites of them doing so for theirSmartBaronHellCasterMorph
emplacement. - It can be useful for player emplacement morphs in particular. Specifically if the player in question has a custom skin, and you have no sprites of said skin actually using your emplacement (i.e you only have sprites of the normal player class and/or specific skins only). This could be used to have the players' unsupported skin appear to be using the emplacement.
This is a visual thinker that purely serves as a visual effect to make emplacements appear to be getting used by their operator, without requiring custom sprites of the operator on said emplacement for the emplacement morph. The visual thinker works by trying to rip the first valid sprite it can find in the See: state of the emplacements' operator. And setting its' graphic to that sprite. While also accounting for sprite rotations relative to the camera, and any player skins that may be in use by the operator, if the operator is a player.
Type: Vector3 The coordinates relative to the emplacement, that the visual thinker warps around. Used to offset where it visually appears.
Type: Actor pointer A pointer to the original, unmorphed actor that is using the emplacement. This is the actor whose sprite the thinker rips in PostBeginPlay().
Type: KAI_Emplacement pointer A pointer to the emplacement the thinker is part of.
Type: State The state whose Sprite the thinker has determined it should rip.
Type: Integer The ID of the player skin that the player operator was using when they entered the emplacement. Used by GetSpriteTexture() to rip the correct player skin. Only used and useful if the Operator is actually a player.
- CamPos: The position of the players' viewpoint.
- SixteenAngles: If the function should return 16 cardinal directions (For 16-angled sprites) instead of the normal 8.
- Returns a sprite rotation for GetSpriteTexture() to use.
This function replicates the native rendering code for getting the correct sprite rotation for an actor sprite to render, based on the position of the viewport. Used to make the visual thinker have actor-like sprite rotations. Since it rips actor sprites.
- Home
- Features
- Classes
- Functions
- Guides