Creature Script Problem

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Creature Script Problem
Infiltrator
Member # 5576
Profile Homepage #0
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:
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.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
The Establishment
Member # 6
Profile #1
Rather than putting the code to prefer item use in an attack state, just have it be at the beginning of the START_STATE. See if that works.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #2
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.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
The Establishment
Member # 6
Profile #3
Perhaps that do_attack_tactic() is broken? I haven't used it extensively, but I have not noticed much effect toward items with it. Your other option is to simulate using an item with scripting. Not as realistic, but plausible.

[ Friday, January 13, 2006 21:26: Message edited by: *i ]

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #4
I couldn't get do_attack_tactic(3) to do anything in the experiments I just ran.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
The Establishment
Member # 6
Profile #5
I would say add it to the list of bugs.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #6
Well, dang. I guess I'll think of something else. I can simulate two out of the three effects that I wanted, and I guess I'll just not have the third. The other settings for do_attack_tactic() certainly work; I have used those a great deal without difficulty.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
The Establishment
Member # 6
Profile #7
What are the things you want to do, perhaps we can help?

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #8
I wanted to make the effect of a candle, so that it would appear that the creature was glowing. I can't think of any other way to do that than a light emitting item.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
The Establishment
Member # 6
Profile #9
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.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #10
I wasn't aware of that, since I know that they could in A2. I can do without it though.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Off With Their Heads
Member # 4045
Profile Homepage #11
Er, I remember a lot of monsters picking up light sources in A2, but not using them. Are you sure?

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Infiltrator
Member # 5576
Profile Homepage #12
Yes, I'm sure that I once located and killed a gaurdian because it used a candle.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Councilor
Member # 6600
Profile Homepage #13
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.
Posts: 4346 | Registered: Friday, December 23 2005 08:00
Agent
Member # 2820
Profile #14
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.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Councilor
Member # 6600
Profile Homepage #15
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.
Posts: 4346 | Registered: Friday, December 23 2005 08:00