Blocking Triggers

Login to reply  Page: « < 1 of 1 > »
17 Nov 2009 - 13:202052
Blocking Triggers
I have written a trigger that blocks a player when they go a particular direction. To make it quick for my builders I made one for each direction as a different trigger. However if I add the triggers to my mobs and add more than one so they block multiple directions, they only block the direction of the first trigger. Below is my trigger for nort, plese let me know what is wrong.

if (%direction%==north && %actor.canbeseen%)
%send% %actor% %self.name% steps in front of you blocking your way.
%echoaround% %actor% %self.name% steps in front of %actor.name% blocking his way.
return 0
end return 0

Also, how do I block based on race of player - I see class options, but not race.



Last edited by mitchm (17 Nov 2009 - 13:20)
17 Nov 2009 - 13:342053
if %direction%==north && %actor.canbeseen%
%send% %actor% %self.name% steps in front of you blocking your way.
%echoaround% %actor% %self.name% steps in front of %actor.name% blocking %actor.hisher% way.
return 0
else
end

races will have to be added to your dg_variables.c file i believe. Just find where it finds the class and copy it, changing it for races.

else if (!str_cmp(field, "class"))
sprinttype(GET_CLASS(c), pc_class_types, str, slen);


should make one for races in the "R" section.





Last edited by rudeboyrave (17 Nov 2009 - 13:35)
17 Nov 2009 - 13:452054
Quote rudeboyrave:
if %direction%==north && %actor.canbeseen%
%send% %actor% %self.name% steps in front of you blocking your way.
%echoaround% %actor% %self.name% steps in front of %actor.name% blocking %actor.hisher% way.
return 0
else
end

races will have to be added to your dg_variables.c file i believe. Just find where it finds the class and copy it, changing it for races.

else if (!str_cmp(field, "class"))
sprinttype(GET_CLASS(c), pc_class_types, str, slen);


should make one for races in the "R" section.




Your code works just fine for blocking north. However the problem arises if I make one trigger for Block North and another trigger for Block South. If I put them both on the same mob the North trigger kicks in and blocks, the south trigger doens't and I can move freely south.



17 Nov 2009 - 13:572055
When attaching more than one trigger of the same type only the first trigger of that type fires. Normally this is bypassed by using a "return 0" but for this trig type return 0 also means prevent movement. You will have to just add elseif's for the other directions. I'm surprised we haven't run into this yet, anyone else have any thoughts on a wokaround?


__________________
Rumble
The Builder Academy
tbamud.com 9091
17 Nov 2009 - 14:002056
Quote Rumble:
When attaching more than one trigger of the same type only the first trigger of that type fires. Normally this is bypassed by using a "return 0" but for this trig type return 0 also means prevent movement. You will have to just add elseif's for the other directions. I'm surprised we haven't run into this yet, anyone else have any thoughts on a wokaround?


I do not understand what you mean about adding elseif's for the other directions.

If I have my North trigger in the list first and then add to the mob my south trigger, should it look different to ensure that it fires as well? Or do you mean the only way to acomplish a mob blocking in two directions is to make one trigger that blocks both ways?


17 Nov 2009 - 18:092058
Quote:

Or do you mean the only way to acomplish a mob blocking in two directions is to make one trigger that blocks both ways?


Yes, something like:

if %actor.canbeseen%
  if %direction% == north
    do stuff
  elseif %direction% == south
    do other stuff
  end
end


__________________
17 Nov 2009 - 19:072059
Quote Fizban:
Quote:

Or do you mean the only way to acomplish a mob blocking in two directions is to make one trigger that blocks both ways?


Yes, something like:

if %actor.canbeseen%
  if %direction% == north
    do stuff
  elseif %direction% == south
    do other stuff
  end
end


Then I assume for speed of building I'll just code flags into the game that block certain directions. That way my builders don't have to create a trigger for each mob that they want to block a particular direction or directions.


Login to reply  Page: « < 1 of 1 > »