Welcome to the Builder Academy

Question Pokeball Trigger

More
07 Jun 2013 00:19 #2922 by mojo
Pokeball Trigger was created by mojo
* By MoJo
* Note that this does not take account for the level of the mob or even if they're !CHARM
* room 8299 must exsist for the pokemon to be transferred into or change the code

Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: catch release
Commands:
if %cmd% == release

if (%self.varexists(captured)%)
%teleport% %captured.name% %self.in_room%
%echoaround% %actor% %actor.name% tosses his pokeball into the middle of the room.
eval releasespeech %random.4%
switch %releasespeech%
case 1
%echoaround% %actor% %actor.name% says, " %captured.name%, I choose you!"
%send% %actor% You toss your pokeball and shout, " %captured.name%, I choose you!"
break

case 2
%echoaround% %actor% tosses a pokeball and shouts, " %captured.name%, let's go!"
%send% %actor% you toss your pokeball and shout, " %captured.name%, let's go!"
break

case 3
%echoaround% %actor% tosses a pokeball and shouts, "Lets go %captured.name%!"
%send% %actor% you toss your pokeball and shout, "Let go %captured.name%!"
break

case 4
%echoaround% %actor% tosses a pokeball and shouts, " %captured.name%! I need your help!"
%send% %actor% you toss your pokeball and shout, " %captured.name%! I need your help!"
break

default
%echoaround% %actor% %actor.name% says, " %captured.name%, I choose you!"
%send% %actor% You toss your pokeball and shout, " %captured.name%, I choose you!"
break
done

%echo% %captured.name% appears in a bright flash!
unset captured

else
%send% %actor.name% there is no pokemon in your ball.
end
halt
end



if !(%arg%)
%send% %actor% Who do you want to catch?
halt
end

makeuid target %arg.id%
%echoaround% %actor% %actor.name% clutches his %self.name% and stares at %target.name%
%send% %actor% You clutch the %self.name% and target %target.name%
case %target.is_pc%
switch %target.is_pc%
case 1
%send% %actor% You can't put players inside pokeballs.
halt
break
default

if %target.room% != %actor.room%
%send% %actor% They must be in the same room as you!
halt
end

if %target.id% == %actor.id%
%send% %actor% You can't fit in there!
halt
end

%send% %actor% You toss %self.shortdesc% at %target.name%
%echoaround% %actor% %actor.name% tosses %self.shortdesc% at %target.name%
eval catchem %random.3%
switch %catchem%
case 1
%force% %target.name% follow %actor.name%
%echo% A bright flash of light envelopes %target.name% and %self.shortdesc% closes around %target.himher% !
dg_affect %target.id% charm on 99
makeuid captured %arg.id%
global captured
%teleport% %target.name% 8299
break
case 2
%echo% %target.name% narrowly escapes being caught in %self.shortdesc%!
break
case 3
%echo% %self.shortdesc% bounces two times and releases %target.name%
break
default
%echo% %self.shortdesc% bounces on the ground 1 time and then releases %target.name%
done



break
done

Please Log in or Create an account to join the conversation.

More
15 Aug 2013 21:10 #4047 by Rumble
Replied by Rumble on topic Pokeball Trigger
Thanks for posting an example. I don't have to be the only one to post trigs of the day :-)

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com

Please Log in or Create an account to join the conversation.

More
17 Aug 2013 03:33 - 17 Aug 2013 03:35 #4075 by Fizban
Replied by Fizban on topic Pokeball Trigger
Indented it to make it easier to read.
Code:
Trigger Intended Assignment: Objects Trigger Type: Command , Numeric Arg: 2, Arg list: catch release Commands: if %cmd% == release if (%self.varexists(captured)%) %teleport% %captured.name% %self.in_room% %echoaround% %actor% %actor.name% tosses his pokeball into the middle of the room. - eval releasespeech %random.4% + set releasespeech %random.4% switch %releasespeech% case 1 %echoaround% %actor% %actor.name% says, " %captured.name%, I choose you!" %send% %actor% You toss your pokeball and shout, " %captured.name%, I choose you!" break case 2 %echoaround% %actor% tosses a pokeball and shouts, " %captured.name%, let's go!" %send% %actor% you toss your pokeball and shout, " %captured.name%, let's go!" break case 3 %echoaround% %actor% tosses a pokeball and shouts, "Lets go %captured.name%!" %send% %actor% you toss your pokeball and shout, "Let go %captured.name%!" break case 4 %echoaround% %actor% tosses a pokeball and shouts, " %captured.name%! I need your help!" %send% %actor% you toss your pokeball and shout, " %captured.name%! I need your help!" break default %echoaround% %actor% %actor.name% says, " %captured.name%, I choose you!" %send% %actor% You toss your pokeball and shout, " %captured.name%, I choose you!" break done %echo% %captured.name% appears in a bright flash! unset captured else %send% %actor.name% there is no pokemon in your ball. end halt end if !(%arg%) %send% %actor% Who do you want to catch? halt end makeuid target %arg.id% %echoaround% %actor% %actor.name% clutches his %self.name% and stares at %target.name% %send% %actor% You clutch the %self.name% and target %target.name% case %target.is_pc% switch %target.is_pc% case 1 %send% %actor% You can't put players inside pokeballs. halt break default if %target.room% != %actor.room% %send% %actor% They must be in the same room as you! halt end if %target.id% == %actor.id% %send% %actor% You can't fit in there! halt end %send% %actor% You toss %self.shortdesc% at %target.name% %echoaround% %actor% %actor.name% tosses %self.shortdesc% at %target.name% - eval catchem %random.3% + set catchem %random.3% switch %catchem% case 1 %force% %target.name% follow %actor.name% %echo% A bright flash of light envelopes %target.name% and %self.shortdesc% closes around %target.himher% ! dg_affect %target.id% charm on 99 makeuid captured %arg.id% global captured %teleport% %target.name% 8299 break case 2 %echo% %target.name% narrowly escapes being caught in %self.shortdesc%! break case 3 %echo% %self.shortdesc% bounces two times and releases %target.name% break default %echo% %self.shortdesc% bounces on the ground 1 time and then releases %target.name% + break done break done

Also found a few things that should probably be changed in it while doing so which are shown in the code box above.

I'd probably change the way it's written more than that if I were to use it, but those three changes don't change the way it's fundamentally written, just minor changes, one default case lacked a break, and eval was used in two spots where set was a better option.
Last edit: 17 Aug 2013 03:35 by Fizban.
The following user(s) said Thank You: mojo

Please Log in or Create an account to join the conversation.

Time to create page: 0.188 seconds