PoLlama Forums  

Go Back   PoLlama Forums > WarCraft > Resources > Spells and Systems

Reply
 
LinkBack Thread Tools Rate Thread
Old 06-10-2007   #1
 
MrApples's Avatar
 
Join Date: Sep 2006
Location: Your Mom
Posts: 2,241
MrApples has a spectacular aura about
[System] String Compare System 0.2

  • Version: 0.2
    Date: 6/11/07
    Credit goes to MrApples and PoLlama.com(if you would be so kind).
Code:
Version Change Log - String Compare System

0.2
-Changed real variable from global to local.
-Took out test messages.
-Added case-converter.
-Fixed a critical bug that had been undone in a crash prior to release.
-Uploaded test map.
-Changed name to "String Compare System"
-Optimized some.
-Adjusted large string balance.

0.1
Initial Release
  • What it Does?
    This function, or action, takes 2 strings, and returns a percentage of how similar they are. If you were to put in MrApples, and Mr.Apples, it would return something high.

    What its intended for?
    Any map which uses chat event triggers, such as allying. This way, a person could misspell someones name, and the trigger will still work, a real crowd impresser!

    This however does not work perfectly, to do that we would have to leak a lot of strings. It still however, works well.

    INSTALLATION
    Copy the below code into the "Custom Script" section of your map. You may find it by selecting the very first item on the trigger list.
Code:
function CompareStrings takes string xs, string xs2 returns real
  local integer xi = 0
  local integer xi2 = 0
  local integer xi3 = 0
  local integer xi4 = 0
  local integer xi5 = 0
  local integer a = 0
  local integer b = 0
  local real xr = 0
  set xs = StringCase( xs, false)
  set xs2 = StringCase( xs2, false)
  if ( StringLength(xs) <= StringLength(xs2) ) then
    set xi5 = StringLength(xs)
  else
    set xi5 = StringLength(xs2)
  endif
  set xi = ( ( xi5 / 6 ) + 0 )
  if ( xi == 0 ) then
    set xi = 1
  else
  endif
  if ( xi == 1 ) then
  else
    if ( xi == 2 ) then
      set xs = ( "xxx" + ( xs + "xxx" ) )
      set xs2 = ( "xxx" + ( xs2 + "xxx" ) )
    else
      if ( xi == 3 ) then
        set xs = ( "xxxxx" + ( xs + "xxxx" ) )
        set xs2 = ( "xxxxx" + ( xs2 + "xxxx" ) )
      else
        if ( xi == 4 ) then
          set xs = ( "xxxxxx" + ( xs + "xxxxxx" ) )
          set xs2 = ( "xxxxxx" + ( xs2 + "xxxxxx" ) )
        else
          if ( xi == 5 ) then
            set xs = ( "xxxxxxxx" + ( xs + "xxxxxxx" ) )
            set xs2 = ( "xxxxxxxx" + ( xs2 + "xxxxxxx" ) )
          else
            if ( xi == 6 ) then
              set xs = ( "xxxxxxxxx" + ( xs + "xxxxxxxxx" ) )
              set xs2 = ( "xxxxxxxxx" + ( xs2 + "xxxxxxxxx" ) )
            else
              set xs = ( "xxxxxxxxxxx" + ( xs + "xxxxxxxxxxx" ) )
              set xs2 = ( "xxxxxxxxxxx" + ( xs2 + "xxxxxxxxxxx" ) )
            endif
          endif
        endif
      endif
    endif
  endif
  set xi5 = ( xi5 + ( ( xi - 1 ) * 2 ) )
  set xi4 = ( ( xi5 - xi ) + 1 )
  set a = 1
  loop
    exitwhen a > xi4
    set b = 1
    loop
      exitwhen b > xi4
      if ( SubStringBJ(xs, a, ( a + ( xi ) )) == SubStringBJ(xs2, b, ( b + ( xi ) )) ) then
        set xi2 = ( xi2 + 1 )
        exitwhen true
      else
      endif
      set b = b + 1
    endloop
    set xi3 = ( xi3 + 1 )
    set a = a + 1
  endloop
  set xr = ( ( I2R(xi2) / I2R(xi3) ) * 100.00 )
  return xr
endfunction

USE
For JASS users.
Code:
set RealVariable = CompareStrings( "bob", "frank")
For GUI users.

Code:
Use of Compare Strings
  Events
    Player - Player 1 (Red) types a chat message containing -compare as An exact match
  Conditions
  Actions
    Set StringVariable = bob
    Set AnotherStringVariable = frank
    Custom script:  set udg_RealVariable = CompareStrings( udg_StringVariable, udg_AnotherStringVariable)
    Game - Display to (All players) for 30.00 seconds the text: (Bob and Frank match up + ((String(RealVariable)) + %))
IN ACTION
"Tonight I go downtown." and "Today I go downtown."
Compared = 63.64%

"Mr.Apples" and "MrApples"
Compared = 75%

"You all totally rock" and "You all completely suck"
Compared = 45.455%

"WarCraft" and "StarCraft"
Compared = 75%

"Dick Cheney" and "Anti-Christ"
Compared = 9.09%

"Apple" and "Orange", "Cow" and "Duck"
Compared = 0%

For Support
Reply here. Suggestions, bug, etc.
Attached Files
File Type: w3x Compare Strings System 0.2.w3x (14.2 KB, 21 views)
MrApples is offline   Reply With Quote
Old 06-10-2007   #2
 
MrOrange's Avatar
 
Join Date: Dec 2006
Posts: 2,948
MrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond repute
Re: [Function] String Comparison

MrApples, when did you start to get so advanced with systems? But yes it is a real crown impresser. Unfortunately I have this thing about using things that I don't know how they work. I know it sounds dumb but it's the only way to actually make me learn something.
MrOrange is offline   Reply With Quote
Old 06-11-2007   #3
 
MrApples's Avatar
 
Join Date: Sep 2006
Location: Your Mom
Posts: 2,241
MrApples has a spectacular aura about
Re: [Function] String Comparison

All my recent works have been close or more complex to this. Their just not done yet.

Ultimate Footmen, Risk Engine, Diplomacy System v2, Xplode Generator, PoLlama Pack, Battle XP System, Apple's Save/Load. All planned upcoming releases.

Why don't you go by the 'Someone else already did it, so why waste my time rule' instead . Its really not that complex though.
MrApples is offline   Reply With Quote
Old 06-11-2007   #4
 
MrOrange's Avatar
 
Join Date: Dec 2006
Posts: 2,948
MrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond reputeMrOrange has a reputation beyond repute
Re: [Function] String Comparison

Oh trust me. When I see something that I don't understand, I can research and try to learn it. Mapping, like my real life, I have no idea what I want to do in it. I don't know if I want to be a trigger, object manager, skinner, terrainer, modeler, ect.

But anyway. To get a better understanding. It would compare and tell you the percentage, so that even if you were to spell a person's name wrong. But if it's close it would still work?
MrOrange is offline   Reply With Quote
Old 06-11-2007   #5
 
MrApples's Avatar
 
Join Date: Sep 2006
Location: Your Mom
Posts: 2,241
MrApples has a spectacular aura about
Re: [System] String Compare System 0.2

0.1 Wasn't working right, as it crashed last night and I rushed to upload it :roll:.

However, I just uploaded 0.2, which should work great. Even has a demo map.
MrApples is offline   Reply With Quote
Old 06-13-2007   #6
 
King_Leopold's Avatar
 
Join Date: Apr 2007
Posts: 2,434
King_Leopold is a jewel in the roughKing_Leopold is a jewel in the roughKing_Leopold is a jewel in the rough
Re: [System] String Compare System 0.2

Wtf is an Xplode generator? does it blow things up? lol

Go to this link, now. [Only registered and activated users can see links. ]
King_Leopold is offline   Reply With Quote
Old 06-13-2007   #7
 
MrApples's Avatar
 
Join Date: Sep 2006
Location: Your Mom
Posts: 2,241
MrApples has a spectacular aura about
Re: [System] String Compare System 0.2

Yeah

Its a system that generates explosions, like a little physics engine. For example, CreateExplosiononLoc( loc, power, height, special). Power is how strong, height controls the angle affected are thrown in, and special covers stuff like burning, debris, nuclear. Its like Pre-Alpha at the moment, i'm busy with other stuff.
MrApples is offline   Reply With Quote
Reply

Tags
None

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may post replies
You may post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[System] Item Stacking System Mr. Zero Spells and Systems 1 12-01-2007 05:28 PM
[System] Leaver & Kick System CaptainSnake Recycling Bin 6 05-14-2007 07:07 PM


All times are GMT -5. The time now is 11:26 AM.

A friend of Wc3Happy
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165