0
0

hello…

So we have created a fev file containing an event for a monster attack and now we are confused how to create multiple instances of the same event – as there are multiple instances of monsters around.

So our loading code (in C#) is like this:
[code:16518sw3]
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using FMOD;

namespace EventLoader
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Test
{
FMOD.EventSystem eventsys = null;
FMOD.EventGroup Angriff = null;
FMOD.EventCategory master = null;
FMOD.Event monsterAttack = null, monsterAttack2 = null;
FMOD.EventParameter distance = null;
FMOD.RESULT result;

    private bool initialised = false;

    float rangemin, rangmax;

    private void ERRCHECK(FMOD.RESULT result)
    {
        if (result != FMOD.RESULT.OK)
        {
            throw new Exception(&quot;FMOD error! &quot; + result + &quot; - &quot; + FMOD.Error.String(result));

        }
    }

    private void initialize()
    {
        if (!initialised)
        {
            result = FMOD.Event_Factory.EventSystem_Create(ref eventsys);
            ERRCHECK(result);

            result = eventsys.init(128, INITFLAG.NORMAL, IntPtr.Zero, EVENT_INIT.NORMAL);
            ERRCHECK(result);

            result = eventsys.setMediaPath(@&quot;F:\Programme\FMODProject\&quot;);
            ERRCHECK(result);

            result = eventsys.load(@&quot;Hink.fev&quot;);
            ERRCHECK(result);

            result = eventsys.getGroup(&quot;Hink/Angriff&quot;, false, ref Angriff);
            ERRCHECK(result);

            result = Angriff.getEvent(&quot;Angriff&quot;, EVENT_MODE.DEFAULT, ref monsterAttack);
            ERRCHECK(result);

            result = Angriff.getEvent(&quot;Angriff&quot;, EVENT_MODE.DEFAULT, ref monsterAttack2);
            ERRCHECK(result);

            result = eventsys.getCategory(&quot;master&quot;, ref master);
            ERRCHECK(result);

            // !!! FAILS with invalid handle!!!
            result = monsterAttack.getParameter(&quot;distance&quot;, ref distance);
            ERRCHECK(result);

        }
    }

    public static void Main(string[] args)
    {
        Test test = new Test();
        test.initialize();


    }
}

}

[/code:16518sw3]

If we remove the line
result = Angriff.getEvent("Angriff", EVENT_MODE.DEFAULT, ref monsterAttack2);

then we can set the parameter for monsterAttack – but if we leave it, it fails – so it seems retrieving an event with getEvent invalidates already retrieved events.

So we are wondering what exactly is the logic behind events – do we have to load a event system for each monster? or is there a way to instanciate events?

any help is appreciated =)

edit:
we figured out that we re not supposed to create more than one eventsystem objects and that event handles can be stolen. But still can anyone suggest how to get this working?

  • You must to post comments
0
0

Whats the Max Playbacks set to, makes sure its not 1. And what is the error being returned?

  • You must to post comments
0
0

Thxalot – it works now :)

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.