X3 Battle Help

XanMag

I imagine this might be a rather lengthy thread eventually. I will try to figure out most of this myself. I also think it will go a lot faster once I get comfortable with it. So... sorry (and thanks!) in advance!

Basic Plan: Because there is NOT a ton of battles to be had and weapons are fairly limited (probably 4-5 total), I plan on placing a simple 'attack' verb on each monster. In this script, I will use a flag setting system to check to see which weapon the player has equipped. For each weapon If/Else If, there will be random chance Ifs nested within. Example: If 60%, then "Great Attack!", Else If 30% "Good Attack.", Else 10% "Missed!". Obviously I've dumbed it down a bit, but...

Question 1: Will this set-up work? I think it will...

Question 2: I would like each successful attack to have a range of health points that get deducted. I know I am being a code noob here, but I was thinking something like this:

if (GetBoolean(femur, "femurequipped")) {
  msg ("You swing the femur down at the fanged rat.")
  if (RandomChance(60)) {
    msg ("Your makeshift hammer catches the rat solidly in the head.  Good strike!")
    Fanged Rat.Health = Fanged Rat.Health - GetRandomInt(10-25)
  }

which obviously doesn't work. I'd like to subtract the health in a range for each type of attack. How do I code for subtracting a GetRandomInt range?


DarkLizerd

That looks like it should work.... except...
first error... GetRandomInt(60)...
60% chance to hit I assume...
try this:
Hit=GetRandomInt(1,100) // number between 1 and 100
if (Hit >39 and Hit<60){
Dam=GetRandomInt(10,25) // number between 10 and 25
msg("You hit and did " + Dam + " points!")
Rat.Health=Rat.Health-Dam
}
//Then you can add other ranges for your hits...
if (Hit>21 and Hit<40){
Dam=GetRandomInt(10,25)/2
// or Dam=GetRandomInt(5,12)
msg("You winged it for " + Dam + " points!")
Rat.Health=Rat.Health-Dam
}
if (Hit<20){
msg("DAMM!!! You missed!")
}


The Pixie

This:

Fanged Rat.Health = Fanged Rat.Health - GetRandomInt(10-25)

... should be (also needs a } at the end):

Fanged Rat.Health = Fanged Rat.Health - GetRandomInt(10, 25)

How many weapons will there be? If it is more than a couple, have an "equipped" script on the player that holds the weapon, and set attributes on the weapon.

if (HasObject(player, "equipped")) {
  msg (player.equipped.attackmsg)
  if (RandomChance(player.equipped.attackchance)) {
    msg (player.equipped.attackhitmsg)
    Fanged Rat.Health = Fanged Rat.Health - GetRandomInt(player.equipped.lower, player.equipped.upper)
  }
}

If you later add more weapons, no need to change the attack verb for every foe.


XanMag

4 or 5 weapons only.


XanMag

Okay. I think I have that part figured out. How would I remove a random value from the player health when player is attacked?

I'm thinking:

msg ("The rat lashes out at you with its viciously sharp teeth.  It grazes your lower leg.")
DecreaseHealth (GetRandomInt (2, 5))

Probably not that easy, but does that make sense? EDIT: It was that easy. That part works wonderfully. =)

But...

I have this issue now:

The player can leave via one exit during the battle. On the before entering room (the adjacent room, not the battle room), I have:

DisableTurnScript (RatAttack)

to essentially stop the rat from attacking if the player flees. The rat remains in the "Battle Room". However, for TWO turns (once when the player exits and again when the player makes a move in the adjacent room), the rat continues to attack. Shouldn't disabling the turnscript stop those scripts (RatAttack) from running??

EDIT2: Have I ever said I HATE Turn Scripts?!? I have a changedHealth attribute on the Fanged Rat. I have this when the health attribute reaches zero:

else if (Fanged Rat.Health <1) {
  DisableTurnScript (RatAttack)
  msg ("The rat has been slain.  Well done.")
  RemoveObject (Fanged Rat)
  MoveObjectHere (Fanged Rat carcass)
}

and yet...apparently the dead rat wants to attack ONE more time after it has been slain. ARGHHH! The logic of these things make no sense to me.


Log in to post a reply.

Support

Forums