Aller au contenu

Photo

Spellhook issue


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

#1
Mythyzyn

Mythyzyn
  • Members
  • 17 messages

Hi I'm trying to override spells, it's near to be OK but there is something strange

 

Here is my script :

#include "x2_inc_switches"
#include "mod_inc_cym_system"
void main()
{
 object oPC = OBJECT_SELF;
 
 int iSpellID = GetSpellId();
 
 SendMessageToPC(oPC, "iSpellID : " + IntToString(iSpellID));
 
 int iSpellLevel = GetSpellLevel(iSpellID); 
 
 SendMessageToPC(oPC, "iSpellLevel : " + IntToString(iSpellLevel)); 

 int iCasterLevel = GetCasterLevel(oPC);  
 
 SendMessageToPC(oPC, "iCasterLevel : " + IntToString(iCasterLevel));
 
 int iSpellCymCost = iSpellLevel * 100; 
 
 SendMessageToPC(oPC, "iSpellCymCost : " + IntToString(iSpellCymCost));
 
 if (!GetIsPC(oPC) || GetIsDM(oPC) || GetIsDMPossessed(oPC)) 
  {
   return;    
  }
 
 if (CS_CheckCym(oPC, iSpellCymCost) != 1)
  {
   SendMessageToPC(oPC, "Vous ne possédez pas assez de Cym pour lancer ce sort.");
   SetNoticeText(oPC, "SORT INTERROMPU (Pas assez de Cym)");
   SetModuleOverrideSpellScriptFinished();     
   return;
  }
 else
  {
   CS_TakeCym(oPC, iSpellCymCost);      
  } 
}  

It alsmot worked but it take the spell casted before the current cast

 

If I cast 2 times the Resistance spell, at first it didnt detect the ID (-1) but then It detect it (151).

 

Cf screen :

 

nwn2_ss_092215_180207.jpg

 

So the problem is that it detects each time the spell cast before the one I want to control

 

Thanks for helping!



#2
kevL

kevL
  • Members
  • 4 052 messages
that's odd. It should work but try substituting int GetLastSpell();

just to see what happens.

Also, am curious what happens if two different spells are cast, eg. Resistance then Light.

#3
Mythyzyn

Mythyzyn
  • Members
  • 17 messages

I substituted to try, but same problem

 

I'll launch many spells tomorrow to check but the issue is accurate for me

 

I go to sleep now (it's late in france :))



#4
kevL

kevL
  • Members
  • 4 052 messages
ok,
I'm guessing something goes wonky in code-flow prior to the spellhook. (Some sort of 'initialization' or 'setter' problem, if the spellhook fails only on the first spellcast after starting a game / loading a save) Or, does it fail at other times also, like after module- and/or area-transitions? I hope it doesn't fail randomly.


so ... it's getting the Casterlevel (OBJECT_SELF) okay ... but it's *not* recognizing the spell itself ... is it like that for every spell: fail on first cast, success on second ?


[edit] It wouldn't be something silly like a rogue Spells.2da in .hak or \Override, would it?

#5
Mythyzyn

Mythyzyn
  • Members
  • 17 messages

Thanks for helping :)

 

We don't use spells.2da or any other which can interact with spells, we just have a separate spells system not linked with nwn2 spells.

 

It does that for each spell, whatever the situation (transition etc...)

 

And It takes each time the ID from the spell casted before, I try with differents spells as you ask :

 

nwn2_ss_092315_094826.jpg



#6
Mythyzyn

Mythyzyn
  • Members
  • 17 messages

I try to do the same on a new module, and it worked on it !

 

I should have some problems on my module, i'll check this out and tell you what



#7
kevL

kevL
  • Members
  • 4 052 messages
sounds interesting :)

#8
Mythyzyn

Mythyzyn
  • Members
  • 17 messages

Finally I used a variable X2_S_UD_SPELLSCRIPT on the module, instead of a script on load

 

Which I set my script name for hook : lps_mod_spelloverride

 

It looks like works better as this

 

Thanks for help btw!



#9
kevL

kevL
  • Members
  • 4 052 messages

y.