Centre of the Universe - Dynamic script
PostPosted: 26 Apr 2014, 20:14
Dear all,
I have contacted multiple players with TS and the forum (Lewin, Sado, Skypper) for help with with a script.
On the moment the reward system and the notification for a reward is working. A message of a reward is displayed for 10 seconds and a hardcoded text is shown.
This is done with the following code, which is mostly was written by Lewin.
However the past days I have tried to shown the reward list when a player clicks on the repair tool of the storehouse. And this was not succesfull.
Does someone have any idea how to use the repair tool for the reward list. The following code was used (with the previous), but did not work:
Also I would like to change hardcoded text (so also the reward list) to .libx files for translations and flexiblity.
This could always makes it possible to enhance to information of the demolishment to for example:
"You found 5 stone in the quarry of Zaamoot" instead of "You found 5 stone in the quarry".
Do you guys have an idea and do you want to help me to better understand scripting for the map.
The full topic can found here: http://knightsandmerchants.net/forum/vi ... f=5&t=1986
Greetings,
Zaamoot
I have contacted multiple players with TS and the forum (Lewin, Sado, Skypper) for help with with a script.
On the moment the reward system and the notification for a reward is working. A message of a reward is displayed for 10 seconds and a hardcoded text is shown.
This is done with the following code, which is mostly was written by Lewin.
- Code:
type TNotification = record Active: Boolean; EventTime: Integer; Player: Integer; Msg: AnsiString; end; var Notifications: array[1..9] of TNotification; const LOC_COUNT = 8; //Total number of locations on this map procedure DeleteOldNotifications; var I: Integer; begin for I:=1 to 9 do if States.GameTime - Notifications[I].EventTime > 100 then begin Notifications[I].Active := False; end; end; procedure AddNotification(aPlayer: Integer; aMsg: AnsiString); var I: Integer; begin //Add it in the first unused slot for I:=1 to 9 do if not Notifications[I].Active then begin Notifications[I].Active := True; Notifications[I].EventTime := States.GameTime; Notifications[I].Player := aPlayer; Notifications[I].Msg := aMsg; Exit; //Only add it once end; end; procedure DisplayNotification; var I: Integer; begin Actions.OverlayTextSet(-1, '') for I:=1 to 9 do if Notifications[I].Active then Actions.OverlayTextAppendFormatted(Notifications[I].Player, Notifications[I].Msg + '|', []) end; procedure OnTick; begin DeleteOldNotifications; DisplayNotification; end; procedure OnHouseDestroyed(aHouseID: integer; aDestroyerIndex: integer); var owner: integer; I: Integer; begin if (aDestroyerIndex < 0) OR (aDestroyerIndex >= LOC_COUNT) then EXIT; if NOT States.HouseIsComplete(aHouseID) then EXIT; owner := States.HouseOwner(aHouseID); if (owner < 0) OR (owner >= LOC_COUNT) then EXIT; // Building Wares // Demolishing Quarry if (States.HouseType(aHouseID) = 14) AND (aDestroyerIndex <> owner) then Actions.GiveWares(aDestroyerIndex, 1, 5); // 5 stones if (States.HouseType(aHouseID) = 14) AND (aDestroyerIndex <> owner) then AddNotification(aDestroyerIndex, 'You have found 5 stones in the quarry'); // Demolishing Woodcutter if (States.HouseType(aHouseID) = 9) AND (aDestroyerIndex <> owner) then Actions.GiveWares(aDestroyerIndex, 0, 2); // 2 tree trunks if (States.HouseType(aHouseID) = 9) AND (aDestroyerIndex <> owner) then AddNotification(aDestroyerIndex, 'You have found 2 tree trunks in the woodcutter'); end;
Does someone have any idea how to use the repair tool for the reward list. The following code was used (with the previous), but did not work:
- Code:
procedure Showrewards(P: Integer); var aHouseID: Integer; houses: array of Integer; I: Integer; begin houses := States.PlayerGetAllHouses(P); for I:=0 to length(houses) do if (States.HouseType(aHouseID) = 11) AND (States.HouseRepair(aHouseID)) then begin Actions.OverlayTextAppend(0, 'test') end; end; procedure OnTick; var I: Integer; begin DeleteOldNotifications; DisplayNotification; Showrewards; end;
This could always makes it possible to enhance to information of the demolishment to for example:
"You found 5 stone in the quarry of Zaamoot" instead of "You found 5 stone in the quarry".
Do you guys have an idea and do you want to help me to better understand scripting for the map.
The full topic can found here: http://knightsandmerchants.net/forum/vi ... f=5&t=1986
Greetings,
Zaamoot