Welcome to the Builder Academy

Question Lag Initiator Snippet for DG_Scripts

More
07 Nov 2019 00:56 - 07 Nov 2019 00:57 #8440 by Sapphire
I got a wild idea in my head tonight to add a dg_script variable which causes a player to lag in a way identical to when you use a skill such as Bash or Kick. In my case, I needed a script to emulate the 1 round of combat lag because of a unique cast type trigger on my mud. I thought I would include this below for anyone else who is interested in allowing triggers to lag a player in-game. Keep in mind, I'm operating off of a SunTzu variant of Circle, but I attempted to convert it to TBA's format for the purposes of this forum. Whereas SunTzu uses "GET_WAIT_STATE(c) = addition * PULSE_VIOLENCE;" in the trigger, I'm assuming TBA follows an identical format to its act.offensive.c format, so I adjusted it to, "WAIT_STATE(c, addition * PULSE_VIOLENCE);" to match the TBA format. Also, SunTzu has the area to include the code in dg_scripts.c, but it looks like TBA moved it all to dg_variables.c.

Note: I included a fail-safe mechanism for if a builder uses negative integers, or a zero. In the case of this variable, it can be called upon with %actor.lag% to determine an existing wait_state, and if you want to lag a player you can use the nop function. IE: "nop %actor.lag(3)%" would lag a player for 3 rounds.

In dg_variables.c

Original:
Code:
case 'l': if (!str_cmp(field, "level")) { if (subfield && *subfield) { int lev = atoi(subfield); GET_LEVEL(c) = MIN(MAX(lev, 0), LVL_IMMORT-1); } else snprintf(str, slen, "%d", GET_LEVEL(c)); } break;

Replace with:
Code:
case 'l': if (!str_cmp(field, "lag")) { if (subfield && *subfield) { int addition = atoi(subfield); if (addition <= 0) { } if (addition >= 1) { WAIT_STATE(c, addition * PULSE_VIOLENCE); } } snprintf(str, slen, "%d", WAIT_STATE(c)); } else if (!str_cmp(field, "level")) { if (subfield && *subfield) { int lev = atoi(subfield); GET_LEVEL(c) = MIN(MAX(lev, 0), LVL_IMMORT-1); } else snprintf(str, slen, "%d", GET_LEVEL(c)); } break;
Last edit: 07 Nov 2019 00:57 by Sapphire.
The following user(s) said Thank You: thomas

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

Time to create page: 0.209 seconds