FOnline Development > Questions and Answers

How to change CrType or Critter type animation by a dialog?!

<< < (2/2)

JovankaB:

--- Code: ---bool d_isHourRange (Critter& player, Critter@ npc, int fromHour, int toHour)
{
    return (fromHour > toHour ? (fromHour >= __Hour || toHour  <= __Hour) : (fromHour >= __Hour && toHour  <= __Hour));
}

bool d_isHour (Critter& player, Critter@ npc, int hour)
{
    return hour == __Hour;
}

bool d_isDay (Critter& player, Critter@ npc)
{
    return d_isHourRange(player, npc, 8, 20);
}

bool d_isNight (Critter& player, Critter@ npc)
{
    return !d_isDay(player, npc);
}

--- End code ---

didn't test it but should work

you get 4 functions: d_isHourRange, d_isHour, d_isDay, d_isNight

Balthasar:
Thanks for the replies :)

It still won't work, though. I did enter the functions into dialog.fos and made new demands within the dialog editor (for nighttime-dialog "[2]-" demand: dialog@d_isNight , for daytime-dialog "[3]-" demand: dialog@d_isDay). Since the dialog.fos script is already within the scripts-config file i don't even need to put it there (though i did tested this with a totally new script also to be sure).

Whenever i talk to the critter he starts with the first pre-dialog (atm this is the nighttime dialog), wether it's day or night. The bool-check itself (without any conditions) seems to work because if i set the return to "false" like:


--- Code: ---bool d_checkBoolTest (Critter& player, Critter@ npc)
{
  return false;
}
--- End code ---

...it skips the first pre-dialog (where the demand check would be "dialog@d_checkBoolTest" in this case) and continues with the daytime-dialog. If i set it to "return true;" he starts with the first again.

So i guess the functions are ok but something with the check of the GameTime itself doesn't work properly. Any idea what i may have done wrong or where i may have to bind/define whatever additionally?

Edit:
@Plech

Yeah, this seems to be the searched function. Lidae already pasted this code for me but it didn't work either. The problem seems to be some general thing with this "GetGameTime" function (see above).

Balthasar:
Ok got it to work. Wrote an own little script, using this __Hour var. Thanks to your script, Jovanka, this idea came into my mind:


--- Code: ---bool d_isNightNeu (Critter& player, Critter@ npc)
{
if (__Hour >= 8 && __Hour <= 20)
{
return false;
}
else
{
return true;
}
}
--- End code ---

I still dont get why Jovankas code isn't working, though. As far as i understand it i see no flaw in it and basically it does the same thing (within the d_isHourRange function).

Lidae:


--- Quote from: Jovanka ---
--- Code: ---bool d_isHourRange (Critter& player, Critter@ npc, int fromHour, int toHour)
{
    return (fromHour > toHour ? (fromHour >= __Hour || toHour  <= __Hour) : (fromHour >= __Hour && toHour  <= __Hour));
}
--- End code ---

--- End quote ---

Looks like the logic got scrambled a bit: the returned statement is always true if fromHour > toHour, and it's always false if it's the other way around. So either way it doesn't work. Could do this instead:


--- Code: ---return (fromHour > toHour ? (fromHour <= _Hour || toHour >= __Hour) : (fromHour <= __Hour && toHour >= __Hour));

--- End code ---

Or this (more elegant imo)


--- Code: ---return ((__hour+24-fromHour)%24 >= (toHour+24-fromHour)%24);

--- End code ---

(The "+24" thing might not be necessary, it depends on how angelscript handles modulus operations (the % sign) on negative numbers. Can't readily check right now).

Anyway, good to know about the __hour variable, wasn't aware of that. And a bit weird that the GetGameTime() function didn't work. Wonder if it's completely defunct/deprecated, or if it's intended to do something else?

Navigation

[0] Message Index

[*] Previous page

Go to full version