Hi, I've been trying to add a damaged message to the civflee cog that Grismath showed to me once, and the wierdest thing keeps happening. With my extra code, when the player damages the civs, they attack the player (I had noticed that previously you could punch them to death without them getting upset) - however, a blackreeyees also is created at the civs position every time damage is called! Why?
As far as I can see, I haven't got any other cog in the level that ever asks CreateThing(reeyees);.
Here is what I had done to ruin Grismath's cog:
As far as I can see, I haven't got any other cog in the level that ever asks CreateThing(reeyees);.Here is what I had done to ruin Grismath's cog:
Code:
# Jedi Knight Cog Script
# CivFlee.cog
# This cog gives civilians an aversion to armed gunmen roaming amongst them.
# [Grismath]
#
# (I added the damaged message so you can't go around punching people in the face with no comeback)
# (Thanks for the cog, Grismath - my level depends on it! - rob_whatman)
# This COG is not supported by Lucasarts
#
symbols
message startup
message pulse
message timer
message damaged
thing player local
thing civ0
thing civ1
thing civ2
thing civ3
thing civ4
thing civ5
thing civ6
thing civ7
ai regular
ai flee
flex fTime // Length of fleeing period
int X=0 local
int Y=0 local
sound bangbang
template pow
end
#======================================================================================#
code
#--------------------------------------------------------
startup:
Sleep(0.5);
for(X=0;X<8;X=X+1) AISetClass(civ0[X], regular);
for(X=0;X<8;X=X+1) CaptureThing(civ0[X]);
player=GetLocalPlayerThing();
SetPulse(1);
return;
#--------------------------------------------------------
pulse:
for(X=0;X<8;X=X+1) {
if(HasLOS(civ0[X], player)) {
if(GetCurWeapon(player) != 1) {
AISetClass(civ0[X], flee);
SetTimerEx(fTime, 1337, X, 0);
}}}
return;
#--------------------------------------------------------
timer:
if(GetSenderID()==1337) {
Y=GetParam(1);
AISetClass(civ0[Y], regular);
}
return;
#--------------------------------------------------------
# I added the damaged message, and the troopers get angry OK - but also a reeyees is created at the ThingPos!
# WHY?!!!!!!
damaged:
creature = GetSenderRef();
player = GetLocalPlayerThing();
actor = GetThingParent(GetSourceRef());
if(actor == player)
{
if(HasLOS(creature, player))
{
SetPulse(0);
AISetFireTarget(creature, player);
FireProjectile(creature, bangbang, pow, -1, 0, 0, 1, 0, 120, 10);
AISetMode(creature, 0x2);
AISetClass(creature, flee);
Print("I'll teach you to mess with me!");
SetPulse(1);
return;
}
}
return;
#-----------------------------------------------------------
end

