Starting Modding - Script isn't called?

Moderator: Pocus

Post Reply
bob999
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 1
Joined: Fri Sep 25, 2015 10:45 am

Starting Modding - Script isn't called?

Post by bob999 » Mon Nov 30, 2020 3:52 pm

Dear Modding Community:

I have been trying to create a "safety net" mod that would provide money if a human controlled nation's money fell below 10. I created the mod in the Events_Plugin.BSF file based on the example wiki, but it never seems to execute. I've set the trigger to the absurdly high "1000 money" for testing, so it should trigger in the first turns, but nothing happens.

The code is here:

Code: Select all

FUNCTION Event_EntryPoint()
{
        // Define safety net events for money, metal and manpower
	EventCustom_SafetyMoney();
}

////   Human Safety Net Functions ////

//     Turn to start looking for event (turn 2, game is zero based)

#define EVTCUSTOM_SAFETY_TURNSTART   0

//     Amount to trigger the event
#define EVTCUSTOM_SAFEMONEY_CHECK   1000

//     Amount of safety net
#define EVTCUSTOM_SAFEMONEY_AMOUNT 5000

FUNCTION EventCustom_SafetyMoney()
{
       int facCount;
       int facIndex;
       int factionID;
       
       if (GetTurn() >= EVTCUSTOM_SAFETY_TURNSTART) 
       {
           //   Loop Around Factions to find the Humans
           facCount = GetNumFactions();
           for (facIndex = 0; facIndex < facCount; facIndex++)
           {
                if (Faction_AI_IsHumanPlayer(factionID) == TRUE )
                {                
                    if (Faction_GetResource(factionID, gResourceMoney) < EVTCUSTOM_SAFEMONEY_CHECK)
                    {
                        Faction_AddResource(factionID, gResourceMoney, EVTCUSTOM_SAFEMONEY_AMOUNT);
                        Message_Faction_ChangeResourcePrivate(factionID, Faction_Politic_SeatOfPower(factionID), EVTCUSTOM_SAFEMONEY_AMOUNT, MSG_IMP_TOP, "IDS_MSG_EVENT_SAFEMONEY");
                    }
                }
           }
       }
}



Any thoughts?? (I've also changed all the if clauses to "if (TRUE == TRUE)", but the whole script never executes.

Bob

Pocus
Ageod
Ageod
Posts: 2704
Joined: Tue Oct 02, 2012 3:05 pm

Re: Starting Modding - Script isn't called?

Post by Pocus » Fri Dec 04, 2020 1:36 pm

Hi and sorry for the delay in answering.

I copy pasted your code and I break into, so there is no fundamental issue. For now the only possible cause of error I see is that you added the function in a scenario but are testing in another ...

Also you might want to use DebugBreak to halt the compiler:

Add DEBUGMODE 1 to My Games\FieldOfGloryEmpires\USER.TXT
http://archonwiki.slitherine.com/index. ... ng_Started

Image
AGEOD Team - Makers of Empires, ACW2, WON, EAW, PON, AJE, RUS, ROP, WIA.

Post Reply

Return to “MOD”