I am stuck trying to write a cog. The first part is fine - the touched message creates three creatures that you go hunting etc.
This is a 'mission', and the idea is that when you have killed all the creatures, the objective will be completed. But I can't write a piece of code to detect if all the creatures have been killed. I put a section in the killed message of their actor cog - but the objective was completed after only one creature died. Also, I've tried reading the health of the creatures with GetHealthThing (), and it often comes back as -1. Can anyone help me?
And here is my attempt at a killed message to see if all three creatures are dead:
This is a 'mission', and the idea is that when you have killed all the creatures, the objective will be completed. But I can't write a piece of code to detect if all the creatures have been killed. I put a section in the killed message of their actor cog - but the objective was completed after only one creature died. Also, I've tried reading the health of the creatures with GetHealthThing (), and it often comes back as -1. Can anyone help me?
Code:
symbols
thing object
thing bug0
thing bug1
thing bug2
template bugType=darosian_mite
sound wav0
int X=0 local
int pandora=0
int bugsaGoGo local
int bugsLife0 local
int bugsLife1 local
int bugsLife2 local
model openBox=crtz.3do
message touched
end
code
startup:
Sleep(0.5);
bugsaGoGo = 0;
return;
touched:
player = GetSenderID();
if (GetSenderID() == player)
{
if(pandora == bugsaGoGo)
{
for (X=0;X<3;X=X+1) CreateThing(bugType, bug0[X]);
for (X=0;X<3;X=X+1) SetThingHealth(bug0[X], 10);
SetThingModel(object, openBox);
Print("SITH OFFICER: Typical! You've let the Darosian hunting mites out!");
Print ("SITH OFFICER: Maybe you'd better find a way to get rid of them, seeing as its your fault.");
Print ("SITH OFFICER: Or would you rather spend a night in the detention wing?");
PlaySoundThing(wav0, object, 1, -1, -1, 0);
questPlayer = GetLocalPlayerThing();
SetGoalFlags(questPlayer, 4, 1);
bugsAgogo = bugsaGoGo + 1;
}}
return;
endAnd here is my attempt at a killed message to see if all three creatures are dead:
Code:
killed:
for (X=0;X<3;X=X+1) bug0[X] = GetSenderID();
for (X=0;X<3;X=X+1) bugsLife0[X] = GetThingHealth();
if (GetSenderID() == bug0)
call bug0died;
else
if (GetSenderID() == bug1)
call bug1died;
else
if (GetSenderID() == bug2)
call bug2died;
else
return;
bug0died:
if (bugsLife1 >0 && bugsLife2 >0)
{
Print("Bug 0 is dead, but you still gotta find some bugs...");
return;
}
else
{
questPlayer = GetLocalPlayerThing();
SetGoalFlags(questplayer, 4, 2);
PlaySoundThing(wav1, questplayer, 1, -1, -1, 0);
Print("You killed all the little critters ... shame on you!");
return;
}
bug1died:
if (bugsLife0 >0 && bugsLife2 >0)
{
Print("Bug 1 is dead, but you still gotta find some bugs...");
return;
}
else
{
questPlayer = GetLocalPlayerThing();
SetGoalFlags(questplayer, 4, 2);
PlaySoundThing(wav1, questplayer, 1, -1, -1, 0);
Print("You killed all the little critters ... shame on you!");
return;
}
return;
bug2died:
if (bugsLife0 >0 && bugsLife1 >0)
{
Print("Bug 2 is dead, but you still gotta find some bugs...");
return;
}
else
{
questPlayer = GetLocalPlayerThing();
SetGoalFlags(questplayer, 4, 2);
PlaySoundThing(wav1, questplayer, 1, -1, -1, 0);
Print("You killed all the little critters ... shame on you!");
return;
}
end



