Jump to content

Creature Script Problem


Niemand

Recommended Posts

I have been working on trying to make a creature use an item when it begins to fight. The creature's definition causes it to start with the item, and I have verified that it does have the item. However, it just won't use it. I have even tried making its species human temporarily, in case that was the problem, but it made no difference. Here is the relevant code snippet from the creature script:

Code:
 beginstate START_STATE; 	// if I have a target for some reason, go attack it	if (target_ok()) {		if (dist_to_char(get_target()) <= 16)			set_state(3);		else 			set_target(ME,-1);	}	// Look for a target, attack it if visible	if (select_target(ME,8,0)) {		do_attack_tactic(3);		set_state(3);		}			// Have I been hit? Strike back!	if (who_hit_me() >= 0) {		set_target(ME,who_hit_me());		do_attack_tactic(3);		set_state(3);	}		if (am_i_doing_action() == FALSE)		end_combat_turn();break;beginstate 3; // attacking	if (target_ok() == FALSE)		set_state(START_STATE);	if(item_type_in_slot(my_number(),13) != 0){		print_num(888);		do_attack_tactic(3);	}	do_attack();break; 
Once the creature sees the party, it begins to print '888', so I know that it knows it has an item, but it continues to print it after several turns, and the use of a scroll of Arcane Blow is very noticeable.
Link to comment
Share on other sites

First of all, I don't want the creature to just fire off its scroll or whatever the first turn after it is inited.

Second, I don't see what that will change, because do_attack_tactic(3) is being called, both when the creature transitions from the START_STATE to the attack state, and repeatedly in the attack state, the creature just chooses to do something other than using the item.

Third, I just tried it and it didn't work.

Link to comment
Share on other sites

They couldn't use light sources anyway. I'm afraid that would not be possible even using the item. A possible solution to the glowing thing could be to make a separate monster and swap the two when the item is used. Store the HP and such in a variable or something.

Link to comment
Share on other sites

I've never seen any NPC use a light source. I've seen the guardian (or black shade) in A2 who always picks up that candle. Every time. Sometimes it darts around the table and picks up the other one. Stupid monster.

 

A custom graphic with the monster outlined in a light color could give the effect that it was glowing. The slith avatar and Garzahd in A2 are examples. It might not be exactly what you are looking for but it can be effective.

 

Dikiyoba.

Link to comment
Share on other sites

The use of items like scrolls, potions, and wands feels pretty random to me. They are often used at the most inappropriate times; for instance, a healing potion at full health.

 

But if it stays alive for a couple of turns, and is of a species capable of using items, it will probably use it.

 

From experience, it just seems that wands will be used most often.

Link to comment
Share on other sites

Somehow, the giant chiefs always know when to drink their invincibility potions. And Dikiyoba isn't complaining when the monster chugs a healing potion at full health. It's sad that Dikiyoba's party won't get it as a reward after killing the monster, but at least the monster won't be able to use it when two-thirds of its health is gone and won't be able to restore its health.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...