Well-Actually War Trall Niemand Posted January 14, 2006 Share Posted January 14, 2006 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 More sharing options...
Easygoing Eyebeast *i Posted January 14, 2006 Share Posted January 14, 2006 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. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted January 14, 2006 Author Share Posted January 14, 2006 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 More sharing options...
Easygoing Eyebeast *i Posted January 14, 2006 Share Posted January 14, 2006 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. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted January 14, 2006 Share Posted January 14, 2006 I couldn't get do_attack_tactic(3) to do anything in the experiments I just ran. Link to comment Share on other sites More sharing options...
Easygoing Eyebeast *i Posted January 14, 2006 Share Posted January 14, 2006 I would say add it to the list of bugs. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted January 14, 2006 Author Share Posted January 14, 2006 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. Link to comment Share on other sites More sharing options...
Easygoing Eyebeast *i Posted January 14, 2006 Share Posted January 14, 2006 What are the things you want to do, perhaps we can help? Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted January 14, 2006 Author Share Posted January 14, 2006 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. Link to comment Share on other sites More sharing options...
Easygoing Eyebeast *i Posted January 14, 2006 Share Posted January 14, 2006 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 More sharing options...
Well-Actually War Trall Niemand Posted January 14, 2006 Author Share Posted January 14, 2006 I wasn't aware of that, since I know that they could in A2. I can do without it though. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted January 14, 2006 Share Posted January 14, 2006 Er, I remember a lot of monsters picking up light sources in A2, but not using them. Are you sure? Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted January 14, 2006 Author Share Posted January 14, 2006 Yes, I'm sure that I once located and killed a gaurdian because it used a candle. Link to comment Share on other sites More sharing options...
Magnificent Ornk Dikiyoba Posted January 15, 2006 Share Posted January 15, 2006 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 More sharing options...
Well-Actually War Trall Fort Posted January 15, 2006 Share Posted January 15, 2006 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 More sharing options...
Magnificent Ornk Dikiyoba Posted January 15, 2006 Share Posted January 15, 2006 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 More sharing options...
Recommended Posts