Author Topic: How to change CrType or Critter type animation by a dialog?!  (Read 5576 times)

How to change CrType or Critter type animation by a dialog?!
« on: December 26, 2012, 07:26:43 pm »
So yeah, im trying to change the player animation via dialog. Adding a result script.
I tried to use "debug" module but it obviously wont work.

I guess i need to add a function like r_MakeMeAGoddamnMutie to the result script but... I have no idea how to write a script sorry, i have no idea of scripting/programing etc

Any charitable soul? I need help

JovankaB

  • Guest
Re: How to change CrType or Critter type animation by a dialog?!
« Reply #1 on: December 26, 2012, 07:48:30 pm »
Paste this in dialog.fos:

Code: [Select]
void r_ChangeSkin(Critter& player, Critter@ npc, int val)
{
    if (player.ChangeCrType(val))
        player.StatBase[ST_BASE_CRTYPE] = val;
}


In dialog editor, result tab:



In this case skin/crtype will be changed to 21 (green super mutant)

Re: How to change CrType or Critter type animation by a dialog?!
« Reply #2 on: December 27, 2012, 01:24:44 am »
Thank you JovankaB!  ;)

I'll go right to testing! I think is a good moment to learn something about this

Re: How to change CrType or Critter type animation by a dialog?!
« Reply #3 on: February 26, 2013, 09:23:18 pm »
I have a question, somehow related to this issue:

I want the predialogue to check if it's day- or nighttime. Luckely this was something Ghosthack did mention within his dialog editor tutorial (via the dialog@d_checkNight script-function). Unfortunatly this function isn't included within the SDK "dialog"-script.

So, if someone could post this function here or an own solution, this would be nice :).

Offline Plech

  • I'm a loner.
Re: How to change CrType or Critter type animation by a dialog?!
« Reply #4 on: February 26, 2013, 11:37:16 pm »
this?
Code: [Select]
bool d_checkNight(Critter& player, Critter@ npc)
{
        uint fullsecond = 0;
        uint16 year=0, month=0, dayOfWeek=0, day=0, hour=0, minute=0, second=0;
        GetGameTime(fullsecond,year,month,dayOfWeek,day,hour,minute,second);
        if (hour >= 8 && hour <= 20)
                return true;
        else
                return false;
}
alias Pic Ho.

JovankaB

  • Guest
Re: How to change CrType or Critter type animation by a dialog?!
« Reply #5 on: February 27, 2013, 12:07:39 am »
Code: [Select]
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);
}

didn't test it but should work

you get 4 functions: d_isHourRange, d_isHour, d_isDay, d_isNight
« Last Edit: February 27, 2013, 12:24:06 am by JovankaB »

Re: How to change CrType or Critter type animation by a dialog?!
« Reply #6 on: February 27, 2013, 06:57:41 pm »
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: [Select]
bool d_checkBoolTest (Critter& player, Critter@ npc)
{
  return false;
}

...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).

« Last Edit: February 27, 2013, 07:10:31 pm by Balthasar »

Re: How to change CrType or Critter type animation by a dialog?!
« Reply #7 on: March 04, 2013, 06:52:20 pm »
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: [Select]
bool d_isNightNeu (Critter& player, Critter@ npc)
{
if (__Hour >= 8 && __Hour <= 20)
{
return false;
}
else
{
return true;
}
}

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).

Re: How to change CrType or Critter type animation by a dialog?!
« Reply #8 on: March 04, 2013, 11:02:50 pm »

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

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: [Select]
return (fromHour > toHour ? (fromHour <= _Hour || toHour >= __Hour) : (fromHour <= __Hour && toHour >= __Hour));

Or this (more elegant imo)

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

(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?