from bge import logic
import random

def smoke(cont):
    own = cont.owner
    act = cont.actuators[0]
    speed = own["max_speed"]
    diff = own["max_diff"]
    act.dLoc= [random.uniform(-diff, diff), random.uniform(-diff, diff), random.uniform(0, speed)]
    cont.activate(act)
    
def stone(cont):
    own = cont.owner
    force = own["max_force"]
    diff = own["max_diff"]
    rot = own["max_rot"]
    own.applyForce([random.uniform(-diff, diff), random.uniform(-diff, diff), random.uniform(0, force)], True)
    own.applyTorque([random.uniform(-rot, rot), random.uniform(-rot, rot), random.uniform(-rot, rot)], True)
	
def addDust(cont):
	own = cont.owner
	height = own["height_max"]
	length = own["length_max"]
	size = own["size_max"]
	speed = own["speed_max"]
	scn = logic.getCurrentScene()
	dust = scn.addObject(scn.objectsInactive["desertDust"], own, own["life"])
	rand_size = random.uniform(size/2, size)
	dust.worldScale = [rand_size, rand_size, rand_size]
	dust.actuators["Motion"].dLoc = [random.uniform(speed/4, speed), 0, 0]
	dust.actuators["Motion"].useLocalDLoc = False
	own.localPosition[2] = random.uniform(-height/4, height)
	own.localPosition[1] = random.uniform(-length, length)
	
def blood(cont):
	own = cont.owner
	maxSize = own["maxSize"]
	maxSpeed = own["maxSpeed"]
	randSize = random.uniform(0.25, maxSize)
	own.worldScale = [randSize, randSize, randSize]
	cont.actuators[0].dLoc = [random.uniform(-maxSpeed, maxSpeed), random.uniform(-maxSpeed, maxSpeed), random.uniform(-maxSpeed, maxSpeed)]
	cont.activate(cont.actuators[0])