featurelist.orgfeaturelist.org
 
U
D
1 points - posted 172 days ago by godjonez - status: Active - 1 comments watch embed this
Add an automated chain lighting effect.

Possible parameters:
- normal beam effect parameters excluding second end point (x,y,z,sprite,color,speed,life)
- initial damage
- initial chain radius
- possibly affected players list
Functional parameters (contains some of the regular beam parameters):
- delay between chains nodes
- beam life
- damage reduction
- radius reduction
- color
- sound file to emit on hit
- sound volume


  • adjustment function



Return: chain lightning identifier (possibly a class instance that holds the required information)

The adjustment function can be set to be called for each beam effect to be drawn. It is to provide new values for the functional parameters. This can be used to dynamically create multiple different behaviors, such as having different algorithms of how damage is calculated based on teams, previous damage and distance.

The function should receive these parameters:
- identifier (the same as received when calling the initial method)
- iteration level
- source userid
- target userid
- distance
- previous damage
- previous radius
- previous color (r,g,b,a)
- previous sound file
- previous sound volume
- previous delay
- previous life

The function should return similar information back:
- new damage
- new radius
- new color
- new sound file
- new sound volume
- new delay
- new life

Or it can also raise StopIteration to force stopping the iteration in this chain.

There should be default values for all of the functional parameters as well, including damage and radius to reduce based on some built-in function.

If the values for functional parameters were set on first call, use those as fall back if the adjustment function returns None for the associated attribute, or if the function itself is not supplied.

Comments welcome.

bonbon posted on 2008-04-10 20:25:50
class commands:
def nearcoord(self, xorigin, yorigin, zorigin, xrange, yrange, zrange, block, team, initiator):
for userid in playerlib.getUseridList(team):
loc = es.getplayerlocation(userid)
if abs(loc[0] - xorigin) <= xrange and abs(loc[1] - yorigin) <= yrange and abs(loc[2] - zorigin) <= zrange:
block(userid, initiator)
def lightning(self, xorigin, yorigin, zorigin, lightningrange, lightningtime, attacker, team):
loc = (x
origin, yorigin, zorigin)
effecttime = 0
effect
loop(loc, lightningtime, lightningrange, attacker, effecttime, team)

def effect
loop(loc, lightningtime, lightningrange, userid, effecttime, team):
if effect
time <= lightningtime:
random1 = random.randint(lightning
range * -1, lightningrange)
random2 = random.randint(lightning
range * -1, lightningrange)
es.server.queuecmd&#40;'est
effect 3 #all 0 sprites/lgtning.vmt %s %s %s %s %s %s 1 10 20 40 250 255 255'%(loc[0] + random1, loc[1] + random2, loc[2], loc[0] + random1, loc[1] + random2, loc[2] + 120&#41;)
effecttime += 0.03
commands().nearcoord(loc[0] + random1, loc[1] + random2, loc[2], 45, 45, 45, lightning
damage, team, userid)
gamethread.delayedname(0.03, 'effect%s'&#xus;erid, effectloop, args=(loc, lightningtime, lightningrange, userid, effecttime, team))

def lightning
damage(userid, attacker):
randomnumber = (random.randint(1, 6) * random.randint(1, 6)) - random.randint(1, 10)
random
number2 = (random.randint(1, 7) * random.randint(1, 7)) - random.randint(1, 10)
randomnumber3 = (random.randint(1, 7) * random.randint(1, 7)) - random.randint(1, 10)
if random
number > 0:
es.server.queuecmd&#40;'damage %s %s 32 %s'%(userid, randomnumber3, attacker&#41;)
es.tell(attacker, '#multi', '#greenYou have dealt #lightgreen%s #greendamage to #lightgreen%s'%(random
number, playerlib.getPlayer(userid).attributes['name']))
else:
if randomnumber2 > 0:
es.server.queuecmd&#40;'damage %s %s 32 %s'%(userid, random
number3, attacker&#41;)
es.tell(attacker, '#multi', '#greenYou have dealt #lightgreen%s #greendamage to #lightgreen%s'%(randomnumber2, playerlib.getPlayer(userid).attributes['name']))
else:
es.server.queuecmd&#40;'damage %s %s 32 %s'%(userid, random
number3, attacker&#41;)
es.tell(attacker, '#multi', '#greenYou have dealt #lightgreen%s #greendamage to #lightgreen%s'%(randomnumber3, playerlib.getPlayer(userid).attributes['name']))

used in a script I had, it uses est
effect, but could be converted if anyone wanted