Aller au contenu

Photo

Death Script riddle, including ressurection


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
andysks

andysks
  • Members
  • 1 651 messages

Hi all. I had this issue today which I didn't see it coming but it's actually quite clear. Bear with me.

 

The creature dies. And an NPC spawns and starts talking. All happens as it's supposed to, with one exception. Thing is, that the hostile creature will resurrect if we don't destroy some pillars around first. See the problem? If we don't destroy the pillars, the creature will resurrect but the NPC will spawn nonetheless which doesn't make sense. Here's the OnDeath script as it looks now. Any work around?

#include "ginc_ipspeaker"

void main()
{
	object oPC        = GetFirstPC();
	object oMessenger = GetObjectByTag("c_roe_sanitmess");
	object oWP        = GetObjectByTag("wp_spawn_messe");
	object oBeh       = GetObjectByTag("c_roe_sanit_beh");
	location locMess  = GetLocation(oWP);
	
	if(GetIsDead(oBeh, FALSE))
		{
		    CreateObject(OBJECT_TYPE_CREATURE, "c_roe_sanitmess", locMess, 0, "");
	            CreateIPSpeaker("c_roe_sanitmess", "sanit_last_convo", locMess, 1.5f);
		}			
	    else
		{
		}	
	
}	

PS: I added the if condition just now and haven't tested it yet. I assume it will work for it checks if the creature is dead. If it resurrects it won't return TRUE. But it happens fast and I don't know how to add a delay to the CreateObject. I think this should solve it if possible. Will ActionWait work here?

Thanks a lot in advance.



#2
AGhost_7

AGhost_7
  • Members
  • 62 messages

How is the original creature re-spawning at all?



#3
andysks

andysks
  • Members
  • 1 651 messages

I set a variable when the pillars are destroyed. A heartbeat checks the variable and if it's not met it calls this. It's part of a bigger script which is unimportant.

 

        effect eResurrect = EffectResurrection();
        
        DelayCommand(1.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eResurrect, oBeh));



#4
Tchos

Tchos
  • Members
  • 5 063 messages

You can't delay the normal CreateObject, because the DelayCommand function only works on void functions, and CreateObject returns a value (an object).  To delay CreateObject, create a new void function that takes the same parameters as CreateObject, and does nothing but execute CreateObject with those parameters.  Then you can delay the new function.  However, delaying it won't do what you want in this case.

 

Since you already have a variable being set when the pillars are destroyed, check for both that AND whether the beholder is dead as conditions for firing CreateObject.


  • Kaldor Silverwand aime ceci

#5
andysks

andysks
  • Members
  • 1 651 messages

So ActionWait won't work huh? is it because if we wait too much after the death then the rest of the stuff won't fire? And the two if conditions should do the trick... I'll just test it now.



#6
andysks

andysks
  • Members
  • 1 651 messages

That did the trick Tchos. Easy solution, thanks.



#7
Tchos

Tchos
  • Members
  • 5 063 messages

From my memory, ActionWait is only for putting a delay in an action queue along with other actions, usually for an NPC doing things.  It won't delay parts of a script from firing.  Like this (with fictitious functions):

 

ActionWalkOverThere();

ActionWait();

ActionSpeakString("Are we done yet?");

ActionWait();

ActionForceExit();

 

These are all immediately added to the NPC's action queue, but the nature of Actions is that unless they're cleared with ClearAllActions or interrupted in some other way (prevented by making the NPC uncommandable), they're executed one at a time, and the ActionWait instructs the NPC to do nothing for a round before it executes the next action.


  • andysks aime ceci

#8
Morbane

Morbane
  • Members
  • 1 883 messages

there is actually a CreateObjectVoid() function in one of the stock includes - but that is moot since it is exactly as Tchos suggested you do yourself (a wrapper) and saves having to #include for one function - even iirc the said include has lots of useful functions that are commonly utilised in a relatively large module-project, as they tend to be these days.