User:Hadr0: Difference between revisions

From WolfWiki
Jump to navigation Jump to search
Hadr0 (talk | contribs)
No edit summary
Hadr0 (talk | contribs)
No edit summary
Line 1: Line 1:
__NOTOC__
<table witdh=100% height=100>
<table witdh=100% height=100>
<tr>
<tr>
<td width=400 align=center valign=center>
<td>
http://www.dinotopia.com/hadro.jpg
http://static.shiven.net/hadro/hadro.jpg
</td>
</td>
<td width=100% align=left valign=center>
<td width=83% align=left valign=center>
== Profile ==
== Lua Scripts ==
* '''ET Server'''
=== [http://static.shiven.net/hadro/old-skbot.lua anti spawnkill bot] ===
** ''[http://www.shiven.net www.shiven.net]''
An old script which was once used to enforce [http://shiven.net shiven.net] spawnkilling rules. Its an example of how gameplay can be changed enormously with Lua. It is however trailored to the Fueldump map. Player positions are constantly checked against conditions. Coordinates for the no-spawnkilling boxes can be read in-game with \viewpos. But more complex 3D shapes may require decompiling the map's .bsp file (with [http://en.wikibooks.org/wiki/Q3Map2 Q3Map2]) and the [http://www.qeradiant.com/cgi-bin/trac.cgi GtkRadiant] map editor.
* '''E-mail'''
** ''adr7777@hotmail.com''
</td>
</td>
</tr>
</tr>
</table>
</table>


==Anti Spawn Kill Bot==
=== [http://static.shiven.net/hadro/inacmod.lua player inactivity modification] ===
In addition to g_inactivity and g_spectatorinactivity, this mod offers the ability to put a player to spectator after being AFK a certain time. It can be configured to only drop spectators when the server has reached a certain population limit. Players on private slots can be protected against the drop.


This bot enforces Shiven spawnkilling rules. It can detect a spawn switch and gives the withdrawing
=== [http://static.shiven.net/hadro/clcomf.lua client command filter] ===
team time to clear the area. It is meant as an illustration of Lua's power.
Primarily used to spam-protect and mute-enforce other Lua mod's et_ClientCommand() function. Optionally block some client commands like \readyteam and the broken \guids. It can put a forced delay between vote-casts per player. Match_mutespecs is made more clear and a muted player can be blocked from PMs and votes.


Players are punished by removing health. Allies can go through axis spawn in the first map part.. but only while holding a knife. Lua's function et_ClientCommand(cno, cmd) can not be triggered by "+attack" command. So making a no-fire zone was done this way.
=== [http://static.shiven.net/hadro/spammod.lua spam modification] ===
Inspired by the oh so addictive ETAdmin_mod !spam, this mod will read a simple file like [http://static.shiven.net/hadro/spammod.luadat spammod.luadat] and allow everyone to spam. It is recommended to load this mod after the client command filter. But don't take my word for it ;)


It currently only supports the Fuel Dump map. But adding more maps should not be hard.
=== [http://static.shiven.net/hadro/ifskrest.lua infight selfkill restrictor] ===
A useful tool for determining box/sphere coordinates is the Radiant map editor.
Inspired by McSteve's infight selfkill announcer, this one simply disables \kill for a period of time after taking damage. By default it will block for two seconds.
Decompile the maps .bsp first using q3map2.


skbot.lua code:
<pre><nowiki>
-----------------------------------------------------------------------------------------------------
-- Lua Guardian
-- Anti Spawn Kill Bot
-- created by Hadro
-- contact adr7777@hotmail.com
-----------------------------------------------------------------------------------------------------
-- many thanks to the regulars from 'shiven.net ** 24/7 action'
-- for putting up with my genocidal beta tests =)
-----------------------------------------------------------------------------------------------------
-- origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3]
-- checks if a player is in a box with lowest coordinates origin[1,2,3] and highest coordinates endpt[1,2,3]
--
-- (ppos[1] - origin[1])^2 + (ppos[2] - origin[2])^2 + (ppos[3] - origin[3])^2 < radius^2
-- checks if a player is in a sphere with center origin[1,2,3] and radius
-- spheres are not used for the fueldump map
-----------------------------------------------------------------------------------------------------
version    = "1.0"
samplerate = 500 -- bot will check player positions every x milliseconds
function et_RunFrame(levelTime)
  if math.mod(levelTime, samplerate) ~= 0 then return end
  if mapname ~= "fueldump" then return end
  for cno=0, num_cl-1, 1 do
    phealth = et.gentity_get(cno, "health")
    if phealth > 0 then
      msg = nil
      ppos = et.gentity_get(cno,"r.currentOrigin")
      teamnum = et.gentity_get(cno, "sess.sessionTeam")
      if teamnum == 1 then -- if you are Axis:
        if fdspawnswitch == nil then
          -- allied spawn hut
          origin = { -2864, -9376, 64 }
          endpt = { 496, -6192, 1152 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^)wiped out ^3for getting too close to allied spawn"
          end
        elseif spawnfullyswitched == 1 then -- if spawn as switched and delay has passed:
          -- balcony lookout
          origin = { -4968, -2066, 792 }
          endpt = { -4454, -808, 1024 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^)crushed ^3for entering allied spawn"
          end
          -- office & balcony over main door
          origin = { -5752, -3080, 488 }
          endpt = { -5192, -1568, 1024 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^)crushed ^3for entering allied spawn"
          end
          --lower office
          origin = { -5720, -2064, 344 }
          endpt = { -4848, -1272, 1024 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^)crushed ^3for entering allied spawn"
          end
        end
      end -- if axis
      if teamnum == 2 then -- if you are Allies:
        if fdspawnswitch == nil then
          -- dont trickjump over axis facade roof in first map part
          origin = { -9272, -5328, 608 }
          endpt = { -8576, -5028, 792 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^3Please don't do that LAME trickjump now, ^7%s"
          end
          -- knife only in axis spawn region
          if et.gentity_get(cno, "s.weapon") ~= 1 then
            -- balcony lookout
            origin = { -4968, -2066, 792 }
            endpt = { -4454, -808, 1024 }
            if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
              msg = "^7%s^3, you can ONLY pass through axis spawn holding a ^7KNIFE"
            end
            -- office & balcony over main door
            origin = { -5752, -3080, 488 }
            endpt = { -5192, -1568, 1024 }
            if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
              msg = "^7%s^3, you can ONLY pass through axis spawn holding a ^7KNIFE"
            end
            -- lower office
            origin = { -5720, -2064, 344 }
            endpt = { -4848, -1272, 1024 }
            if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
              msg = "^7%s^3, you can ONLY pass through axis spawn holding a ^7KNIFE"
            end
          end
        else -- if spawn switched
          -- axis facade
          origin = { -9424, -5600, 440 }
          endpt = { -8928, -5160, 600 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^5spanked ^3for entering axis upper spawn"
          end
          -- axis rear spawn exit
          origin = { -9240, -7448, 208 }
          endpt = { -8728, -7184, 352 }
          if origin[1] < ppos[1] and ppos[1] < endpt[1] and origin[2] < ppos[2] and ppos[2] < endpt[2] and origin[3] < ppos[3] and ppos[3] < endpt[3] then
            msg = "^7%s ^3was ^)annihilated ^3for entering axis rear spawn"
          end
        end
      end -- if allies
      if msg ~= nil then
        et.gentity_set(cno, "health", -511)
        msg = string.format(msg, et.Info_ValueForKey(et.trap_GetUserinfo(cno), "name"))
        msg = string.format("qsay %s\n", msg)
        et.trap_SendConsoleCommand(et.EXEC_APPEND, msg)
        et.trap_SendServerCommand(cno, "cp \"^1!! DO NOT SPAWNKILL !!\"\n" )
      end
    end -- if health > 0
  end -- for loop
  if fdspawnswitch == 1 and spawnfullyswitched == nil then
    if switchcounter == switchtime then
      spawnfullyswitched = 1
    else
      if switchcounter == 0 then
        et.trap_SendServerCommand(-1, "cpm \"^6Lua^7: allied spawn will be protected in 45 seconds\"\n")
      end
      if switchcounter == switchtime - 1 then
        et.trap_SendServerCommand(-1, "cpm \"^6Lua^7: allied spawn is now protected\"\n")
      end
      switchcounter = switchcounter + 1
    end
  end
end
function et_InitGame(levelTime, randomSeed, restart)
  num_cl = et.trap_Cvar_Get("sv_maxclients")
  mapname = et.trap_Cvar_Get("mapname")
  origin = {}
  endpt = {}
  switchcounter = 0
  switchtime = 45 / samplerate * 1000 -- 45 seconds to spawn protection switch
end
function et_ClientCommand(cno, cmd)
  if cmd ~= "say" then return 0 end
  if string.lower(et.ConcatArgs(1)) ~= "!luatest" then return 0 end
  et.trap_SendConsoleCommand(et.EXEC_APPEND, "qsay \"^3test for ^6Lua ^7Guardian - Anti Spawn Kill Bot\"\n")
  if mapname == "fueldump" then
    tosend = string.format("qsay \"^3>version ^7%s ^3sampling at ^7%d ^3milliseconds\"\n", version, samplerate)
    et.trap_SendConsoleCommand(et.EXEC_APPEND, tosend)
  else
    tosend = string.format("qsay \"^3>version ^7%s ^3no parameters set for ^7%s ^3map\"\n", version, mapname)
    et.trap_SendConsoleCommand(et.EXEC_APPEND, tosend)
  end
  return 0
end
function et_Print(text)
  if text == "Setting Axis autospawn to Axis Fuel Dump\n" then fdspawnswitch = 1 end
end
</nowiki></pre>
Note that shiven.net uses a slightly different type of anti spawnkill bot. One that uses 'invincibility zones' for more info see our [http://www.shiven.net/rules.html server rules]. The essence however is still the same.<br>
Not much time was spent programming this so feel free to do with it what you please.


----
----


[[Category:ETPro:Mods]]
[[Category:ETPro:Mods]]

Revision as of 00:46, 20 August 2007

http://static.shiven.net/hadro/hadro.jpg

Lua Scripts

anti spawnkill bot

An old script which was once used to enforce shiven.net spawnkilling rules. Its an example of how gameplay can be changed enormously with Lua. It is however trailored to the Fueldump map. Player positions are constantly checked against conditions. Coordinates for the no-spawnkilling boxes can be read in-game with \viewpos. But more complex 3D shapes may require decompiling the map's .bsp file (with Q3Map2) and the GtkRadiant map editor.

player inactivity modification

In addition to g_inactivity and g_spectatorinactivity, this mod offers the ability to put a player to spectator after being AFK a certain time. It can be configured to only drop spectators when the server has reached a certain population limit. Players on private slots can be protected against the drop.

client command filter

Primarily used to spam-protect and mute-enforce other Lua mod's et_ClientCommand() function. Optionally block some client commands like \readyteam and the broken \guids. It can put a forced delay between vote-casts per player. Match_mutespecs is made more clear and a muted player can be blocked from PMs and votes.

spam modification

Inspired by the oh so addictive ETAdmin_mod !spam, this mod will read a simple file like spammod.luadat and allow everyone to spam. It is recommended to load this mod after the client command filter. But don't take my word for it ;)

infight selfkill restrictor

Inspired by McSteve's infight selfkill announcer, this one simply disables \kill for a period of time after taking damage. By default it will block for two seconds.