Author Topic: Is this done/doable?  (Read 1274 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« on: May 16, 2016, 12:26:43 am »


               

Okay I was scrolling around and a thought popped into my head and I am hoping someone could help me understand the concept of making this better '<img'> 


 


Basically I was playing this game where you could summon a temporary door (lasting for example a 10 seconds?) speaking to the door and simply click on it and poof you are ported to the destination its assigned to. 


 


What I had in mind was to have it on an item and I believe not so much the clicking to make it port but to make the item appear at all and last for only a short duration of time....


 


also my question (and I know I might be stretching this a bit) is making it work by attaching it to an unique Power on an item?  Giving it the same name as the script? I know I read that somewhere but cannot really find where I read so I just figured I ask here. 


 


Thanks beforehand '<img'> 



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Is this done/doable?
« Reply #1 on: May 16, 2016, 08:15:45 am »


               You can do that with a Unique Power item. You need an OnActivateItem event script. If you don't want to change the module script, enable tag-based scripting, then create a script with the same name as the item tag.

You'll need to make a placeable template for the door, then CreateObject in the item script. A regular Unique Power item has a target, allowing the player to specify where the door is created, but if that doesn't matter, Unique Power (Self Only) could be used to create the door in front of the player.

Regarding timing, if it suits your purpose, you might like to have the script start the conversation, deleting the door when the conversation ends (even if the player decides not to use the door), to ensure that the world doesn't become cluttered with doors, yet giving the player time to respond.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Is this done/doable?
« Reply #2 on: May 16, 2016, 09:15:02 am »


               

The time settings might be a little tricky to get.


 


Instead of scheduling the destruction of the door after 10 seconds, you will need to schedule the 'checking' to see if a player has spoken with the door yet.


 


Workflow would look like this:


 


Player Summons Door -> Start 10 second countdown.


 


On 10 Seconds - One of two things happens.


Player has started conversation with door - so we don't want to destroy the door.


Player has not started conversation with door, or are no longer in conversation with door - so we do destroy the door.


 


 


To determine if the conversation is inprogress for the door -


Call 



   IsInConversation(object)

 


If this returns false - then you know it is safe to destroy the door.


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Is this done/doable?
« Reply #3 on: May 16, 2016, 11:02:22 am »


               

Not being as expert as some of the guys on here my suggestion could well have problems or not work at all so please bear with me. Just a thought but couldn't you use a user defined event coupled with a delaycommand? This is what I am thinking -


 


When the calling object is activated it raises an event.


The summoned door has a script attached to its OnUserDefined event that destroys the door after 10 seconds using delaycommand.


 


Would that work?


 


TR



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #4 on: May 17, 2016, 06:31:02 am »


               


Not being as expert as some of the guys on here my suggestion could well have problems or not work at all so please bear with me. Just a thought but couldn't you use a user defined event coupled with a delaycommand? This is what I am thinking -


 


When the calling object is activated it raises an event.


The summoned door has a script attached to its OnUserDefined event that destroys the door after 10 seconds using delaycommand.


 


Would that work?


 


TR




will try that later today (or tomorrow) and see if it works will keep you guys updated on my progress! '<img'>


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #5 on: May 25, 2016, 07:21:52 am »


               

well have not had the time to test this, actually been in quite a struggle actually getting it to work,...


 


for some reason it is simply not working...tried the Tagbased scripting template of Lilac (not working)


Tried to create it myself (again....not working)


 


I know I am doing something wrong but I dunno what! the tutorials I find are in general very contradicting....so would like to have a bit of help getting this done ..


 


item script (same name as Item)




void main()

{

    object oSpawn;

    effect eVFX;

    object oEventItem = GetItemActivated();

    object oActTarget = GetItemActivatedTarget();

    location lActTarget = GetItemActivatedTargetLocation();

    object oActivator = GetItemActivator();

 

    object oPC = oActivator;

 

    // This item cannot be used in combat.

    if ( GetIsInCombat(oActivator) )

    {

        SendMessageToPC(oActivator, "Improper use of this item!");

        return;

    }

 

    // This item must target a location (not an object).

    if ( GetIsObjectValid(oActTarget) )

    {

        SendMessageToPC(oActivator, "Improper use of this item!");

        return;

    }

 

    // Spawn "marissasportal".

    eVFX = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);

    oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "marissasportal", lActTarget);

    DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSpawn));

}

 


 


 





(ON ItemActivation Script module)


 



ExecuteScript ("MarissasPortal", OBJECT_SELF);


 



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Is this done/doable?
« Reply #6 on: May 25, 2016, 07:24:58 am »


               

looking at it now....


 


*Edited to add response.


 


One quick question...


Did you create a placeable and set the resref to the value "marissasportal" or did you only set the tag to that value. '<img'>


 


Worked fine for me....Make sure that tag based scripts are enabled and that your script has the name of the items tag and that the placeables resref is set to whatever string value you use in the CreateObject method.


 


You can quickly test if the item activated works by targeting an object. you should get the error message if the activating item runs the tag based script.



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #7 on: May 25, 2016, 08:52:56 am »


               


looking at it now....


 


*Edited to add response.


 


One quick question...


Did you create a placeable and set the resref to the value "marissasportal" or did you only set the tag to that value. '<img'>


 


Worked fine for me....Make sure that tag based scripts are enabled and that your script has the name of the items tag and that the placeables resref is set to whatever string value you use in the CreateObject method.


 


You can quickly test if the item activated works by targeting an object. you should get the error message if the activating item runs the tag based script.




 


*very awkward whistle* 


 


hehe okay yeah that works! How foolish of me! Thanks! Now will try to make it disappear after 10 sec! '<img'>


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #8 on: May 25, 2016, 09:08:19 am »


               

so here is just a random thought which I thought of sharing with you guys since I might probably go about it all the wrong way here.... basically I dont want a conversation for the placeable portal. Just it being spawned temporary. Would a HB script for this do the tric?



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Is this done/doable?
« Reply #9 on: May 25, 2016, 09:16:47 am »


               

Try a two pronged approach.


 


You could set a simple hb script for it to destroy itself after x number of hb's, but maybe you also want to add a local int on the portal when used so that the hb script will override the delay and destroy it on the next hb after use....or have a delay set into the on use event script to destroy itself once used....A combination of one, two or more, whatever makes sense to you.

 


Since I don't know what or how you specifically intend to use the portal, those are just some ideas.



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Is this done/doable?
« Reply #10 on: May 25, 2016, 09:17:59 am »


               

Since vanilla nwn doesn't really have any good timing functions for determining amount of seconds between X and Y, using a Heartbeat could be an answer.


 


The heartbeat for placeables runs more a less every 6-7 seconds.


You could use the heartbeat to increment a local variable by 1 each time, and when it reaches the threshold, it will destroy the portal.


The downside of this is that the portal will only despawn at second intervals of 6-7.


Eg: After 6 Seconds, After 12 Seconds, After 18 Seconds etc..


Or, if you wish to get more control, you can use DelayCommand - to assign a command to the portal to destroy itself after X seconds, or check for a condition to be met, before destroying itself.


 


 


Normal hb approach:


 


 
void main(){
 
int times = GetLocalInt(OBJECT_SELF,"Times");
times++;
 
//Destroy self after 30'ish seconds.
if(times >= 5){
      DestroyObject(OBJECT_SELF,0.5);
}
SetLocalInt(OBJECT_SELF,"Times",times);
}
 

 


 


 
 
 
 
 
 
//Placeables have no 'on-spawn' event, so we need to use the hb script to kick things off
void main(){
 
int done = GetLocalInt(OBJECT_SELF,"Done");
if(done){
return;
}
 
//Destroy self after 30 seconds
DestroyObject(OBJECT_SELF,30.00);
 
//Alternatively, you can put a function call here that will check for a condition, then destroy self.
 
}
 
 
 
 
 
 

               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Is this done/doable?
« Reply #11 on: May 25, 2016, 10:08:16 am »


               


*very awkward whistle* 


 


hehe okay yeah that works! How foolish of me! Thanks! Now will try to make it disappear after 10 sec! '<img'>




Hehe, Don't sweat it, can't tell you the number of times I resembled that very statement. It's always the simple stuff, like making sure the appliance is plugged in before calling the repair man. ':blink:'  


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #12 on: May 25, 2016, 10:57:27 am »


               Awesome! Thanks guys! I will try it out when I am off work.


Basically the intend is to make a spawnable transition door to a safehouse. Got inspired by the mordensteins (or whatchacallit) mansion spell i saw once on a server.


Everything works except for the part that it destroys itself after a set ammount of time.
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Is this done/doable?
« Reply #13 on: May 25, 2016, 08:18:58 pm »


               

okay I got it all to work thank you all soooooo much for the input and the patience guys! YOU GUYS ROCK! '<img'>