Welcome to the Builder Academy

Question multiple attacks question

More
17 Nov 2016 18:36 - 17 Nov 2016 22:51 #6274 by JTP
Hey

I have added multiple attacks, and that Works just fine.

Then thought ok lets have move do something....
I then added a refresh spell, also good.

I then wanted to subtract 1 move per attack done...

I then added GET_MOVE(ch) -= 1; where i have written /* added first */ It Works perfect subtracting move from mobs, if just the added first and added secondly is added, and not in attacks2-4 if mobs in one round has 2 attacks, 1 missed attack and 1 spell then its -4 move...
If mob has 3 attacks and 1 spell, then -4
If 2 attacks -2 and so on...so that Works just fine so far for mobs...



I then added GET_MOVE(ch) -= 1; where i wrote /* added secondly */
that takes -1 move no matter how many attacks a char has or miss....

I then tried adding it to attack2, attack3 and attack4

BUT here is the problem then, if a player does 1 attack it subtracts -4, and if a player does 2 attacks it subtracts -4 move...And if a player does 3 attacks its -4. So something is wrong with the -1 move from each attack when its a player.. BUT then mobs was subtracted 2 move per round :(


Any idea why ??

Code:
if (GET_POS(ch) < POS_FIGHTING) { send_to_char(ch, "You can't fight while sitting!!\r\n"); continue; } if (GET_MOVE(ch) <= 0) continue; if (GROUP(ch)) { while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) { if (tch == ch) continue; if (!IS_NPC(tch) && !PRF_FLAGGED(tch, PRF_AUTOASSIST)) continue; if (IN_ROOM(ch) != IN_ROOM(tch)) continue; if (FIGHTING(tch)) continue; if (GET_POS(tch) != POS_STANDING) continue; if (!CAN_SEE(tch, ch)) continue; do_assist(tch, GET_NAME(ch), 0, 0); } } hit(ch, FIGHTING(ch), TYPE_UNDEFINED); GET_MOVE(ch) -= 1; /* added secondly */ /* more attacks */ //2nd attack**************************************************************** 2nd, 3rd, and 4th attack - bs cjl //Mob multi attacks by level ************ NPC ATTACKS begin if (IS_NPC(ch)) { int level=GET_LEVEL(ch); while (level>24) {level-=24; if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) { stop_fighting(ch); continue; } if (rand_number(1,GET_LEVEL(ch)) < (GET_LEVEL(ch)/2)) hit(ch, FIGHTING(ch), TYPE_UNDEFINED); GET_MOVE(ch) -= 1; /* added first */ } } if (!IS_NPC(ch)) { if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) { stop_fighting(ch); continue; } if (rand_number( 1, 101 ) < (GET_SKILL(ch, SKILL_ATTACK2) / 2)) /* 50% chance to activate */ hit(ch, FIGHTING(ch), TYPE_UNDEFINED); } //3rd attack***************************************************************** if (!IS_NPC(ch)) { if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) { stop_fighting(ch); continue; } if (rand_number( 1, 101 ) < (GET_SKILL(ch, SKILL_ATTACK3) / 4)) /* 25% chance to activate */ hit(ch, FIGHTING(ch), TYPE_UNDEFINED); } //4th attack***************************************************************** if (!IS_NPC(ch)) { if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) { stop_fighting(ch); continue; } if (rand_number( 1, 101 ) < (GET_SKILL(ch, SKILL_ATTACK4) / 8)) /* 12.5% chance to activate */ hit(ch, FIGHTING(ch), TYPE_UNDEFINED); }
Last edit: 17 Nov 2016 22:51 by JTP.

Please Log in or Create an account to join the conversation.

More
17 Nov 2016 21:57 - 17 Nov 2016 21:57 #6275 by WhiskyTest
It's the 'if' statements missing some braces {} that are causing this.

Wherever you have the check for an extra hit, put the two things that should happen in braces.
(extra hit happens AND player loses a move point)
Code:
if (rand_number( 1, 101 ) < (GET_SKILL(ch, SKILL_ATTACK3) / 4)) /* 25% chance to activate */ { hit(ch, FIGHTING(ch), TYPE_UNDEFINED); GET_MOVE(ch) -= 1; }

Another way to handle this would be to add the move point reduction inside the hit() function.
Last edit: 17 Nov 2016 21:57 by WhiskyTest. Reason: add code tages

Please Log in or Create an account to join the conversation.

More
17 Nov 2016 22:49 #6277 by JTP
Replied by JTP on topic multiple attacks question
Thanks alot whiskytest

Please Log in or Create an account to join the conversation.

Time to create page: 0.192 seconds