Game Development Community

Command question.

by Nathan Cox · in General Discussion · 06/11/2008 (9:01 am) · 5 replies

Is there a way to disable a command in a certain trigger and make something else happen without actually editing the command itself? Let's say the trigger is called exampleTrigger, on entry to the trigger the player cannot use a certain command, if they do onChatMessage("\c2You cannot use that here."); will be executed.

#1
06/11/2008 (10:22 am)
Think the easiest solution would be to just wrap the trigger callback in a function that first checks to see if the action is valid. You could do that elegantly with a package:

package MyTriggerStuff
{
    function MyTrigger::onEnterTrigger( %this, %trigger, %obj )
    {
        if( !isOkayToTriggerCommand() )
            ;//do your chat feedback thing here
        else
            Parent::onEnterTrigger( %this, %trigger, %obj );
    }
}

activatePackage( MyTriggerStuff );

//Edit: fixed typo
#2
06/12/2008 (9:52 am)
Huh? Where do i put the command i wish to disable? You don't get what im saying...

I want it so that when inside the trigger if someone uses a command it wont work and it will come up with the message. So basically in my game i dont want people to use the fireball spell inside a safe zone so it would look something like this:

datablock triggerData(safeZoneTrigger)
{
     tickPeriodMS = 100;
}

function safeZoneTrigger::OnEnterTrigger(%this, %trigger, %obj)
{
     //here will be the bit im on about
}
#3
06/12/2008 (11:06 am)
function safeZoneTrigger::OnEnterTrigger(%this, %trigger, %obj)
{
      %obj.canCastFireballSpell = 0;
}

And then in your fireball spell, you can check that flag when the player tries it, and then send a message or do whatever if it's set, and let it rip when it's not. I haven't tested that, but it should work just fine.
#4
06/12/2008 (12:39 pm)
But that's the problem. I made the fireball Data a DSO file so i cannot edit, this is why i'm asking the question!
#5
06/12/2008 (12:46 pm)
You don't have a .cs copy of it?

I got nothin' then... Sorry... :(