Triggered conditions

This forum is currently in read-only mode.
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • Ok so when a state changes from true to false or from false to true I want to generate a triggered event. I know that I use the flag CND_TRIGGERED and the generateEvent() call. but what would the ADDCND function look like because the event is generated in the switch action.

    if( strcmp(tempState.name, tempString) =0)
    		{
    			if(tempState.state)
    			{
    				tempState.currentState = false;
    
    				// call the true to false trigger here
    				
    			}
    			else
    			{
    				tempState.currentState = true;
    				// call the false to true trigger here
    			}
    
    		}[/code:13g8hh22]
  • if( strcmp(tempState.name, tempString) =0)[/code:1gkjhzbu]
    This line is wrong, you need == to compare to zero.  Otherwise you're assigning 0 to the result of strcmp, but it should actually give you a compile error.
    
    I'm not sure I understand your question.  You call GenerateEvent() to trigger an event, and the event you trigger must have the CND_TRIGGERED flag.  Which part of this are you having trouble with?
    
    Edit:  Don't forget you can look at what other plugins do on SVN.  Here's a triggered condition in Sprite:
    [code:1gkjhzbu]ADDCND("On any animation finished", "Animations", "%o %n: Any animation finished", &ExtObject::cTrigger, "AnyAnimFinished", CND_TRIGGERED);[/code:1gkjhzbu]
    
    cTrigger just returns true:
    
    [code:1gkjhzbu]long ExtObject::cTrigger(LPVAL params)
    {
    	return true;
    }[/code:1gkjhzbu]
    
    ...because it should always run the event when GenerateEvent is called.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How do i distuguish between the two triggered events in the generate event call?

    void ExtObject::aSwitchState(LPVAL params)
    {
    
    	for( int i = 0; i< (int) stateVector.size(); i++)
    	{
    		state tempState = stateVector[i]
    		CString tempString = params[0].GetString();
    
    		if( strcmp(tempState.name, tempString) == 0)
    		{
    			if(tempState.state)
    			{
    				tempState.currentState = false;
                                    GenerateEvent(); // how do the GenerateEvent() calls distiguish between the two?
    				// call the true to false trigger here
    				
    			}
    			else
    			{
    				tempState.currentState = true;
    				GenerateEvent();
    				// call the false to true trigger here
    			}
    
    		}
    
    	}
    }[/code:3bbpr97n]
  • ...you haven't added any parameters to GenerateEvent! What made you think you call it like that? It takes three parameters, again using Sprite as an example:

    pRuntime->GenerateEvent(info.oid, 7, this);[/code:11c7mqmh]
    The first and last parameters are always 'info.oid' and 'this'.  The second parameter is the zero based index of the condition to trigger (0 is the first condition added by ADDCND, 1 is the second etc).
    
    I'd really recommend downloading the other plugin/behavior sources and seeing how they do things.  You'll learn a lot about how the SDK works that way.
  • Dont worry Im not calling them that way lol I know they take params I looked at the definitions. It took me a bit to download the SVN i was just asking about how the generateEvent function knew which triggered event to trigger. So I would call the GenerateEvent(info.id, 3, this) if it is the 3rd condition defined in the ACETable.cpp right?

  • the id of the triggered condition is it's order in the ACE Table,

    first condition is 0, and you count all conditions, triggered or not.

  • It's zero based so 3 would refer to the fourth condition added by ADDCND.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)