Jump to content

NPC override script: CreateCreature wherever the NPC is?


Recommended Posts

I want to set something up in a blue-circle NPC's override script such that, once a certain battle begins, it starts a timer (maybe 5 rounds or so), and then when the timer is up (so should be in the thick of battle), they "transform" into a red-circle monster. This will be an alternative path to a dialogue in which they can transform; from dialogue, there is a cut scene that does CreateCreature("ThisCRE",[x.y]) and then DestroySelf(). That works because I know the precise X and Y coordinates where the NPC is standing when in dialogue. But in the battle, they will be moving around, and it can be chaotic. So from my rough pseudocode script:

IF
	GlobalGT("a_variable","global",5)
	!Dead("ThisCRE")
	See([enemy])
THEN
	RESPONSE #100
		[set a 30-second counter]
END

IF
	[counter done]
THEN
	RESPONSE #100
		CreateCreature("ThisCRE",[where I am])
		DestroySelf()
END

Anyone have pointers to turn that into a working script?

Link to comment
1 hour ago, jastey said:

I think CreateCreatureObject is what you need, with 0,0 so it spawns directly where the cre is. Example:

CreateCreatureObject("C#AJSHBO","C#Ajantis",0,0,0)

CreateCreatureObject() always spawns the creature next to the target creature. The three numeric parameters don't have any special meaning (except for the first one which defines the orientation). Polymorph() or PolymorphCopy() could work, however.

 

3 hours ago, subtledoctor said:

I want to set something up in a blue-circle NPC's override script such that, once a certain battle begins, it starts a timer (maybe 5 rounds or so), and then when the timer is up (so should be in the thick of battle), they "transform" into a red-circle monster.

You could apply a spell that performs the transformation with an execution delay of 30 seconds. It has the advantage that it can't be blocked by status changes or busy scripts.

The werewolf transformation of the "fighters" in the Windspear Hills area does something like this. The spell for their transformation is SPWI948.SPL.

Link to comment
9 hours ago, argent77 said:

CreateCreatureObject() always spawns the creature next to the target creature. The three numeric parameters don't have any special meaning (except for the first one which defines the orientation).

Oh, ok. Maybe I am mixing this up with some other action. I remember there being one where i could shuffle the appearance in relation to the object with giving +/- parameters, like -10 would be close behind, +10 in front etc.

Link to comment
Posted (edited)

But will Polymorph adopt all of the new creature’s attributes, including override script and script name?

Realistically, this will likely happen behind the PCs, in a big crowd of NPCs in the middle of the chaos of the battle for Bridgefort. If the new creature spawns a few pixels away from the creature “transforming,” I doubt the player will notice. CreateCreatureObject() will probably work fine.

Edited by subtledoctor
Link to comment
Posted (edited)

The "ChangeAnimation" script action truly transforms a creature; it becomes the new CRE, while still being the same actor and inheriting some things like active effects from the original. It's not perfect, though; in my experience, it's very flawed when used to transform a spellcaster. Any buffs on that creature become impossible to dispel or remove with the likes of Breach.

If your blue-circle creature hasn't been doing much, it should be pretty safe.

(This action is used for the Durlag's tower doppelgangers)

Edited by jmerry
Link to comment

If you want to actually replace the creature then definitely, as argent77 says, do it by applying a self targeted .spl with opcode #151, as used by Abazigal.

Interestingly Draconis in unmodified ToB instead uses the ChangeAnimation() action instead, I'm not a fan of that for various reasons.

However, if you want the creature to be the same actor, but the animation (opcode #53) and any number of other stats (hp, AC, THAC0, saves, attacks per round, resistances etc.) to be different then I'd just bundle all those effects into an undroppable equipped item in the creature's weapon slots, so when it's time to change:

THEN	
	RESPONSE #100
		SelectWeaponAbility(SLOT_WEAPON1,0)
		SetName(#STRINGREF#)  // Real name of the shapechanger
		SetGlobal("IChanged","LOCALS",1)
END

Note that if the initial creature doesn't have a character class, then charming them shouldn't enable you to see the "weapon" associated with their alternative form, but you might prefer them to have a class (for caster level and such) when morphed, so add the ChangeClass() action to the above block.

Link to comment
Posted (edited)

More context: the thing I am modifying is Elandro, the scared guy in Bridgefort who inadvertently summons a Greater Feyr. I am changing that encounter to seem like he transforms into a feyr. For… reasons. 

I’m a big fan of limiting my game modifications as much as possible. Elandro’s dialogue/script already includes a CreateCreature() action, so the easiest adjustment seems like it would be to tack on a DestroySelf() action right next to it. 

Separately, I want to cover the eventuality that Charname never talks to Elandro and Thirrim. If you start the Bridgefort battle and Elandro has never been talked to, I want him to freak out and become a feyr right in the middle of the battle. :devil: This may not even be in the player’s field of vision, so maybe CreateCreatureObject() + DestroySelf() will be fine for this. 

Alternatively, a spell with op151. Will look into it. 

Thanks for the guidance, all. 

Edited by subtledoctor
Link to comment

There's also SaveObjectLocation() and, I think, CreateCreatureAtLocation() to spawn there from the area's script. Note that variable's scope must be fully in uppercase for location data (no idea why it's the only weird one).

But realistically just use 151, somehow, it's less hassle.

Link to comment
On 5/31/2024 at 4:35 AM, polytope said:

Interestingly Draconis in unmodified ToB instead uses the ChangeAnimation() action instead, I'm not a fan of that for various reasons.

Draconis is the perfect storm of everything that can go wrong with ChangeAnimation(); mage buffs becoming unbreakable, selection circle growth trapping anyone that's already in melee. I remember one instance in which my protagonist wound up trapped immobile under the dragon, while he had an undispellable/unbreachable PFMW up ... and I still won the fight.

The application here, of a humanoid civilian transforming into a monster, won't run into buff issues. But the selection circle does expand; the feyr animation has a parameter of 24 there, compared to a standard humanoid's 16. So there's a small risk of trapping someone if they're up in Elandro's personal space.

Link to comment
10 hours ago, jmerry said:

Draconis is the perfect storm of everything that can go wrong with ChangeAnimation(); mage buffs becoming unbreakable, selection circle growth trapping anyone that's already in melee. I remember one instance in which my protagonist wound up trapped immobile under the dragon, while he had an undispellable/unbreachable PFMW up ... and I still won the fight.

Does that rise to the level of something the FixPack should address?

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...