Well-Actually War Trall BainIhrno Posted January 29, 2013 Share Posted January 29, 2013 I've written a creature script for one of the final bosses, I was wondering if anyone would like to take a look at it. // VARNOTH // begincreaturescript; variables; short i,j,k,choice; INIT_STATE; break; DEAD_STATE; break; START_STATE; break; beginstate 3; if who_hit_me(char_has_item_of_class_equip(get_selected_char,3,0) damage_char(i,50,4); break; beginstate 4; if (tick_difference(last_abil_time,get_current_tick()) > 0)) print_str_color("Varnoth breathes!",1); put_boom_on_char(ME,0,1); put_boom_on_char(ME,0,1); put_boom_on_char(ME,0,1); put_boom_on_char(ME,0,1); put_boom_on_char(ME,0,1); put_boom_on_char(ME,0,1); run_animation_sound(167); damage_near_loc(my_loc_x(),my_loc_y(),get_ran(35,2,10),2,1); last_abil_time = get_current_tick(); } if (target_ok() == FALSE) set_state(START_STATE); do_attack(); break; ------------------------- So basically, state 4 is a custom breathing weapon. I've based it off of t13 in Za-Khazi Run With state 3, I'm trying to create a weapon that does extra damage to this specific character alone. Will this coding work? Thanks. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Enraged Slith Posted January 29, 2013 Share Posted January 29, 2013 State 3 and 4 aren't going to run if you don't have anything that activates them. Your creature isn't going to do anything at all. In any creature script, you essentially want something that designates a target and specifies actions to take if a target is found. States simply exist to ease organization, and you can handle everything in a single state if you so choose. A creature will run through whichever state it is set to run until it runs out of AP. If it runs out of AP mid state or is told to stop, it will keep running through to the end of the script before stopping. It will not change to another state unless told to do so. basicnpc cycles between the start state (searching for a target) and state 3 (attacking). If you want your boss to check what it's damaged by every turn, you'll want that code in each state you're using. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted January 30, 2013 Share Posted January 30, 2013 The way to check any script is with Alint. If that goes okay check it in practice, create an Arena town, have the boss monster placed there for a party to fight. Finding a spare town entrance is easy, Genmar occupies 3 separate town entrances and only needs 1 in BoA. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted January 31, 2013 Share Posted January 31, 2013 Check this versus basicnpc.txt, the latter will show how a creature script is supposed to work. In state 3 you need an extra bracket at the end of this line: if who_hit_me(char_has_item_of_class_equip(get_selected_char,3,0) In state 4 you have an excess bracket at the end of this line: if (tick_difference(last_abil_time,get_current_tick()) > 0)) Then you have a redundant bracket: last_abil_time = get_current_tick(); } should be: last_abil_time = get_current_tick(); In a text editor like Crimson Editor, if the Syntax Type is set to C++, clicking on a bracket will highlight it and any matching bracket it is paired with, if it has a matching one. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted March 17, 2013 Author Share Posted March 17, 2013 Out of curiosity, is there any way to allow a creature to do special damage to three random targets at once? Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Enraged Slith Posted March 17, 2013 Share Posted March 17, 2013 Yeah. Just make a script that cycles through all nearby targets until it assigns three as a target. Then have it deal the damage. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted March 18, 2013 Author Share Posted March 18, 2013 Thanks. Also, do the 'boom' calls play the sound of their fields automatically, or does that need to be programmed too? (For example, if I call a fire explosion, will the fire bolt sound play if I don't tell it to?) Quote Link to comment Share on other sites More sharing options...
Garrulous Glaahk Dark Sniper Posted March 18, 2013 Share Posted March 18, 2013 No, sir. Scripts are like a servant. They will do everything for you inside the game, if you treat it properly and give proper orders. Actually, in fact you can give a sound of door opening to the mooing of a cow. Why the boom will even have default sound at your case. 'boom' calls don't have preset sounds. I also used Enraged Slith's Sneak Attack script for a boss for my 'Second' scenario. The first one is still not posted and will require a dose of betatest. I am STILL lacking that custom graphics and scripts for which i made two topics. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted March 18, 2013 Share Posted March 18, 2013 Thanks. Also, do the 'boom' calls play the sound of their fields automatically, or does that need to be programmed too? (For example, if I call a fire explosion, will the fire bolt sound play if I don't tell it to?) In case the previous response is unclear, the answer is no. That's the reason for the run_animation_sound() call; what goes inside the parentheses tells it what sound to play as the animation runs. Otherwise you get silence. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted April 9, 2013 Author Share Posted April 9, 2013 I've now reached a town in testing where one of the creatures uses a custom script: for some reason, the game doesn't recognize the 'last_abil_time' call, even though the same call is used in ZKR. Can anyone help? The specific line is: if (tick_difference(last_abil_time,get_current_tick()) > 0) Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted April 9, 2013 Share Posted April 9, 2013 Make sure it is defined where it is used, it may be a private variable. Check the ZKR files for it. I just used the Find in Files function of Crimson Editor, I checked the ZKR files for "last_abil_time". I kept seeing "short last_abil_time;", it is being defined each time it is used, hence it is not an official BoA call, hence it must be defined in every script where it is used. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted April 9, 2013 Author Share Posted April 9, 2013 Thanks. That did the trick. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted April 14, 2013 Author Share Posted April 14, 2013 Okay, another problem. At another creature script, I get an error message saying: "Error: No body declared", "Error: State not found - 0". I've looked through the scripts extensively, and can't find what I'm doing wrong. Could someone tell me what these messages mean? EDIT: Nevermind. Figured it out. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted April 14, 2013 Share Posted April 14, 2013 You're supposed to have a line that says "body;" after you declare your variables but before your states. State 0 is the INIT_STATE, so if it's telling you that you don't have that state, you need to add it. Are you writing a creature script from scratch? If so, that's probably putting you in for a world of pain. You want to start from basicnpc and edit. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted April 14, 2013 Author Share Posted April 14, 2013 I think the 'body;' must have been deleted accidentally, but I put it back in and it's working. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted June 10, 2013 Author Share Posted June 10, 2013 I know this sounds dumb, but can a creature script check which way the creature is facing? I had the idea of when you defeat a large dragon, the creature/PC directly behind it would take damage from the dragon's big back falling on them. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted June 10, 2013 Share Posted June 10, 2013 Not unless there is a get_facing call. Character Facing is found in the Bas file but unless there is a relevant call it can't be used in a script. There is a set_facing call but I see no get_facing call. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall BainIhrno Posted June 24, 2013 Author Share Posted June 24, 2013 Maybe I'll just have the creature fall down in a random direction (i.e. a 1/8th chance of which adjacent square). I'm having trouble getting a mage fight to work properly. Creature script: beginstate 3; // attacking if (tick_difference(last_abil_time,get_current_tick()) > 0) { print_str_color("Sovash-Thinox casts: Dark Blow",3); put_boom_on_space(char_loc_x(get_target()),char_loc_y(get_target()),7,0); run_animation_sound(43); damage_near_loc(char_loc_x(get_target()),char_loc_y(get_target()),get_ran(10,1,10),0,4); last_abil_time = get_current_tick(); } if (target_ok() == FALSE) set_state(START_STATE); do_attack(); break; Technically, everything works, but I'm finding the Slith mage rarely casts the regular spells (he is set to level 27 on Mage Spells. The creature also is set to cr_default_strategy = 1.) The mage either (1) casts the special spell he's been given, or (2) just uses melee attacks, and he uses the Dark Blow special spell more often than I think he should be. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted June 24, 2013 Share Posted June 24, 2013 My reading is that he will be casting Dark Blow every round, looking at this code: if (tick_difference(last_abil_time,get_current_tick()) > 0) { (four lines omitted) last_abil_time = get_current_tick(); } Change ">0" to ">2" to get the Dark Blow used less often? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.