Aller au contenu

Photo

[solved] Getting item and its script into OC


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

#1
zamiwas

zamiwas
  • Members
  • 10 messages
Hoping someone can help me with this,

I made a new item, and a script for its On-hit-cast-spell (unique power),   and they work in a test module.

Now Im trying to get the item into the HotU OC single player to play with. So I put the .UTI and .nss  (?)  into the override folder.  and While I can get the item,  the script does not seem to be coming wth it : (

I tried both importing a saved char,  and dm_spawnitem,   but the script for its On-Hit just isnt there. 
Hopefully theres a simple solution for my newbie understanding. Thanks

Modifié par zamiwas, 04 janvier 2012 - 03:33 .


#2
wyldhunt1

wyldhunt1
  • Members
  • 246 messages
.nss is the uncompiled text. The .ncs is the compiled script that the engine uses.
Make sure that you have the .ncs as well.

#3
zamiwas

zamiwas
  • Members
  • 10 messages
I do have the .ncs as well, But its still not working : /

#4
WhiZard

WhiZard
  • Members
  • 1 204 messages

zamiwas wrote...

I do have the .ncs as well, But its still not working : /


HotU likely uses a module prefix (like "X2_") which would need to be the first character's of the script name (e.g. X2_SCRIPT_TAG would be needed where instead of SCRIPT_TAG).

EDIT: Looking through the HotU OnActivateItem script, it appears the above is not the case.  So long as the tag of the item matches the item, (and is not a special case like the relic of the reaper or Tynan's top)  your script should fire.

Modifié par WhiZard, 02 janvier 2012 - 08:42 .


#5
zamiwas

zamiwas
  • Members
  • 10 messages
Ok I tested a new working item and script (x2_dummy.uti and x2_dummy.ncs) but it still doesnt work in HotU. Arrg

#6
wyldhunt1

wyldhunt1
  • Members
  • 246 messages
You would need to check and see what the prefix is. X2_ was just an example.
It might be set in ModLoad. You can also have a script that grabs the prefix from the variable set on the mod and either dump it to a log file or send it to the character so that you know what it is.

I'm at work now, so I can't check myself.

#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

zamiwas wrote...

Ok I tested a new working item and script (x2_dummy.uti and x2_dummy.ncs) but it still doesnt work in HotU. Arrg


I just found that HotU doesn't use the prefix, though the HotU version does include the prefix possibility.  One last suggestion is to check capitalization; does the tag use capital letters?

#8
zamiwas

zamiwas
  • Members
  • 10 messages
Nope, everythings lowercase. And it does work in a mod, just not the oc.

I'll troubleshoot if its something wrong in the script

#9
WhiZard

WhiZard
  • Members
  • 1 204 messages

zamiwas wrote...

Nope, everythings lowercase. And it does work in a mod, just not the oc.

I'll troubleshoot if its something wrong in the script


I found the problem.  I should have relooked and seen that you were using On-Hit unique power, the only custom script one that does not go through the activate item event.  HoTU replaces the normal custom script firing with its own set of events.

Go into "x2_s3_onhitcast"

Scroll to the bottom "else" command which looks like this:

else
   {
        // Error: Spell was not cast by an item
   }

Insert into this else command

ExecuteScript(GetTag(oItem), oSpellOrigin);

Modifié par WhiZard, 02 janvier 2012 - 09:03 .


#10
zamiwas

zamiwas
  • Members
  • 10 messages
I tried editing the "x2_s3_onhitcast", in the toolset, and threw it in the override folder.
Even tried erasing everything and just putting your code, but it still doesnt seem to be working

#11
WhiZard

WhiZard
  • Members
  • 1 204 messages

zamiwas wrote...

I tried editing the "x2_s3_onhitcast", in the toolset, and threw it in the override folder.
Even tried erasing everything and just putting your code, but it still doesnt seem to be working


The HotU's module script takes precedence over the override.  If you are limited to overrides, then you might want to change the spells.2da entry that calls "x2_s3_onhitcast", to have it call a different and not yet defined script,  then copy what is in "x2_s3_onhitcast" into that script and put the generic script caller into the else argument.

If you are not limited to overrides, copy the HotU modules from the "nwm" folder into the "modules" folder.  Rename the copied modules to be *.mod instead of *.nwm.  Then you can edit the *.mod entries and the game will show up under "Other Modules".

Modifié par WhiZard, 02 janvier 2012 - 09:54 .


#12
zamiwas

zamiwas
  • Members
  • 10 messages
Edit:   
Ok I think I edited the spells.2da, and the new onhitcast script correctly.   But that isn't working.

So I tried doing the HotU as a Module,  edited the "x2_s3_onhitcast"  script as you described,  but its not working that way either.

Im probably missing something obvious,  meddling in unknown territory.   : /

Modifié par zamiwas, 03 janvier 2012 - 01:08 .


#13
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
First the scripts in the module do not override the override folder.  The override folder overrides the scripts in the module. EDIT:  I am wrong on that one.  Good thing I don't use the override folder much.  
The code inserted into x2_s3_onhitcast will probably be the best way to go as Whizard has sugested.  The only problen there is that he picked the wrong place in the script to place the code.   He also missed setting the userdefined event number if your script is checking for it.

Make the code look like this then compile it and place the  x2_s3_onhitcast.ncs into your override folder.

//::///////////////////////////////////////////////
//:: User Defined OnHitCastSpell code
//:: x2_s3_onhitcast
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    This file can hold your module specific
    OnHitCastSpell definitions
    How to use:
    - Add the Item Property OnHitCastSpell: UniquePower (OnHit)
    - Add code to this spellscript (see below)
   WARNING!
   This item property can be a major performance hog when used
   extensively in a multi player module. Especially in higher
   levels, with each player having multiple attacks, having numerous
   of OnHitCastSpell items in your module this can be a problem.
   It is always a good idea to keep any code in this script as
   optimized as possible.

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-22
//:://////////////////////////////////////////////
#include "x2_inc_switches"
//:: UPDATE August 5/03 - Add Goblin marker Arrows for Level 2 of Undermountain
void main()
{
   object oItem;        // The item casting triggering this spellscript
   object oSpellTarget; // On a weapon: The one being hit. On an armor: The one hitting the armor
   object oSpellOrigin; // On a weapon: The one wielding the weapon. On an armor: The one wearing an armor
   // fill the variables
   oSpellOrigin = OBJECT_SELF;
   oSpellTarget = GetSpellTargetObject();
   oItem        =  GetSpellCastItem();
   if (GetIsObjectValid(oItem))
   {
       // Add your desired behaviour here
       // Example: (make target burst in flames)
       // if (GetTag(oItem) == "my_cool_weapon")
       // {
       //    ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_FLAME_M), oSpellTarget);
       // }
          //If a PC is hit by a goblin marker arrow - the Goblin chiefs switches will cause effects
          //on that pc (or associate)
        if (GetTag(oItem) == "q2cmarker")
        {
            ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_HIT_ACID), oSpellTarget);
            ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_CHUNK_GREEN_MEDIUM), oSpellTarget);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_GLOW_GREEN), oSpellTarget, 30.0);
            if (GetLocalInt(oSpellTarget, "X2_Q2CGoblinMark") == 0)
            {
                SetLocalInt(oSpellTarget, "X2_Q2CGoblinMark", 1);
                FloatingTextStrRefOnCreature(84143 , oSpellTarget);
                object oArea = GetArea(oSpellTarget);
                AssignCommand(oArea, DelayCommand(30.0, SetLocalInt(oSpellTarget, "X2_Q2CGoblinMark", 0)));
            }
            return;
        }
        // * 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_ONHITCAST);
        int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
        if (nRet == X2_EXECUTE_SCRIPT_END)
        {
           return;
        }
      }
   }
   else
   {
        // Error: Spell was not cast by an item
   }


Also keep in mind, before you try and start adding other Tag based Scripts to the OC, The modules are not set op for tag based scripting.   I also only checked one of the modules in the HoTU  if the other modules use different versions of the x2_s3_onhitcast script, you may introduce bugs into the game.   

Modifié par Lightfoot8, 03 janvier 2012 - 02:41 .


#14
WhiZard

WhiZard
  • Members
  • 1 204 messages

Lightfoot8 wrote...

First the scripts in the module do not override the override folder.  The override folder overrides the scripts in the module.


Umm...

The order from what I've been told many times is...

Module Scripts> Hak pak > override > core scripts

The HotU module inserted its own x2_s3_onhitcast to override the core x2_s3_onhitcast

#15
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Well, The test I just ran says you are right and I am wrong. Back to running more tests. Most likely I am wrong on that one though.

#16
WhiZard

WhiZard
  • Members
  • 1 204 messages
Just to note Lightfoot is correct concerning the ExecuteScript() placement.

However, I have never really seen how the ExecuteScriptAndReturnInt() really functions in the On Hit: Unique Power spell script. If after the script being called completes, the value X2_EXECUTE_SCRIPT_END is found to be set, then the calling script immediately completes and ends, otherwise it naturally completes and ends.

#17
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Yea, That was just a cut and paste. commenting out the check for the TagBased scripting switch since TBS is not enabled in the OC anyway.

#18
Alex Warren

Alex Warren
  • Members
  • 179 messages

WhiZard wrote...

The order from what I've been told many times is...

Module Scripts> Hak pak > override > core scripts


This looks wrong. (Sorry, I'm too lazy to search it now ;p )
IIRC this should be

hak pak > override > module scripts > core scripts

#19
zamiwas

zamiwas
  • Members
  • 10 messages
I'm a bit stumped. I don't even think the "x2_s3_onhitcast" script is being reached and executed.

edit:  I noticed HotU mod has different Module Properties,  for Events.  So I'll troubleshoot there

Modifié par zamiwas, 03 janvier 2012 - 07:40 .


#20
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
It goes
highest ---> lowest priority
hak -> module -> override -> core resources

the only thing you can override using the overrides folder are core resources. If the module itself (or a hak) has the same resource in it, that version will have priority over both overrides and core resources. I believe that's what you're seeing here.

Why don't you simply edit the hotu module directly, add in your stuff, then rebuild it?

#21
zamiwas

zamiwas
  • Members
  • 10 messages
I'm trying to. Its getting the item's script for On-hit-cast-spell-unique-power to work that's the problem

Modifié par zamiwas, 05 janvier 2012 - 04:43 .


#22
zamiwas

zamiwas
  • Members
  • 10 messages
Thanks guys, the x2_s3_onhitcast is working.
Its just that my spell isnt, in the HoTU mod only. It's just strange.

Modifié par zamiwas, 05 janvier 2012 - 04:44 .


#23
zamiwas

zamiwas
  • Members
  • 10 messages
Woohoo!! Solved

Thanks everyone especially WhiZard.

Summed up answer:   
Copy the HoTU files ("X2..") from the nwm folder into modules folder. Give a different filename AND .mod extension.

In the Toolset, open the modules' "x2_s3_onhitcast"  script.   Add a statement  'if (GetTag(oItem) == "item-tag" ', containing the weapon's on-hit script directly.  Then make an item, or put the .UTI into the override folder.   Save, and start the OC through the New > other modules.

I used Lilac Soul's script program for the on-hit script.  Also used cheat dm_spawnitem (item) to get item in game.

Modifié par zamiwas, 05 janvier 2012 - 04:46 .