Possession & Rage Script

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: Possession & Rage Script
Shock Trooper
Member # 932
Profile #0
I've tested this, and it seems to work. If anyone would like to test it more thoroughly, comment on it, whatever, go ahead.

EDIT 1:
Oops. Forgot to check for party size... Shouldn't have been coding at 2am.
// rager.txt
//
// A relatively simple text. Creature attacks anything it hates
// nearby, and will occasionally "possess" someone.
//
// Memory Cells:
// Cell 0,1 - Stuff done flag.
// --------------------------------------------------------------
// If both 0, nothing. Otherwise when this is killed, set to 1.
// [Example: If cell 1 is 3 and cell 2 is 5, when creature
// is killed, sets SDF(3,5) to 1.]
// --------------------------------------------------------------
// Cell 2 - Dialogue node to start with if talked to.
// If left at 0, this character doesn't talk.
// --------------------------------------------------------------
// Cell 3 - Can possess?
// When possessing someone, the creature will become immobile,
// and charm it's last target every turn, unless it's target
// is dead OR the target is cured of their charmed status.
// If the party size is equal to 1, then possession will
// never happen. If using multiples of this script, let only
// one of them to do this.
// --------------------------------------------------------------
// <= 0 - False
// >= 1 - True
// --------------------------------------------------------------
// Cell 4 - Goes invulnerable while in possession of someone?
// Status will be set to invulnerable whilst in possession of
// a victim.
// --------------------------------------------------------------
// <= 0 - False
// >= 1 - True
// --------------------------------------------------------------
// Cell 5 - Can rage?
// Will be divinely touched when at 2/3 of full health, will
// continue to be touched every 5 turns with a 5 turn effect.
// [The reason being so that if the creature is healed that the
// rage can wear off over a few rounds. Yeah, just like in real
// life.]
// --------------------------------------------------------------
// <= 0 - False
// >= 1 - True
// --------------------------------------------------------------
// Cell 6 - Unused
// Cell 7 - Unused
// Cell 8 - Unused
// Cell 9 - Unused

begincreaturescript;

variables;

short last_rage; // For telling when the last rage was.
short last_update,last_target,last_possession;
short possession;

body;

beginstate INIT_STATE;
last_update = get_current_tick();
last_target = -1;
last_rage = get_current_tick();
last_possession = -1;
possession = -1;
break;

beginstate DEAD_STATE;
// Set the appropriate stuff done flag for this character being dead.
if ((get_memory_cell(0) != 0) || (get_memory_cell(1) != 0))
set_flag(get_memory_cell(0),get_memory_cell(1),1);
break;

beginstate START_STATE;
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();
set_state(3);
}

// Have I been hit? Strike back!
if (who_hit_me() >= 0) {
set_target(ME,who_hit_me());
do_attack();
set_state(3);
}
break;

beginstate 3; // Attack State
// If "can rage" is true, and we are below half our health
// and we have waited a decent amount of time THEN rage
if ((get_memory_cell(5) > 0) && (get_health(ME) < (get_max_health(ME) * 2) / 3) && (tick_difference(last_rage,get_current_tick()) >= 5)) {
print_named_str(ME,"enters a demonic rage!");

put_sparkles_on_char(ME,1,10);
run_animation_sound(48);
set_char_status(ME,16,5,1,0);
last_rage = get_current_tick();
}

// If we possessing something that fell over and died...
if ((possession == 1) && (char_ok(last_target) == FALSE)) {
// Remove invulnerablity if Cell 4 is a positive integer.
if (get_memory_cell(4) >= 1)
set_char_status(ME,4,-1,1,0);
last_target = -1;
// Reset last_possession so we wait at LEAST five ticks
// before attempting to possess again.
last_possession = get_current_tick();
possession = -1;
set_mobility(ME,1);
}

// If we aren't possessing something & our target is dead,
// then return to START_STATE.
if (target_ok() == FALSE)
set_state(START_STATE);

// Update possession if we are possessing someone, they are a
// living target, and at least 1 turn has passed since we last
// updated this phase.
if ((possession == 1) && (char_ok(last_target)) && (tick_difference(get_current_tick(),last_update) >= 1)) {
if (get_char_status(last_target,8) == 0) {
if (get_memory_cell(4) >= 1)
set_char_status(ME,4,-1,1,0);
set_target(ME,last_target);
last_target = -1;
last_possession = get_current_tick();
possession = -1;
set_mobility(ME,1);
}

else {
if (get_memory_cell(4) >= 1)
set_char_status(ME,4,1,1,0);
// We do NOT want to update the possession more than once
// per turn. Apart from that, it makes it difficult to
// turn off the charmed & invulnerability status.
set_char_status(last_target,8,1,1,0);
last_update = get_current_tick();
}
}

// If can possess is true, we haven't already possessed someone,
// we have waited a half decent amount of time & we get a < 50
// THEN possess our current target.
if ((get_memory_cell(3) >= 1) && (party_size() >= 2) && (possession == -1) && (get_ran(1,0,100) < 50) && (tick_difference(last_possession,get_current_tick()) >= 5)) {
print_named_str(get_target(),"is possessed!");

// Setup and play SFX + sound
put_sparkles_on_char(ME,10,10);
put_effect_on_char(get_target(),2,10,0);
run_animation_sound(7);

// Set creature invulnerable if Cell 4 is a positive integer.
if (get_memory_cell(4) >= 1)
set_char_status(ME,4,1,1,0);
set_char_status(get_target(),8,2,1,0);

last_update = get_current_tick();
last_target = get_target();
last_possession = get_current_tick();
possession = 1;
set_target(ME,-1);
set_mobility(ME,0);
}

do_attack();
break;

beginstate TALKING_STATE;
if (get_memory_cell(3) == 0) {
print_str("Talking: It doesn't respond.");
end();
}
begin_talk_mode(get_memory_cell(3));
break;


[ Tuesday, September 14, 2004 13:48: Message edited by: CPeters ]
Posts: 215 | Registered: Sunday, April 7 2002 08:00