Here’s the script. It’s messy so I didn’t want to show the whole thing but it’s ok as long as y’all can read it:
import bge
from random import randint
scene = bge.logic.getCurrentScene()
handR = scene.objects['playerRightHand']
rightArm = scene.objects['rightArmSkel']
inv = scene.objects['inv']
cont = bge.logic.getCurrentController()
ironSword = cont.owner
if inv['itemRh'] != "":
itemRh = scene.objectsInactive[inv['itemRh']]
else:
itemRh = ""
if inv['itemLh'] != "":
itemLh = scene.objectsInactive[inv['itemLh']]
else:
itemLh = ""
mouse = bge.logic.mouse
key = bge.logic.keyboard
mmb = bge.logic.KX_INPUT_ACTIVE == mouse.events[bge.events.MIDDLEMOUSE]
lmb = cont.sensors['lmb']
rmb = cont.sensors['rmb']
hitSens = cont.sensors['hitRadar']
hittableCheck = cont.sensors['hittableCheck']
npcCheck = cont.sensors['npcCheck']
if rmb.positive:
#Check if lh is shield
#If not, animate, start block timer.
if "Sword" in itemRh.name:
if mmb:
rightArm.playAction("rightArm", 230, 240, 0, 0, 0, bge.logic.KX_ACTION_MODE_PING_PONG, 0.0, 0, 0.75)
handR.playAction("playerRightHandAction", 230, 240, 0, 0, 0, bge.logic.KX_ACTION_MODE_PING_PONG, 0.0, 0, 0.75)
else:
rightArm.playAction("rightArm", 250, 260, 0, 0, 0, bge.logic.KX_ACTION_MODE_PING_PONG, 0.0, 0, 0.75)
handR.playAction("playerRightHandAction", 250, 260, 0, 0, 0, bge.logic.KX_ACTION_MODE_PING_PONG, 0.0, 0, 0.75)
def onRmbRelease():
pass
if lmb.positive:
#if in right hand, attack
#if in left hand, block
#for attacking; check whereabouts attacker is in position to defender
#Figure out corresping damage values, and account for defender's blocking
#Also account for dodge perhaps?
target = hitSens.hitObject
if "Sword" in itemRh.name:
if mmb:
rightArm.playAction("rightArm", 135, 170, 0, 0, 0, 0, 0.0, 0, 0.75)
handR.playAction("playerRightHandAction", 135, 170, 0, 0, 0, 0, 0.0, 0, 0.75)
if target:
bge.logic.sendMessage("attackAlt", "", target.name, "")
else:
animChoose = randint(0,1)
if animChoose == 0:
rightArm.playAction("rightArm", 90, 135, 0, 0, 0, 0, 0.0, 0, 0.75)
handR.playAction("playerRightHandAction", 90, 135, 0, 0, 0, 0, 0.0, 0, 0.75)
if target:
print(type(target)
cont.sendMessage("attack", "", target.name, "")
elif animChoose == 1:
rightArm.playAction("rightArm", 200, 230, 0, 0, 0, 0, 0.0, 0, 0.75)
handR.playAction("playerRightHandAction", 200, 230, 0, 0, 0, 0, 0.0, 0, 0.75)
if target:
print(type(target)
cont.sendMessage("attack", "", target.name, "")
def getEquippedActor():
pass
def endSwordObj():
itemRh.endObject()