Jump to content

Character Scripts problem


Recommended Posts

I keep trying to have things happen in my character scripts, like the enemy gets healed every turn, or kills off the party if you don't kill it in a time limit, but they never work. The calls in the START_STATE do not get performed every turn, and the effects don't happen! Twice I've had to move the effects to the town script, and that just bugs me, because half of the effects will not work in a town script (Damage_nearby, etc.). Does anyone know what could be the problem? There were no bugs in the scripts, or they wouldn't have worked in the town script.

 

Here are both scripts. The first one works fine in a town script, but does not work in a Creature Script, the desired location:

 

Code:
if(get_flag(10,4)==1) {		if (get_flag(10,5)==0) {			message_dialog("The enemy cackles and gathers energy from the machinery. If it builds up, who knows what would happen?","");			set_flag(10,5,1);		}		print_str_color("The enemy charges up energy.",4);		trns = trns + 1;		if (trns == 5) {			message_dialog("The enemy has built up enough energy. It unleashes it on you in a storm of fire. There is no way you will survive.","");			damage_char(0,1000,4);			damage_char(1,1000,4);			damage_char(2,1000,4);			damage_char(3,1000,4);			//killing blow			damage_char(0,1,4);			damage_char(1,1,4);			damage_char(2,1,4);			damage_char(3,1,4);		}	}

The first SDF flag is set to 1, and the integer 'trns' has been properly declared.

 

And the next script doesn't work in a Creature script either, and fails to do any damage (or did the last time I checked, but I have done something to fix this, and will update if it works[still doesn't work]) even when I put it in a town script.

 

Code:
if (get_flag(20,1) == 1) {		dizz = dizz + 1;		if (dizz == 3) {			print_str_color("The enemy emits a blast of fire.",4);			damage_nearby(50,5,1,0);			dizz = dizz - 3;		}	}
Link to comment
Share on other sites

Creature scripts are probably the most complicated of the basic scripts. I'm still pretty rusty at them.

 

From what I understand, creature scripts will call what ever state they're set to every turn, until specified otherwise. If you just pasted that into the start state, it could be that the creature set it's state to it's attack state, which would account for why it isn't working.

 

Also, if creature scripts aren't constructed properly, the creature will just shut down.

Link to comment
Share on other sites

It's worth noting, tangentially, that there's not really such a thing as 'ATTACK_STATE'. It is merely Jeff's convention to use state 3 for a creature's fighting logic. (In fact, he doesn't even do this strictly, as basicnpc will actually make attacks while still in the START_STATE just before switching to state 3.) It is entirely possible to write a creature script so that all combat and peaceful logic is contained within the START_STATE, so that it has multiple states used while fighting, or even so that the START_STATE handles combat and the creature switches to a different state when not fighting, and so on.

 

That being said, if you use basicnpc as a template, you do need to think carefully about the effects of the creature switching between states 2 and 3.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...