Blog
Last modified by Victor Zhang on 16:38, 07/04/2020
Jun 11, 2020
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
Jun 9, 2020
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
Jun 5, 2020
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
Jun 3, 2020
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
Jun 2, 2020
Development log - GDice
The log of the development, major problems and things to improve
May 21, 2020
Development log - GDice - Number
- Developed Nixie Tube's appearance as spritesheet
- Test use here: Nixie Spritesheet
- Has all source files
- Uploaded to: https://opengameart.org/content/nixie-digits-spritesheet as CC-BY-4.0
- Might not be used in final project as the numbers are too small
- Maybe it's just better to photoshoot the tube running using Arduino
May 18, 2020
Raycast on Phaser Camera3D Plugin
- The problem is actually discovered by a student when trying to implement a forward running game (They need to click the enemy)
- The camera3d class provides a ray function: https://photonstorm.github.io/phaser3-docs/Phaser.Cameras.Sprite3D.PerspectiveCamera.html#getPickRay__anchor
- In that way, calculating the x,y on the target plane and then do some hit-test manually would do the job
- Used example: http://labs.phaser.io/edit.html?src=src\camera\3D%20camera\floor.js
- Modify line 33 to : var balls = camera.createRect({ x: 8, y: 1, z: 8 }, 32, 'ball');
- Add following block to create():
balls.forEach( function(ball){
ball.setData('tag', 'ball'+ball.x+':'+ball.y+':'+ball.z);
} )
this.input.on('pointerdown', function (pointer) {
ray = camera.getPickRay(pointer.x, pointer.y);
balls.forEach( function(ball){
// r is hardcoded here
let r = 4;
// calculate x y @ z of the object
let tx, ty;
let tz = ball.z;
tx = ray.origin.x + ray.direction.x * (tz - ray.origin.z ) / ray.direction.z;
ty = ray.origin.y + ray.direction.y * (ray.origin.z - tz) / ray.direction.z;
let tl = Math.sqrt( Math.pow(tx - ball.x, 2) + Math.pow(ty - ball.y, 2) );
if( tl < r ){
console.log(ball.getData('tag')+' isHit');
ball.gameObject.alpha = 0;
}
} );
}, this); - Explanation:
- the radius is hard coded here (5)
- more complex hit testing will need to be implemented for complex shapes
- manually enumerated through all object, inefficient (may need to implement some obvious exclusion for optimization)
- Extra problem
- Why is y axis reversed here?
- To study:
- Math of https://codepen.io/samme/pen/PBMaLJ ray blocking ,will be useful for next project
May 6, 2020
Imaging Device and Webcam
- As the recent need for remote learning, trying to setup stream hardware
- ITS has Doc Cam hardware however the driver they provide here: https://www.elmoeurope.com/index.php/en/download-service/software installs the device as "Imaging devices" which is somehow different from "Cameras" ( from device manager)
- TWAIN is also used by scanner so understand why it does make sense for Chat apps not supporting it
- But why do real-time doc cam register as TWAIN instead of Cameras
- It doesn't provide better quality
- Speculations:
- YUV format?
- FPS?
- Irregular resolution?
- PS Eye driver written by this company https://codelaboratories.com/products/eye/driver/
- Archive (link : https://archive.org/download/CLEyeDriver5.3.0.0341Emuline/CL-Eye-Driver-5.3.0.0341-Emuline.exe)[ ]
- Also registers as "Imaging devices" thus meaning can't be used by most of the windows apps
- Making a TWAIN to Camera bridge
- Does it worth the effort?
- As newer devices(even doc cams) supports UVC driver
- If as a hobby project, what's the effort
- Device driver
- Bridging service
Apr 29, 2020
Ultrasonic Directional Speaker
- Open source one:https://hackaday.io/project/9085/logs
- Probably first saw in "future weapons" as a military equipment for crowd control
- It uses the directional properties of ultrasound
- Modulates and trick our ear of hearing it
- Presumably can achieve a lot of interesting effects, like spatial sound
Example: