Archive
Blog - posts for June 2020
Terraria Mods, technical explorations 02
Existing big mods:
- Throrium
- Calamity
- Quite a few famous ones: https://terraria.gamepedia.com/Mods
Seems right now my intention to pay tribute to other games isn't clashing with other famous mods.
Also seems prominent mods aren't open source as I would understand they want to have some control and not having copy all over the place.
https://github.com/tModLoader/tModLoader/wiki/Advanced-Vanilla-Code-Adaption For vanilla override, need to do this.
Softether on OpenWRT Trick
Reason that softether on OpenWRT lose settings on reboot is because it only saves config after stopping the service, so need to tunnel in and stop the service then reboot after reconfigure
Remember to set Virtual NAT+DHCP, or else windows client autodrop.
Update: The NAT+DHCP doesn't have to be on softether, create a tap device and use the host as NAT+DHCP is possible. Setting isolation mode in Softether will block host from forwarding packets.
Meaning:
- Reverst VPN is possible
- Have one server connect in and DSTNAT is possible
- Static DHCP through OpenWRT also possible which is good as SoftEther's DHCP can't do static, which is bad for servers
- IPv4 Address. . . . . . . . . . . : 192.168.X.X
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 0.0.0.0
Seems to be bacause how windows implemented, the DHCP server still performs normally ( has 255.255.x.x and a proper gateway )
Weird behaviour:
- Having Router(Mikrotik) connect to the Softether and device connected to the Router also connect to Softether
- The session list in softether seems OK
- However, the tap device will confuse one of the device under the router with router itself, so DHCP will have some problem (how to solve?)
- Workaround will be using a machine under the router to connect to the Softether to reverse VPN
Additional setup:
- As routerOS still doesn't support advanced encryption of handshaking on SSTP, will open legacy L2TP just for routers.
Prepare For IPv6
As the device number grow, the infrastructure will eventually transition to IPv6, so it's good to prepare server to IPv6.
- First step is actually to add IPv6 to DNS server
- Iptable and rule needs to change for host VPS
- Set the NGINX to be compatible with IPv6
- Every docker container does have a IPv6 address, however there it might not just work
Note for POLYUCS Edison Traffic Light
- Download package:
- Makes use of FreeWiFi via POLYU (with a workaround)
- Makes use of mqtt.eclipse.org
- Announce topic: POLYUCS/esp8266/shared/pub (will have start msg and ping msg)
- Config topic: POLYUCS/esp8266/devices/ESP8266Client-bcddc22df583/pub
- If switch device should then be : POLYUCS/esp8266/devices/<device-id>/pub
- Worked on top of Clifford Choy's implementation
- Commands and example:
- Set sequence timer, in ms, d[green, greenblink, yellow, red]:
{
"c": "setTime",
"d": [5000,5000,5000,5000]
} - Set blink on off time, in ms, d[ontime, offtime]:
{
"c": "setBlink",
"d": [500,200]
} - Set brightness, d:0..255
{
"c": "setBrt",
"d": 128
} - Reboot, d:<a number hardcoded>
{
"c": "reboot",
"d": 1234
}
- Set sequence timer, in ms, d[green, greenblink, yellow, red]:
- To change Defaults (Starting from Line405):
int brt = 255;
const unsigned long max_seq_time[] = {120000, 60000, 60000, 120000}; // for now not allowing more than 2 minutes
unsigned long seq_time[] = {20000, 5000, 4000, 25000}; // default green, blink, yellow, red
unsigned long blink_time[] = {400, 200}; - MQTTBox settings:
Terraria Mods, technical explorations 01
- The tModLoader ships with Terraria, so it means now it updates automatically with steam
- Need to look out for API changes
- TModLoader all classes
- Useful vanilla fields
- I don't get why the document isn't with TModLoader APIs (even appendix)
- Vanilla sound IDs
- Examplemod somehow has an Error in ExampleCritter.cs, so had to download the source and recompile, rightnow muted the autoupdate override of the item, however still can't findout where the out of index comes from, error message stack trace:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at ExampleMod.NPCs.ExampleCritterNPC.HookStatue(ILContext il) in ExampleMod\NPCs\ExampleCritter.cs:line 0
at MonoMod.Cil.ILContext.Invoke(Manipulator manip)
at MonoMod.RuntimeDetour.ILHook.Context.InvokeManipulator(MethodDefinition def, Manipulator cb)
at MonoMod.RuntimeDetour.ILHook.Context.Refresh()
at MonoMod.RuntimeDetour.ILHook.Apply()
at MonoMod.RuntimeDetour.ILHook..ctor(MethodBase from, Manipulator manipulator, ILHookConfig& config)
at MonoMod.RuntimeDetour.HookGen.HookEndpoint._NewILHook(MethodBase from, Manipulator to)
at MonoMod.RuntimeDetour.HookGen.HookEndpoint._Add[TDelegate](Func`3 gen, TDelegate hookDelegate)
at MonoMod.RuntimeDetour.HookGen.HookEndpoint.Modify(Delegate hookDelegate)
at MonoMod.RuntimeDetour.HookGen.HookEndpointManager.Modify(MethodBase method, Delegate callback)
at IL.Terraria.Wiring.add_HitWireSingle(Manipulator )
at ExampleMod.NPCs.ExampleCritterNPC.Autoload(String& name) in ExampleMod\NPCs\ExampleCritter.cs:line 19
at Terraria.ModLoader.Mod.AutoloadNPC(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModContent.<>c.<Load>b__38_0(Mod mod)
at Terraria.ModLoader.ModContent.LoadModContent(CancellationToken token, Action`1 loadAction)
at Terraria.ModLoader.ModContent.Load(CancellationToken token)
at Terraria.ModLoader.ModLoader.Load(CancellationToken token) - Seems no one else raises the issue on the issue page?
- Need to pay follow the updates
- Study on the example item:
- The item sound seems inconsistant between when classify as weapon and when classify as connsumable(like potion), same sound id gives different sound, but managable, just need trial and error
- Item will not be able to be consumed unless overriding UseItem and return true:public override bool UseItem(Player player){
return true;
}- Also , can have UseItem(Item item, Player player)
- Player according to the vanilla field can not set currentHP, so there's probably no way to directly self-inflict damage
- However, it might be possible to spawn an enemy projectile that does the damage and change world state
- Did not find any world state extention method, but seems possible as vanilla has world fields, need to find how to extend them
- Study on ExampleMod:
- Chasing projectile possible, look at the wisp example.
- Custom properties with mount might be possible
- The example mount car has 3 balloons that can be damaged when player take damage, also in comment, syncing modplayer can even have functional use
- Same reason, the mounted mg like metal-slug style might be achievable
- Tilting with terrain seems not possible, it loads static spritesheet from <mount>_Back.png and <mount>_Front.png
Android Manifest Versioning
- Version code is always interger
- So it should be a good practice if start with 100 for having subversions
- General rule, larger number the recent
- The version to show is the "name" field of the version
- Rolling out new release still takes a week for google play to review
- Correction: update takes less time than new review, the 1.01 took around 1 day
Terraria Mods, thoughts
- Making mod is a good way of learning how to collaborate alone
- The mod loader usually needs to follow a pattern in order to "hook" the apis from the original game, so although working alone, it's kind of like working with other people.
- Usually it follows a design pattern
- Good opportunity to learn how to work from existing framework
- Now with 1.4, tModLoader become official, which lead me to believe the community will be more active, so it's easier to seek advice/help from the community.
- Gaps identified
- As it's a small hobby project, I do not want to scope to get too large.
- There's large mods with every element of the game play even transforming game play, however I'm going to make the first attempt simple.
- The one thing seems to be lacking in the current mod is weaponized mounts
- It's possible that it's not doable that's why no-one is making it
- However, there's sign the system supports that, as there's mining vehicles in vanilla and mod that has overriden the "fire/use" button for mining. Also in vanilla and mods there are auto-targeting weapons.
- Reference from other game:
- Preliminary plans:
- First step of this one is actually not design but technical exploration
- It could be that it can not be done, as if it can I'm positive someone will have attempted to make it
Adversarial Attack on Human Vision
- Shame on me wasting time on youtube again, it's me browsing through random videos and saw this
- The human vision very much could be hacked like AI
- However the given example, my hunch is that the picture is altered more than the computer AI Adversarial Attack example ( could totally be wrong about it, as I did not do objective verifiable calculation )
- Based on my preception the picture (again totaly could be wrong), the noise they use changed several contour feature of the "cat" original picture, but that's only one example, probably will need to see the dataset compared to AI test.
- Original paper is here: Adversarial Examples that Fool both Computer Vision and Time-Limited Humans
- So the main takeaway of the study was not to fool human, it's the indication from time-limited human vs no time-limit human(robust) to infer there's potential for AI to be more robust.
- Previous example for AI to be known vulnerable to adversarial attack is cited by Ref 13 also on same web site: EXPLAINING AND HARNESSING ADVERSARIAL EXAMPLES , "A demonstration of fast adversarial example generation applied to GoogLeNet (Szegedy et al., 2014a) on ImageNet", which shows the attack on panda image being wrongly recognized gibbon. However, I would argue this is only possible when they have control to finely rewrite input cache as 255*0.007 = 1.7 85, I doubt such grain could be picked up by real camera and even if so, would easily drown by noise of the sensor that even it accidently formed severl frames out of hundreds, in real application, the system could use statitstical method to make output more robust (Also I could be wrong), or the subtlety of modification is exaggerated.
- However it never the less points out the flaw of the algorithm so that it could be improved upon.
- There had been attempts to fool face recognition technology
- The Privacy Wars: Goggles That Block Facial Recognition Technology
- COUNTER SURVEILLANCE MAKEUP
- Spoofing Faces Using Makeup: An Investigative Study
- They are obvious, can only disable thre recognition, is it possible to project IR noise onto face to be recognized as someone else?
Like kinect's noise projection: kinect projected ir pattern, project calculated adversarial attack
Development log - GDice
The log of the development, major problems and things to improve