Welcome to the Builder Academy

Question Combat trigger help

More
24 May 2025 05:10 #10713 by Salty
Combat trigger help was created by Salty
Greetings,

I'm trying to write a combat trigger which targets only a random person in the room.  I've hit a wall with %random.char% as it seems to be written for random triggers and not combat triggers.  I've also noticed random triggers do not fire in combat.
Code:
#2108 Mictlantecuhtli aura of death~ 0 k 100 ~ if %random.char%   set target %random.char%   %echo% Target is %target.name%   if %target%     %send% %target% An icy wind eminates from %self.name% and your soul is chilled!     %damage% %target% 1000   else     %echo% ERROR   end else   %echo%  NO RANDOM CHAR end ~

The trigger will fire once and then send ERROR.

Any thoughts?

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

More
24 May 2025 10:23 - 24 May 2025 10:23 #10714 by thomas
Replied by thomas on topic Combat trigger help
What you're doing isn't really supported via default parameters, but since dg_scripts are flexible, you can do it like this:
Code:
Trigger Intended Assignment: Mobiles Trigger Type: Fight , Numeric Arg: 100, Arg list: None Commands: set count 0 set temp %self.room.people% while %temp%   if %temp% == %self%     eval temp %temp.next_in_room%     continue   end   eval count %count% + 1   set vict%count% %temp%   eval temp %temp.next_in_room% done if %count% > 0   eval targetnum %%random.%count%%%   eval target %%vict%targetnum%%%   %send% %target% An icy wind eminates from %self.name% and your soul is chilled!   %echoaround% %target% %target.name% is hit by an icy wind!   %damage% %target% 1000 else   %echo% No targets found for icy wind attack end
Last edit: 24 May 2025 10:23 by thomas. Reason: formatting

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

More
24 May 2025 18:22 - 25 May 2025 00:13 #10716 by Salty
Replied by Salty on topic Combat trigger help
Thanks, that worked a treat.  One small issue is that it's still erroring if an immortal is in the room with nohassle.

I tried adding:
Code:
if %temp.pref(NO_HASS)%   eval temp %temp.next_in_room%   continue end
into the while loop without success.   mdamage, mechoaround and msend error out and the trigger doesn't fire on mortals at all if an Imm is in the room with nohassle.
Code:
[ Mob (Mictlantecuhtli, God of the Dead, VNum 2109):: msend: victim (}10000001) does not exist ] [ Mob (Mictlantecuhtli, God of the Dead, VNum 2109):: mechoaround: victim (}10000001) does not exist] [ Mob (Mictlantecuhtli, God of the Dead, VNum 2109):: mdamage: victim (}10000001) does not exist ]


I've looked high and low in the dg_*.c files and can't tease out a reason why.  In an object trigger a similar if statement with a level prohibition works to prevent the trigger firing on immortals with nohassle.

In my game NPC attacks may target the room (drawing non-combat characters into combat), but nohassle bypasses the attacks from targeting the Immortal.  For safety sake I'd like nohassle to bypass the spec as well.

Thoughts on how to make nohassle and the spec work together?

Thanks!

Edit:

The NPC can hit itself with the trigger:
Code:
An icy wind eminating from Mictlantecuhtli, God of the Dead blasts Mictlantecuhtli, God of the Dead!

I tried adding the following into the while loop:
Code:
  if !%temp.is_pc%     eval temp %temp.next_in_room%     continue   end
It seems like the %temp% == %self% block didn't do it either.  This behavior only happens when there is more than 1 NPC in the room.
I'm kinda confused at this point.
Last edit: 25 May 2025 00:13 by Salty.

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

More
25 May 2025 00:27 #10717 by Salty
Replied by Salty on topic Combat trigger help
Seems like I fixed it:
Code:
Mictlantecuhtli aura of death~ 0 k 100 ~ set count 0 set temp %self.room.people% while %temp%   eval count %count% + 1   set vict%count% %temp%   eval temp %temp.next_in_room% done if %count% > 0   eval targetnum %%random.%count%%%   eval target %%vict%targetnum%%%   if !%target.is_pc%     eval targetnum %%random.%count%%%     eval target %%vict%targetnum%%%   end   %send% %target% @RAn icy wind eminates from %self.name% and your soul is chilled!@n   %echoaround% %target% @RAn icy wind eminating from %self.name% blasts %target.name%!@n   %damage% %target% 10000 end ~
I moved the logic checking for PC/NPC out of the while loop into the count if statement.  Now if there's a NPC selected, we reelect a new target.  Either we get a PC or the trigger doesn't fire.

Hopefully there's a more graceful way to do this?

Thanks

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

More
25 May 2025 14:59 - 25 May 2025 14:59 #10718 by thomas
Replied by thomas on topic Combat trigger help
Yeah, that won't necessarily work - you've just been lucky that the random check has hit what you expected.

try this instead:
Code:
Trigger Intended Assignment: Mobiles Trigger Type: Fight , Numeric Arg: 100, Arg list: None Commands: set count 0 set temp %self.room.people% while %temp%   if %temp% == %self%     eval temp %temp.next_in_room%     continue   end   if %temp.is_pc% && %temp.canbeseen% && !%temp.pref(NO_HASS)%     eval count %count% + 1     set vict%count% %temp%   end   eval temp %temp.next_in_room% done if %count% > 0   eval targetnum %%random.%count%%%   eval target %%vict%targetnum%%%   %send% %target% An icy wind eminates from %self.name% and your soul is chilled!   %echoaround% %target% %target.name% is hit by an icy wind! end
Last edit: 25 May 2025 14:59 by thomas. Reason: formatting

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

Time to create page: 0.189 seconds