Author Topic: PYTHON SCRIPT/SCHEME EXCHANGE  (Read 62894 times)

0 Members and 1 Guest are viewing this topic.

Amarillo

  • Sergeant
  • *
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #45 on: October 09, 2006, 06:35:42 PM »
Is there any possibility of increasing its resolution beyond 100x100?

I believe so. When I had a look at the script a second time I realized that I'm an idiot and that my solution is ridiculously overcomplicated. I think it would be possible to solve the problem simply by using Pythagoras' theorem. If we assume that the battlefield is perfectly square it is easy to derive the two formulas:

y = ( p2 - b2 + a2 ) / 2p
x = sqrt( a2 - y2 )

where a is the distance from corner A to the agent, b is the distance from corner B to the agent and p is the distance form corner A to corner B.

This way the problem with extremely large numbers will most likely disappear for battlefields of reasonable size. It still won't be perfect because of the rounding errors, but since the distances are measured in centimeters i don't think this will cause any notable interference. Otherwise you could just scale all distances to get a coordinate system with a resolution of e.g. 1000x1000.

Thus spake Nosferatu

  • Neighbor of the Beast
  • Grandmaster Knight
  • *
  • Et tu spiritu cool
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #46 on: October 09, 2006, 07:18:21 PM »
yeah, traingulation.  You can also just normalize your results to whatever scale you like beforehand and convert back.
"One day," God said, "This is what I will do. I'll send down my son, I'll send him to you, to clear up all this jehovity hullabaloo. His name will be Christ and he'll never wear shoes. And his pals will all call him the King of the Jews!"

jamoecw

  • Squire
  • *
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #47 on: October 24, 2006, 05:19:27 PM »
playing around with the formula and some numbers i found that any number that is negative is past A (off the map if the points are at the edges of the map), while any number greater than p is past B (off the map in the other direction), which means that the first formula works even if the points calculated are not at the edges of the map, the problem occurs if the map is not square and/or y is negative.   the problem with y being negative can be fixed two ways:
1 - use the absolute of y in the next equation - x = (a - |y|)
2 - use the first formula modified to find x - x = (p2 - c2 + b2) / 2p
                   *note p is now the distance from point B to C, c = distance from C to agent, b = distance B to agent (like before).

the second method also should also find x even when the points aren't square (not a square battlefeild), i'm not a mathematician so i could easily be wrong.

Amarillo you seem to be good at this, are my assumptions correct?

Thus spake Nosferatu

  • Neighbor of the Beast
  • Grandmaster Knight
  • *
  • Et tu spiritu cool
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #48 on: October 25, 2006, 07:48:34 AM »
Out of the goodness of my heart, I have made you a face code generator - originally for yoshiboy, but free for all to use.

The beauty of this script is that you give it a range of values.  So if you want the script to generate out asians, you just take two asiany faces and the results will all be between those two values. 

I thought of adding in parameters to it so you could specifically give it a list of beards and skins and crap, but this seems to work pretty good already so I didn't bother.  Let me know if you encounter any bugs or anything.

Anyone is free to use it without asking permission!  This is in perl, btw.

Code: [Select]


sub generateRawRandomFace
{

    return &generateRandomFace("0000001c0000000000000",
                               "10940901f8ffffffffffff");
}


sub generateRandomFace
{
    #0x00000000000c600301c2510211a5b292 -marnid
    #0x00000000000c000001c0000000000000 - min face
    #0x0000000000
    #0x00000000000c600301c2510211a5b292
    #            10940901f8ffffffffffff
    my $lowerCode = $_[0];
    my $upperCode = $_[1];

    my $finalCode = "0x0000000000";

    my $lowerHair = substr($lowerCode, 0, 2);
    my $upperHair = substr($upperCode, 0, 2);


    $lowerHair = hex($lowerHair)/4;
    $upperHair = hex($upperHair)/4;

    my $lowerCode = substr($lowerCode, 2);
    my $upperCode = substr($upperCode, 2);

    if($lowerHair>$upperHair)
    {
        my $swap = $upperHair;
       
        $upperHair=$lowerHair;
        $lowerHair=$swap;
    }
 

    my $range = $upperHair-$lowerHair;



    my $randomValue = int(rand($range+1));

    $randomValue = ($randomValue + $lowerHair)*4;



    my $hairCode = sprintf("%x", $randomValue);

    if(length($hairCode)<2)
    {
        $hairCode = "0".$hairCode;
    }


    $finalCode = $finalCode."$hairCode";



    my $lowerSkin = substr($lowerCode, 0, 1);
    my $upperSkin = substr($upperCode, 0, 1);

    if($lowerSkin>$upperSkin)
    {
        my $swap = $upperSkin;
       
        $upperSkin=$lowerSkin;
        $lowerSkin=$swap;
    }
   

    $lowerCode = substr($lowerCode, 1);
    $upperCode = substr($upperCode, 1);

    $range = $upperSkin-$lowerSkin;

    $randomValue = int(rand($range+1));


    my $finalValue = $randomValue + $lowerSkin;

    $finalCode = $finalCode."$finalValue";




    $lowerBeard = substr($lowerCode, 0, 2);
    $upperBeard = substr($upperCode, 0, 2);

    #print "lowerBeard = $lowerBeard\n";
    #print "upperBeard = $upperBeard\n";

    $lowerBeard = hex($lowerBeard)/4;
    $upperBeard = hex($upperBeard)/4;

    if($lowerBeard>$upperBeard)
    {
        my $swap = $upperBeard;

        $upperBeard=$lowerBeard;
        $lowerBeard=$swap;
    }


    $lowerCode = substr($lowerCode, 2);
    $upperCode = substr($upperCode, 2);


    $range = $upperBeard-$lowerBeard;


    $randomValue = int(rand($range+1));

    $randomValue = ($randomValue + $lowerBeard)*4;


    my $beardCode = sprintf("%x", $randomValue);

    if(length($beardCode)<2)
    {
        $beardCode = "0".$beardCode;
    }


    $finalCode = $finalCode."$beardCode";


    my $lowerHair = substr($lowerCode, 0, 1);
    my $upperHair = substr($upperCode, 0, 1);

    if($lowerHair>$upperHair)
    {
        my $swap = $upperHair;

        $upperHair=$lowerHair;
        $lowerHair=$swap;
    }

    $lowerCode = substr($lowerCode, 1);
    $upperCode = substr($upperCode, 1);



    $range = $upperHair-$lowerHair;

    $randomValue = int(rand($range+1));

    my $finalValue = $randomValue + $lowerHair;


    $finalCode = $finalCode."$finalValue";



    #remove that 01 thing
    $lowerCode = substr($lowerCode, 2);
    $upperCode = substr($upperCode, 2);
    $finalCode = $finalCode."01";




    my $lowerEyebrows = substr($lowerCode, 0, 2);
    my $upperEyebrows = substr($upperCode, 0, 2);

    $lowerEyebrows = hex($lowerEyebrows);
    $upperEyebrows = hex($upperEyebrows);


    $lowerEyebrows = $lowerEyebrows-192;
    $upperEyebrows = $upperEyebrows-192;


    $lowerEyebrows2 = $lowerEyebrows%8;
    $upperEyebrows2 = $upperEyebrows%8;

    if($lowerEyebrows2>$upperEyebrows2)
    {
        my $swap = $upperEyebrows2;

        $upperEyebrows2=$lowerEyebrows2;
        $lowerEyebrows2=$swap;
    }


    $lowerEyebrows = int($lowerEyebrows/8);
    $upperEyebrows = int($upperEyebrows/8);

    if($lowerEyebrows>$upperEyebrows)
    {
        my $swap = $upperEyebrows;

        $upperEyebrows=$lowerEyebrows;
        $lowerEyebrows=$swap;
    }


    $range = $upperEyebrows - $lowerEyebrows;


    $randomValue = int(rand($range+1));


    $finalValue = $lowerEyebrows+$randomValue;

    $finalValue = $finalValue*8;
    $finalValue = $finalValue+192;



    $range = $upperEyebrows2 - $lowerEyebrows2;


    $randomValue = int(rand($range+1));


    $finalValue = $finalValue+$randomValue+$lowerEyebrows2;


    $finalValue = sprintf("%x", $finalValue);

    $finalCode = "$finalCode".$finalValue;


    $lowerCode = substr($lowerCode, 2);
    $upperCode = substr($upperCode, 2);



    $finalValue = &chompFace(substr($lowerCode, 0, 3),
                             substr($upperCode, 0, 3));

    $lowerCode = substr($lowerCode, 3);
    $upperCode = substr($upperCode, 3);


    $finalCode = "$finalCode".$finalValue;


    $finalValue = &chompFace(substr($lowerCode, 0, 3),
                             substr($upperCode, 0, 3));

    $lowerCode = substr($lowerCode, 3);
    $upperCode = substr($upperCode, 3);


    $finalCode = $finalCode."$finalValue";



    $finalValue = &chompFace(substr($lowerCode, 0, 3),
                             substr($upperCode, 0, 3));

    $lowerCode = substr($lowerCode, 3);
    $upperCode = substr($upperCode, 3);

    $finalCode = "$finalCode".$finalValue;



    $finalValue = &chompFace(substr($lowerCode, 0, 3),
                             substr($upperCode, 0, 3));

    $lowerCode = substr($lowerCode, 3);
    $upperCode = substr($upperCode, 3);


    $finalCode = "$finalCode".$finalValue;

    if(length($finalCode)!=34)
    {
        $codeLength = length($finalCode);
        die "Bad code length of $codeLength\n";

    }
   


    return $finalCode;
}

sub chompFace
{
   my $lower = $_[0];
   my $upper = $_[1];



   my $lowerValue = hex($lower);
   my $upperValue = hex($upper);


   $lowerValue4 = $lowerValue%8;
   $upperValue4 = $upperValue%8;

   $lowerValue = int($lowerValue/8);
   $upperValue = int($upperValue/8);

   $lowerValue3 = $lowerValue%8;
   $upperValue3 = $upperValue%8;

   $lowerValue = int($lowerValue/8);
   $upperValue = int($upperValue/8);

   $lowerValue2 = $lowerValue%8;
   $upperValue2 = $upperValue%8;

   $lowerValue = int($lowerValue/8);
   $upperValue = int($upperValue/8);

   $lowerValue1 = $lowerValue%8;
   $upperValue1 = $upperValue%8;



   if($lowerValue1>$upperValue1)
   {
       my $swap = $lowerValue1;
       $lowerValue1=$upperValue1;
       $upperValue1=$swap;
   }

   if($lowerValue2>$upperValue2)
   {
       my $swap = $lowerValue2;
       $lowerValue2=$upperValue2;
       $upperValue2=$swap;
   }

   if($lowerValue3>$upperValue3)
   {
       my $swap = $lowerValue3;
       $lowerValue3=$upperValue3;
       $upperValue3=$swap;
   }

   if($lowerValue4>$upperValue4)
   {
       my $swap = $lowerValue4;
       $lowerValue4=$upperValue4;
       $upperValue4=$swap;
   }

   my $range1 = $upperValue1 - $lowerValue1;
   my $range2 = $upperValue2 - $lowerValue2;
   my $range3 = $upperValue3 - $lowerValue3;
   my $range4 = $upperValue4 - $lowerValue4;

   my $randomValue1 = int(rand($range1+1));
   my $randomValue2 = int(rand($range2+1));
   my $randomValue3 = int(rand($range3+1));
   my $randomValue4 = int(rand($range4+1));

   my $finalValue1 = $randomValue1 + $lowerValue1;
   my $finalValue2 = $randomValue2 + $lowerValue2;
   my $finalValue3 = $randomValue3 + $lowerValue3;
   my $finalValue4 = $randomValue4 + $lowerValue4;


   $finalValue1 = $finalValue1*8*8*8;
   $finalValue2 = $finalValue2*8*8;
   $finalValue3 = $finalValue3*8;

   my $finalValue = $finalValue1+$finalValue2+$finalValue3+$finalValue4;


   $finalValue = sprintf("%x", $finalValue);

   if(length($finalValue)<3)
   {
       $finalValue = "0$finalValue";
   }
   if(length($finalValue)<3)
   {
       $finalValue = "0$finalValue";
   }
   if(length($finalValue)<3)
   {
       $finalValue = "0$finalValue";
   }


   return $finalValue;
}




"One day," God said, "This is what I will do. I'll send down my son, I'll send him to you, to clear up all this jehovity hullabaloo. His name will be Christ and he'll never wear shoes. And his pals will all call him the King of the Jews!"

Yoshiboy

  • Master baiter
  • Moderator
  • *
  • - Everything is a metaphor -
    • View Profile
    • My Website
  • Faction: Neutral
  • MP nick: irc://yoshiboy
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #49 on: October 25, 2006, 09:40:03 AM »
looks great! I'll try it out.

KON_Air

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: KON_Air
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #50 on: November 01, 2006, 03:12:41 PM »
Updated Fujiwara's calender and added a tiny line to show date.

To Strings;
Code: [Select]
("date","Date is {reg1} / {reg2} / {reg3} "),
to triggers;
Code: [Select]
#Calender Thingy
(0.0, 0, ti_once, [], [(assign,"$day",0), (assign,"$month",1), (assign,"$year",1)]),

(0.0, 0, 24.0, [(lt, "$day", 31)], [(val_add,"$day",1)]),
(0.0, 0, 0.0, [(eq,"$day",31),(lt,"$month",13)], [(val_add,"$month",1), (assign,"$day",1)]),
(0.0, 0, 0.0, [(eq,"$month",13)], [(val_add,"$year",1), (assign,"$month",1)]),

#show  date every 6 hours
(0.0, 0, 6.0, [], [(assign,reg(1),"$day"),(assign,reg(2),"$month"),(assign,reg(3),"$year"),(display_message,"str_date")]),


Also not a real script (lot's of c/p)but a quick start button for testers, add to start_game_1 menu, jumps straight to face creation as a male with high stats;
Code: [Select]
   ("start_rush",[],"RUSH",
       [
           (troop_set_type,0,0),
           (assign,"$character_gender",0),
           (troop_raise_attribute, "trp_player",ca_agility,30),
           (troop_raise_attribute, "trp_player",ca_intelligence,30),
   (troop_raise_attribute, "trp_player",ca_strength,30),
   (troop_raise_attribute, "trp_player",ca_charisma,30),
   (troop_raise_proficiency, "trp_player",0,400),
   (troop_raise_proficiency, "trp_player",1,400),
           (troop_raise_proficiency, "trp_player",2,400),
    (troop_raise_proficiency, "trp_player",3,400),
        (troop_raise_proficiency, "trp_player",4,400),
(troop_raise_proficiency, "trp_player",5,400),
(troop_raise_proficiency, "trp_player",6,400),
(troop_raise_skill, "trp_player",skl_ironflesh,10),
        (troop_raise_skill, "trp_player",skl_weapon_master,10),
        (troop_raise_skill, "trp_player",skl_power_strike,10),
(troop_raise_skill, "trp_player",skl_power_draw,10),
(troop_raise_skill, "trp_player",skl_power_throw,10),
        (troop_raise_skill, "trp_player",skl_riding,10),
(troop_raise_skill, "trp_player",skl_horse_archery,10),
        (troop_raise_skill, "trp_player",skl_tactics,10),
        (troop_raise_skill, "trp_player",skl_shield,10),
        (troop_raise_skill, "trp_player",skl_leadership,10),
        (troop_raise_skill, "trp_player",skl_prisoner_management,10),
        (troop_raise_skill, "trp_player",skl_spotting,10),
        (troop_raise_skill, "trp_player",skl_surgery,10),
        (troop_raise_skill, "trp_player",skl_wound_treatment,10),
        (troop_raise_skill, "trp_player",skl_first_aid,10),
        (troop_raise_skill, "trp_player",skl_tracking,10),
        (troop_raise_skill, "trp_player",skl_pathfinding,10),
        (troop_raise_skill, "trp_player",skl_trade,10),
(troop_raise_skill, "trp_player",skl_inventory_management,10),
(troop_add_item, "trp_player","itm_leather_jerkin",imod_ragged),
        (troop_add_item, "trp_player","itm_arming_sword",imod_rusty),
        (troop_add_item, "trp_player","itm_hunting_crossbow",0),
        (troop_add_item, "trp_player","itm_leather_boots",0),
        (troop_add_item, "trp_player","itm_leather_gloves",imod_tattered),
        (troop_add_item, "trp_player","itm_bolts",0),
        (troop_add_item, "trp_player","itm_smoked_fish",0),
        (troop_add_item, "trp_player","itm_saddle_horse",imod_swaybacked),
        [troop_add_gold, "trp_player", 1000000],
           (change_screen_return,0),
        ]
       ),
« Last Edit: November 01, 2006, 03:39:57 PM by KON_Air »
Comparing Fallout 3 and 1-2 is like comparing an apple to a mutated apple which is trying to bite your face.

El Duke

  • Grandmaster Knight
  • *
  • One eyed king of the blind men wastelands
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #51 on: November 01, 2006, 09:32:32 PM »
i want a code to make an npc go hostile to the player...inside towns(like a bar fight).

Thus spake Nosferatu

  • Neighbor of the Beast
  • Grandmaster Knight
  • *
  • Et tu spiritu cool
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #52 on: November 01, 2006, 10:31:58 PM »
i want a code to make an npc go hostile to the player...inside towns(like a bar fight).

There's already a bar fight mod somewhere.  Just search on bar fight to find it.
"One day," God said, "This is what I will do. I'll send down my son, I'll send him to you, to clear up all this jehovity hullabaloo. His name will be Christ and he'll never wear shoes. And his pals will all call him the King of the Jews!"

El Duke

  • Grandmaster Knight
  • *
  • One eyed king of the blind men wastelands
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #53 on: November 02, 2006, 01:35:13 AM »
oh...ok, but is it ope sourced? i thought this was a very simple thing, can't someone just give me the code?

Thus spake Nosferatu

  • Neighbor of the Beast
  • Grandmaster Knight
  • *
  • Et tu spiritu cool
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #54 on: November 02, 2006, 01:45:20 AM »
oh...ok, but is it ope sourced? i thought this was a very simple thing, can't someone just give me the code?

Just search on it there is code.  i think it is right int his thread somewhere. 
"One day," God said, "This is what I will do. I'll send down my son, I'll send him to you, to clear up all this jehovity hullabaloo. His name will be Christ and he'll never wear shoes. And his pals will all call him the King of the Jews!"

El Duke

  • Grandmaster Knight
  • *
  • One eyed king of the blind men wastelands
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #55 on: November 02, 2006, 07:38:31 PM »
I know this must be very tricky, but i really hate that text" you lay were you fell as your enemies walk away yada yada".in my mod since there are zombies to fight and no mercenary troops, only heroes...it would be realy uncool. so is it possible to have a "game over" when you lose a battle?just a screen message and a reset to the game main menu.


also the code in the bar fight minimod doesn't work for me...it's basically a modification of the arena code, that divides all the people in the tavern into 2 teams and make them fight with certain equipment...

now, what i want, is that one of the dialog paths in a conversation between the player and a npc end up with the npc going hostile and trying to kill the player. this event would happen in a tavern or town center.what i want to know is how to set a trigger to make the npc go hostile at the end of the dialog and what else to add to make it work alright( like...in the case the player dies, and "remove troop from spot" too right? assuming the player kills the guy.he can't be there next time he enters the tavern)

Yoshiboy

  • Master baiter
  • Moderator
  • *
  • - Everything is a metaphor -
    • View Profile
    • My Website
  • Faction: Neutral
  • MP nick: irc://yoshiboy
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #56 on: November 02, 2006, 07:40:10 PM »
Its not possible to just turn a person hostile. You need to re-load the scene if you want a fight to break out.

Highlander

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: irc://Highlander
  • WB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #57 on: November 02, 2006, 07:42:47 PM »
" you lay were you fell as your enemies... " is not modular, it is saved in the data folder not modules. to end the game I would remove_party,"p_main_party" you can of course have a window string too
< AND DUDE I NEVER USE STUPID CAPS LOCK!

El Duke

  • Grandmaster Knight
  • *
  • One eyed king of the blind men wastelands
    • View Profile
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #58 on: November 02, 2006, 07:43:45 PM »
ok and how do i do that?would it work? what about the other people in the scene? will they be doing nothing(that's what i want?


and highlander,how can i do what you are sugesting?

Thus spake Nosferatu

  • Neighbor of the Beast
  • Grandmaster Knight
  • *
  • Et tu spiritu cool
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #59 on: November 02, 2006, 07:49:33 PM »
What does maw do?  I always sort of wondered that.  If you remove the main party, the game will crash, so I don't think that is a great way to handle things.
"One day," God said, "This is what I will do. I'll send down my son, I'll send him to you, to clear up all this jehovity hullabaloo. His name will be Christ and he'll never wear shoes. And his pals will all call him the King of the Jews!"