Aller au contenu

Photo

On module load script extending single player


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

#1
Bofra

Bofra
  • Members
  • 5 messages
I'm trying to create a module that levels up the player to level 12 when he starts a new game but I'm having trouble with the scripting. I have the module extending single player (selected in hierarchy properties and module properties) and I have the following script as the modules core script:


void main()
{
    event ev   = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    switch (nEvent) 
    {        
            case EVENT_TYPE_MODULE_START:      
            {            
            // get the object which contains the player
            object oPlayer = GetHero();

            // Levelup script
            RewardXP(oPlayer, RW_GetXPNeededForLevel(12), TRUE, FALSE);
            SetAutoLevelUp(oPlayer, 0);
            break;
            }
           default:
           {
               break;
           }
    }
}


This doesn't do anything though.. I tried the same with EVENT_TYPE_MODULE_LOAD instead and it works fine but it means I need to reload the game after creating a character for it to take effect and I want it to happen directly after Character Generation. What am I doing wrong? Is the module not properly intercepting the MODULE_START event? Do I have to intercept character generation too, and if so how?

I know that I could simply just give the player the XP with console commands but I want to know why this doesn't work so I can learn how the Toolset actually works.. Thanks in advance!

Modifié par Bofra, 15 avril 2010 - 01:10 .


#2
avantoreon

avantoreon
  • Members
  • 115 messages
Try using EVENT_TYPE_CHARGEN_END instead of EVENT_TYPE_MODULE_START, then as soon as you exit character generation you'll gain the experience you need.



I think the CHARGEN_END event fires whenever you level up though, so you'll need to use a plot flag to make sure that you're only executing your custom script once.

#3
Bofra

Bofra
  • Members
  • 5 messages
Thank you avantoreon, that actually worked, don't know why I didn't try it before. Maybe because the example script on the wiki (http://social.biowar...cter_generation) uses the MODULE_START event.



I'm still not quite clear on why my mod doesn't capture the MODULE_START event though.. Could it be that it does actually capture it and runs the RewardXP script but during character generation so it actually can't give any XP yet?



Either way, thanks for the suggestion!

#4
Proleric

Proleric
  • Members
  • 2 360 messages
Incidentally, the likely reason that your original script didn't work is that it's implicitly followed by character generation, which tends to wipe out any player information and start again.