Combing Script functions?
#1
Posté 07 janvier 2012 - 09:06
http://nwvault.ign.c....Detail&id=3841
and
http://nwvault.ign.c....Detail&id=3846
As well as
http://nwvault.ign.c....Detail&id=3842
Now all of these call for having their own module On_Activate scripts in place. I haven't tried putting them in because I wanted to keep the defualt scripts in place that are set because other things I have in the current module call on the default scripts. (default meaning X2_mod_on_act) etc etc.
What I did for one of these script sets was append the ON_Equip/OnUnequip with the scripts the author provided, and it seems to work just fine. But I can't do that with the above for the On_Activate/On_Acquire. How can I combine/join these script functions together?
(Be gentle I am a newb at this.)
#2
Posté 07 janvier 2012 - 10:11
edit
Nevermind, apparently im not even allowed to be here. gtg
I propably wont be able to help you. (Due to lack of access to a computer D:)
Modifié par Xardex, 07 janvier 2012 - 10:14 .
#3
Posté 07 janvier 2012 - 06:32
//::///////////////////////////////////////////////
//:: Example XP2 OnActivate Script Script
//:: x2_mod_def_act
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
Put into: OnItemActivate Event
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
#include "x2_inc_switches"
void main()
{
object oItem = GetItemActivated();
// * Generic Item Script Execution Code
// * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// * it will execute a script that has the same name as the item's tag
// * inside this script you can manage scripts for all events by checking against
// * GetUserDefinedItemEventNumber(). See x2_it_example.nss
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
ExecuteScript(GetTag(GetItemActivated()),
OBJECT_SELF);
}
{
return;
}
}
}
The underlined section is what I was trying to add. Seems to be the function the Tag Based Script wants to call on. Technically its just about the same thing as what is already there, but the Tag script does not utilize it. So whats the proper way to add the extra lines in?
Modifié par Foregone_Conclusion, 07 janvier 2012 - 06:33 .
#4
Posté 07 janvier 2012 - 06:40
ExecuteScript("ac_"+GetTag (GetModuleItemAcquired()), OBJECT_SELF);
Just add that line to your onactivate event script somewhere inside of the void main() brackets, but above the
// * Generic Item Script Execution Code
line.
As to your code above:
move the highlighted line a couple lines higher. it should be closer to:
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
ExecuteScript(GetTag(GetItemActivated()),
OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
The line that says "if (nRet == X2_EXECUTE_SCRIPT_END)" means that anything in the brackets under it will only fire if another tag based script has fired and that script returned a specific variable marking it as complete.
Normally, your tag based scripts will have a prefix that you can choose. Say we use "itm_". So, if we have a item tagged "myitem", the name of the script that fires will be named itm_myitem.
That's what this line does:
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
Your new line always calls a script with only the tag and no prefix.
This can be an issue if you have tag based scripts enabled and do not use a prefix. The script can be called twice.
If you notice that the items are being called twice, delete that new line.
Modifié par wyldhunt1, 07 janvier 2012 - 06:46 .
#5
Posté 07 janvier 2012 - 06:46
X2_EXECUTE_SCRIPT_END must be set in the executed script.
#6
Posté 07 janvier 2012 - 09:05
But the ForceRest potion and the town portal scripts are not calling their scripts via their tags.
#7
Posté 07 janvier 2012 - 09:17
Is it the one you where currently using?
If not please post your original OnItemActivate Event script here ot at pastebin.com with a link back here.
#8
Posté 07 janvier 2012 - 09:39
MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS
I don't have access to NWN right now, but there should be an option to enable it. I think it's enabled by default, but it may not be if you're using old code.
Take a look in your OnModLoad event and see if you can find it.
#9
Posté 07 janvier 2012 - 09:43
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
if (GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
And yes the script above is the standard bioware script. Not using anything different. I am running some custom haks but I can't think of anything that would interfere with the scripting system.
#10
Posté 07 janvier 2012 - 11:09
It's probably something simple.
I haven't downloaded the erf that you are using yet, since I'm at work.
Can you post the townportal item tag and the script name?
And, would you mind posting your OnActivate script exactly as it is now, with the changes you've made?
#11
Posté 07 janvier 2012 - 11:24
void main()
{
object oItem = GetItemActivated();
// * Generic Item Script Execution Code
// * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// * it will execute a script that has the same name as the item's tag
// * inside this script you can manage scripts for all events by checking against
// * GetUserDefinedItemEventNumber(). See x2_it_example.nss
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
ExecuteScript(GetTag(GetItemActivated()),
OBJECT_SELF);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
Correct?
Town Portal item tag is : scrl_twnpp_strk
The script name is : scrl_twnpp_strk
There is an older town portal system that I am going to try later, that I think should actually work as intended.
#12
Posté 07 janvier 2012 - 11:33
The Krit in comments on the vault even sugested that the author convert them to comform to standard TBS. I have to agree. instead of messing with the module events, it would be better to just edit the scripts to conform to the standard TBS.
Looking at the transport system, I am not even sure it worked for the get go yet. But I have just barly glanced over them.
EDIT: Ok It would work the way he has it wtitten. But he has him modifying three module events for a system that uses only one of them.
Instead of simply placing the filter int the script to not run the other events.
Problem two. It requires him to write a script for each waypoint/scroll combination using the ones given as a templet.
Problem three: If used on a PW where all the players have the habit of grouping up ito a single party to chat. It will take everyone who is in the party to the waypoint reguardless of where they are.
@ForeGone: All of that can be fixed. But i would sugest finding a better teleport system.
I have not looked at the other two systems yet, But from what I have read so far thay also should be cleaned up a bit. At least as far as brining them back into TBS standard.
Here is the script of the transport system if you wanted to still see it Whyled. http://pastebin.com/bVgfXka2
Modifié par Lightfoot8, 07 janvier 2012 - 11:48 .
#13
Posté 08 janvier 2012 - 12:09
Bad code. Bad!
@Foregone Conclusion
Yes. You seem to have your OnActivate set up to trigger the code the way they intended.
For starters, the reason it's failing is because of this:
location lTarget;
oTarget = GetWaypointByTag("stp_link_strk");
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
lTarget is never given a location, so it never has an area. The script exits before it ever starts.
I also advise you to find a new system.
Modifié par wyldhunt1, 08 janvier 2012 - 12:10 .
#14
Posté 08 janvier 2012 - 03:45
This isn't tested. In fact I'm still at work, so I haven't even tried to compile it. I just typed it out in Notepad, based on the code that Lightfoot posted...
It may need some tweaks.
http://pastebin.com/Ws3ADdUj
It is set up to use tag based scripting.
There is a tutorial to help you understand how tag based scripting works here:
http://www.nwnlexico...dscripting.html
Notes:
The target location is a waypoint with a unique tag.
The tag of the waypoint needs to be set on the item as a string variable named JUMPTO.
This is a potential flaw if you intend to sell unlimited quantities of these items in a store.
Items get all of their variables wiped when they are set to unlimited in a store.
I've fixed that in Adelan (Our PW) by deleting any storebought items acquired and then re-creating them in the players inventory. If you want that fix, let me know.
The advantage of this is that you can make multiple copies of the item and give them all the same tag, but change their name and JUMPTO variable. The one script will handle as many items and jump locations as you want.
It is set up so that it jumps all party members in the characters current area. They all get the special effects from the old script. This can cause a lag spike if there are a lot of party members in the area. If you want it to only trigger the special effects on the character using the item, I can change that for you. I can also stagger the timing a little bit on when each member jumps by a fraction of a second so that all of the effects don't lag quite as bad. I just didn't have time right now.
I can also change it to only jump party members within a set distance of the character (Say, party members within 20 feet). Again, I just didn't have time (Or good enough memory of Aurora script to do it all from memory).
Modifié par wyldhunt1, 08 janvier 2012 - 04:28 .
#15
Posté 09 janvier 2012 - 12:49
void main()
{
// variable init
object oItem = GetItemActivated(); // gets which item activated
object oPC = GetItemActivator(); // gets item activator
string sItemTag = GetTag(oItem); // gets tag of activated item
if (sItemTag == "townportal") { // checks if it's the town portal scroll that was used
location lLoc = GetItemActivatedTargetLocation(); // sets the location the scroll was casted at
// Effects start
effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD, FALSE);
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, lLoc, 6.0);
// Effects stop
CreateObject(OBJECT_TYPE_PLACEABLE,sItemTag,lLoc,TRUE); // creates the actual portal
SetLocalLocation(oPC, "Portal", GetItemActivatedTargetLocation()); // stores the location variable in the PC itself
}
}
Looks to be well written and I do know it works, as I've used it before. Though last time I had some sort of trouble with it conflicting with other tag fired scripts...
@Wldly hunt. Yours is the raw post data correct? That actually compiled when I used it in the script editor. However I can't seem to get the on_activate to work still. I think maybe the tag-based scripts themselves may need some touch ups?
#16
Posté 09 janvier 2012 - 07:36
Your OnActivate script appears to be correct as well as your switch in ModLoad.
My guess is that you're missing some small detail in the implementation.
When I get home from work tonight, I'm going to see if I have time to package it up in an erf and maybe a sample mod so you can see exactly how it was intended to be used.
Even if you decide to use a different system, I want to try to get this one working for you also. It's a good chance to learn a bit more about the way the engine works.
The code that you posted doesn't use tag based scripting. It does appear to be decent code.
All that code does is summon a placeable with a resref equal to the used items tag at the targeted location. I'm assuming the portal placeable has another script on it to do any actual jumping.
#17
Posté 09 janvier 2012 - 10:13
Since I'm not sure how new you are to the toolset or Aurora script, I'm going to try to be as specific as possible.
I'm a programmer, not a builder. Thus, my instructions on how to create/modify items may be a bit vague.
Note that you do not need to alter any of your modules event scripts to make this work. As long as you have tag based scripting enabled in your ModLoad script, this should work.
I plan to improve on the script I posted before I upload the erf and example mod so that only party members standing close to the character using the item will teleport instead of all party members in the area. The improved code will work exactly the same as this code.
If this item is purchased from a store, it may fail. The custom variables get deleted from store-bought items.
The fix I use for this is easy, and I'll upload that tonight also.
To make the code I posted work, you'll need 3 things:
A useable item. The code assumes that it is a scroll, although that's not essential. The code plays an animation of the player reading a scroll before teleporting them. The important things for the item are the tag, item powers, and a variable.
- For this example, I will use the tag jumpitem. The important thing to remember is that the tag of the item must match the name of the script, which I'll cover later. For now, change the tag of your new item to "jumpitem" (Without the quotes).
- In the item properties tab, remove any default properties that may be on the item. Then add a new property. The property that you want to add is "Cast Spell: Unique Power (Self Only)". I think it's listed as a spell. If this is a scroll, you should set it to Single Use.
- Now, open the variables page for the item. I forget exactly where you go to do that... In one of the tabs, there should be a var button. At the bottom of that window, you need to enter the following as the name of the variable (Left side text box): "JUMPTO" (Without the quotes). In the center box, choose String. The right hand text box is the value of the new variable. This value needs to match the tag of the waypoint that we are going to create in a few minutes. For this example, I am going to use JUMPDEST. Go ahead and type "JUMPDEST" (Without the quotes) in the right hand box and click the Add button to add it to the item.
A Waypoint This is the easiest part. Create a new waypoint. Give it a tag that matches the JUMPTO value that you set on the item. For the sake of the example, set the tag of the waypoint to "JUMPDEST" (Without the quotes).
A Script Create a new script and delete any default code that appears in the new script. Copy/Paste my code in to the script. Save the script with the same name as the tag of your item. For this example, save it as "jumpitem" (Without the quotes). Compile the script.
That should be all you need. To set it up in the mod, place one of your custom waypoints in your mod, and make sure the players can find the item that you made.
When a player uses the item, they will read a scroll and then teleport (along with any party members in the area) to the location of the waypoint.
If you want to make multiple items that teleport to different locations, all you have to do is make a copy of the item (Don't change its tag), change the value of the JUMPTO variable, and make a new waypoint with a tag that is the same as the new JUMPTO value.
EDIT: Fixed a few minor typos.
Modifié par wyldhunt1, 09 janvier 2012 - 11:59 .
#18
Posté 10 janvier 2012 - 09:27
It has the teleport script, item, and waypoint.
It has a working example mod.
It has the fix for store-bought items losing their variables, which is very handy.
EDIT:
Download it from here:
http://nwvault.ign.c....Detail&id=3852
Modifié par wyldhunt1, 11 janvier 2012 - 03:18 .
#19
Posté 11 janvier 2012 - 12:47
Modifié par Foregone_Conclusion, 11 janvier 2012 - 01:08 .
#20
Posté 11 janvier 2012 - 06:31
I recommend deleting the line that you added to your OnActivate script:
ExecuteScript(GetTag(GetItemActivated()),
OBJECT_SELF);
because that will tend to make a lot of scripts fire twice. As long as you have tag based scripts enabled and you haven't declared a script prefix in your ModLoad script (I assume that you haven't), then the default code will call the same script.
#21
Posté 13 janvier 2012 - 04:17
I have a question that is not entirely related. I was searching for a script I had a while ago that locked certain transitions from one side until they have been passed through from the opposite end without the need for key or extra items to be collected. Any chance someone knows of the script I'm speaking of?





Retour en haut






