# Free Script Repository + 2.54 Scripts

Thanks for sharing everyone this will help much people

the way i would do that is to make animations for the ground, and then have it Play-stop specific ones when the mouse is over top and pressed down.

how would i mod killers track to mouse to a top down script

correction : it’s rising from the dead !

it’s a zomby !!

@mjw

what do you really want to do ?

i want to make a 2d fps script get mouse pozition set rot

no its a corps. completely dead

Sorry, have been busy recently, feel free to contribute your own scripts though!

Pretty sure it’s dead. Not to mention it was supposed to be a repository and not a request line.

Thx for sharing
It would be a repository!

Hi, I believe many people would apreciate a bullet hole script, so here it is.

``````#BulletHole.py
from math import sin, cos, sqrt
# vector functions!!
def VEC_length(x):
return sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])
def VEC_normalize(x):
length = VEC_length(x)
return [x[0]/length,x[1]/length,x[2]/length]
def VEC_cross(x, y):
return  [x[1]*y[2] - x[2]*y[1],
x[2]*y[0] - x[0]*y[2],
x[0]*y[1] - x[1]*y[0]]
def VEC_min(x, y):
return [x[0] - y[0], x[1] - y[1], x[2] - y[2]]
def MAT_trackvector(fw, y):
if abs(abs(fw[2]) - abs(y[2])) &lt; .001: #prevent gimbol lock
y.append(y[0])
del y[0]
right = VEC_normalize(VEC_cross(y, fw))
up = VEC_cross(fw, right)
return [[right[0], up[0], fw[0]],
[right[1], up[1], fw[1]],
[right[2], up[2], fw[2]]]
ownAmmo = GameLogic.getCurrentScene().getObjectList()["OBBulletSpawn"]
cont = GameLogic.getCurrentController()
obj = cont.getOwner()
ray_sensor = cont.getSensor("ray_bullet")
lmb_sensor = cont.getSensor("LMB")
# position the last added bullet hole
if obj.ebhole and ray_sensor.isPositive():
hit_pos = ray_sensor.getHitPosition()
hit_norm = ray_sensor.getHitNormal()

newobj.setOrientation(MAT_trackvector(hit_norm, [0.0,0.0,1.0]))
pass
newobj.setPosition(hit_pos)
obj.ebhole = 0
# determine whether or not to create a new bullet hole
make_bullet = ray_sensor.isPositive() and lmb_sensor.isPositive() and ownAmmo.Bullets &gt; 0
if make_bullet:
# I am making the bullet hole.
obj.ebhole = 1

``````

What does MAT_trackvector do?

Content has been removed. MayDev

hey thanks for make change it for the 2.5 version, this script is very usefull, and i think that this thread should be stick again, i hope that people help each other with their scripts.

Content has been removed. MayDev

A few utility functions, all using the 2.5 API:

inSight()

``````def inSight(object, other, distance, scope=90):
"""Determines if a point is within a an objects sight cone.
Assumes +y is forward.

Arguments:

object -- object doing the looking
other - point being determined
distance -- max distance to look
scope -- angle of the sight code (degrees)
"""
dis, gvec, lvec = object.getVectTo(other)
if dis &lt;= distance:
angle = lvec.angle(Vector([0,1,0]))
return math.degrees(angle) &lt; (scope / 2)
``````

singleRayCollisionDetection()

``````def singleRayCollisionDetection(object, distance, width):
"""Uses a single ray cast in the direction of the object
to detect if any objects are infront of it. Assumes +y as forward.

Arguments:

object -- object doing the scanning
distance -- distance to look ahead
width -- width of the object (sould give it a buffer)
"""
x = (bge.logic.getRandomFloat()*width) - (width/2)
vec = Vector([x, distance, 0]) * object.worldOrientation
vec = vec + object.worldPosition

hit_obj, point, normal = object.rayCast(vec, None, distance)
return point
``````

multiRayCollsionDetection()

``````def multiRayCollisionDetection(object, distance, width):
"""Uses 3 rays cast in the direction of the object
to detect if any objects are infront of it. Assumes +y as forward.
More accurate than single ray detection.

Arguments:

object -- object doing the scanning
distance -- distance to look ahead
width -- width of the object (sould give it a buffer)
"""
vecs = [Vector([-width/2, distance, 0]),
Vector([0, distance, 0]),
Vector([width/2, distance, 0])]

for vec in vecs:
vec = vec + object.worldPosition
vec = vec * object.worldOrientation
hit_obj, point, normal = object.rayCast(vec, None, distance)
return point
``````

FIRST POST UPDATED!!! Completely new “look” for the repository now! It looks a lot more official now. Now start posting more scripts!!

Content has been removed. MayDev

hehe hopefully we can get other veteran coders to just dump all their prototype scripts here (we all have them sitting on our computer somewhere!)

I’ll start posting more of my own stuff tomorrow after work.

Does anyone know how to make that track to mouse script work in 2.5? It’d be really usefull…

#EDIT#

There appears to be a problem with the name ‘gamelogic’ at the beginning… Does it need to be defined or am i just a noob?