New server feature - Event command scripts

Forum Archive - from http://theuniversal.net
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

New server feature - Event command scripts

Post by Mit »

Hia.. Heres a nice new toy that should become quite a powerful tool for serious world owners. In the 0.50.6 servers you'll be able to add a file called Data/ServerGameScript.mts - a text file like the 'GameScript.mts' that can contain commands and 'events'. heres an example of one..

Code: Select all

Event( "NewBuilding", "3" )
{
*command=say %PLAYER% built building 3
*command=grantcash %PLAYER% 400
}
Event( "UseItem", "KudosItem1" )
{
*command=say %PLAYER% used the kudos item
*command=grantkudos %PLAYER% 1
*command=resetpos %PLAYER%
}
This file defines 2 events. In the example above, whenever a player ('Mit' for instance) builds building type 3, the commands within { } braces are executed.
i.e.
*say Mit built building 3
*grantcash Mit 400

would be entered - the say message will appear in red for all players and 'Mit' will get an extra 40s. Similar procedure for the other event should someone use the kudos item.
Hopefully should be fairly straightforward to get..

With all the different * commands available i reckon it could allow some useful effects and novel gameplay features.

More event types (other than just 'UseItem' and 'NewBuilding' ) can/will be added.. feel free to pop ideas/requests/questions on this thread as im sure you'll be able to think of some interesting possibilities.
Longer term i'll also look at adding some conditional operations (so bits of script can only be run when certain other conditions have been met) and some persistent variable storage (so for instance, you can have a flag to indicate whether the player has already achieved a particular award).
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

:) been waiting for this

Code: Select all

Event( "MonthDate", "1" )
{
*command=whatever
}

Event( "Gamedate", "December 25" )
{
*command=say MERRY CHRISTMAS
}
the first would run said command every gamemonth on that set date

the 2nd one is obvious
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

thats freakin awesome!

useing the item/command type thing, it should be possible to get all those extra things to work. like the resetpos item, flogging stick, etc. plus could easily rename other things for other commands. not to mention it vastly increases the options for items on a world for food, materials, etc :)

but...hmm...when 'used' will the item diseapear?
or will that still depend on the items design?
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

i image it would work like a kudos item does as it is anyway.. whether not the system uses it and anything is gaind, if its used, its gone.
would using a food type item trigger such an event, is what id like to know.

some example script ideas:

Code: Select all

Event("killcount","25")
{
*comamnd=grantkudos %player% 1
}    (executes when player makes x kills)

Event ("deathcount","25")
{
*command=grantkudos %player% -1
}   (opposit of previous)

Event ("playerkill")  
{
*command=grantcash %player% 50
*command=grantkudos %player% 1
}  (executes when %player% kills another player)

Event ("playerdeath")
{
*command=grantcash %player% -50
*command=grantkudos %player% -1
}       (executes when %player% dies)

Event ("buildingdestroy","15")
*command=grantkudos %player% 1
} (when %player% destroyes building 15, executes script.   a 0 would apply to 'any building')

Event ("buildingdecay","15")
{
*command= say %player% has let his %buildingname% go to waste!
}  (executes when %player% building has decayed to destruction, %buildingdesc% would be building description as in bdat(or possibly on planet use %buildingname%))  use "0" for any building.

Event ("startcapture","74")
{
*command=say WAKE UP, TEAM 213!  %Player% HAS STARTED TO CAPTURE YOUR NUKE LAB!
} (executed on capture start, 74 being the building number in bdat.    use 0 for 'any building to exectue script'  %buildingname% or %buildingdesc% could also pull the bdat 'description' (or name of the building on planet)

Event ("buildingcapture","74")
{
*command=say Well what are you going to do now? %player% now has your nuke building! 
*command=Grantcash %player% 50000
*command=grantitem %player% 1 beer
} (executed on capture successfull, 74 being the building number in bdat.    use 0 for 'any building to exectue script' again, %buildingname% or %buildingdesc% for more generic messages)
 
Event ("buildingpurchase","30")
{
*command=say %Player% has purchased the Startersville Plinth
*command=*knight %player%
} (same building scenarios as above)
is there any way to get a command to grant all players that are members of a certain
team cash and items and such?

and a command to demolish any of a certain building # (Bdat building #) currently standing

umm a little thought and i could kick up some more.

*edit* cleaned up with a code box, and used examples as examples on if i were to use them on my planet.
Last edited by morbydvisns on Tue Apr 03, 2007 3:36 am, edited 1 time in total.
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

Code: Select all

Event( "Listen", "test" ) 
{ 
*command=say Hello there, %player%.
} 
That would be really useful, as you could have customized commands using scripts.
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

that could work for making a new player help file script.
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

Code: Select all

Event( "Buildingclick", 2) //Click Tractor Factory
{
*command=setvehicle %player% 2 //set to Tractor
}
This would be especially useful for making NPCs (click them, and they say something).
To do that, this would be useful as well:

Code: Select all

*msg VDZ 1 Hello, I'm an NPC.
This would display the text "Hello, I'm an NPC." for VDZ only, in the color assigned to #1.
It would be useful if *say would have multiple colors, too.
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

Code: Select all

*Textbox VDZ test.txt
This would make a small window pop up on VDZ's client, with the contents of test.txt.
This could be useful for several things, such as:

Code: Select all

Event( "Listen", "help me" )
{
*command=textbox %player% newbie.txt //Send newbie help
}
User avatar
Magicfinger
Staff
Staff
Posts: 1078
Joined: Tue Sep 30, 2003 10:38 am
Location: here,there and everywhere

Post by Magicfinger »

zaroba wrote: but...hmm...when 'used' will the item diseapear?
or will that still depend on the items design?

Code: Select all

Event( "UseItem", "KudosItem1" )
{
*command=say %PLAYER% used the kudos item
*command=grantkudos %PLAYER% 1
*command=grantitem %PLAYER% -1 KudosItem1
*command=resetpos %PLAYER%
}
wouldn't that do what you wanted?
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

as bongz correctly surmised.. the useitem event will be called when the player manually selects to use one of those items that work that way.. e.g. kudos items and anything else not food, a vehicle or a weapon. the items do get automatically removed in that case, so the script above would remove 2 items everytime u used one. not what's wanted probably, but still a valid script to use, aye..

lotsa nice script command suggestions.. particularly useful when they're in those little code boxes which provides a nice example use. :] will try to get some of em done before the new server goes up..
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Code: Select all

Event("itemcount", "Hemp Seeds,50,","OncePerLife" )
{
*command=grantskill %player% Colony Research
} 

Event("itemcount","Hemp Amulet,25","Holy Orb,3","OncePerLife")
{
*comamnd=grantitem %player% 1 Bongo's Blessing
}


itemcount event would requre an item, and amnt definer. This applies to item count in player inventory at that time. OncePerLife is an example of a needed way for this event to only happen once per players lifetime. (until a wipe / reset / whatever, regard;ess of 'lives' defined in *settings. This would both keep multiple grantskills that may remove a skill not intending to. also for abusers that may buidl a certain bldg or trigger over n over for cash and other prizes that my be only really meant for a one time thing.

the second demonstrates the ability to add multiple item requirements to in inventory to trigger the event.

i could cut out a few buildings with this XD
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

Code: Select all

Event "*QuaryProperties" %item%
*msg %player% %item properties% (weight, max capacity if set, item type, hunger/thirst amount, etc)

Event "*QuaryScript" %item%
*msg %player% %Item Properties% (show any script effects associated with the item)
both of the above could be used in conjunction with a highlighted item to show the properties or script effect of the item.

of course, actual commands could be added for those, but, similer things could be used to 'make' new shortcut commands to do things.

like:

Code: Select all

Event= "*2"
Command="*setvehicle %player% vehicle 2"

Event= "*worldreset"
AuthReq="24"
Command="*Killbillall"
Command="*resetmap"
FileDelete="data/families.dat"
FileDelete="data/banking.dat"
FileDelete="data/towns/*.*"
FileDelete="data/mail/*.*"
the ability to link a script action with an auth level would be nice aswell.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

i like the listen events above.. and the requirements to execute would be a nice control.... along with an authreq, might as well throw a few more possibilities in....

Code: Select all

Event("listen","Ask For Blessing")
{
SkillReq="Colony Advancement"
ItemReq="Hemp Amulet,25","Holy Orb,3"  (((MUST BE IN INVENTORY)))
VehicleReq="7"              (((MUST BE IN VEH. 7)))
*command=%Player% has obtained 1 Bongo's Blessing (Kudo)
*command=Grantkudo %Player% 1
}

---other requirement strings of use---
MinKudos=
MaxKudos=
MaxKills=
MinKills=
MaxDeaths=
MinDeaths=
MinCash=
MaxCash=
VehicleReq=
TeamReq=

if an attempt to execute an event is made but a requirement isnt met a generic 'you do not have proper skill, items, not in proper vehicle, etc etc displayed on client end.

of course then theres the route of bringing if/thens into the equasion :wink:
User avatar
VDZ
Posts: 1205
Joined: Wed Apr 07, 2004 11:32 am
Location: Netherlands

Post by VDZ »

Yes, we would need conditional events for that.

Code: Select all

Event("listen","Ask For Blessing")
{
if (SkillPossessed("Colony Advancement") && ItemCount("Hemp Amulet") > 25 && ItemCount("Holy Orb") > 3 && CurrentVehicle=7)
 {
 *command=say %Player% has obtained 1 Bongo's Blessing (Kudo)
 *command=Grantkudo %Player% 1
 }
}
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

lil extra update :
i've added the command..

Code: Select all

*msg <NAME> <TEXT>
and the event..

Code: Select all

Event ("buildingpurchase","30") 
{ 
...
}
as they'll be particularly useful (and were easy to add :])

Also.. on checking the inventory code i realised that currently the only items that you can actually 'use' are the Kudos Items, End Sequence Items and the demolition kit.. which isnt much use. Soo, rather than making all items 'usable' (which would have bandwidth implications for the general items that, currently, arent expected to be used that way), i've added 32 new 'Usable' items. These can be traded and sold as normal, but have the additional 'Use Item' option when selected from the inventory. (The selection screen for which has also been fixed up).
In addition, if you're not using hunger and thirst (i.e. *settings -> Life -> Hunger and thirst = 0 ) then any food or drink items also have the 'use item' option.
User avatar
Magicfinger
Staff
Staff
Posts: 1078
Joined: Tue Sep 30, 2003 10:38 am
Location: here,there and everywhere

Post by Magicfinger »

thought we would celebrate with a new style code block :)
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

oooh eek nooo! :] can i have the old one back please? :]
User avatar
zaroba
World Owner
World Owner
Posts: 7257
Joined: Fri Oct 10, 2003 11:06 pm
Location: Hereford, PA
Contact:

Post by zaroba »

what about an event that will say a message to a player when they login?
that could be useful for many things. like world news/notices, help info, world info, etc.
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

mit, on those 'usable items' youve added... can those be made to where a script can require certain amnts of those on hand, if the others arent?
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

not yet..
Longer term i'll also look at adding some conditional operations
;] Dont expect that sorta stuff for a month or three..
Locked