Jump to content


Creature script


  • Please log in to reply
18 replies to this topic
BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 28 January 2013 - 09:19 PM #1 Creature script

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.

Spoiler

Thanks.

Enraged Slith Enraged Slith

Revenge of the Slith

  • Member
    • Member ID: 27
  • 2,634 posts

Posted 29 January 2013 - 04:29 AM #2 Creature script

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.

Ishad Nha Ishad Nha

Hand of Avadon

  • Member
    • Member ID: 4,773
  • 2,366 posts

Posted 29 January 2013 - 06:27 PM #3 Creature script

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.

Ishad Nha Ishad Nha

Hand of Avadon

  • Member
    • Member ID: 4,773
  • 2,366 posts

Posted 30 January 2013 - 06:05 PM #4 Creature script

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.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 17 March 2013 - 03:06 PM #5 Creature script

Out of curiosity, is there any way to allow a creature to do special damage to three random targets at once?

Enraged Slith Enraged Slith

Revenge of the Slith

  • Member
    • Member ID: 27
  • 2,634 posts

Posted 17 March 2013 - 03:51 PM #6 Creature script

Yeah.  Just make a script that cycles through all nearby targets until it assigns three as a target.  Then have it deal the damage.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 17 March 2013 - 05:31 PM #7 Creature script

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?)

Dark Sniper Dark Sniper

Soldier

  • Member
    • Member ID: 8,605
  • 111 posts
  • LocationStanding on a Cliff

Posted 17 March 2013 - 05:39 PM #8 Creature script

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.
If one seeks me for killing you, then consider
yourself dead in the next 10 minutes. You are alive
because no one has announced any
bounty in the town.

For now, I seek Ohsky.

Kelandon Kelandon

!!!

  • Global Moderator
    • Member ID: 2,682
  • 9,786 posts

Posted 17 March 2013 - 05:58 PM #9 Creature script

View PostBainIhrno, on 17 March 2013 - 05:31 PM, said:

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.
VCH: I believe we settled this way back when: Kelandon was the most attractive.
SoT: You'd be happy, too, if you were such a clever spider.
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 08 April 2013 - 06:10 PM #10 Creature script

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)

Ishad Nha Ishad Nha

Hand of Avadon

  • Member
    • Member ID: 4,773
  • 2,366 posts

Posted 08 April 2013 - 07:52 PM #11 Creature script

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.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 09 April 2013 - 03:24 AM #12 Creature script

Thanks. That did the trick.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 13 April 2013 - 05:17 PM #13 Creature script

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.

Kelandon Kelandon

!!!

  • Global Moderator
    • Member ID: 2,682
  • 9,786 posts

Posted 13 April 2013 - 05:22 PM #14 Creature script

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.
VCH: I believe we settled this way back when: Kelandon was the most attractive.
SoT: You'd be happy, too, if you were such a clever spider.
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 13 April 2013 - 08:54 PM #15 Creature script

I think the 'body;' must have been deleted accidentally, but I put it back in and it's working.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 09 June 2013 - 05:27 PM #16 Creature script

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.

Ishad Nha Ishad Nha

Hand of Avadon

  • Member
    • Member ID: 4,773
  • 2,366 posts

Posted 09 June 2013 - 06:16 PM #17 Creature script

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.

BainIhrno BainIhrno

Hand of Avadon

  • Moderator
    • Member ID: 3,311
  • 1,312 posts

Posted 23 June 2013 - 07:15 PM #18 Creature script

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:

Spoiler

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.

Ishad Nha Ishad Nha

Hand of Avadon

  • Member
    • Member ID: 4,773
  • 2,366 posts

Posted 24 June 2013 - 07:18 AM #19 Creature script

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users