Jump to content

Monster AP (again)


Thralni

Recommended Posts

Got a problem here... I have a monster in my scenario, that should be constantly trying to follow the party, and it does that, that's all working right. But, it should not be doing that as fast as it does it now. problem is this: I want it to only take two steps, yet now it's taking a lot more, three or even four. In the datacscript I made sure the ap bonus of this monster is -2 (Hoping that the normal amount of ap is 4). So, i need a way to solve this. I've been thinking of ways, but maybe you guys can come up with better stuff. My idea was a variable gradually decreasing:

 

Code:
int action;action = 2;//monster follows partyaction = action - 1;// the monster takes a step, and action decreases. Then when it has reached 0:if (action == 0) {action = 2;end_combat_turn(); // (or whatever the call's name was)

 

This bit of code is rather ppor in appearnce, I know. That's because I was too lazy to take the actual script and put these bits in the correct spots.

Link to comment
Share on other sites

Nioca: "action = action - 1;"

'action' is Thralni's variable which is used to stop the creature script from running when it's run enough.

 

Smoo makes a good point: It may work better to just deduct extra AP before letting the creature move. One extra AP deducted each time would hopefully halve the creature's speed.

Link to comment
Share on other sites

Originally Posted By: Niemand
Nioca: "action = action - 1;"
'action' is Thralni's variable which is used to stop the creature script from running when it's run enough.

Yeah, I know that. I mean, not having seen the creature's action itself, how exactly will it get reduced? It appears to be after the whole string of action, but it could lead to problems if the code can make the monster take more than one step in a single run.

Assuming, of course, that you don't decide to do as Smoo suggested.
Link to comment
Share on other sites

Christ, your right Smoo! Completely forgot about that. I shall use that, and if it works, hooray. Otherwise, I'll just use what I showed in this thread.

 

Nioca: actually, what I figured later, is that I should start at 0, then add 1 every time the monster takes a step, and when it reaches 2, set it back to 0 and end the turn. I'll try Smoo's suggestion first, though.

Link to comment
Share on other sites

Nioca: Thralni's method is elegant in that it doesn't need to know or alter the AP, as long as the movement call only takes one step at a time and the game's creature script driver works by calling the creature script repeatedly until the creature is out of AP. Smoo's idea, on the other hand, is nice because it relies less on the details of how Jeff programmed the game to run creature scripts.

 

EDIT: I did a little testing, and it appears that in combat mode the game does keep running a creature's script until it uses up its AP, and furthermore calling do_attack() only causes the creature to take one step at a time if the creature decided to walk. Negative cr_ap_bonus values definitely do not work, I tried a bonus of -2 on a soldier, and it started its turn with 8 AP, not 2. Go figure.

 

For the curious, my testing method was to make a duplicate of basicnpc, in which I replaced every do_attack() call with this block:

 

Code:
clear_buffer();append_string("Current AP: ");append_number(my_ap());get_buffer_text(str);print_str(str);do_attack();
Link to comment
Share on other sites

In the end I used the method I suggested. I also wanted to monsters that took only three steps, and that couldn't have been done neatly with deduct_ap. I realize I could have given them an extra 2 ap with the datascript, but I voted aginst that.

 

Anyway, it works as I wanted now, and that's the important thing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...