I'm trying to make a spell that creates a ball that follows the User, increasing some state.
This spell must be active for 20 seconds and then disappear. But it can be used up to 5 times, creating five balls, and each use must reset the counter, leaving it active for another 20 seconds every use.
Problem description:
I have no idea how to make a stackable counter that would delete all balls when run out.
If anyone can give me a tip I appreciate.
verb do not know if I did it right. But it is working. Thanks Pirion |
That's not a datum.
|
You could use what you currently have in theory. However you will want to make a check at the:
usr.btime += 20 because with that it will add 20, so if you added 5 really quickly the timer will be 100 seconds and not reset the counter. You could use an obj instead of a datum for the balls, depends on if they will move, how much control you want over their features, etc... If you don't plan to have them move, and just want them to be an overlay type of effect then use a datum as such: datum or you could use an obj: obj This would make each ball its own individual thing, and because it is an object it can still do things like an object, such as move. This may work better because say each ball gives the player a buff than now you can refer to the owner in the New() definition to point to the owner's stats. The above code may be buggy, and will probably not work from what is up there. It is meant to show an example and point you to another possibility. |
mob/m is an argument. This means that the New() proc of the object is expecting something to be passed into it.
In this case we have to change the verb for the player to: verb So whoever uses this verb will be the owner (from previous code) of the ball obj and their stats will be the one effected by created ball. Well because we have made a new obj that refrences to the player that used it we could in theory change the obj's New Proc to: New(mob/m) Rough idea, I have to go to work so I can try to illaborate later. |
Sorry, just a nit pick here!
Naming a looping proc "tick" is dangerous... Because it says it will tick, but not that it will loop. I much more prefer this design... Thing Having a proc named Tick which starts a loop is misleading. |
creating a datum to handle this can be done in the following way:
ball_spell |
Have the datum create a balls and set the timer to 20. Let this happen as long as balls > 5.
Have a loop decrement the timer, and then delete the balls when it expires.