Welcome to the Builder Academy

Question Mob cast

More
17 Apr 2018 13:45 #7943 by JTP
Mob cast was created by JTP
Hi

Ok i know How to get a mob to cast a spell in fight.

But If i wanted a mob to always have a spell on, How would i go about doing that with a trigger ?
So when the spell runs out, it recast it. Or If dispelled it recast it.

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

More
17 Apr 2018 15:58 - 17 Apr 2018 16:08 #7944 by lacrc
Replied by lacrc on topic Mob cast
Hmm, I don't think there's a "affect" type of trigger that constantly checks affects and is fired when they change.

But I think it's possible to make a 'random' type trigger that fires every X minutes and checks if the affect is in place and acts accordingly.
According to the documentation if you set a 'random' type trigger's Num Argument to 20, it should fire about every minute (got that from here: dgscripts.tbamud.com/index.php?page=trigtypes&type=mob )

Then the script would be something like:
Code:
# Replace <SPELL> with Spellname if !%self.affect(<SPELL>)% dg_cast '<SPELL>' %self% end

Would that work for you?

EDIT: Just realized you said "in fight" so you would need to add a check to the fighting variable:
Not sure if %char.fighting% or %char.pos% is more suitable here, maybe someone can chip in.
With fighting:
Code:
if (!%self.affect(<SPELL>)% && %self.fighting%) dg_cast '<SPELL>' %self% end
Or with pos:
Code:
if (!%self.affect(<SPELL>)% && %self.pos% == Fighting) dg_cast '<SPELL>' %self% end
Last edit: 17 Apr 2018 16:08 by lacrc.

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

More
17 Apr 2018 16:31 #7945 by JTP
Replied by JTP on topic Mob cast
Atm i have it set as fighting.. but i would like it to be always on.

Thoug If dispelled it would be cool it it waited alittle before recast.

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

More
17 Apr 2018 17:37 - 17 Apr 2018 17:56 #7947 by JTP
Replied by JTP on topic Mob cast
if !%self.affect(spellname)%
dg_cast 'spellname' %self%
end

when mob loaded it after alittle cast the spell, but it didnt show any message that the spell ran out, and it took alot of time before it recast it :(
Last edit: 17 Apr 2018 17:56 by JTP.

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

More
17 Apr 2018 18:02 - 17 Apr 2018 18:21 #7948 by lacrc
Replied by lacrc on topic Mob cast
Oh sorry, I think I should've elaborated better, according to the link I sent earlier from the documentation:

Since random triggers fire every 13 seconds you can set how often the trigger fires by modifying numeric arg to the following values:

1% = about 22 minutes
2% = about 11 minutes
5% = about 4 minutes
10% = about 2 minutes
20% = about 1 minute
50% = about 26 seconds
100% = 13 seconds

Once you reduce the numeric arg below 100, because the numeric arg equates to the chance that the trigger will fire, the above timings are an average. It is possible that even at 1%, the trigger will fire twice, 13 seconds apart.

The actual equation is 100/numeric arg X 13 = time in seconds.
For example, 100/20 X 13 = 65 seconds

So, the Num Argument is the chance of the trigger firing, not the actual time for it to fire, but you can get the average chance of it firing by calculating the equation as mentioned (since it fires every 13secs using 50% chance would be 26 secs in average)

EDIT: You COULD control the timing by setting the chance to 100% and using a variable remoted.
Something like:
Code:
# First let's make sure the variable exists if !%actor.varexists(spell_control)% # It didn't so let's create it set spell_control 3 remote spell_control %self.id% else # Okay so the variable exists, let's check if we can cast already or if we should wait more # If the variable is still not zero we're waiting, so subtract from the variable and stop the script if %actor.spell_control% > 0 set spell_control %actor.spell_control% - 1 remote spell_control %self.id% return 0 halt end end # Now it will cast the spell, and reset the variable if !%self.affect(spellname)% dg_cast 'spellname' %self% set spell_control 3 remote spell_control %self.id% end
With this script (and Num Argument 100) the trigger will run every 13 secs, this is unchangeable with random triggers (as far as I know).
The first time it runs it will set the variable and the spell will be cast.
But then there will be a delay of 3*13 seconds to recast the spell (you can change that by changing the "set spell_control 3" lines), a window of 39 seconds for the player to kill the mob.

This is just an idea tho, not sure if it will work for ya.
I haven't tested the script so sorry if there's any mistakes :)

PS: And I'm not sure if you have to remote the variable again after you set the value so, if anyone could please help haha
Last edit: 17 Apr 2018 18:21 by lacrc.

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

More
17 Apr 2018 19:11 #7949 by JTP
Replied by JTP on topic Mob cast
Any idea why it doesnt show a message when the spell runs out by itself ? Like it does on players.
It just goes away.

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

Time to create page: 0.210 seconds