// Try attacking another actor public int TryAttackingAnotherActor(Actor target,Attack attack) { int result = 0; Random rand = new Random(); // Try to hit against ac int toHit = attack.toHit; int hit = toHit+rand.Next(0, 20); // If hit successful if(hit >= target.ac) { // Get what damage should be done int dmgMod = 0; int dmgRaw = dmgMod + rand.Next(attack.dmgMin, attack.dmgMax); int dmgFinal = dmgRaw; // Do damage to the target target.hp -= dmgFinal; // Desc. the target's state string targetState = target.genderNomTitle+" "; string s = "appears to be in good health"; float hpp = (target.hp / target.hpMax); if(hpp > 0) { s = "appears close to death."; } if (hpp > 25) { s = "appears gravely wounded."; } if (hpp > 50) { s = "appears somewhat wounded."; } if (hpp > 75) { s = "appears slightly wounded."; } targetState += s; // If the target dies if (target.hp <= 0) { target.UpdateStatus(); // Log if (isPlayer) { ui.Log("You " + attack.verb1P + " the " + target.name + ", killing it.", Color4.Yellow); } else { if (target == worldMap.player) { ui.Log("The " + name + " " + attack.verb3P + " you. You die!", Color4.Red); } else { ui.Log("The " + name + " " + attack.verb3P + " the "+target.name+", killing it."); } } result = 3; } else { // Log if (isPlayer) { ui.Log("You " + attack.verb1P + " the " + target.name + ". "+ targetState, Color4.Yellow); } else { if (target == worldMap.player) { ui.Log("The " + name + " " + attack.verb3P + " you.", Color4.Red); } else { ui.Log("The " + name + " " + attack.verb3P + " the " + target.name + ". " + targetState); } } result = 2; } } else { // If attack misses // Log if (isPlayer) { ui.Log("You try to " + attack.verb1P + " the " + target.name + ", but miss."); } else { if (target == worldMap.player) { ui.Log("The " + name + " tries to " + attack.verb1P + " you, but misses."); } else { ui.Log("The " + name + " tries to " + attack.verb1P + " the " + target.name + ", but misses."); } } result = 1; } return result; }
// Try equipping an item public int TryEquippingItemAtSlot(int slot) { int result = 0; int eq = -1; if (items[slot].canBeEquipped) { // Check if the item is already equipped if (equipped[Actor.RIGHT_HAND] == slot) { eq = Actor.RIGHT_HAND; } if (equipped[Actor.LEFT_HAND] == slot) { eq = Actor.LEFT_HAND; } if (equipped[Actor.TORSO] == slot) { eq = Actor.TORSO; } if (equipped[Actor.HEAD] == slot) { eq = Actor.HEAD; } if (equipped[Actor.BACK] == slot) { eq = Actor.BACK; } if (equipped[Actor.LEGS] == slot) { eq = Actor.LEGS; } if (equipped[Actor.FEET] == slot) { eq = Actor.FEET; } // If the item is not equipped already if (eq == -1) { // Item needs to be used in hands if (items[slot].equipAt == Item.EQUIP_HANDS) { // Item requires two hands if (items[slot].requiresTwoHands) { equipped[RIGHT_HAND] = slot; attackMain = items[slot].attackMain; equipped[LEFT_HAND] = -1; } else { if (equipped[RIGHT_HAND] == -1) { equipped[RIGHT_HAND] = slot; attackMain = items[slot].attackMain; } else { if (equipped[LEFT_HAND] == -1) { equipped[LEFT_HAND] = slot; attackAlt = items[slot].attackMain; } else { equipped[RIGHT_HAND] = slot; attackMain = items[slot].attackMain; } } } } // Item needs to be worn on the body if (items[slot].equipAt == Item.EQUIP_TORSO) { equipped[TORSO] = slot; } if (items[slot].equipAt == Item.EQUIP_HEAD) { equipped[HEAD] = slot; } if (items[slot].equipAt == Item.EQUIP_BACK) { equipped[BACK] = slot; } if (items[slot].equipAt == Item.EQUIP_LEGS) { equipped[LEGS] = slot; } if (items[slot].equipAt == Item.EQUIP_FEET) { equipped[FEET] = slot; } // Log if (items[slot].equipAt == Item.EQUIP_HANDS) { ui.Log("You ready the " + items[slot].name + "."); } else { ui.Log("You put on the " + items[slot].name + "."); } result = 1; } else { // Remove the item // Item needs to be used in hands if (items[slot].equipAt == Item.EQUIP_HANDS) { // Item requires two hands if (items[slot].requiresTwoHands) { equipped[RIGHT_HAND] = -1; equipped[LEFT_HAND] = -1; attackMain = null; attackAlt = null; } else { equipped[eq] = -1; if(eq == Actor.RIGHT_HAND) { attackMain = null; } else { attackAlt = null; } } } else { equipped[eq] = -1; } // Log if (items[slot].equipAt == Item.EQUIP_HANDS) { ui.Log("You return the " + items[slot].name + " to your pack."); } else { ui.Log("You remove the " + items[slot].name + "."); } result = 2; } } else { if (isPlayer) { ui.Log("You can't equip or wear that."); } } return result; }
public FeralCat(int x, int y, int z) { tileX = x; tileY = y; tileZ = z; tileXLast = tileX; tileYLast = tileY; tileZLast = tileZ; // Stats hpMax = 4f; hp = hpMax; spMax = 2f; sp = spMax; fpMax = 1f; fp = fpMax; acBase = 4; acMod = 0; ac = acBase + acMod; name = "feral cat"; nameTitle = "Feral Cat"; desc = "A feral cat."; descDetailed = "It's fur is matted and dark. It appears rather agitated."; sightRange = 6; actionPointsMax = 1; actionPoints = actionPointsMax; isHostile = true; faction = 1; // General enemies attackMain = new Attack("Claw","claw","claws",1,1,4,Attack.DMG_TYPE_SLASH); image = 'c'; color = Color4.Yellow; ai = new ActorAI(ActorAI.AI_TYPE_MOVEMENT_CHASE, ActorAI.AI_TYPE_ATTACK_MELEE); }
// Construct public Player() { // Stats hpMax = 8f; hp = hpMax; spMax = 5f; sp = spMax; fpMax = 3f; fp = fpMax; acBase = 4; acMod = 0; ac = acBase + acMod; descDetailed = "You're in perfect health."; sightRange = 5; actionPointsMax = 3; actionPoints = actionPointsMax; isPlayer = true; attackBare = new Attack("Punch","punch","punches",3,1,4,Attack.DMG_TYPE_NORMAL); equipped[RIGHT_HAND] = -1; equipped[LEFT_HAND] = -1; equipped[TORSO] = -1; equipped[HEAD] = -1; equipped[BACK] = -1; equipped[LEGS] = -1; equipped[FEET] = -1; }
public Dagger(int x, int y, int z) { tileX = x; tileY = y; tileZ = z; name = "dagger"; nameTitle = "Dagger"; desc = "A common dagger."; descPlural = "A few daggers."; descDetailed = "A rather mundane weapon. The blade and hilt are in good condition."; effects[0] = "none"; effectValue[0] = 0; canBeEquipped = true; equipAt = Item.EQUIP_HANDS; attackMain = new Attack("Slash","slash","slashes",3,2,5,Attack.DMG_TYPE_SLASH); attackAlt = new Attack("Stab", "stab", "stabs", 2, 1, 4, Attack.DMG_TYPE_PIERCE); image = '/'; color = Color4.LightGray; typeID = name + "," + effects[0]; }