Aller au contenu

Photo

constant fire trigger


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

#1
DynV

DynV
  • Members
  • 18 messages
I'm still on the same map and it's for new players, so level 1, and there's a fireplace without a protective grill that the walkmesh get on the added flame effect so I'd like to give a bit of pain when it's too close.  A minor fire trap is likely to kill right away, it's comment mention Min to Max player level: 3 - 8:huh:  I'd like to have something very low, like 1d2 / second.

I could use On Heartbeat Script but that would only be fired every 6 seconds.  Perhaps there's a way to create a thread with a 1 second timer that would be launched by On Enter Script and be stopped by On Exit Script but I'm concerned that it might not be stoppedas it should thus doom the player and a failsafe would be good checking if the player is still on the trigger and if not stop itself ; although a thread cannot stop itself so it would need a creator thread with the only task of killing its offspring (while on a timer to see if it's still alive).  Threads are complicated! :blush:

Thank you!  :)

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
OnHeartbeat would be fine if you then use a DelayCommand statement to add a "pseudo-heartbeat." A number of scripters recently have talked about this.



Say you wanted an effect that happened every 3 seconds instead of every six, a single DelayCommand with a 3-second interval would do the trick. If you delayed a whole custom function you wrote, you could also check whether the character is still within the trigger area before applying the damage.



Also, I assume by your usage of it that "thread" is the word you're using for "script," right?

#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
There is a script in the West Harbor module of the OC that applies a 2 hp effect to anyone standing in a fire. I don't recall its name, but I know I have it somewhere.

#4
DynV

DynV
  • Members
  • 18 messages

Kaldor Silverwand wrote...

There is a script in the West Harbor module of the OC that applies a 2 hp effect to anyone standing in a fire. I don't recall its name, but I know I have it somewhere.


That would be great!  How can you open the maps of the OC (assuming it standfor Original Campaign) ?

MasterChanger wrote...

OnHeartbeat would be fine if you then use a DelayCommand statement to add a "pseudo-heartbeat." A number of scripters recently have talked about this.

Say you wanted an effect that happened every 3 seconds instead of every six, a single DelayCommand with a 3-second interval would do the trick. If you delayed a whole custom function you wrote, you could also check whether the character is still within the trigger area before applying the damage.


This sound to me like it would launch a spell that would last, alike to The Elder Scrolls (TES) have duration to their spell so you do a single action that have multiple effect divided along its duration (I'd be careful when a foe was near death as waiting for a few seconds would often finish it instead of spellcasting again).  If it's the case, the effect would last through the heartbeat even if you got off the trigger right after the event was fired which isn't desirable.

MasterChanger wrote...

Also, I assume by your usage of it that "thread" is the word you're using for "script," right?


No I'm talking about a basic programming concept ; see Thread (computer science), Deadlock & Race condition for an overview.

#5
Guest_ElfinMad_*

Guest_ElfinMad_*
  • Guests

DynV wrote...

No I'm talking about a basic programming concept ; see Thread (computer science), Deadlock & Race condition for an overview.


I'm pretty sure the game process is single threaded so those senarios cannot happen. A script runs and exits before another is run.

#6
MasterChanger

MasterChanger
  • Members
  • 686 messages

DynV wrote...

MasterChanger wrote...

OnHeartbeat would be fine if you then use a DelayCommand statement to add a "pseudo-heartbeat." A number of scripters recently have talked about this.

Say you wanted an effect that happened every 3 seconds instead of every six, a single DelayCommand with a 3-second interval would do the trick. If you delayed a whole custom function you wrote, you could also check whether the character is still within the trigger area before applying the damage.


This sound to me like it would launch a spell that would last, alike to The Elder Scrolls (TES) have duration to their spell so you do a single action that have multiple effect divided along its duration (I'd be careful when a foe was near death as waiting for a few seconds would often finish it instead of spellcasting again).  If it's the case, the effect would last through the heartbeat even if you got off the trigger right after the event was fired which isn't desirable.


OK, let me explain it using an example, and see if it makes more sense. Take a look at nw_s0_crpdoom. The main portions of interest are the DelayCommand statement within a loop:

for ( i = 1; i <= nDuration; i++ )
{
    //Run Swarm function and delay the activation of each
     DelayCommand( RoundsToSeconds(i), RunSwarmAttack(oTarget, fDuration) );
}

...and also the definitions of RunSwarmAttack:
//This function deals the damage and applies the poison effect
void RunSwarmAttack( object oTarget, float fDuration )
{
    if (!GetHasSpellEffect(SPELL_CREEPING_DOOM, oTarget))
        return;

    int nDam;
    effect ePoison = EffectPoison( POISON_SMALL_CENTIPEDE_POISON );
    
    //Roll to hit target, if true then deal damage
    if (RunRollToHit( oTarget ))
    {
        //Determine and apply damage + poison, DC save against this poison is 11
        nDam = d6(2);
        effect eHurt = EffectDamage( nDam, DAMAGE_TYPE_PIERCING );
        ApplyEffectToObject( DURATION_TYPE_INSTANT, eHurt, oTarget );
        ApplyEffectToObject( DURATION_TYPE_TEMPORARY, ePoison, oTarget, 30.0f);
    }

}

So what RunSwarmAttack does, at least in theory, is determine whether the effect is still valid and the target is hit at the delayed time, not at the outset. You should be able to use GetIsInSubArea as part of your delayed function.

Modifié par MasterChanger, 22 septembre 2010 - 01:18 .


#7
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
The script is named nw2_t1_firebaby.



Here it is:

//::///////////////////////////////////////////////
//:: Baby Fire Trap
//:: nw2_t1_firebaby
//:: Copyright (c) 2005 Obsidian Entertainment.
//:://////////////////////////////////////////////
/*
    Does 1d2 damage to all within 5 ft.
*/
//:://////////////////////////////////////////////
//:: Created By: John Lee
//:: Created On: October 6, 2005
//:://////////////////////////////////////////////
//DBR 3/16/6 - restructed, now occurs every set number of seconds

#include "NW_I0_SPELLS"


void DoDamage(object oTarget)
{
    effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
    effect eDam;
	int nDamage;
    int nSaveDC = 10;
       //Roll damage
       nDamage = d2(1);
       //Adjust the trap damage based on the feats of the target
        if(!MySavingThrow(SAVING_THROW_REFLEX, oTarget, nSaveDC, SAVING_THROW_TYPE_TRAP))
        {
            if (GetHasFeat(FEAT_IMPROVED_EVASION, oTarget))
            {
                nDamage /= 2;
            }
        }
        else if (GetHasFeat(FEAT_EVASION, oTarget) || GetHasFeat(FEAT_IMPROVED_EVASION, oTarget))
            nDamage = 0;
        else
            nDamage /= 2;

        if (nDamage > 0)
        {
            if (nDamage > 0)
            {
                //Apply effects to the target.
				if (GetIsPC(oTarget))
				{
                	eDam = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
                	ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
                	ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
				}					
            }
        }
}

void InFire(object oTrap, float fPainInterval)
{
	object oIter = GetFirstInPersistentObject(oTrap,OBJECT_TYPE_CREATURE);
	while (GetIsObjectValid(oIter))
	{
		if (oIter==OBJECT_SELF)
		{
			DoDamage(OBJECT_SELF);	
			DelayCommand(fPainInterval,InFire(oTrap,fPainInterval));
			return;
		}
		oIter=GetNextInPersistentObject(oTrap,OBJECT_TYPE_CREATURE);
	}
}

void main()
{
    //Declare major variables
    object oTarget = GetEnteringObject();
	object oTrap = OBJECT_SELF;
	
    if(!GetIsReactionTypeFriendly(oTarget))
    {
		float fPainInterval=GetLocalFloat(OBJECT_SELF,"PainInterval");
			DoDamage(oTarget);	
			AssignCommand(oTarget,DelayCommand(fPainInterval,InFire(oTrap,fPainInterval)));
		//AssignCommand(oTarget,InFire(OBJECT_SELF,fPainInterval));
    }
}



You can open the OC modules in the toolset by doing File >> Open... and navigating to the Program Files\\Atari\\Neverwinter Nights 2\\modules folder and opening "1100_West_Harbor.mod". Before doing this though go to View >> Options and under General set Autosave to False. Autosave if left on will mess you up in the toolset.



Regards

#8
Morbane

Morbane
  • Members
  • 1 883 messages
A formatted version of the script Kaldor posted is here http://pastebin.myrror.net/2715
It might give you trouble with all the extra carriage returns ;)

Modifié par Morbane, 22 septembre 2010 - 03:57 .


#9
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
The extra carriage returns seem to be because these forums stupidly assume everyone is posting from a Windows PC. I'm not.



Thanks Bioware.

#10
DynV

DynV
  • Members
  • 18 messages

Kaldor Silverwand wrote...

The script is named nw2_t1_firebaby.

Here it is:

//::///////////////////////////////////////////////
//:: Baby Fire Trap
//:: nw2_t1_firebaby
//:: Copyright (c) 2005 Obsidian Entertainment.
//:://////////////////////////////////////////////
/*
    Does 1d2 damage to all within 5 ft.
*/
//:://////////////////////////////////////////////
//:: Created By: John Lee
//:: Created On: October 6, 2005
//:://////////////////////////////////////////////
//DBR 3/16/6 - restructed, now occurs every set number of seconds

// quoted code cropped


Here's what's apprearing when I filter with "fire" the Open Conversation/Script window: http://s231.photobuc...script-fire.png  I suppose the code was introduced in NWN2 expansion as I currently have none installed ?!  I'd prefer the module to require no expansion but if I added the script to the module instead of just referring to it, would I commit a copyright breach?

Edit 1:  The forum doesn't automatically transform a URL text to a link...  It would indeed need an overhaul.

Modifié par DynV, 22 septembre 2010 - 09:40 .


#11
Morbane

Morbane
  • Members
  • 1 883 messages

DynV wrote...

I suppose the code was introduced in NWN2 expansion as I currently have none installed ?!  I'd prefer the module to require no expansion but if I added the script to the module instead of just referring to it, would I commit a copyright breach?


I wouldn't worry about it. Really...

#12
MasterChanger

MasterChanger
  • Members
  • 686 messages
Strange that the script doesn't use the sleeker GetReflexAdjustedDamage function. But who doesn't want a script called "Fire Baby"? :lol:

Also, to the OP, to make nice URLs you can use url= with square brackets around it, then what you want to call it, then /url at the end. I guess they figure people can use that...

#13
DynV

DynV
  • Members
  • 18 messages
Is there a way to make a check to access the original script if accessible?  Upon new stable releases (or popular softwares), people will often make backports of the new version as their system haven't migrated yet but they'd like to benefit from the new functionnalities ASAP.  For example, the capital words are to be replaced:



LANGUAGE_OLD_VERSION_functionX() { // ie: php4_
  if (is_function_exist( functionX )) {
    return functionX();
  } else {
    // @todo Insert backport code.
  }
}


You could also consider a case where it reached a certain subversion an it's better to have that one as: if (is_function_lower( functionX, VERSION_OF_BACKPORT )) return functionX(); // ie: 4.3  I can't stand ifs without brackets.  <_<

So is there a way to apply this in case the player do have the expantion?  It's very possible there might be an update later and it would be better to run the newer version instead of the copy of the function.

Modifié par DynV, 23 septembre 2010 - 06:03 .


#14
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I don't think there is any code in the script that requires an expansion by installed. Just load it into your campaign folder and see if it works and don't worry about it.

#15
DynV

DynV
  • Members
  • 18 messages
Ok so I've created a new script with a name starting with "nw2_t1_firebaby" pasting thew content from this thread then made a blueprint copy of New Generic, added a variable named PainInterval of float type & value of 1 and assigned On Enter Script to it, it functioned as expected: small constant fire damage. When my character died and I finished laughing, I hit re-spawned and I landed right in the trap (my initial spawn point is out of the trap) but it was as there was no trap so I got off then when I came back it was as expected.

Trying to have the trap cause damage even if the character is spawned in it, I put it's trap type to NONE then switch the script call to On Trap Triggered Script but not only didn't it made up the lack of its predecessor, it didn't function at all, not even from the start (freshly loading the map thus from initial spawn point).

Was the script fashioned to be used otherwise? Am I stuck this way and have to hope the player doesn't re-spawn in the trap?

Kaldor Silverwand wrote...

I don't think there is any code in the script that requires an expansion by installed. Just load it into your campaign folder and see if it works and don't worry about it.


I agree with you (php5 was made with php4 thus you could make a fork redoing it differently). The issue was with the later part of the paragraph:

DynV wrote...

So is there a way to apply this in case the player do have the expantion?  It's very possible there might be an update later and it would be better to run the newer version instead of the copy of the function.


Let's say the version that was pasted in this thread has something to do with DBR 3/16/6, let's say I still add it to my mod and after I upload it I disappear from Internet then 6 months after a newer version of that script with a higher DBR come out (I wonder what it mean), then it would be beneficial for those users that have an updated version on their system could access it instead when using the mod.  As I disappeared, I can't create a newer version of the script then reupload the mod.

Just like when I make a backport I won't only check the version but also the subversion in case a server is migrated to the newer version but still have an older version of the script.

Modifié par DynV, 24 septembre 2010 - 12:49 .


#16
Morbane

Morbane
  • Members
  • 1 883 messages
DBR afaik is a release date type abbreviation. But I could be wrong . . .

#17
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages

DynV wrote...
Trying to have the trap cause damage even if the character is spawned in it, I put it's trap type to NONE then switch the script call to On Trap Triggered Script but not only didn't it made up the lack of its predecessor, it didn't function at all, not even from the start (freshly loading the map thus from initial spawn point).

Was the script fashioned to be used otherwise? Am I stuck this way and have to hope the player doesn't re-spawn in the trap?


I don't think the on enter event is fired if you spawn inside a trigger. You would need to trap it some other way. Personally I wouldn't worry about it. The player is going to get the damage and back off. Not likely they will leave their character there to die.

So is there a way to apply this in case the player do have the expantion?  It's very possible there might be an update later and it would be better to run the newer version instead of the copy of the function.


The script is not a global function, it is just a custom OC script (nothing to do with the expansions by the way) so you need to provide it yourself in your campaign. If an update to the OC is released that changes the script then the new version of the script would work in the OC, but would not in your campaign unless you subsequently released an update to your campaign replacing your version of the script with the newer one.

Regards

Modifié par Kaldor Silverwand, 24 septembre 2010 - 06:38 .